:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #647089;
  --line: #dde3ef;
  --accent: #2563eb;
  --accent-strong: #1749b6;
  --ok: #0f8b5f;
  --warn: #9a5b00;
  --bad: #b42318;
  --ink-soft: #eef3ff;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #fbfcff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.brand span,
.topbar h2,
.topbar p,
.panel h3,
.auth-panel h2 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.1;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab,
.toolbar-button,
.primary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.nav-tab {
  justify-content: flex-start;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
}

.nav-tab.active,
.nav-tab:hover {
  background: var(--ink-soft);
  color: var(--accent-strong);
}

.nav-tab svg,
.toolbar-button svg,
.primary-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.auth-panel {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.auth-panel h2 {
  font-size: 14px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input {
  min-height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 150px;
  padding: 12px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 82px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 2px;
  font-size: 24px;
}

.toolbar-button,
.icon-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.toolbar-button {
  padding: 0 14px;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.toolbar-button:hover,
.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.view {
  display: none;
  padding: 24px 28px;
}

.view.active {
  display: block;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: 20px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header,
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel h3 {
  font-size: 16px;
}

.tool-list {
  display: grid;
  max-height: calc(100vh - 172px);
  overflow: auto;
}

.tool-row {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.tool-row:hover,
.tool-row.active {
  background: #f6f9ff;
}

.tool-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 750;
}

.tool-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag,
.count-badge,
.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
}

.tag,
.count-badge,
.state-pill.neutral {
  background: #edf1f7;
  color: #4a5872;
}

.state-pill {
  width: fit-content;
  background: #fff5df;
  color: var(--warn);
}

.state-pill.ok {
  background: #e7f7f0;
  color: var(--ok);
}

.state-pill.bad {
  background: #fff0ee;
  color: var(--bad);
}

.run-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.tool-meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.primary-button {
  width: fit-content;
  min-width: 120px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 750;
}

.primary-button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.primary-button:disabled,
.toolbar-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.result-area {
  border-top: 1px solid var(--line);
}

.result-header {
  border-bottom: 0;
}

pre {
  margin: 0 18px 18px;
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5eefc;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.artifact-list,
.skill-grid {
  display: grid;
  gap: 12px;
  padding: 0 18px 18px;
}

.artifact-item,
.skill-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.artifact-item a,
.skill-item a {
  color: var(--accent);
  font-weight: 750;
  text-decoration: none;
}

.artifact-item a:hover,
.skill-item a:hover {
  text-decoration: underline;
}

.skill-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-top: 18px;
}

.skill-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.mcp-grid {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.mcp-grid textarea {
  min-height: 180px;
}

.mcp-grid pre {
  margin: 0;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    gap: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-tab {
    justify-content: center;
  }

  .auth-panel {
    margin-top: 0;
  }

  .split-layout,
  .skill-grid {
    grid-template-columns: 1fr;
  }

  .tool-list {
    max-height: 360px;
  }
}

@media (max-width: 560px) {
  .topbar,
  .view {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-button,
  .primary-button {
    width: 100%;
  }

  .nav-tabs {
    grid-template-columns: 1fr;
  }
}
