:root,
[data-theme="dark"],
[data-theme="foundry"] {
  --bg: #14120f;
  --panel: #1c1a16;
  --panel-2: #24211c;
  --line: rgba(232, 196, 120, 0.14);
  --line-strong: rgba(232, 196, 120, 0.28);
  --text: #ece6d8;
  --muted: #9a917f;
  --spark: #e8b86d;
  --spark-dim: rgba(232, 184, 109, 0.14);
  --spark-ink: #1a1713;
  --heat: #e07058;
  --ok: #8fbf88;
  --info: #d4b483;
  --brass: #e8b86d;
  --hover: rgba(232, 184, 109, 0.08);
  --select: rgba(232, 184, 109, 0.16);
  --glass: rgba(20, 18, 15, 0.78);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
  --status: #1a1713;
  --files-w: 268px;
  --chat-w: 420px;
  --term-h: 200px;
  --hdr-h: 52px;
  --title-h: 32px;
  --status-h: 26px;
  --act-w: 52px;
  --sash-size: 4px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font-display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --font-ui: "Outfit", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", Consolas, "Cascadia Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  color-scheme: dark;
}

body {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

.sr,
.skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip:focus {
  position: fixed;
  z-index: 80;
  top: 8px;
  left: 8px;
  width: auto;
  height: auto;
  clip: auto;
  padding: 10px 14px;
  background: var(--spark);
  color: var(--spark-ink);
  text-decoration: none;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--spark);
  outline-offset: 2px;
}

a {
  color: var(--info);
}

::selection {
  background: rgba(232, 184, 109, 0.28);
  color: var(--text);
}

.stencil {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.btn-spark,
.btn-primary {
  background: var(--spark);
  color: var(--spark-ink);
  border: 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  min-height: 32px;
  padding: 6px 14px;
  box-shadow: 0 0 0 1px rgba(232, 184, 109, 0.18);
}

.btn-spark:hover,
.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-spark:active,
.btn-primary:active {
  filter: brightness(0.94);
}

.btn-spark:disabled,
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
  border-radius: var(--radius-sm);
}

.btn-line:hover {
  border-color: var(--spark);
  background: var(--hover);
}

.btn-heat,
.btn-ghost {
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  font-family: var(--font-ui);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.btn-tiny {
  min-height: 40px;
  padding: 6px 10px;
  font-size: 13px;
}

.btn-icon,
.btn-chip {
  min-width: 40px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  border-radius: 999px;
  background: transparent;
}

.btn-chip[aria-checked="true"] {
  color: var(--spark-ink);
  border-color: var(--spark);
  background: var(--spark);
}

.btn-hdr {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 13px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

body::after {
  display: none;
}

.boot,
.gate,
.workbench,
.palette,
.modal,
.toasts {
  position: relative;
  z-index: 1;
}

.plate {
  background: linear-gradient(180deg, rgba(232, 184, 109, 0.06), transparent 42%), var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg);
  z-index: 60;
}

body:not([data-loading="true"]) .boot {
  display: none;
}

.boot-word {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 0;
}

/* GATE */
.gate {
  min-height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px 48px;
  z-index: 5;
  pointer-events: auto;
}

.gate button,
.gate a,
.gate input {
  position: relative;
  z-index: 6;
  pointer-events: auto;
}

.gate-frame {
  width: min(560px, 100%);
  padding: 28px 28px 32px;
  border: 1px solid var(--line-strong);
}

.gate-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.serial {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.gate-title {
  margin: 18px 0 10px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: clamp(36px, 8vw, 56px);
  line-height: 1.05;
  letter-spacing: 0;
}

.lede {
  margin: 0 0 28px;
  color: var(--muted);
  max-width: 42ch;
}

.gate-block {
  margin: 0 0 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-giant {
  width: 100%;
  min-height: 44px;
  font-size: 15px;
  padding: 10px 16px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.device-panel {
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: var(--radius-sm);
}

.device-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.device-url {
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--info);
}

.device-code-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.device-code {
  margin: 0;
  flex: 1;
  font-family: var(--font-mono);
  font-size: 28px;
  letter-spacing: 0.12em;
  user-select: all;
  color: var(--text);
}

.key-row {
  display: flex;
  gap: 8px;
}

.key-row input {
  flex: 1;
  min-height: 44px;
  padding: 8px 10px;
  background: var(--panel-2);
}

.gate-user {
  margin: 8px 0 16px;
  font-size: 18px;
}

.gate-status {
  min-height: 1.4em;
  margin: 8px 0 0;
  color: var(--brass);
  font-family: var(--font-mono);
  font-size: 12px;
}

.gate-status.is-err {
  color: var(--heat);
}

.gate-status.is-ok {
  color: var(--ok);
}

/* WORKBENCH */
.workbench {
  height: 100%;
  display: grid;
  grid-template-rows: var(--title-h) 1fr var(--status-h);
  background: var(--bg);
}

body.is-yolo .workbench {
  box-shadow: inset 0 2px 0 var(--heat);
}

.hdr {
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.brand-mark {
  width: 8px;
  height: 8px;
  background: var(--text);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.cwd-lab {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.cwd {
  flex: 1 1 220px;
  min-width: 120px;
  min-height: 36px;
  padding: 4px 8px;
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 12px;
}

.cwd.is-bad {
  border-color: var(--heat);
}

.model {
  min-height: 36px;
  max-width: 180px;
  padding: 4px 8px;
  background: var(--bg);
  appearance: none;
  font-family: var(--font-mono);
  font-size: 12px;
}

.yolo {
  appearance: none;
  -webkit-appearance: none;
  min-height: 28px;
  min-width: 64px;
  padding: 4px 10px;
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.yolo[aria-checked="true"] {
  background: var(--heat);
  color: #fff;
  border-color: var(--heat);
}

.mcp,
.usage,
.heat-lab,
.acp-lab {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}

.usage {
  color: var(--brass);
}

.statusbar .usage {
  font-weight: 600;
  letter-spacing: 0;
}

.usage-bar {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
}

.statusbar .usage.is-warn {
  color: var(--brass);
}

.statusbar .usage.is-hot {
  color: var(--heat);
}

.statusbar .usage.is-hot .usage-bar i {
  background: var(--heat);
}

.statusbar .usage.is-warn .usage-bar i {
  background: var(--brass);
}

.heat-lab.is-hot,
body.is-forging .heat-lab {
  color: var(--spark);
}

.acp-lab.is-on {
  color: var(--ok);
}

.acp-lab.is-off {
  color: var(--heat);
}

.heat-gauge {
  display: flex;
  gap: 3px;
  height: 12px;
  align-items: end;
}

.heat-gauge i {
  display: block;
  width: 6px;
  height: 100%;
  background: var(--line);
  transform-origin: bottom;
}

body.is-forging .heat-gauge i {
  background: var(--heat);
  animation: heatfill 0.5s ease both;
}

body.is-forging .heat-gauge i:nth-child(1) { animation-delay: 0s; height: 40%; }
body.is-forging .heat-gauge i:nth-child(2) { animation-delay: 0.05s; height: 55%; }
body.is-forging .heat-gauge i:nth-child(3) { animation-delay: 0.1s; height: 70%; }
body.is-forging .heat-gauge i:nth-child(4) { animation-delay: 0.15s; height: 100%; }
body.is-forging .heat-gauge i:nth-child(5) { animation-delay: 0.2s; height: 85%; }
body.is-forging .heat-gauge i:nth-child(6) { animation-delay: 0.25s; height: 60%; }
body.is-forging .heat-gauge i:nth-child(7) { animation-delay: 0.3s; height: 75%; }
body.is-forging .heat-gauge i:nth-child(8) { animation-delay: 0.35s; height: 50%; }

@keyframes heatfill {
  from { opacity: 0.25; transform: scaleY(0.4); }
  to { opacity: 1; transform: scaleY(1); }
}

.account-chip {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 36px;
  padding: 4px 8px;
  font-size: 12px;
  border-color: var(--line);
  color: var(--text);
}

.wb-body {
  display: flex;
  min-height: 0;
  min-width: 0;
}

.cols {
  display: flex;
  min-height: 0;
  min-width: 0;
  flex: 1;
}

.col-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.row-top {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.panel {
  background: var(--panel);
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.files {
  width: var(--files-w);
  flex: 0 0 var(--files-w);
  border-right: 1px solid var(--line);
}

.forge {
  flex: 1;
  background: var(--bg);
  position: relative;
}

.hearth {
  height: var(--term-h);
  flex: 0 0 var(--term-h);
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.agent {
  width: var(--chat-w);
  flex: 0 0 var(--chat-w);
  border-left: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}

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

.slot.is-empty {
  display: none;
}

.slot-west {
  width: var(--files-w);
  flex: 0 0 var(--files-w);
  border-right: 1px solid var(--line);
}

.slot-east {
  width: var(--chat-w);
  flex: 0 0 var(--chat-w);
  border-left: 1px solid var(--line);
}

.slot-south {
  height: var(--term-h);
  flex: 0 0 var(--term-h);
  border-top: 1px solid var(--line);
}

.slot-west:has(#agent),
.slot-east:has(#agent) {
  width: var(--chat-w);
  flex-basis: var(--chat-w);
}

.slot-south:has(#agent) {
  height: var(--term-h);
  flex-basis: var(--term-h);
}

.slot .files,
.slot .agent,
.slot .hearth,
body.is-agent-split .slot .agent {
  width: auto;
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
  border: 0;
}

.slot.is-drop {
  outline: 1px dashed var(--info);
  outline-offset: -2px;
}

.slot-tabs {
  display: flex;
  flex: 0 0 auto;
  min-height: 28px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.slot-tabs[hidden] {
  display: none;
}

.slot-tab {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.slot-tab.is-on {
  color: var(--text);
  background: var(--panel);
}

.panel-grip {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-width: 16px;
  min-height: 28px;
  padding: 0 2px;
  cursor: grab;
  flex: 0 0 auto;
}

.panel-grip:hover {
  color: var(--text);
}

.panel-grip:active {
  cursor: grabbing;
}

.layout-drop {
  position: fixed;
  z-index: 40;
  inset: var(--title-h) 0 var(--status-h) var(--act-w);
  pointer-events: none;
}

.layout-drop[hidden] {
  display: none;
}

.drop-edge {
  position: absolute;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 12px;
  background: rgba(232, 184, 109, 0.16);
  border: 1px dashed var(--spark);
  border-radius: var(--radius);
}

.drop-west {
  left: 8px;
  top: 18%;
  bottom: 22%;
  width: 76px;
}

.drop-east {
  right: 8px;
  top: 18%;
  bottom: 22%;
  width: 76px;
}

.drop-south {
  left: 18%;
  right: 18%;
  bottom: 8px;
  height: 72px;
}

.drop-center {
  left: 28%;
  right: 28%;
  top: 22%;
  bottom: 30%;
}

#forge.is-drop {
  outline: 2px dashed var(--spark);
  outline-offset: -4px;
}

body.no-forge #forge,
body.no-forge #gutter-chat {
  display: none !important;
}

body.no-forge .slot-east,
body.no-forge .slot-east:has(#agent),
body.no-forge.is-agent-split .slot-east:has(#agent),
body.no-forge.is-agent-split .slot-west:has(#agent),
body.no-forge .slot-west:has(#agent) {
  flex: 1 1 auto;
  width: auto;
  min-width: 280px;
  flex-basis: auto;
}

body.no-forge.no-east .slot-west {
  flex: 1 1 auto;
  width: auto;
  flex-basis: auto;
}

body.no-side .activity,
body.no-side #slot-west,
body.no-side #gutter-files {
  display: none !important;
}

body.no-south #slot-south,
body.no-south #gutter-term,
body.no-term #slot-south,
body.no-term #gutter-term {
  display: none !important;
}

.preview-host {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

.stage-host {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0e0d0b;
}

.stage-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 36px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.stage-now {
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-film {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: auto hidden;
  justify-content: flex-end;
}

.stage-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
}

.stage-chip.is-on {
  border-color: var(--spark);
  color: var(--spark);
  background: var(--spark-dim);
}

.stage-view {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: auto;
}

.stage-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.stage-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  object-fit: contain;
}

.stage-empty,
.stage-card,
.stage-swatch-wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 24px 48px;
  text-align: center;
}

.stage-empty p,
.stage-card p {
  margin: 0;
  max-width: 420px;
  color: var(--muted);
  font-size: 14px;
}

.stage-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--spark-dim);
  color: var(--spark);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stage-name {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 22px;
  word-break: break-word;
}

.stage-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 520px;
}

.stage-swatch {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.md-preview.stage-md {
  padding: 24px 28px 48px;
}

.stage-live {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 28px 24px 22px;
  background: linear-gradient(transparent, rgba(14, 13, 11, 0.92) 42%);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.25;
  pointer-events: none;
  text-align: center;
}

.stage-host.is-busy .stage-live {
  color: var(--spark);
}

.stage-scene {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 24px 88px;
  text-align: center;
  overflow: hidden;
}

.stage-orb {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 184, 109, 0.3), transparent 70%);
  filter: blur(10px);
  animation: stage-pulse 2.4s ease-in-out infinite;
  pointer-events: none;
}

.stage-host.is-busy .stage-orb {
  animation-duration: 1.4s;
}

@keyframes stage-pulse {
  0%, 100% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.08); opacity: 1; }
}

.stage-kicker {
  margin: 0;
  z-index: 1;
}

.stage-scene .stage-name,
.stage-scene .stage-file,
.stage-scene .stage-swatches,
.stage-scene .stage-bits {
  z-index: 1;
}

.stage-file {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.stage-bits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 520px;
}

.stage-bit {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

#btn-stage[aria-pressed="true"] {
  color: var(--spark);
}

.preview-body {
  min-height: 100%;
  padding: 24px 28px 48px;
}

.preview-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  background: repeating-conic-gradient(#2a2722 0% 25%, #1c1a16 0% 50%) 0 0 / 16px 16px;
}

.md-preview {
  max-width: 760px;
  margin: 0 auto;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
}

.md-preview h1,
.md-preview h2,
.md-preview h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 1.2em 0 0.4em;
}

.md-preview h1 { font-size: 1.6em; }
.md-preview h2 { font-size: 1.3em; }
.md-preview h3 { font-size: 1.1em; }

.md-preview p,
.md-preview ul,
.md-preview ol {
  margin: 0.6em 0;
}

.md-preview a {
  color: var(--spark);
}

.md-preview code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--panel-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.md-preview pre {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow: auto;
}

.md-preview pre code {
  background: transparent;
  padding: 0;
}

.md-preview img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-xs);
}

.md-preview blockquote {
  margin: 0.8em 0;
  padding: 0.2em 0 0.2em 12px;
  border-left: 3px solid var(--spark);
  color: var(--muted);
}

.md-preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8em 0;
  font-size: 0.92em;
}

.md-preview th,
.md-preview td {
  border: 1px solid var(--line);
  padding: 6px 8px;
}

#btn-preview[aria-pressed="true"] {
  color: var(--spark);
}

.drop-edge.is-over {
  background: rgba(232, 184, 109, 0.38);
}

.editor-groups {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.editor-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#editor-group-1 {
  border-left: 1px solid var(--line);
}

.tab {
  cursor: grab;
}

.tab.is-dragging {
  opacity: 0.4;
}

.tab.drop-before {
  box-shadow: inset 2px 0 0 var(--info);
}

.tab.drop-after {
  box-shadow: inset -2px 0 0 var(--info);
}

.forge.is-settings .editor-groups {
  position: absolute;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}

.agent-h {
  gap: 4px;
  flex: 0 0 auto;
}

.agent-tabs {
  flex: 1;
  display: flex;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 0;
  padding-bottom: 2px;
  scrollbar-width: auto;
  scrollbar-color: var(--brass) rgba(255, 255, 255, 0.08);
}

.agent-tabs::-webkit-scrollbar {
  height: 8px;
}

.agent-tabs::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
}

.agent-tabs::-webkit-scrollbar-thumb {
  background: var(--brass);
  border-radius: 4px;
}

.tabs-scroll {
  flex: 0 0 22px;
  min-width: 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 16px;
  line-height: 20px;
  color: var(--text);
}

.tabs-scroll:disabled {
  opacity: 0.35;
}

.agent-tab.is-dragging {
  opacity: 0.45;
}

.agent-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  min-width: 72px;
  max-width: 148px;
  flex: 0 1 auto;
  padding: 0 8px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  cursor: grab;
}

.agent-tab-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-tab.is-on {
  color: var(--text);
  background: var(--bg);
  box-shadow: inset 0 -2px 0 var(--spark);
  max-width: 208px;
}

.agent-tab:not(.is-on) .agent-tab-ctx,
.agent-tab:not(.is-on) .agent-tab-ctx-lab {
  display: none;
}

#btn-agent-more {
  flex: 0 0 auto;
  min-width: 36px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--text);
}

.agent-tab.is-run {
  color: var(--text);
  background: var(--spark-dim);
  font-weight: 600;
  box-shadow: none;
}

.agent-tab.is-run.is-on {
  color: var(--text);
  background: var(--bg);
  box-shadow: inset 0 -2px 0 var(--spark);
}

.agent-tab.is-run .agent-tab-dot {
  width: 8px;
  height: 8px;
  background: var(--spark);
  box-shadow: 0 0 0 3px var(--spark-dim);
  animation: tab-run 0.9s ease-in-out infinite;
}

.agent-tab-live {
  display: none;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--spark);
  color: var(--spark-ink);
  flex: 0 0 auto;
}

.agent-tab.is-run .agent-tab-live {
  display: inline-block;
}

@keyframes tab-run {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 0 3px var(--spark-dim);
  }
  50% {
    transform: scale(1.22);
    opacity: 1;
    box-shadow: 0 0 0 5px var(--spark-dim), 0 0 10px var(--spark);
  }
}

.agent-tab.is-wait .agent-tab-dot {
  background: var(--spark);
  box-shadow: 0 0 0 3px var(--spark-dim);
}

.agent-tab-q {
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: 7px;
  background: var(--spark-dim, rgba(232, 184, 109, 0.25));
  color: var(--spark);
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  font-family: var(--font-mono);
  flex: 0 0 auto;
}

.agent-tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.agent-tab-ctx {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  flex: 0 0 auto;
}

.agent-tab-ctx .ctx-ring {
  width: 12px;
  height: 12px;
}

.agent-tab-ctx.is-warn {
  color: var(--brass);
}

.agent-tab-ctx.is-hot {
  color: var(--heat);
}

.agent-tab-ctx.is-warn .ctx-ring-val {
  stroke: var(--brass);
}

.agent-tab-ctx.is-hot .ctx-ring-val {
  stroke: var(--heat);
}

.agent-tab-x {
  border: 0;
  min-width: 18px;
  min-height: 18px;
  padding: 0;
  flex: 0 0 auto;
  line-height: 18px;
  text-align: center;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.agent-tab-x:hover {
  color: var(--heat);
}

.agent-panes {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-panes.is-mosaic {
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  min-width: 0;
}

.agent-col {
  display: flex;
  flex-direction: column;
  min-width: 220px;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--panel);
}

.agent-col + .agent-mosaic-gutter + .agent-col {
  border-left: 0;
}

.agent-tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 72px;
  overflow: hidden;
  border-bottom: 1px solid var(--line-strong);
}

.agent-tile:last-child {
  border-bottom: 0;
}

.agent-tile.is-on {
  box-shadow: inset 3px 0 0 var(--spark);
}

.agent-tile.is-on .agent-tile-h {
  background: var(--spark-dim);
  color: var(--text);
}

.agent-tile.is-run .agent-tile-h .agent-tab-live {
  display: inline-block;
}

.agent-tile.is-run .agent-tab-dot {
  width: 8px;
  height: 8px;
  background: var(--spark);
  box-shadow: 0 0 0 3px var(--spark-dim);
  animation: tab-run 0.9s ease-in-out infinite;
}

.agent-tile-h {
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0 6px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  cursor: grab;
}

.agent-tile-h:active {
  cursor: grabbing;
}

.agent-tile-h .agent-tab-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text);
}

.agent-tile-h .agent-tab-dot {
  flex: 0 0 auto;
}

.agent-tile .agent-pane {
  flex: 1 1 auto;
  min-height: 0;
  width: auto;
  border: 0;
}

.agent-mosaic-gutter {
  position: relative;
  z-index: 3;
  flex: 0 0 var(--sash-size);
  touch-action: none;
  background: transparent;
}

.agent-mosaic-gutter.is-x {
  cursor: ew-resize;
}

.agent-mosaic-gutter.is-y {
  cursor: ns-resize;
}

.agent-mosaic-gutter::before {
  content: '';
  position: absolute;
  background: var(--line);
  pointer-events: none;
}

.agent-mosaic-gutter.is-x::before {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--line-strong);
}

.agent-mosaic-gutter.is-y::before {
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: var(--line-strong);
}

.agent-mosaic-gutter::after {
  content: '';
  position: absolute;
  pointer-events: auto;
}

.agent-mosaic-gutter.is-x::after {
  inset: 0 -4px;
}

.agent-mosaic-gutter.is-y::after {
  inset: -4px 0;
}

.agent-mosaic-gutter:hover::before,
.agent-mosaic-gutter.is-on::before {
  background: var(--spark);
}

.agent-mosaic-gutter.is-x:hover::before,
.agent-mosaic-gutter.is-x.is-on::before {
  width: 2px;
  margin-left: -1px;
}

.agent-mosaic-gutter.is-y:hover::before,
.agent-mosaic-gutter.is-y.is-on::before {
  height: 2px;
  margin-top: -1px;
}

body.is-agent-mosaic #agent > .agent-h {
  min-height: 36px;
  padding: 0 6px;
  gap: 4px;
}

body.is-agent-mosaic #agent-tabs {
  display: flex;
}

body.is-agent-mosaic .agent-col {
  min-width: 200px;
}

body.is-agent-mosaic .agent-tile-h {
  flex: 0 0 22px;
  min-height: 22px;
  padding: 0 8px 0 6px;
}

body.is-agent-mosaic .jump-bottom {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  right: 8px;
  bottom: 8px;
}

body.is-agent-mosaic .transcript {
  padding: 8px 8px 8px;
  gap: 6px;
  background: var(--bg);
}

body.is-agent-mosaic .log {
  flex: 0 0 auto;
  height: auto;
  padding: 8px 10px;
  gap: 4px;
  border-radius: var(--radius-xs);
}

body.is-agent-mosaic .log.is-you,
body.is-agent-mosaic .log.is-grok {
  margin-left: 0;
  margin-right: 0;
}

body.is-agent-mosaic .composer {
  padding: 6px 8px 8px;
  gap: 4px;
}

body.is-agent-mosaic .composer textarea {
  min-height: 34px;
  padding: 7px 8px;
  font-size: 13px;
  border-radius: var(--radius-xs);
}

body.is-agent-mosaic .composer-hint,
body.is-agent-mosaic .ctx-meter-lab,
body.is-agent-mosaic .composer-tokens {
  display: none;
}

body.is-agent-mosaic .ctx-meter {
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  gap: 0;
}

body.is-agent-mosaic .ctx-ring {
  width: 18px;
  height: 18px;
}

body.is-agent-mosaic .btn-send,
body.is-agent-mosaic .btn-stop,
body.is-agent-mosaic .btn-mic,
body.is-agent-mosaic .btn-jump,
body.is-agent-mosaic .btn-attach,
body.is-agent-mosaic .btn-gear {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
}

body.is-agent-mosaic .composer-queue {
  max-height: 72px;
}

body.is-agent-mosaic .composer,
body.is-agent-mosaic .composer-bar {
  min-width: 0;
}

body.is-agent-mosaic .chat-home {
  gap: 8px;
  max-width: none;
  justify-content: flex-start;
  padding: 4px 0;
}

body.is-agent-mosaic .chat-home .btn-chip {
  min-height: 28px;
  font-size: 12px;
}

.agent-group {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-group[hidden] {
  display: none !important;
}

.agent-group-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-group.is-drop,
.agent-col.is-drop,
.agent-tile.is-drop {
  box-shadow: inset 0 0 0 2px var(--spark);
}

.agent-tabs.is-drop {
  box-shadow: inset 0 -2px 0 var(--spark);
  background: var(--spark-dim);
}

body.is-agent-split .agent-group {
  flex: 1 1 0;
  min-height: 88px;
}

.agent-split-gutter {
  flex: 0 0 var(--sash-size);
  flex-grow: 0;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  cursor: ns-resize;
  touch-action: none;
  background: transparent;
}

.agent-split-gutter[hidden] {
  display: none !important;
}

.agent-split-gutter::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  margin-top: -0.5px;
  background: var(--line);
  pointer-events: none;
}

.agent-split-gutter::after {
  content: '';
  position: absolute;
  inset: -4px 0;
}

.agent-split-gutter:hover::before,
.agent-split-gutter.is-on::before {
  height: 2px;
  margin-top: -1px;
  background: var(--spark);
}

.agent-h-south {
  min-height: 32px;
  flex: 0 0 auto;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  border-top: 0;
}

body.is-agent-split-col #agent.agent,
body.is-agent-split-col .slot .agent {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) var(--sash-size) minmax(140px, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

body.is-agent-split-col #agent > .agent-h {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

body.is-agent-split-col #agent-panes {
  display: contents;
}

body.is-agent-split-col #agent-group-0 {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
}

body.is-agent-split-col #gutter-agent-split {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: var(--sash-size);
  height: auto;
  flex: none;
  cursor: ew-resize;
  align-self: stretch;
}

body.is-agent-split-col #agent-group-1 {
  grid-column: 3;
  grid-row: 1 / span 2;
  min-width: 0;
  min-height: 0;
}

body.is-agent-split-col #attach-input,
body.is-agent-split-col #mic-audio-input,
body.is-agent-split-col #mic-sheet {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}

body.is-agent-split-col .agent-split-gutter::before {
  left: 50%;
  right: auto;
  top: 0;
  bottom: 0;
  width: 1px;
  height: auto;
  margin: 0 0 0 -0.5px;
}

body.is-agent-split-col .agent-split-gutter:hover::before,
body.is-agent-split-col .agent-split-gutter.is-on::before {
  width: 2px;
  height: auto;
  margin-left: -1px;
}

body.is-agent-split-col .agent-split-gutter::after {
  inset: 0 -4px;
}

body.is-agent-split-col .agent-h-south {
  border-left: 1px solid var(--line);
}

#btn-agent-split[aria-pressed="true"] {
  color: var(--spark);
}

#agent.is-drop-left::after,
#agent.is-drop-right::after,
#agent.is-drop-south::after {
  content: '';
  position: absolute;
  z-index: 6;
  pointer-events: none;
  background: var(--spark-dim);
  border: 1px dashed var(--spark);
}

#agent.is-drop-left::after {
  left: 0;
  top: 0;
  bottom: 0;
  width: 50%;
}

#agent.is-drop-right::after {
  right: 0;
  top: 0;
  bottom: 0;
  width: 50%;
}

#agent.is-drop-south::after {
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
}

body.is-split-drag,
body.is-sash-drag,
body.is-gutter-drag {
  user-select: none;
}

body.is-sash-x,
body.is-gutter-drag:not(.is-sash-y) {
  cursor: ew-resize;
}

body.is-sash-y,
body.is-split-drag:not(.is-sash-x) {
  cursor: ns-resize;
}

body.is-gutter-drag textarea,
body.is-gutter-drag iframe,
body.is-sash-drag textarea,
body.is-sash-drag iframe,
body.is-sash-drag .xterm,
body.is-sash-drag .monaco-editor {
  pointer-events: none;
}

body.is-split-drag textarea,
body.is-split-drag iframe {
  pointer-events: none;
}

body.is-split-drag .agent-group {
  min-height: 0;
}

body.is-split-drag .transcript {
  overflow: hidden;
}

.agent-pane {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 0;
}

.transcript-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.jump-bottom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 6;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel);
  color: var(--spark);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
  opacity: 0.45;
}

.jump-bottom[hidden] {
  display: none !important;
}

.jump-bottom.is-away,
.jump-bottom:hover,
.jump-bottom:active {
  opacity: 1;
  background: var(--spark);
  color: var(--spark-ink);
}

#btn-jump-bottom,
.agent-tile-jump {
  min-width: 32px;
  min-height: 32px;
  color: var(--muted);
}

#btn-jump-bottom.is-away,
.agent-tile-jump.is-away {
  color: var(--spark-ink);
  background: var(--spark);
}

.agent-pane[hidden] {
  display: none !important;
}

.panel-h {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.forge-h {
  padding-right: 0;
}

.panel-h .stencil,
.side-title {
  flex: 0 0 auto;
}

.side-title,
.term-tab {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
}

.term-tablist {
  display: flex;
  flex: 0 1 auto;
  max-width: 58%;
  min-width: 0;
  overflow-x: auto;
  gap: 0;
}

.term-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  min-height: 28px;
  padding: 0 8px;
  color: var(--muted);
  box-shadow: none;
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.term-tab.is-on {
  color: var(--text);
  box-shadow: inset 0 -1px 0 var(--text);
}

.hearth-cwd {
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.gutter {
  position: relative;
  z-index: 4;
  touch-action: none;
  background: transparent;
  flex-grow: 0;
  flex-shrink: 0;
}

.gutter-x {
  width: var(--sash-size);
  flex-basis: var(--sash-size);
  cursor: ew-resize;
}

.gutter-y {
  height: var(--sash-size);
  flex-basis: var(--sash-size);
  cursor: ns-resize;
}

.gutter::before {
  content: '';
  position: absolute;
  background: var(--line);
  pointer-events: none;
}

.gutter-x::before {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  margin-left: -0.5px;
}

.gutter-y::before {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  margin-top: -0.5px;
}

.gutter::after {
  content: '';
  position: absolute;
}

.gutter-x::after {
  inset: 0 -4px;
}

.gutter-y::after {
  inset: -4px 0;
}

.gutter:hover::before,
.gutter.is-on::before {
  background: var(--spark);
}

.gutter-x:hover::before,
.gutter-x.is-on::before {
  width: 2px;
  margin-left: -1px;
}

.gutter-y:hover::before,
.gutter-y.is-on::before {
  height: 2px;
  margin-top: -1px;
}

/* TREE */
.tree {
  flex: 1;
  overflow: auto;
  padding: 4px 0 16px;
  font-family: var(--font-ui);
  font-size: 13px;
}

.tree ul {
  margin: 0;
  padding: 0 0 0 12px;
  list-style: none;
}

.tree > ul {
  padding-left: 0;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 12px);
  min-height: 28px;
  margin: 1px 6px;
  padding: 2px 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  text-align: left;
  color: var(--text);
}

.tree-row:hover {
  background: var(--hover);
}

.tree-row.is-active {
  background: var(--select);
  box-shadow: inset 2px 0 0 var(--spark);
}

.tree-row:focus,
.tree-row.is-tree-on {
  outline: 1px solid var(--spark);
  outline-offset: -1px;
}

#btn-tabs-more {
  flex: 0 0 auto;
  min-width: 36px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.tree-twist {
  width: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.tree-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-row[data-type="dir"] .tree-name {
  color: var(--text);
}

.empty-hint {
  margin: 16px 12px;
  color: var(--muted);
  font-size: 13px;
}

.files-empty-hide #files-empty {
  display: none;
}

/* TABS + EDITOR */
.tabs {
  flex: 1;
  display: flex;
  gap: 0;
  overflow-x: auto;
  min-width: 0;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 8px 0 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}

.tab.is-on {
  color: var(--text);
  background: var(--bg);
  box-shadow: inset 0 -2px 0 var(--spark);
}

.tab.is-dirty .tab-name::after {
  content: " *";
  color: var(--heat);
}

.tab-close {
  border: 0;
  min-width: 22px;
  min-height: 22px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.tab-close:hover {
  color: var(--heat);
}

.editor-host,
.editor-fallback {
  flex: 1;
  min-height: 0;
}

.editor-fallback {
  width: 100%;
  resize: none;
  border: 0;
  padding: 12px;
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.forge-empty {
  position: absolute;
  inset: 36px 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.home.forge-empty {
  pointer-events: auto;
  flex-direction: column;
  justify-content: flex-start;
  overflow: auto;
  gap: 18px;
  padding: 28px 24px 40px;
  color: var(--text);
}

.home.forge-empty.is-open {
  padding-top: 36px;
  gap: 14px;
}

.home.forge-empty.is-open .home-lead {
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
}

.home-lead {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.home-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.home-cards,
.chat-home {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 720px;
  justify-content: center;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  width: min(720px, 100%);
}

.home-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  min-height: 88px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
  overflow: hidden;
}

.home-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 99px;
  background: var(--line-strong);
}

.home-card[data-profile="landing"]::before { background: #7eb6d9; }
.home-card[data-profile="bot"]::before { background: #e8b86d; }
.home-card[data-profile="enot"]::before { background: #8fbf88; }
.home-card[data-profile="smsb"]::before { background: #c89ad4; }
.home-card[data-profile="grok"]::before { background: var(--spark); }

.home-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  background: var(--panel-2);
}

.home-card.is-on {
  border-color: var(--spark);
  background: var(--panel-2);
  box-shadow: 0 0 0 1px rgba(232, 184, 109, 0.22), 0 10px 28px rgba(0, 0, 0, 0.28);
}

.home-card-name {
  font-size: 15px;
  font-weight: 600;
  padding-left: 8px;
}

.home-card-hint {
  font-size: 12px;
  color: var(--muted);
  padding-left: 8px;
}

.home-card.is-add {
  align-items: center;
  justify-content: center;
  min-width: 0;
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

.home-card.is-add::before {
  display: none;
}

.home-card-plus {
  font-size: 28px;
  line-height: 1;
  color: var(--spark);
}

.home-recents {
  max-width: 720px;
  width: min(720px, 100%);
}

.home-sess {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 720px;
  width: min(720px, 100%);
}

.home-sess button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.home-sess button:hover {
  border-color: var(--spark);
  background: var(--hover);
}

.home-sess-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.home-sess-when {
  font-size: 11px;
  color: var(--muted);
}

.git-diff {
  margin: 8px;
  padding: 10px;
  max-height: 220px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: pre-wrap;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.git-row {
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.git-row .side-hit {
  flex: 1;
  min-width: 0;
}

.git-row .btn-quiet {
  flex: 0 0 auto;
  min-width: 28px;
  padding: 0 6px;
}

#git-list {
  padding: 4px 0 12px;
}

.git-file {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 8px 6px;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.git-file:hover {
  border-color: var(--line-strong);
}

.git-file-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  text-align: left;
  min-height: 32px;
  padding: 0;
}

.git-file-st {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  min-width: 1.6em;
  white-space: nowrap;
  color: var(--spark);
}

.git-file-st.is-d { color: var(--heat); }
.git-file-st.is-a { color: var(--ok); }
.git-file-st.is-q { color: var(--muted); }

.git-file-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.git-file .btn-quiet {
  flex: 0 0 auto;
  min-width: 28px;
  min-height: 28px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  color: var(--text);
}

.modal-card input[type="text"] {
  width: 100%;
  min-height: 40px;
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
}

.log-tools {
  display: flex;
  gap: 6px;
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.log:hover .log-tools,
.log:focus-within .log-tools {
  opacity: 1;
}

.log.is-grok:not(.has-copy) .log-tools {
  display: none !important;
}

.log-tools .btn-quiet {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px 4px;
}

.composer-actions .btn-chip {
  min-height: 32px;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  background: var(--panel);
}

.agent-tab input {
  width: 110px;
  min-height: 22px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--status);
}

.diff-host {
  position: absolute;
  inset: 36px 0 0 0;
}

.chat-home {
  padding: 16px 12px;
  flex-direction: column;
  align-items: stretch;
  display: flex;
  gap: 10px;
}

.chat-home-lead {
  margin: 8px 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.chat-home .composer-actions {
  padding: 0;
}

.chat-home .btn-chip {
  min-height: 34px;
  padding: 0 12px;
}

.chat-home .home-card::before {
  display: none;
}

.chat-home .home-card-name,
.chat-home .home-card-hint {
  padding-left: 0;
}

.done-files {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.done-files .linkish {
  border: 0;
  background: transparent;
  padding: 2px 0;
  min-height: 0;
  color: var(--info);
  text-align: left;
  flex: 1;
}

.done-file-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
}

.done-file-st {
  font-size: 11px;
  color: var(--muted);
  min-width: 64px;
}

.done-file-row.is-kept .linkish {
  color: var(--ok);
}

.done-file-row.is-rej .linkish {
  color: var(--muted);
  text-decoration: line-through;
}

.done-file-act {
  min-height: 26px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: 999px;
}

.side-tools.git-commit {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.side-tools.git-commit input {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.side-tools.git-commit .btn-run {
  width: 100%;
  min-height: 36px;
  margin: 0;
  border-radius: var(--radius-sm);
}

.git-push-ask .git-commit {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: stretch;
}

.forge {
  position: relative;
}

.forge.has-file .forge-empty,
.forge.has-stage .forge-empty {
  display: none;
}

.editor-host {
  visibility: visible;
}

.forge:not(.has-file):not(.has-stage) .editor-host,
.forge:not(.has-file):not(.has-stage) .editor-fallback,
.forge:not(.has-file):not(.has-stage) .diff-host,
.forge:not(.has-file):not(.has-stage) .preview-host,
.forge:not(.has-file):not(.has-stage) .stage-host {
  visibility: hidden;
}

.monaco-editor,
.monaco-editor-background,
.monaco-editor .margin {
  background-color: var(--bg) !important;
}

/* TERM */
.term-stack {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.term-host {
  flex: 1;
  min-height: 0;
  padding: 6px 8px 8px;
}

.term-host[hidden] {
  display: none !important;
}

.tab-pin {
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--spark);
  flex: 0 0 auto;
  transform: rotate(45deg);
}

.tab.is-pinned {
  padding-left: 8px;
}

.term-fallback {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.term-out {
  flex: 1;
  margin: 0;
  overflow: auto;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
}

.term-in {
  border: 0;
  border-top: 1px solid var(--line);
  min-height: 36px;
  padding: 6px 10px;
  font-family: var(--font-mono);
}

.xterm {
  height: 100%;
}

.xterm-viewport {
  overflow-y: auto !important;
}

/* CHAT */
.transcript {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
  padding: 14px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  height: auto;
  align-self: stretch;
}

.log[hidden] {
  display: none !important;
}

.log.is-you {
  margin-left: 18px;
  background: var(--panel-2);
  border-color: var(--line-strong);
}

.log.is-grok {
  margin-right: 18px;
}

.log.is-sys {
  border: 0;
  background: transparent;
  padding: 2px 4px;
  box-shadow: none;
}

.log.is-sys .log-k { display: none; }

.log.is-sys .log-v {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.85;
}

.log.is-done {
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 12px 14px;
}

.log.is-done .log-k {
  display: block;
  color: var(--ok);
}

.log-k {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.log-k.is-you { color: var(--spark); }
.log-k.is-grok { color: var(--ok); }
.log-k.is-sys { color: var(--muted); }

.log-v {
  min-width: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
  flex: 0 0 auto;
  height: auto;
}

.log-v:empty,
.grok-live:empty,
.log-v p:empty {
  display: none;
}

.log.is-grok.has-copy .log-v {
  padding-right: 76px;
}

.grok-live {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.grok-live[hidden] {
  display: none !important;
}

.log-v p { margin: 0 0 8px; }
.log-v p:last-child { margin-bottom: 0; }

.log-v pre,
.log-v code {
  font-family: var(--font-mono);
  font-size: 12px;
}

.log-v pre {
  overflow: auto;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
}

.log-v code {
  background: var(--bg);
  padding: 0 4px;
}

.log-v a { color: var(--info); }

.thoughts {
  display: none !important;
}

.thoughts > summary {
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  list-style: none;
  padding: 8px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--bg);
}

.thoughts > summary::before {
  content: '▸ ';
  color: var(--muted);
}

.thoughts[open] > summary::before {
  content: '▾ ';
}

.thoughts > summary::-webkit-details-marker { display: none; }

.thoughts:not([open]) > .thoughts-body {
  display: none;
}

.thoughts-body {
  margin: 0;
  padding: 0 10px 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-wrap;
  max-height: 28vh;
  overflow: auto;
}

.tool {
  border: 1px solid var(--line);
  background: var(--bg);
  box-shadow: inset 3px 0 0 var(--muted);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tool.kind-read { box-shadow: inset 3px 0 0 var(--info); }
.tool.kind-edit { box-shadow: inset 3px 0 0 var(--brass); }
.tool.kind-execute { box-shadow: inset 3px 0 0 var(--heat); }
.tool.kind-search { box-shadow: inset 3px 0 0 var(--ok); }
.tool.kind-fetch { box-shadow: inset 3px 0 0 var(--info); }

.tool-h {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.tool-kind {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.tool-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.tool-st {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.tool-st.is-run { color: var(--brass); }
.tool-st.is-ok { color: var(--ok); }
.tool-st.is-fail { color: var(--heat); }

.tool-b {
  display: none;
}

.tool.is-open .tool-b {
  display: block;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  overflow: auto;
  max-height: 180px;
  white-space: pre-wrap;
}

.tool-h {
  cursor: pointer;
}

.diff {
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: auto;
  max-height: 240px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.diff-path {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--brass);
}

.diff-line {
  padding: 0 8px;
  white-space: pre;
}

.diff-line.is-del {
  color: #ffb3a3;
  background: #2a1410;
}

.diff-line.is-add {
  color: #b6ffd4;
  background: #102418;
}

.plan {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plan li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13px;
}

.plan-st {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: capitalize;
  color: var(--muted);
  min-width: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--hover);
}

.plan li.is-run .plan-st { color: var(--spark); background: var(--spark-dim); }
.plan li.is-ok .plan-st { color: var(--ok); }

.slash-hints,
.at-hints {
  padding: 4px 12px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  max-height: 180px;
  overflow: auto;
}

.slash-hints button,
.at-hints button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  min-height: 32px;
  padding: 4px 8px;
  color: var(--text);
  background: transparent;
}

.slash-hints button.is-on,
.slash-hints button:hover,
.at-hints button.is-on,
.at-hints button:hover {
  background: var(--hover);
  border-radius: var(--radius-xs);
}

.git-push-ask {
  margin: 8px 10px 10px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--spark-dim);
}

.git-push-ask p {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text);
}

.git-push-row {
  padding: 0 8px 8px;
}

.turn-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin: 0;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
}

.turn-progress[hidden] {
  display: none;
}

.turn-progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brass);
  flex: 0 0 auto;
  animation: turn-pulse 1.2s ease-in-out infinite;
}

.agent-pane:not(.is-busy) .turn-progress-dot {
  background: var(--ok);
  animation: none;
}

.turn-progress-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

@keyframes turn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 10px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer textarea {
  width: 100%;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}

.composer textarea:focus {
  border-color: var(--spark);
  outline: none;
  box-shadow: 0 0 0 3px var(--spark-dim);
}

.composer-shots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.composer-shots[hidden] {
  display: none;
}

.shot {
  position: relative;
  width: 72px;
  height: 56px;
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
  border-radius: var(--radius-xs);
}

.shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shot button {
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 20px;
  border: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  line-height: 20px;
}

.log-shots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.log-shots img {
  max-width: 100%;
  max-height: 220px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.composer.is-dictating textarea {
  border-color: var(--heat);
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.composer-send {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  margin-left: auto;
}

.composer-hint {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctx-meter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  margin: 0;
  padding: 0 10px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
}

.ctx-meter:hover {
  border-color: var(--spark);
  background: var(--hover);
}

.ctx-meter.is-warn {
  color: var(--brass);
  border-color: var(--brass);
}

.ctx-meter.is-hot {
  color: var(--heat);
  border-color: var(--heat);
}

.ctx-ring {
  width: 22px;
  height: 22px;
  transform: rotate(-90deg);
  flex: 0 0 auto;
}

.ctx-ring-track {
  stroke: var(--line-strong);
  stroke-width: 2.4;
}

.ctx-ring-val {
  stroke: var(--spark);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 37.7;
  stroke-dashoffset: 37.7;
  transition: stroke-dashoffset 0.2s ease, stroke 0.2s ease;
}

.ctx-meter.is-warn .ctx-ring-val {
  stroke: var(--brass);
}

.ctx-meter.is-hot .ctx-ring-val {
  stroke: var(--heat);
}

.ctx-meter-lab {
  min-width: 2.6em;
  text-align: left;
}

.composer-tokens {
  font-family: var(--font-mono);
  font-size: 11px;
  color: inherit;
  opacity: 0.8;
}

.composer-queue {
  list-style: none;
  margin: 0;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text);
  border-top: 1px solid var(--line);
  max-height: 40vh;
  overflow: auto;
}

.composer-queue li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 28px;
  padding: 2px 0;
}

.queue-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
}

.queue-text:hover {
  border-color: var(--line-strong);
}

.queue-shots {
  display: inline-block;
  margin-left: 6px;
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.queue-edit {
  flex: 1;
  min-width: 0;
  min-height: 64px;
  resize: vertical;
  padding: 6px 8px;
  border: 1px solid var(--spark);
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
}

.queue-x,
.composer-queue li button.queue-x {
  flex: 0 0 auto;
  min-width: 28px;
  min-height: 28px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.queue-x:hover {
  color: var(--heat);
}

.log.is-ask .log-k {
  color: var(--spark);
}

.ctx-nudge {
  margin: 0 10px 8px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--spark-dim);
  font-size: 12px;
  color: var(--text);
}

.ctx-nudge[hidden] {
  display: none;
}

.ctx-nudge p {
  margin: 0 0 6px;
}

.ctx-nudge-break {
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-mono);
}

.ctx-nudge button {
  margin-right: 8px;
}

.ctx-nudge.is-hot {
  border-color: var(--heat);
  background: rgba(224, 112, 88, 0.14);
}

.disk-lock {
  margin: 0 10px 8px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--spark-dim);
  font-size: 12px;
  color: var(--text);
}

.disk-lock[hidden] {
  display: none;
}

.disk-lock p {
  margin: 0 0 6px;
}

.disk-lock button {
  margin-right: 8px;
}

.attn-hold {
  margin: 0 10px 8px;
  padding: 10px 12px;
  border: 1px solid var(--brass);
  border-radius: var(--radius-sm);
  background: rgba(232, 184, 109, 0.16);
  font-size: 12px;
  color: var(--text);
}

.attn-hold[hidden] {
  display: none;
}

.attn-hold p {
  margin: 0 0 8px;
}

.attn-hold button {
  margin-right: 8px;
}

.attn-need {
  color: var(--brass);
  font-weight: 600;
}

@keyframes tab-attn {
  0%, 100% {
    background: var(--brass);
    color: var(--spark-ink);
    box-shadow: inset 0 -2px 0 #111;
  }
  50% {
    background: var(--heat);
    color: #fff;
    box-shadow: inset 0 -2px 0 #111, 0 0 14px rgba(224, 112, 88, 0.55);
  }
}

@keyframes tab-attn-dot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

.agent-tab.is-attn,
.agent-tab.is-attn.is-on,
.agent-tab.is-run.is-attn,
.agent-tab.is-run.is-on.is-attn {
  color: var(--text);
  background: var(--bg);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--spark);
  animation: none;
}

.agent-tab.is-attn .agent-tab-dot {
  background: var(--spark);
  box-shadow: 0 0 0 3px var(--spark-dim);
  animation: tab-attn-dot 0.85s ease-in-out infinite;
}

.unfin-hold {
  margin: 0 10px 8px;
  padding: 10px 12px;
  border: 1px solid var(--heat);
  border-radius: var(--radius-sm);
  background: rgba(224, 112, 88, 0.16);
  font-size: 12px;
  color: var(--text);
}

.unfin-hold[hidden] {
  display: none;
}

.unfin-hold p {
  margin: 0 0 8px;
}

.unfin-hold button {
  margin-right: 8px;
}

.agent-tab.is-unfin {
  color: var(--heat);
}

.agent-tab.is-unfin .agent-tab-dot {
  background: var(--heat);
  box-shadow: 0 0 0 3px rgba(224, 112, 88, 0.4);
}

.agent-tab.is-unfin .agent-tab-live.is-unfin {
  display: inline-block;
  background: var(--heat);
  color: #1a1713;
}

.term-pty {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ok);
}

.btn-quiet {
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
}

.btn-quiet:hover {
  color: var(--text);
  background: var(--hover);
  border-radius: var(--radius-xs);
}

.btn-mic {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-mic:hover {
  color: var(--text);
  background: var(--panel-2);
}

.btn-mic.is-on {
  color: #fff;
  background: var(--heat);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

.mic-sheet {
  position: fixed;
  z-index: 40;
  right: 24px;
  bottom: 88px;
  width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.mic-sheet p {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.4;
}

.mic-sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(241, 76, 76, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(241, 76, 76, 0); }
}

.agent-pane.is-busy .thoughts:not([open]) > summary {
  color: var(--brass);
}

@media (prefers-reduced-motion: reduce) {
  .btn-mic.is-on { animation: none; }
  .turn-progress-dot { animation: none; }
  .agent-tab.is-run .agent-tab-dot { animation: none; }
  .agent-tab.is-attn,
  .agent-tab.is-attn.is-on,
  .agent-tab.is-run.is-attn,
  .agent-tab.is-run.is-on.is-attn {
    animation: none;
    background: var(--bg);
    color: var(--text);
  }
  .agent-tab.is-attn .agent-tab-dot { animation: none; }
}

.btn-send {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--spark);
  color: var(--spark-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-send:hover {
  filter: brightness(1.08);
}

.btn-jump {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--spark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-jump.is-away,
.btn-jump:hover,
.btn-jump:active {
  background: var(--spark);
  color: var(--spark-ink);
  border-color: var(--spark);
}

.btn-stop {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--panel-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stop-sq {
  width: 10px;
  height: 10px;
  background: var(--text);
}

/* PALETTE + MODAL */
.palette,
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(9, 10, 8, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}

.palette-plate,
.modal-card {
  width: min(640px, 100%);
  border: 1px solid var(--line-strong);
  padding: 18px;
  backdrop-filter: blur(16px);
}

.palette-plate input {
  width: 100%;
  min-height: 44px;
  margin: 10px 0;
  padding: 8px 10px;
  background: var(--bg);
  font-family: var(--font-mono);
}

.palette-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 50vh;
  overflow: auto;
}

.palette-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  min-height: 40px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}

.palette-item.is-on,
.palette-item:hover {
  background: var(--select);
  box-shadow: none;
  border-radius: var(--radius-xs);
}

.modal-card h2 {
  margin: 8px 0;
  font-family: var(--font-display);
  font-size: 22px;
}

.perm-detail {
  color: var(--muted);
  margin: 0 0 16px;
}

.perm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toasts {
  position: fixed;
  z-index: 50;
  top: auto;
  left: calc(var(--act-w) + var(--files-w) + 16px);
  right: auto;
  bottom: 36px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(360px, 42vw);
}

.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  font-size: 13px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.toast.is-err { border-color: var(--heat); }
.toast.is-ok { border-color: #2f4a3a; }

.dock {
  display: none;
  gap: 6px;
  padding: 6px 8px;
  background: #12100d;
  border-top: 1px solid var(--line);
}

.dock-btn {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-top: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.dock-btn.is-on,
.dock-btn.is-open {
  color: var(--spark-ink);
  background: var(--spark);
}

.dock-sheet {
  display: none;
}

/* MOBILE */
@media (max-width: 900px) {
  body.no-side .activity,
  body.no-side #slot-west,
  body.no-side #gutter-files {
    display: revert !important;
  }

  .toasts {
    left: 12px;
    right: 12px;
    top: calc(env(safe-area-inset-top, 0px) + 52px);
    bottom: auto;
    max-width: none;
    z-index: 20;
  }

  #hdr-mode,
  .statusbar .mode-chip {
    display: none !important;
  }

  .workbench {
    display: grid;
    grid-template-rows: 1fr 52px var(--status-h);
    height: var(--vvh, 100dvh);
    padding-top: env(safe-area-inset-top, 0px);
  }

  .dock {
    display: flex;
    z-index: 5;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .dock-btn {
    min-height: 44px;
    font-size: 14px;
  }

  .activity {
    display: none;
  }

  .titlebar { z-index: 2; }
  .menubar { display: none; }
  .heat-gauge { display: none; }

  .wb-body {
    min-height: 0;
    position: relative;
  }

  .cols {
    flex: 1;
    min-height: 0;
    min-width: 0;
    position: relative;
    display: block;
  }

  .col-main,
  .row-top {
    display: contents;
  }

  .gutter { display: none; }

  .slot,
  .editor-groups,
  .editor-group {
    display: contents;
  }

  .slot-tabs,
  .panel-grip,
  .layout-drop {
    display: none !important;
  }

  .files,
  .forge,
  .agent,
  .hearth {
    display: none;
    width: auto;
    flex: none;
    height: auto;
    border: 0;
    position: absolute;
    inset: 0;
  }

  body[data-dock="files"] .files,
  body[data-dock="forge"] .forge,
  body[data-dock="agent"] .agent,
  body[data-dock="hearth"] .hearth {
    display: flex;
  }

  .tree-row { min-height: 40px; }
  .btn-send, .btn-stop, .btn-mic, .btn-jump { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
  .sb-cwd { max-width: 110px; }
}

@media (max-width: 640px) {
  .key-row,
  .device-code-row {
    flex-direction: column;
    align-items: stretch;
  }

  .gate-frame { padding: 20px 16px 24px; }
  .mcp { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .btn-spark:active {
    transform: none;
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(232, 196, 120, 0.22);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(232, 196, 120, 0.4);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.mode-chip,
.btn-gear {
  min-height: 36px;
  min-width: 36px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg);
  border: 1px solid var(--line);
}

.btn-gear {
  font-size: 16px;
  letter-spacing: 0;
  text-transform: none;
}

body[data-mode="plan"] .mode-chip {
  color: var(--info);
  border-color: var(--info);
}

body[data-mode="yolo"] .mode-chip {
  color: var(--heat);
  border-color: var(--heat);
}

.ctx {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.ctx-bar {
  display: inline-block;
  width: 64px;
  height: 6px;
  background: var(--line);
  position: relative;
}

.ctx-bar {
  border-radius: 99px;
  overflow: hidden;
}

.ctx-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--spark);
}

.ctx-bar-lg {
  width: 100%;
  height: 8px;
  margin: 0 0 10px;
}

.ctx-break-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 8px;
  align-items: center;
}

.ctx-break-bar {
  display: block;
  height: 6px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.ctx-break-bar i {
  display: block;
  height: 100%;
  background: var(--spark);
}

.draw {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(9, 10, 8, 0.72);
  display: flex;
  justify-content: flex-end;
}

.draw-plate {
  width: min(420px, 100%);
  height: 100%;
  overflow: auto;
  padding: 16px 18px 32px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.draw-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.draw-k {
  margin: 16px 0 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.draw-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.draw-stat {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.draw-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
}

.draw-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
}

.draw-list li:last-child { border-bottom: 0; }

.draw-list .linkish {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 0;
  text-align: left;
  color: var(--info);
}

.btn-chip.is-on {
  color: var(--spark-ink);
  border-color: var(--spark);
  background: var(--spark);
}

/* TITLEBAR + ACTIVITY + STATUS (VS Code chrome) */
.titlebar {
  height: var(--title-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
  user-select: none;
}

.title-mark {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--spark);
  box-shadow: 0 0 10px rgba(232, 184, 109, 0.45);
  flex: 0 0 auto;
}

.menubar {
  display: flex;
  align-items: center;
  gap: 0;
}

.menu-root {
  border: 0;
  min-height: 24px;
  min-width: 0;
  padding: 2px 8px;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
}

.menu-root:hover,
.menu-root.is-on {
  background: var(--panel-2);
}

.titlebar-title {
  margin: 0;
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.activity {
  width: var(--act-w);
  flex: 0 0 var(--act-w);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #12100d;
  border-right: 1px solid var(--line);
}

.act-btn {
  width: calc(100% - 8px);
  height: 44px;
  min-height: 44px;
  min-width: 0;
  margin: 4px 4px 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #8d8678;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.act-btn:hover {
  color: var(--text);
  background: var(--hover);
}

.act-btn.is-on {
  color: var(--spark);
  background: var(--spark-dim);
}

.act-btn.is-on::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 99px;
  background: var(--spark);
}

.act-btn.is-live::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--spark);
  box-shadow: 0 0 0 3px var(--spark-dim);
}

.act-gap {
  flex: 1;
}

.statusbar {
  height: var(--status-h);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  background: var(--status);
  color: #d8d0c0;
  font-family: var(--font-ui);
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  border-top: 1px solid var(--line-strong);
  box-shadow: inset 3px 0 0 var(--spark);
}

body.is-yolo .statusbar {
  box-shadow: inset 3px 0 0 var(--heat);
}

body.is-forging .statusbar {
  box-shadow: inset 3px 0 0 var(--spark);
}

.heat-lab.is-hot {
  font-weight: 600;
}

.heat-lab.is-done {
  font-weight: 600;
}

#hdr-heat {
  flex: 1;
  min-width: 72px;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  justify-content: flex-end;
}

#hdr-acp {
  flex: 0 1 auto;
  max-width: 9.5em;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.is-forging #hdr-acp {
  display: none !important;
}

#hdr-usage-lab {
  font-variant-numeric: tabular-nums;
}

.sb-item,
.sb-item.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  height: 22px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.sb-item:hover,
button.sb-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

#sb-folder {
  max-width: 42vw;
  min-width: 120px;
}

.sb-folder-btn {
  border: 0;
  min-height: 22px;
  min-width: 22px;
  padding: 0;
  background: transparent;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sb-cwd,
input.sb-cwd {
  min-height: 18px;
  height: 18px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 11px;
  max-width: 220px;
  min-width: 72px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-gap {
  flex: 1;
}

.statusbar .mcp,
.statusbar .heat-lab,
.statusbar .acp-lab {
  font-size: 11px;
  letter-spacing: 0.04em;
}

.statusbar .usage {
  font-size: 11px;
  letter-spacing: 0;
}

.statusbar .ctx-bar {
  width: 48px;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
}

.statusbar .ctx.is-warn .ctx-bar i {
  background: var(--brass);
}

.statusbar .ctx.is-hot .ctx-bar i {
  background: var(--heat);
}

.statusbar .ctx.is-hot {
  color: var(--heat);
}

.statusbar .heat-gauge {
  height: 10px;
}

.statusbar .mode-chip {
  font-weight: 600;
}

body[data-mode="plan"] .statusbar .mode-chip {
  color: var(--info);
  background: rgba(212, 180, 131, 0.14);
}

body[data-mode="yolo"] .statusbar .mode-chip {
  background: var(--heat);
  color: #1a1713;
}

.menu-fly {
  position: fixed;
  z-index: 55;
  min-width: 220px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
}

.chat-pop {
  width: 280px;
  padding: 12px 12px 8px;
}

.chat-pop-h {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
}

.chat-pop-lab {
  margin: 8px 0 4px;
  font-size: 11px;
  color: var(--muted);
}

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

.chat-pop .model {
  width: 100%;
  min-height: 32px;
  margin: 0 0 8px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.chat-pop-all {
  margin-top: 4px;
  color: var(--muted);
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  text-align: left;
  font-size: 13px;
  color: var(--text);
}

.menu-item:hover,
.menu-item:focus {
  background: var(--select);
  outline: none;
}

.menu-k {
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-mono);
}

.menu-note {
  margin: 0;
  padding: 6px 12px 8px;
  color: var(--muted);
  font-size: 12px;
  max-width: 260px;
}

.menu-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--line);
}

/* SETTINGS EDITOR (VS Code Settings tab) */
.settings-editor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.settings-editor[hidden] {
  display: none !important;
}

.forge.is-settings .editor-host,
.forge.is-settings .editor-fallback,
.forge.is-settings .diff-host,
.forge.is-settings .forge-empty,
.forge.is-settings #stage-host {
  position: absolute;
  inset: 36px 0 0 0;
  visibility: hidden;
  pointer-events: none;
}

.forge.is-settings #stage-host {
  display: none !important;
}

.forge.is-settings .forge-empty {
  display: none;
}

.set-phone-bar {
  display: none;
}

body > #settings-editor:not([hidden]) {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: calc(52px + env(safe-area-inset-bottom, 0px) + var(--status-h, 26px));
  z-index: 40;
  display: flex !important;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
}

body > #settings-editor .set-phone-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

body > #settings-editor .set-search-wrap {
  display: none;
}

body > #settings-editor .set-toc {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  border-right: 0;
  border-bottom: 1px solid var(--line);
}

.set-search-wrap {
  padding: 12px 18px 8px;
  border-bottom: 1px solid var(--line);
}

#set-search {
  width: 100%;
  max-width: 560px;
  min-height: 36px;
  padding: 8px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.set-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 200px 1fr;
}

.set-toc {
  overflow: auto;
  padding: 12px 0 24px;
  border-right: 1px solid var(--line);
}

.set-toc-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  min-height: 28px;
  padding: 4px 16px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.set-toc-btn:hover {
  color: var(--text);
  background: var(--panel-2);
}

.set-toc-btn.is-on {
  color: var(--text);
  background: var(--spark-dim);
  box-shadow: inset 2px 0 0 var(--spark);
}

.set-list {
  overflow: auto;
  padding: 8px 28px 48px;
}

.set-h {
  margin: 22px 0 8px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0;
  font-family: var(--font-ui);
}

.set-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 16px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  align-items: start;
}

.set-copy {
  flex: 1 1 240px;
}

.set-ctrl {
  flex: 1 1 220px;
}

.set-name {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.set-desc {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  max-width: 52ch;
}

.set-ctrl {
  min-width: 0;
}

.set-cwd-ctrl,
.set-account-ctrl {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.set-cwd-ctrl .cwd {
  flex: 1;
  min-width: 160px;
}

.tab.is-virtual .tab-name {
  font-style: normal;
}

@media (max-width: 900px) {
  .ctx { display: none; }
  .menubar { display: none !important; }
  .titlebar-title { display: none; }
  .composer-tokens { display: none; }
}

.files {
  overflow: hidden;
}

.side-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.side-tools {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.side-tools input {
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12px;
  border-radius: var(--radius-xs);
}

.side-tools input:focus {
  border-color: var(--spark);
  outline: none;
  box-shadow: 0 0 0 3px var(--spark-dim);
}

.side-list {
  list-style: none;
  margin: 0;
  padding: 0 0 16px;
  overflow: auto;
  flex: 1;
}

.side-list li {
  margin: 0;
}

.side-hit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  min-height: 32px;
  padding: 6px 10px;
  background: transparent;
  color: var(--text);
}

.side-hit {
  border-radius: var(--radius-xs);
  margin: 2px 6px;
  width: calc(100% - 12px);
}

.side-hit:hover {
  background: var(--hover);
}

.side-hit.is-open {
  background: var(--select);
  box-shadow: inset 2px 0 0 var(--spark);
}

.sess-group {
  margin: 0 0 10px;
}

.sess-group-h {
  margin: 10px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.sess-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tab-picker {
  width: min(320px, 86vw);
  padding: 8px;
}

.tab-picker input {
  width: 100%;
  min-height: 32px;
  margin-bottom: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  background: var(--bg);
}

.tab-picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow: auto;
}

.tab-pick {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: var(--radius-xs);
  min-height: 36px;
  padding: 6px 10px;
  background: transparent;
  color: var(--text);
}

.tab-pick:hover,
.tab-pick.is-on {
  background: var(--select);
}

.tab-pick.is-run .tab-pick-name {
  color: var(--spark);
}

.tab-pick-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  font-size: 13px;
}

.tab-pick-meta {
  font-size: 11px;
  color: var(--muted);
}

.side-hit-path {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.side-hit-text {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.auto-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding-right: 8px;
}

.auto-row .side-hit {
  flex: 1;
}

.btn-run {
  min-height: 28px;
  min-width: 64px;
  margin: 4px 0;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: var(--spark);
  color: var(--spark-ink);
  font-size: 12px;
  font-weight: 600;
}

.palette-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gutter:hover,
.gutter.is-on {
  background-color: transparent;
}

.remote-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: 420px;
}

.remote-link {
  color: var(--spark);
  text-decoration: underline;
  word-break: break-all;
  cursor: pointer;
}

.remote-pass-lab {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text);
}

.remote-qr {
  width: 220px;
  height: 220px;
  padding: 10px;
  background: #ece6d8;
  border-radius: var(--radius-sm);
}

.remote-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

#remote-pass {
  font-size: 16px;
  min-height: 44px;
}

#dock-more {
  display: none;
}

@media (max-width: 900px) {
  .activity {
    display: none !important;
  }

  .dock {
    display: flex;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .dock-extra {
    display: none;
  }

  #dock-more {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .dock-sheet:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
  }

  .dock-sheet-dismiss {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.45);
  }

  .dock-sheet-card {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px) + var(--status-h));
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .dock-sheet-btn {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-size: 16px;
    text-align: left;
    touch-action: manipulation;
  }

  .dock-sheet-btn.is-on,
  .dock-sheet-btn:active {
    background: var(--select);
    color: var(--spark);
  }

  body.kb-open .dock-sheet {
    display: none !important;
  }

  #set-search {
    font-size: 16px;
    max-width: none;
  }

  .workbench {
    height: var(--vvh, 100dvh);
    padding-top: env(safe-area-inset-top, 0px);
    grid-template-rows: 1fr 52px var(--status-h);
  }

  .titlebar {
    display: none !important;
  }

  .titlebar-title {
    font-size: 13px;
  }

  .agent {
    background: var(--bg);
  }

  .agent-pane {
    padding: 0;
  }

  .composer {
    position: relative;
    z-index: 8;
    padding: 8px 10px;
  }

  .composer-send {
    position: relative;
    z-index: 9;
    gap: 8px;
  }

  .composer textarea {
    font-size: 16px;
    min-height: 56px;
    max-height: 36vh;
  }

  .btn-send, .btn-stop, .btn-mic, .btn-jump {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }

  body.is-agent-mosaic .btn-send,
  body.is-agent-mosaic .btn-stop,
  body.is-agent-mosaic .btn-mic,
  body.is-agent-mosaic .btn-jump {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .agent-h {
    min-height: 44px;
  }

  .agent-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .menubar,
  .panel-grip,
  #btn-agent-add-1,
  #btn-agent-split {
    display: none !important;
  }

  #btn-agent-more {
    display: inline-flex !important;
    min-width: 44px;
    min-height: 44px;
  }

  .agent-h {
    min-height: 48px;
    padding: 0 4px;
  }

  .agent-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 4px;
  }

  .agent-tabs::-webkit-scrollbar {
    display: none;
  }

  .agent-tab {
    min-height: 44px;
    min-width: 0;
    max-width: 42vw;
    flex: 0 0 auto;
    padding: 0 10px;
    font-size: 14px;
    cursor: pointer;
    touch-action: manipulation;
  }

  .agent-tab-x {
    display: none !important;
  }

  .agent-tab-ctx,
  .agent-tab-ctx-lab {
    display: none !important;
  }

  .agent-panes.is-mosaic,
  .agent-group {
    flex-direction: column !important;
  }

  .agent-col {
    min-width: 0 !important;
    width: 100%;
    flex: 1;
  }

  .agent-mosaic-gutter,
  #agent-group-1,
  .agent-h-south {
    display: none !important;
  }

  .tab-picker {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: none;
    max-height: 70vh;
  }

  .tab-pick {
    min-height: 48px;
    padding: 10px 12px;
  }

  .tab-pick-name {
    font-size: 15px;
  }

  .transcript {
    -webkit-overflow-scrolling: touch;
    padding: 10px 10px 16px;
  }

  .jump-bottom {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    right: 12px;
    bottom: 12px;
  }

  #btn-jump-bottom {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }

  .log {
    font-size: 15px;
  }

  .chat-home {
    padding: 20px 16px;
  }

  .composer-hint {
    display: none;
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body.is-agent-mosaic #agent-tabs {
    display: flex !important;
  }

  body.is-agent-mosaic .agent-tile-h {
    display: none;
  }

  body.kb-open .dock,
  body.kb-open .statusbar {
    display: none !important;
  }

  body.kb-open #workbench {
    position: fixed;
    left: 0;
    right: 0;
    padding-top: 0;
    overflow: hidden;
    grid-template-rows: minmax(0, 1fr);
  }

  body.kb-open .composer {
    padding-bottom: 8px;
    flex-shrink: 0;
    z-index: 6;
  }

  body.kb-open .composer textarea {
    min-height: 44px;
    max-height: 22vh;
  }

  body.kb-open .agent-h {
    min-height: 40px;
  }

  body.kb-open .transcript {
    min-height: 0;
    flex: 1 1 auto;
  }

  body.kb-open .agent,
  body.kb-open .agent-panes,
  body.kb-open .agent-pane {
    min-height: 0;
  }

  .sb-cwd,
  .statusbar .ctx,
  #sb-preset,
  #sb-model,
  #sb-git {
    display: none;
  }

  .set-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .set-toc {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
    gap: 6px;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg);
    -webkit-overflow-scrolling: touch;
  }

  .set-toc-btn {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    width: auto;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 14px;
    background: var(--panel-2);
    box-shadow: none;
  }

  .set-toc-btn.is-on {
    background: var(--spark);
    color: var(--spark-ink);
    box-shadow: none;
  }

  .set-list {
    padding: 8px 12px 96px;
  }

  .set-row {
    flex-direction: column;
    padding: 12px;
    margin: 6px 0;
    gap: 10px;
  }

  .set-copy,
  .set-ctrl {
    flex: 1 1 auto;
    width: 100%;
  }

  .set-h {
    margin: 14px 0 6px;
    font-size: 16px;
  }

  .forge.is-settings .editor-groups,
  .forge.is-settings .editor-group,
  .forge.is-settings .forge-h,
  .forge.is-settings .editor-host,
  .forge.is-settings #stage-host,
  .forge.is-settings #preview-host,
  .forge.is-settings #diff-host,
  .forge.is-settings #editor-fallback {
    display: none !important;
  }

  #settings-editor.settings-editor:not([hidden]) {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: calc(52px + env(safe-area-inset-bottom, 0px) + var(--status-h));
    z-index: 30;
    display: flex !important;
    background: var(--bg);
  }

  .set-phone-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
  }

  .set-phone-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
  }

  #btn-set-close {
    min-height: 40px;
    padding: 0 14px;
  }

  .set-search-wrap {
    display: none;
  }

  .set-ctrl .btn-chip {
    min-height: 40px;
    padding: 0 12px;
  }

  #set-cwd {
    display: none;
  }

  .set-cwd-lab {
    display: block;
    margin: 0 0 8px;
    font-size: 14px;
    word-break: break-all;
    color: var(--muted);
  }

  .settings-editor select,
  .settings-editor .model {
    font-size: 16px;
    min-height: 44px;
  }

  #chat-pop.chat-pop {
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px) + var(--status-h));
    width: auto;
    max-height: 70vh;
    overflow: auto;
    z-index: 40;
  }

  #chat-pop .model {
    font-size: 16px;
    min-height: 44px;
  }
}
