/* Litica Playground — committed dark theme.
   Palette: dataviz reference instance (validated 2026-07-19, dark surface #1a1a19).
   Roles only — swap hex here, never inline in JS. */

:root {
  color-scheme: dark;
  /* Litica brand (logo: violet/coral/amber/teal on warm cream; ink #110F14).
     Chrome uses raw brand hues; the 6 data channels use validated steps of
     the same hues (dataviz gates, dark surface #17141c, 2026-07-22). */
  --page: #0f0d13;
  --surface: #17141c;
  --surface-raised: #201d26;
  --ink: #f5f2ea;
  --ink-2: #cbc5ba;
  --ink-muted: #8f887f;
  --hairline: #2e2a35;
  --ring: rgba(245, 242, 234, 0.12);
  --accent: #646bdb;          /* brand violet — actions, buttons */
  --brand-coral: #ff633d;     /* pulses, wordmark dot */
  --brand-amber: #ffaa2f;     /* gists, badges */
  --brand-teal: #2aadb8;      /* value nodes */
  --seq-hi: #aab0ff;          /* violet ramp — top score */
  --seq-lo: #4a4f9e;          /* violet ramp — low score */
  --value-node: #2aadb8;
  --gist-node: #ffaa2f;
  --status-good: #0ca30c;
  --status-warn: #ffaa2f;
  --d-goals: #646bdb;
  --d-entities: #1f9ea9;
  --d-valence: #d55181;
  --d-temporal: #c98500;
  --d-constraints: #5da24a;
  --d-gist: #e8552f;
  /* graph canvas colors (read by JS at style time — canvas can't use vars) */
  --graph-action: #646bdb;
  --graph-value: #2aadb8;
  --graph-gist: #ffaa2f;
  --graph-gist-fill: #17141c;
  --graph-edge: #38323f;
  --graph-edge-pulse: #ff633d;
  --graph-label: #cbc5ba;
  --graph-label-dim: #8f887f;
  --graph-score-hi: #aab0ff;
  --graph-score-lo: #4a4f9e;
  --graph-ring: #f5f2ea;
}

/* Light mode — the brand's warm cream (logo background). Data channels are
   the light-validated steps (dataviz gates pass on #FAF8F3, 2026-07-22);
   high score = darker ink on light, inverted from dark mode. */
:root[data-theme="light"] {
  color-scheme: light;
  --page: #FAF8F3;
  --surface: #FCFCF9;
  --surface-raised: #F2EFE9;
  --ink: #110F14;
  --ink-2: #52504a;
  --ink-muted: #8b8578;
  --hairline: #E4E0D8;
  --ring: rgba(17, 15, 20, 0.12);
  --brand-amber: #9a6a00;
  --seq-hi: #343a9e;
  --seq-lo: #c3c6f2;
  --value-node: #0b93a6;
  --gist-node: #9a6a00;
  --status-good: #0a7c0a;
  --status-warn: #9a6a00;
  --d-goals: #4a51c9;
  --d-entities: #0b93a6;
  --d-valence: #c04570;
  --d-temporal: #9a6a00;
  --d-constraints: #3d8a35;
  --d-gist: #cf4520;
  --graph-action: #4a51c9;
  --graph-value: #0b93a6;
  --graph-gist: #9a6a00;
  --graph-gist-fill: #FCFCF9;
  --graph-edge: #ddd7cb;
  --graph-edge-pulse: #cf4520;
  --graph-label: #52504a;
  --graph-label-dim: #8b8578;
  --graph-score-hi: #343a9e;
  --graph-score-lo: #c3c6f2;
  --graph-ring: #110F14;
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; }
body {
  background: var(--page);
  color: var(--ink-2);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  /* full-viewport app: the page itself never scrolls — panels do */
  overflow: hidden;
}

#layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 360px;
  /* clamp the single row to the viewport; without this an auto row grows
     with panel content (long why-panel/inspector) and scrolls the page */
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.drawer-close { display: none; margin-bottom: 10px; }

/* narrower windows: shrink the side columns before anything overflows */
@media (max-width: 1180px) {
  #layout { grid-template-columns: 188px minmax(0, 1fr) 300px; }
}

/* small windows: drawer becomes a slide-over so the graph keeps the width */
@media (max-width: 940px) {
  #layout { grid-template-columns: 170px minmax(0, 1fr); }
  #drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(360px, 88vw);
    transform: translateX(105%);
    transition: transform 0.25s ease;
    box-shadow: -10px 0 28px rgba(0, 0, 0, 0.5);
    z-index: 40;
  }
  #drawer.open { transform: translateX(0); }
  .drawer-close { display: inline-flex; }
}

/* ---------- left: spaces ---------- */

#spaces-panel {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.panel-title { color: var(--ink); font-weight: 600; letter-spacing: .2px; }
.wordmark-dot { color: var(--brand-coral); }
.instance-banner {
  margin: 10px 14px 0; padding: 9px 12px; font-size: 13px;
  border: 1px solid var(--status-warn); border-radius: 8px;
  color: var(--ink-2); background: var(--surface);
}

.mock-badge {
  align-self: flex-start;
  font-size: 10px; font-weight: 700; letter-spacing: .8px;
  color: var(--brand-amber);
  border: 1px solid var(--status-warn);
  border-radius: 3px; padding: 1px 6px;
}
.section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--ink-muted); margin-top: 6px;
}
#spaces-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#spaces-list li {
  padding: 7px 9px; border-radius: 6px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
}
#spaces-list li:hover { background: var(--surface-raised); }
#spaces-list li.active { background: var(--surface-raised); color: var(--ink); box-shadow: inset 2px 0 0 var(--accent); }
#spaces-list .space-kind { font-size: 10px; color: var(--ink-muted); }
#new-space-form { display: flex; flex-direction: column; gap: 6px; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: 12px; }
.toggle-row { display: flex; gap: 7px; align-items: center; cursor: pointer; }
.spacing-row {
  display: flex; gap: 8px; align-items: center; font-size: 12px;
  color: var(--ink-2);
}
.spacing-row input[type="range"] { flex: 1; accent-color: var(--accent); }
#legend { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot-action { background: var(--accent); }
.dot-value { background: var(--value-node); width: 7px; height: 7px; }
.dot-gist { background: transparent; border: 2px dashed var(--gist-node); }

/* ---------- center ---------- */

#main-panel { display: flex; flex-direction: column; min-width: 0; }

#topbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
#add-form { display: flex; gap: 6px; flex: 1.2; min-width: min(300px, 100%); }
#search-form { display: flex; gap: 6px; flex: 1; min-width: min(280px, 100%); }
input[type="text"], input[type="password"], select {
  background: var(--page); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 6px;
  padding: 7px 10px; font: inherit; width: 100%; min-width: 0;
}
input:focus, select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
select { width: auto; }
button {
  font: inherit; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent; padding: 7px 14px;
  background: var(--accent); color: #fff;
}
button:hover { filter: brightness(1.12); }
.ghost-btn { background: transparent; color: var(--ink-2); border-color: var(--hairline); }
.ghost-btn:hover { background: var(--surface-raised); filter: none; }

#pipeline-strip {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; background: var(--surface);
  border-bottom: 1px solid var(--hairline); font-size: 12px;
}
.strip-label { color: var(--ink-muted); text-transform: uppercase; font-size: 10px; letter-spacing: .8px; }
#pipeline-stages { list-style: none; display: flex; gap: 4px; padding: 0; }
#pipeline-stages li {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--hairline); color: var(--ink-muted);
}
#pipeline-stages li i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--hairline);
}
#pipeline-stages li.active { color: var(--ink); border-color: var(--accent); }
#pipeline-stages li.active i { background: var(--status-warn); animation: pulse 0.9s ease-in-out infinite; }
#pipeline-stages li.done { color: var(--ink-2); }
#pipeline-stages li.done i { background: var(--status-good); animation: none; }
@keyframes pulse { 50% { opacity: 0.3; } }
.pending-badge {
  background: var(--surface-raised); border: 1px solid var(--status-warn);
  color: var(--status-warn); border-radius: 12px; padding: 2px 9px; font-size: 11px;
}

.preset-row { display: flex; gap: 6px; padding: 8px 14px 0; flex-wrap: wrap; }
.preset-chip {
  font-size: 12px; padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--hairline); background: transparent; color: var(--ink-2);
}
.preset-chip:hover { border-color: var(--accent); color: var(--ink); background: transparent; filter: none; }

#cy { flex: 1; min-height: 0; }

#toast {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--surface-raised); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 8px; padding: 9px 16px;
  box-shadow: 0 4px 18px rgba(0,0,0,.5); z-index: 30; max-width: 70%;
}
#toast.error { border-color: #d03b3b; }
#main-panel { position: relative; }

/* ---------- right drawer ---------- */

#drawer {
  background: var(--surface); border-left: 1px solid var(--hairline);
  overflow-y: auto; padding: 14px;
}
.drawer-hint { color: var(--ink-muted); padding: 28px 10px; text-align: center; }
.drawer-hint em { color: var(--ink-2); }

.drawer-section-title {
  color: var(--ink); font-weight: 600; font-size: 15px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.drawer-kicker {
  font-size: 10px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--ink-muted); margin-bottom: 4px;
}
.memory-text { color: var(--ink); margin: 6px 0 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.chip {
  font-size: 11px; border-radius: 10px; padding: 2px 8px;
  border: 1px solid var(--hairline); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 5px;
}
.chip .dm { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12px; margin: 8px 0; }
.kv dt { color: var(--ink-muted); }
.kv dd { color: var(--ink-2); font-variant-numeric: tabular-nums; }

.gauge { height: 6px; background: var(--surface-raised); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.gauge > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }

table.mini {
  width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 4px;
}
table.mini th {
  text-align: left; color: var(--ink-muted); font-weight: 500;
  border-bottom: 1px solid var(--hairline); padding: 3px 4px;
}
table.mini td { padding: 4px; border-bottom: 1px solid var(--hairline); color: var(--ink-2); }
table.mini td.num { text-align: right; font-variant-numeric: tabular-nums; }

.linked-item { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.linked-item:hover { background: var(--surface-raised); color: var(--ink); }

/* why panel */
.result-card {
  background: var(--surface-raised);
  border: 1px solid var(--hairline); border-radius: 8px;
  padding: 10px; margin-bottom: 10px;
}
.result-card.expanded { border-color: var(--ring); }
.result-head { display: flex; gap: 9px; cursor: pointer; align-items: baseline; }
.rank-pill {
  min-width: 22px; text-align: center; font-size: 11px; font-weight: 700;
  background: var(--accent); color: #fff; border-radius: 11px; padding: 1px 6px;
}
.result-text { flex: 1; color: var(--ink); font-size: 13px; }
.result-score { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }

.waterfall { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.wf-row { display: grid; grid-template-columns: 118px 1fr 52px; gap: 8px; align-items: center; }
.wf-label { color: var(--ink-2); display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; }
.wf-label .dm { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.wf-bar-track { height: 8px; border-radius: 4px; background: transparent; }
.wf-bar { height: 8px; border-radius: 4px; min-width: 2px; }
.wf-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.wf-step {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--hairline); padding-top: 6px; margin-top: 2px;
  color: var(--ink-muted);
}
.wf-step b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.wf-substep { padding-left: 14px; font-size: 11px; color: var(--ink-muted); display: flex; justify-content: space-between; }
.wf-final { display: flex; justify-content: space-between; border-top: 1px solid var(--ring); padding-top: 7px; margin-top: 3px; }
.wf-final b { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.wf-note { font-size: 11px; color: var(--ink-muted); margin-top: 4px; }

.why-controls { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; font-size: 12px; }

/* settings modal */
dialog {
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--hairline); border-radius: 10px; padding: 18px;
  width: min(420px, 90vw);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h3 { color: var(--ink); margin-bottom: 6px; }
dialog label { display: block; margin: 10px 0; font-size: 12px; color: var(--ink-muted); }
dialog label input { margin-top: 4px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin-top: 14px; }

.muted { color: var(--ink-muted); font-size: 12px; }

/* sign-in overlay (LIT-074) */
#signin-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: var(--page);
  display: flex; align-items: center; justify-content: center;
}
.signin-card { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.signin-brand { color: var(--ink); font-weight: 600; font-size: 18px; }

.user-box {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  border: 1px solid var(--hairline); border-radius: 7px; padding: 5px 8px;
}
.user-box .ghost-btn { padding: 3px 9px; font-size: 11px; }

/* API-keys panel (settings modal) */
#keys-panel { border-top: 1px solid var(--hairline); margin-top: 14px; padding-top: 12px; }
#keys-panel h4 { color: var(--ink); font-size: 13px; margin-bottom: 8px; }
.key-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--hairline); font-size: 12px;
}
.key-row .key-label { flex: 1; color: var(--ink-2); }
.key-row.revoked .key-label { text-decoration: line-through; color: var(--ink-muted); }
.key-row .key-revoke { padding: 2px 9px; font-size: 11px; }
.keys-create-row { display: flex; gap: 6px; margin-top: 10px; }

.ghost-btn svg { vertical-align: -2px; }
.icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: inline; }
[hidden] { display: none !important; }
