:root {
  color-scheme: dark;
  --bg: #091014;
  --chrome: #101820;
  --chrome-2: #121d25;
  --panel: #0d151b;
  --line: #25333e;
  --line-soft: #1a2831;
  --text: #edf5f7;
  --muted: #90a3af;
  --soft: #c6d4db;
  --teal: #19d3a2;
  --teal-strong: #10b98d;
  --amber: #f2c14e;
  --red: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 340px;
  height: 100vh;
  min-width: 980px;
  background:
    linear-gradient(180deg, rgba(25, 211, 162, 0.07), transparent 22rem),
    var(--bg);
}

.rail,
.inspector,
.workspace {
  min-height: 0;
}

.rail,
.inspector {
  background: rgba(13, 21, 27, 0.94);
  border-color: var(--line-soft);
}

.rail {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 25px;
  font-weight: 750;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border: 2px solid var(--teal);
  clip-path: polygon(50% 0, 94% 25%, 94% 75%, 50% 100%, 6% 75%, 6% 25%);
  box-shadow: inset 0 0 0 6px rgba(25, 211, 162, 0.12);
}

.rail-section,
.resource-panel {
  padding: 18px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.rail-section.grow {
  flex: 1;
  overflow: auto;
}

.section-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-heading,
.actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nav-item,
.agent-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  padding: 0 10px;
  color: var(--soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.agent-row:hover,
.nav-item.active,
.agent-row.active {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.nav-icon,
.count,
.status-dot {
  display: inline-grid;
  place-items: center;
}

.nav-icon {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  color: var(--teal);
  font-size: 11px;
}

.count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(25, 211, 162, 0.22);
  color: #bdf9e9;
  font-size: 12px;
}

.agent-list {
  margin-top: 12px;
}

.agent-row {
  grid-template-columns: 18px minmax(0, 1fr) auto;
  background: rgba(255, 255, 255, 0.03);
}

.agent-row small {
  color: var(--teal);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
}

.empty-list {
  margin-top: 12px;
  padding: 12px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.resource-panel {
  padding: 16px 20px 22px;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  margin: 12px 0 6px;
  color: var(--soft);
  font-size: 13px;
}

.meter {
  height: 7px;
  overflow: hidden;
  background: #25313a;
  border-radius: 999px;
}

.meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #5de0bd);
}

.workspace {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 280px;
  min-width: 0;
}

.topbar,
.tabbar,
.console-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 24, 32, 0.92);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(170px, 230px) minmax(170px, 1fr) auto auto auto;
  padding: 10px 12px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field.compact {
  width: auto;
}

.token-field {
  min-width: 220px;
  flex: 1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  color: var(--text);
  background: #121c24;
  border: 1px solid #30404c;
  border-radius: 6px;
  padding: 8px 10px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 211, 162, 0.14);
}

.button,
.icon-button,
.tab,
.console-tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #151f27;
  cursor: pointer;
}

.button {
  min-width: 64px;
  padding: 0 12px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.button.primary {
  min-width: 92px;
  border-color: rgba(25, 211, 162, 0.6);
  background: linear-gradient(180deg, #20d7a8, #0da57e);
  color: #03100c;
}

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: rgba(255, 107, 107, 0.4);
  color: #ffd1d1;
}

.icon-button {
  width: 30px;
  height: 30px;
  color: var(--teal);
}

.editor-frame {
  min-height: 0;
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr);
  background: #0b1116;
}

.tabbar {
  gap: 0;
  min-width: 0;
}

.tab {
  height: 40px;
  min-width: 112px;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  background: #121a21;
}

.tab.active {
  color: var(--amber);
  background: #0d141a;
}

.tab-spacer {
  flex: 1;
}

.editor-status {
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.editor {
  min-height: 0;
}

.fallback {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 14px;
}

.console-panel {
  min-height: 0;
  border-top: 1px solid var(--line);
  background: #0c1318;
}

.console-tabs {
  height: 38px;
  gap: 0;
}

.console-tab {
  height: 38px;
  min-width: 130px;
  border-top: 0;
  border-left: 0;
  border-bottom: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.console-tab.active {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--teal);
}

.run-state {
  margin-left: auto;
  margin-right: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
}

.run-state[data-tone="ok"] {
  color: #bdf9e9;
  background: rgba(25, 211, 162, 0.18);
}

.run-state[data-tone="busy"] {
  color: #ffe6a3;
  background: rgba(242, 193, 78, 0.16);
}

.run-state[data-tone="error"],
.run-state[data-tone="warn"] {
  color: #ffd1d1;
  background: rgba(255, 107, 107, 0.15);
}

.console-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  height: calc(100% - 38px);
  min-height: 0;
}

pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.console-output,
.audit-output {
  padding: 14px 16px;
}

.audit-output {
  border-left: 1px solid var(--line);
  color: #b8c6ce;
}

.inspector {
  overflow: auto;
  border-left: 1px solid var(--line);
}

.inspector-section {
  padding: 18px 20px 22px;
  border-bottom: 1px solid var(--line);
}

.inspector h2 {
  margin: 0 0 16px;
  font-size: 18px;
  line-height: 1.2;
}

.inspector .field + .field,
.check-row,
.actions-row {
  margin-top: 14px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--soft);
  font-size: 13px;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--teal);
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 220px minmax(620px, 1fr);
    min-width: 0;
    min-height: 100vh;
    height: auto;
  }

  .inspector {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    min-width: 0;
  }

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    height: 48px;
    font-size: 16px;
  }

  .rail-section {
    padding: 10px;
  }

  .rail-section.grow,
  .resource-panel {
    display: none;
  }

  .workspace {
    grid-template-rows: auto 440px 260px;
    min-height: 760px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: end;
  }

  .topbar .button {
    width: 100%;
  }

  .token-field {
    min-width: 0;
  }

  .tab {
    min-width: 84px;
  }

  .editor-status {
    display: none;
  }

  .console-grid {
    grid-template-columns: 1fr;
  }

  .audit-output {
    display: none;
  }

  .inspector {
    display: block;
    border-left: 0;
  }
}
