:root {
  color-scheme: dark;
  --bg: #050907;
  --panel: rgba(8, 18, 15, 0.94);
  --panel-solid: #08120f;
  --panel-2: #0e1d19;
  --line: rgba(117, 224, 207, 0.18);
  --line-strong: rgba(117, 224, 207, 0.46);
  --text: #edf5ee;
  --muted: #9ab0a7;
  --soft: #627a71;
  --teal: #75e0cf;
  --gold: #e8bb55;
  --pink: #ef8da3;
  --blue: #9fb7ff;
  --danger: #f17f78;
  --shadow: 0 20px 64px rgba(0, 0, 0, 0.38);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #e8f0eb;
  --panel: rgba(246, 250, 247, 0.95);
  --panel-solid: #f6faf7;
  --panel-2: #dfeae4;
  --line: rgba(29, 86, 74, 0.2);
  --line-strong: rgba(29, 111, 94, 0.48);
  --text: #102a23;
  --muted: #4f6d63;
  --soft: #748c83;
  --teal: #087c68;
  --gold: #9b6500;
  --pink: #b33d62;
  --blue: #315eb6;
  --shadow: 0 20px 50px rgba(31, 61, 52, 0.18);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--bg);
  background-image: linear-gradient(rgba(3, 8, 7, 0.86), rgba(3, 8, 7, 0.94)), url('/assets/hollow-cave-ruins.webp');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="light"] {
  background-image: linear-gradient(rgba(232, 240, 235, 0.9), rgba(232, 240, 235, 0.96)), url('/assets/hollow-cave-ruins.webp');
}

body, button, a, input, textarea, select { cursor: url('/assets/hollow-knight-cursor.png') 4 4, auto; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: 26px; letter-spacing: 0; }
h2 { font-size: 34px; line-height: 1.1; letter-spacing: 0; }
h3 { font-size: 18px; letter-spacing: 0; }
p { line-height: 1.6; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  padding: 18px;
}
.brand-block { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 11px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.brand-block strong { display: block; font-size: 18px; letter-spacing: 0.18em; }
.brand-block small { display: block; margin-top: 3px; color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: 0.12em; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--teal); font-size: 19px; font-weight: 950; transform: rotate(45deg); }
.brand-mark span { transform: rotate(-45deg); }
.nav-stack { display: grid; gap: 7px; margin: 20px 0; }
.nav-button, .quiet-button {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
  font-weight: 750;
}
.nav-button:hover, .nav-button.active { border-color: var(--line); background: var(--panel-2); color: var(--text); }
.nav-button.active svg { color: var(--teal); }
.sidebar-section { border-top: 1px solid var(--line); padding: 17px 2px; }
.section-label, .eyebrow { color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: 0.15em; text-transform: uppercase; }
.runtime-row { display: flex; align-items: center; gap: 8px; margin: 13px 0; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--teal); box-shadow: 0 0 14px var(--teal); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 14px var(--danger); }
.runtime-details { display: grid; gap: 8px; }
.runtime-details div { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.runtime-details dt { color: var(--soft); }
.runtime-details dd { max-width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-weight: 700; }
.toggle-row { min-height: 44px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.toggle-row input, .theme-switch input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 38px; height: 21px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel-2); position: relative; }
.toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; border-radius: 50%; background: var(--soft); transition: transform 0.18s ease, background 0.18s ease; }
input:checked + .toggle-track::after { transform: translateX(17px); background: var(--teal); }
.quiet-button { width: 100%; border-color: var(--line); margin-top: 8px; font-size: 12px; }
.sidebar-footer { margin-top: auto; display: grid; gap: 4px; padding-top: 18px; color: var(--teal); font-size: 11px; font-weight: 800; }
.sidebar-footer small { color: var(--soft); font-weight: 600; }
.sidebar-close, .mobile-menu { display: none; }

.main-surface { min-width: 0; padding: 22px 26px 28px; }
.topbar { height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.topbar > div:first-child { display: grid; gap: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.model-pill, .mode-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 0 13px; color: var(--muted); font-size: 12px; font-weight: 800; }
.theme-switch { display: grid; grid-template-columns: 18px 38px 18px; align-items: center; gap: 7px; color: var(--soft); }
.view { min-width: 0; animation: view-in 0.28s ease both; }
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: stretch; min-height: calc(100vh - 134px); }
.command-panel, .telemetry-panel, .forge-controls, .image-stage, .system-overview, .system-checks {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.command-panel { min-width: 0; display: grid; grid-template-rows: auto auto auto minmax(280px, 1fr) auto auto auto; padding: 18px; }
.mode-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.mode-header > div { display: grid; gap: 7px; }
.mode-header p { color: var(--muted); font-size: 13px; }
.mode-pill { color: var(--teal); }
.mode-strip { display: flex; gap: 7px; overflow-x: auto; padding: 14px 0 16px; scrollbar-width: thin; }
.mode-button, .prompt-chips button, .feature-status, .load-more {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
}
.mode-button:hover, .mode-button.active { border-color: var(--line-strong); color: var(--teal); }
.selected-features { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); padding: 10px 0; }
.feature-chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel-2); color: var(--teal); padding: 5px 9px; font-size: 11px; }
.feature-chip button { border: 0; background: transparent; color: inherit; padding: 0; display: grid; }
.chat-log { min-height: 300px; max-height: calc(100vh - 410px); overflow-y: auto; border-top: 1px solid var(--line); padding: 14px 5px 14px 0; scrollbar-width: thin; }
.message { width: min(82%, 760px); margin-bottom: 16px; }
.message.user { margin-left: auto; }
.message-meta { display: flex; gap: 8px; align-items: center; color: var(--soft); font-size: 10px; font-weight: 850; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 6px; }
.message.user .message-meta { justify-content: flex-end; }
.message-body { border-left: 2px solid var(--teal); background: rgba(117, 224, 207, 0.06); padding: 13px 15px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.62; font-size: 14px; }
.message.user .message-body { border-left: 0; border-right: 2px solid var(--gold); background: rgba(232, 187, 85, 0.07); }
.message.error .message-body { border-color: var(--danger); color: var(--danger); }
.message.pending .message-body { color: var(--muted); }
.message-actions { display: flex; gap: 5px; margin-top: 5px; }
.message-actions button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--soft); padding: 4px 6px; font-size: 10px; }
.prompt-chips { display: flex; gap: 7px; overflow-x: auto; padding: 8px 0; }
.prompt-chips button { min-height: 30px; font-weight: 650; }
.composer { border: 1px solid var(--line-strong); border-radius: 7px; background: var(--panel-solid); padding: 9px; }
.composer textarea, .forge-controls textarea { width: 100%; resize: vertical; border: 0; background: transparent; color: var(--text); outline: 0; line-height: 1.5; }
.composer textarea { min-height: 66px; max-height: 180px; padding: 5px; resize: none; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.composer-tools, .composer-actions { display: flex; align-items: center; gap: 7px; }
.composer-tools > span { color: var(--soft); font-size: 10px; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--muted); padding: 0; }
.icon-button:hover { color: var(--teal); border-color: var(--line-strong); }
.send-button, .stop-button, .primary-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--teal); border-radius: 6px; background: var(--teal); color: #06100d; padding: 0 14px; font-weight: 900; }
.stop-button { border-color: var(--danger); background: transparent; color: var(--danger); }
.send-button:disabled, .primary-button:disabled { opacity: 0.5; }
.voice-dock { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding-top: 9px; }
.voice-dock > span { display: flex; align-items: center; gap: 6px; margin-right: 4px; color: var(--soft); font-size: 11px; }
.voice-dock .icon-button { width: 29px; height: 29px; }
.telemetry-panel { padding: 16px; }
.telemetry-heading { display: flex; justify-content: space-between; align-items: center; color: var(--teal); }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.metric-grid article { min-height: 92px; display: flex; flex-direction: column; justify-content: flex-end; border: 1px solid var(--line); background: var(--panel-2); padding: 11px; }
.metric-grid strong { color: var(--teal); font-size: 23px; }
.metric-grid article:nth-child(2) strong { color: var(--gold); }
.metric-grid article:nth-child(3) strong { color: var(--blue); }
.metric-grid article:nth-child(4) strong { color: var(--pink); }
.metric-grid span { color: var(--soft); font-size: 10px; margin-top: 4px; }
.signal-block { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 13px 0; }
.signal-block > div:first-child { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.signal-block strong { color: var(--teal); }
.signal-bars { height: 22px; display: flex; align-items: flex-end; gap: 4px; margin-top: 8px; }
.signal-bars i { width: 12px; background: var(--teal); animation: signal 1.8s ease-in-out infinite alternate; }
.signal-bars i:nth-child(1) { height: 6px; }.signal-bars i:nth-child(2) { height: 10px; }.signal-bars i:nth-child(3) { height: 14px; }.signal-bars i:nth-child(4) { height: 18px; }.signal-bars i:nth-child(5) { height: 22px; }
.tool-list { display: grid; gap: 7px; padding: 13px 0; }
.tool-item { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 9px; min-height: 44px; border-bottom: 1px solid var(--line); }
.tool-item i { width: 24px; height: 24px; display: grid; place-items: center; color: var(--gold); font-style: normal; font-size: 10px; }
.tool-item strong { display: block; font-size: 12px; }.tool-item span { display: block; color: var(--soft); font-size: 10px; margin-top: 2px; }
.boundary-note { display: grid; grid-template-columns: 26px 1fr; gap: 9px; border: 1px solid var(--line); padding: 11px; color: var(--gold); }
.boundary-note p { display: grid; gap: 3px; }.boundary-note strong { font-size: 11px; }.boundary-note span { color: var(--soft); font-size: 10px; line-height: 1.4; }

.forge-layout { min-height: calc(100vh - 134px); display: grid; grid-template-columns: 370px minmax(0, 1fr); gap: 18px; }
.forge-controls { padding: 26px; }.forge-controls h2 { margin: 10px 0 12px; }.forge-controls > p { color: var(--muted); margin-bottom: 24px; }
.forge-controls form { display: grid; gap: 11px; }.forge-controls label { color: var(--gold); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: 0.1em; }
.forge-controls textarea { min-height: 190px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); padding: 12px; }
.image-stage { min-height: 560px; display: grid; place-items: center; overflow: hidden; padding: 18px; }
.stage-empty { display: grid; justify-items: center; gap: 12px; color: var(--soft); text-align: center; }.stage-empty svg { width: 42px; height: 42px; }.stage-empty strong { color: var(--muted); }
.generated-image { width: 100%; height: 100%; min-height: 520px; object-fit: contain; background: #020504; }
.image-result-meta { width: 100%; display: flex; justify-content: space-between; align-items: center; color: var(--soft); font-size: 11px; margin-top: 10px; }

.feature-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 18px; border-bottom: 1px solid var(--line); padding: 10px 0 20px; }
.feature-toolbar h2 { margin-top: 8px; }
.feature-filters { display: flex; gap: 8px; }
.feature-filters label { min-width: 230px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 0 10px; }
.feature-filters input, .feature-filters select { height: 40px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); padding: 0 10px; outline: 0; }
.feature-filters label input { min-width: 0; width: 100%; border: 0; background: transparent; padding: 0; }
.feature-summary { display: flex; justify-content: space-between; gap: 12px; padding: 13px 0; color: var(--soft); font-size: 11px; }
.feature-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.feature-row { min-height: 112px; display: grid; grid-template-rows: auto 1fr auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 12px; }
.feature-row > span { color: var(--soft); font-size: 10px; }.feature-row strong { margin: 9px 0; line-height: 1.35; }.feature-row footer { display: flex; justify-content: space-between; align-items: center; }
.feature-status { min-height: 24px; padding: 0 8px; color: var(--gold); }.feature-status.built { color: var(--teal); }
.use-feature { border: 0; background: transparent; color: var(--blue); font-size: 10px; font-weight: 850; }
.load-more { display: block; margin: 16px auto 0; }

.system-layout { min-height: calc(100vh - 134px); display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr); gap: 18px; }
.system-overview, .system-checks { padding: 26px; }.system-overview h2 { margin: 10px 0 12px; }.system-overview > p { color: var(--muted); max-width: 700px; }
.architecture-flow { display: grid; grid-template-columns: 1fr 32px 1fr 32px 1fr; align-items: center; gap: 8px; margin-top: 42px; }
.architecture-flow > svg { color: var(--teal); justify-self: center; }.architecture-flow article { min-height: 180px; display: flex; flex-direction: column; justify-content: flex-end; border: 1px solid var(--line); background: var(--panel-2); padding: 18px; }.architecture-flow article svg { width: 32px; height: 32px; color: var(--gold); margin-bottom: auto; }.architecture-flow span { color: var(--soft); font-size: 11px; margin-top: 7px; }
.system-checks h3 { margin-bottom: 18px; }.system-checks ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }.system-checks li { min-height: 46px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }.system-checks li svg { color: var(--teal); }

.toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; max-width: min(360px, calc(100vw - 36px)); border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel-solid); color: var(--text); box-shadow: var(--shadow); padding: 12px 14px; transform: translateY(130%); transition: transform 0.2s ease; }
.toast.show { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes signal { from { opacity: 0.45; } to { opacity: 1; } }

@media (max-width: 1080px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); }.telemetry-panel { display: none; }
  .feature-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .forge-layout, .system-layout { grid-template-columns: 1fr; }.image-stage { min-height: 480px; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-102%); width: min(300px, 88vw); transition: transform 0.2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }.sidebar-close { display: grid; }
  .mobile-menu { display: grid; position: fixed; z-index: 30; left: 12px; top: 12px; background: var(--panel-solid); }
  .main-surface { padding: 12px; padding-top: 64px; }
  .topbar { height: auto; min-height: 56px; align-items: flex-start; }.topbar h1 { font-size: 22px; }.model-pill { display: none; }
  .command-panel { padding: 12px; min-height: calc(100vh - 144px); }.chat-log { max-height: none; min-height: 340px; }
  .message { width: 94%; }.feature-toolbar { align-items: stretch; flex-direction: column; }.feature-toolbar h2 { font-size: 27px; }.feature-filters { flex-direction: column; }.feature-filters label { min-width: 0; }.feature-list { grid-template-columns: 1fr; }
  .forge-controls { padding: 18px; }.image-stage { min-height: 390px; }.generated-image { min-height: 350px; }
  .architecture-flow { grid-template-columns: 1fr; }.architecture-flow > svg { transform: rotate(90deg); }.architecture-flow article { min-height: 135px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
