:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #101318;
  --surface-2: #151a21;
  --surface-3: #1b222b;
  --border: #29313b;
  --text: #f4f7fb;
  --muted: #9aa6b2;
  --muted-2: #717d89;
  --accent: #47d6b6;
  --accent-soft: rgba(71, 214, 182, 0.14);
  --danger: #ff6b6b;
  --radius: 12px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  width: min(980px, 100%);
  height: 100svh;
  max-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(41, 49, 59, 0.75);
  background: rgba(11, 13, 16, 0.92);
  backdrop-filter: blur(14px);
}

.nav-button,
.close-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.nav-button:hover,
.close-button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-button svg,
.close-button svg {
  width: 21px;
  height: 21px;
}

.nav-button path,
.close-button path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.brand-mark {
  min-width: 0;
}

.brand-mark strong,
.brand-mark small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark strong {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
}

.brand-mark small {
  margin-top: 1px;
  color: var(--muted-2);
  font-size: 11px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.status-dot strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #caa35a;
}

.pulse.ok {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(71, 214, 182, 0.12);
}

.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.58);
  opacity: 0;
  transition: opacity 180ms ease;
}

.drawer-mask.open {
  opacity: 1;
}

.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 21;
  width: min(82vw, 312px);
  padding: 10px;
  border-right: 1px solid var(--border);
  background: #0f1217;
  box-shadow: 16px 0 48px rgba(0, 0, 0, 0.4);
  transform: translateX(-102%);
  transition: transform 240ms ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 4px 8px 8px;
}

.drawer-head strong,
.drawer-head small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-head strong {
  font-size: 16px;
  font-weight: 650;
}

.drawer-head small {
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 12px;
}

.drawer-nav {
  display: grid;
  gap: 4px;
}

.drawer-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.drawer-item span,
.drawer-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-item span {
  font-size: 14px;
  font-weight: 620;
}

.drawer-item small {
  color: var(--muted-2);
  font-size: 12px;
}

.drawer-item:hover,
.drawer-item.active {
  background: var(--surface-2);
}

.drawer-item.active span {
  color: var(--accent);
}

.view {
  display: none;
  min-height: 0;
  overflow: hidden;
}

.view.active {
  display: grid;
}

.view-agent {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
}

.intro-strip,
.page-title {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}

.intro-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 5.4vw, 34px);
  line-height: 1.12;
  letter-spacing: 0;
}

.intro-strip p,
.page-title p,
.ability-card p,
.key-state {
  color: var(--muted);
}

.intro-strip > p {
  max-width: 280px;
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
}

.agent-console {
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr) auto;
  min-height: 0;
}

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.console-head span {
  color: var(--text);
  font-weight: 620;
}

.console-output {
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

.line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  margin: 0 0 14px;
  animation: lineIn 220ms ease both;
}

.line p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.prompt {
  color: #7fa7d8;
  font-size: 13px;
}

.system-line .prompt {
  color: var(--accent);
}

.command-form {
  border-top: 1px solid var(--border);
  padding: 10px;
  background: rgba(16, 19, 24, 0.92);
}

.command-form label {
  display: none;
}

.command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  align-items: end;
}

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

textarea {
  min-height: 44px;
  max-height: 112px;
  padding: 10px 11px;
  resize: none;
  line-height: 1.45;
}

input {
  height: 42px;
  padding: 0 11px;
}

textarea:focus,
input:focus {
  border-color: rgba(71, 214, 182, 0.62);
  box-shadow: 0 0 0 2px rgba(71, 214, 182, 0.1);
}

.command-row button,
.config-form button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  color: #06110f;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

#view-abilities,
#view-api {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
}

.page-title p {
  max-width: 620px;
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.55;
}

.ability-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.ability-card {
  min-height: 150px;
  padding: 16px;
}

.ability-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.ability-card p {
  margin: 0;
  line-height: 1.58;
}

.api-panel {
  width: min(720px, 100%);
  min-height: 0;
  overflow: auto;
}

.config-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.config-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.config-form button {
  grid-column: 1 / -1;
  color: #06110f;
}

.key-state {
  margin: 0 14px 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  line-height: 1.55;
  font-size: 13px;
}

.lift-1,
.lift-2 {
  opacity: 0;
  transform: translateY(10px);
}

[data-mounted="true"] .lift-1,
[data-mounted="true"] .lift-2 {
  animation: assemble 360ms ease forwards;
}

[data-mounted="true"] .lift-2 {
  animation-delay: 60ms;
}

@keyframes assemble {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes lineIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
  }

  .status-dot {
    padding: 0 9px;
  }

  .status-dot strong {
    max-width: 38px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .view-agent,
  #view-abilities,
  #view-api {
    padding: 8px;
  }

  .intro-strip {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px;
  }

  .intro-strip > p {
    max-width: none;
    font-size: 12px;
    text-align: left;
  }

  h1 {
    font-size: 23px;
  }

  .agent-console {
    grid-template-rows: 38px minmax(0, 1fr) auto;
  }

  .console-output {
    padding: 12px;
  }

  .line {
    grid-template-columns: 1fr;
    gap: 4px;
    margin-bottom: 12px;
  }

  .prompt {
    font-size: 12px;
  }

  .command-form {
    padding: 8px;
  }

  .command-row {
    grid-template-columns: minmax(0, 1fr) 58px;
  }

  .command-row button {
    min-height: 42px;
    padding: 0 10px;
  }

  textarea {
    min-height: 42px;
    max-height: 92px;
  }

  .ability-list,
  .config-form {
    grid-template-columns: 1fr;
  }

  .ability-list {
    gap: 8px;
  }

  .ability-card {
    min-height: 112px;
    padding: 14px;
  }

  .api-panel {
    width: 100%;
  }
}

@media (min-width: 761px) {
  .drawer-mask,
  .drawer {
    position: fixed;
  }
}
