/* ==========================================================================
   surface-pass.css — DORIC_SURFACE_PASS_SPEC §6b: the Files Panel (doc-sidebar)
   CSS. doc-sidebar.js emits semantic ds-* markup; until now NO stylesheet
   defined any ds-* rule, so the browser rendered defaults ("Now2", identical
   bordered boxes, no icons). This is the missing visual layer — Law 9: a surface
   ships its CSS. The surface-conformance guard refuses to ship ds-* without it.

   Quiet, hierarchical, per STOA_DESIGN_LANGUAGE: tier header = a section header,
   not a box; doc row = a quiet list item; clear tier -> type -> doc indentation.
   Tokens only (no hard-coded colors) so light/dark both work.
   ========================================================================== */

.doc-sidebar { display: flex; flex-direction: column; gap: 2px; padding: 4px 2px; }

/* ---- tier section -------------------------------------------------------- */
.doc-sidebar .ds-tier { display: flex; flex-direction: column; }

/* tier header = a quiet section header (NOT a bordered box) */
.doc-sidebar .ds-tier-head {
  display: flex; align-items: center; gap: 8px;
  width: 100%; box-sizing: border-box;
  padding: 7px 10px; margin: 0;
  border: 0; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--text-primary); text-align: left;
  border-radius: 7px;
}
.doc-sidebar .ds-tier-head:hover { background: var(--bg-hover); }
/* Master is pinned, always expanded, no chevron, slightly stronger presence */
.doc-sidebar .ds-master > .ds-tier-head { cursor: default; }
.doc-sidebar .ds-master > .ds-tier-head:hover { background: transparent; }

/* tier icon (lucide swaps <i data-lucide> -> <svg>) */
.doc-sidebar .ds-tier-icon { width: 15px; height: 15px; flex: 0 0 auto; color: var(--text-secondary); }
.doc-sidebar .ds-tier-icon svg { width: 15px; height: 15px; }

.doc-sidebar .ds-tier-label { flex: 1 1 auto; min-width: 0; letter-spacing: .01em; }

/* count pill — right-aligned with a gap, muted; only rendered when > 0 */
.doc-sidebar .ds-tier-count {
  flex: 0 0 auto; margin-left: auto;
  min-width: 18px; padding: 1px 7px;
  border-radius: 10px; background: var(--bg-hover);
  color: var(--text-muted); font-size: 11px; font-weight: 600; text-align: center;
}

/* disclosure chevron — rotates when the tier is open */
.doc-sidebar .ds-chevron {
  width: 14px; height: 14px; flex: 0 0 auto; color: var(--text-muted);
  transition: transform .16s ease;
}
.doc-sidebar .ds-chevron svg { width: 14px; height: 14px; }
.doc-sidebar .ds-tier.ds-open > .ds-tier-head .ds-chevron { transform: rotate(90deg); }
/* when the count is present the chevron follows it (no extra auto-margin) */
.doc-sidebar .ds-tier-count + .ds-chevron { margin-left: 4px; }
.doc-sidebar .ds-tier-head > .ds-chevron:not(.ds-tier-count + .ds-chevron) { margin-left: auto; }

/* empty tier (Law 4 "earned, not always-on"): just a muted header, no body */
.doc-sidebar .ds-tier-empty > .ds-tier-head { color: var(--text-muted); }
.doc-sidebar .ds-tier-empty > .ds-tier-head .ds-tier-icon { color: var(--text-muted); opacity: .7; }

/* ---- tier body: hidden unless the tier is open -------------------------- */
.doc-sidebar .ds-tier-body { display: none; padding: 2px 0 6px; }
.doc-sidebar .ds-tier.ds-open > .ds-tier-body { display: block; }

/* release sub-group (Shipped) */
.doc-sidebar .ds-release {
  padding: 6px 10px 3px 30px; font-size: 11px; font-weight: 600;
  color: var(--text-secondary); letter-spacing: .02em;
}

/* type sub-label (Feature, Spec, ...) inside Now/Shipped */
.doc-sidebar .ds-typelabel {
  padding: 4px 10px 2px 30px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
}

/* doc row = a quiet list item (NOT a button-box), indented under its tier */
.doc-sidebar .ds-doc {
  display: flex; align-items: center; width: 100%; box-sizing: border-box;
  padding: 5px 10px 5px 30px; margin: 0;
  border: 0; background: transparent; cursor: pointer; border-radius: 6px;
  font-family: inherit; font-size: 12.5px; color: var(--text-secondary); text-align: left;
}
.doc-sidebar .ds-doc:hover { background: var(--bg-hover); color: var(--text-primary); }
.doc-sidebar .ds-doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* docs nested under a type sub-label indent one step deeper */
.doc-sidebar .ds-typelabel + .ds-doc,
.doc-sidebar .ds-doc { padding-left: 30px; }

/* gentle empty state (Master with no doc yet) */
.doc-sidebar .ds-empty { padding: 6px 10px 6px 30px; font-size: 12px; color: var(--text-muted); font-style: italic; }

/* code/CSS footer: a clearly-tappable affordance, not a sentence */
.doc-sidebar .ds-codehint,
.ds-codehint {
  display: block; width: 100%; box-sizing: border-box;
  margin-top: 6px; padding: 8px 10px;
  border: 0; border-top: 0.5px solid var(--border); background: transparent;
  cursor: pointer; font-family: inherit; font-size: 11.5px; color: var(--accent); text-align: left;
}
.doc-sidebar .ds-codehint:hover, .ds-codehint:hover { color: var(--accent-dark); background: var(--bg-hover); }

/* ==========================================================================
   The credits meter (sidebar footer) — DORIC_SURFACE_PASS_SPEC §6b + PRICING
   §9/§10a. app.js renders credit-meter* markup (paid-dollar balance + thin bar,
   never a unitless "Free 0/100"); like ds-*, the classes had no CSS. Quiet, one
   source of truth, low/out states escalate. Tokens only.
   ========================================================================== */
.credit-meter {
  display: flex; flex-direction: column; gap: 5px;
  padding: 9px 12px; margin: 4px 6px 6px;
  border: 0.5px solid var(--border); border-radius: 9px; background: var(--bg-secondary);
  font-size: 11.5px; color: var(--text-secondary);
}
.credit-meter-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.credit-meter-label { color: var(--text-muted); font-weight: 600; letter-spacing: .01em; }
.credit-meter-value { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.credit-meter-bar { position: relative; height: 4px; border-radius: 3px; background: var(--bg-hover); overflow: hidden; }
.credit-meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); border-radius: 3px; transition: width .25s ease; }
/* getting low (75%+): amber-ish via accent-dark; out (98%): error-leaning red */
.credit-meter--low .credit-meter-fill { background: var(--accent-dark); }
.credit-meter--low .credit-meter-value { color: var(--accent-dark); }
.credit-meter--out { border-color: #C2410C; }
.credit-meter--out .credit-meter-fill { background: #C2410C; }
.credit-meter--out .credit-meter-value { color: #C2410C; }

/* ==========================================================================
   env-switcher — Staging | Production + owner-only Promote (A7 §3). A quiet
   floating control, top-right under the mode cluster; earned (hidden with no
   project). Tokens only.
   ========================================================================== */
.env-switcher {
  position: fixed; top: 52px; right: 16px; z-index: var(--z-chrome, 2000);
  display: none; align-items: center; gap: 6px;
  padding: 4px 6px; border: 0.5px solid var(--border); border-radius: 10px;
  background: var(--bg-primary); box-shadow: var(--shadow-md);
  font-family: inherit; font-size: 11px; color: var(--text-secondary);
}
.env-switcher-label { color: var(--text-muted); padding: 0 2px; font-weight: 600; }
.env-switcher .env-tab {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 4px 9px; border: 0; border-radius: 7px; background: transparent;
  cursor: pointer; font-family: inherit; color: var(--text-secondary);
}
.env-switcher .env-tab:hover { background: var(--bg-hover); }
.env-switcher .env-tab-on { background: var(--accent-soft); color: var(--accent); }
.env-switcher .env-tab-name { font-size: 11.5px; font-weight: 600; }
.env-switcher .env-tab-build { font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.env-switcher .env-promote {
  padding: 5px 11px; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); cursor: pointer;
  font-family: inherit; font-size: 11.5px; font-weight: 600;
}
.env-switcher .env-promote:hover:not(:disabled) { background: var(--accent); color: #fff; }
.env-switcher .env-promote:disabled { opacity: .45; cursor: not-allowed; }

/* ask-chips — quick-reply chips for any enumerable asking turn (F2) */
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.ask-chips .ask-chip {
  padding: 6px 12px; border: 0.5px solid var(--accent); border-radius: 16px;
  background: var(--accent-soft); color: var(--accent); cursor: pointer;
  font-family: inherit; font-size: 12.5px; line-height: 1.2;
}
.ask-chips .ask-chip:hover { background: var(--accent); color: #fff; }
