/* =====================================================================================================================================
   SAVANNAH AI — OFFICIAL DESIGN SYSTEM. Loaded LAST, after styles.css, chat-v1.css and glass.css (shell, sidebar, settings and loading rules; no palette of its own).
   Full specification: docs/DESIGN_SYSTEM.md.

   LOCKED NEUTRAL PALETTE (taken from the approved Screen 2 / Screen 4): var(--sv-sidebar-bg) · var(--sv-app-bg) · var(--sv-composer-bg) · var(--sv-elevated) · var(--sv-border) · var(--sv-text-2) · var(--sv-text-3) · var(--sv-text) · var(--sv-text).
   Nothing else is a UI colour: no green, beige, gold, red, blue or any accent. State (selected, active, success, warning, error) is shown with
   contrast, opacity, borders, icons and text labels, never with hue. The only colourful pixels in the product are the founder's supplied feather artwork.
   Type: Newsreader everywhere, Doto for technical activity only (css/fonts.css, css/typography.css). Only titles and headings are bold. Icons: js/icons.js.
   ===================================================================================================================================== */
:root {
  /* LOCKED PALETTE (the approved Screen 2 / Screen 4 neutrals). Nothing else is a UI colour. */
  --c-black: var(--sv-sidebar-bg); --c-deep: var(--sv-app-bg); --c-charcoal: var(--sv-composer-bg); --c-graphite: var(--sv-elevated); --c-border: var(--sv-border);
  --c-silver: var(--sv-text-2); --c-grey: var(--sv-text-3); --c-white: var(--sv-text); --c-offwhite: var(--sv-text);
  --c-text-2: var(--sv-text-2); --c-text-3: var(--sv-text-3); --glow-none: none;
  --ds-bg: var(--c-black); --ds-g1: var(--c-charcoal); --ds-g2: var(--c-graphite); --ds-g3: var(--c-graphite);
  --ds-ink: var(--c-white); --ds-ink-2: var(--c-silver); --ds-ink-3: var(--c-grey);
  --ds-accent: var(--c-silver); --ds-accent-soft: rgba(var(--sv-text-2-rgb), .14); --ds-danger: var(--c-offwhite);
  --ds-line: rgba(var(--sv-text-rgb), .085); --ds-line-strong: var(--c-border);
  --ds-radius-sm: 12px; --ds-radius-md: 16px; --ds-radius-lg: 22px; --ds-pill: 999px;
  --icon-size: 20px; --row-gap: 14px;
  --font-ui: var(--font-brand);
  --font-display: var(--font-brand);
  --accent: var(--c-white); --accent-dim: rgba(var(--sv-text-rgb), .07);
  --text-primary: var(--c-white); --text-secondary: var(--c-silver); --text-tertiary: var(--c-grey);
  --border-subtle: var(--ds-line); --border-strong: var(--c-border); --silver-border: var(--ds-line);
  --glass-border: var(--c-border); --glass-border-focus: var(--c-silver);
  --glass-fill: rgba(var(--sv-composer-bg-rgb), .66); --glass-fill-strong: rgba(var(--sv-composer-bg-rgb), .94); --glass-solid: var(--c-graphite);
  --success: var(--c-offwhite); --warning: var(--c-offwhite); --danger: var(--c-offwhite); --info: var(--c-silver);
  --c-black-legacy: var(--c-black);
}
html, body, button, input, select, textarea { font-family: var(--font-ui); }
body { background: var(--ds-bg); color: var(--ds-ink); -webkit-font-smoothing: antialiased; }

/* ---- WEIGHT RULE ------------------------------------------------------------------------------------------------------------------------------------ */
body *:not(h1, h2, h3, h4, h5, h6) { font-weight: 400 !important; }
h1, h2, h3, h4, h5, h6, .sh-title, .sh-nav-title, .sh-h3, .page-header-row h2, .notice-modal h3 { font-family: var(--font-display); font-weight: 700 !important; letter-spacing: -.01em; }
.sidebar-brand-name, .bs-name { font-family: var(--font-brand); font-weight: 400 !important; }
.sh-title { font-size: 30px; }
.sh-h3, h3 { font-size: var(--sv-type-body-size); }

/* ---- icons ------------------------------------------------------------------------------------------------------------------------------------------- */
.sv-icon { width: var(--icon-size); height: var(--icon-size); flex: none; display: inline-block; vertical-align: middle; stroke-width: 1.75; }
button > .sv-icon, a > .sv-icon { pointer-events: none; }

/* ---- buttons / pills --------------------------------------------------------------------------------------------------------------------------------- */
.btn { border-radius: var(--ds-pill); }
.btn, .chat-pane-action, .chat-pane-chip, .sh-actions .btn, .sh-tools .btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.btn-glass, .chat-pane-action { background: rgba(var(--sv-text-rgb), .05) !important; border: 1px solid var(--ds-line-strong) !important; color: var(--ds-ink) !important; border-radius: var(--ds-pill); }
.chat-pane-action.danger { color: var(--ds-danger) !important; background: rgba(var(--sv-text-3-rgb), .1) !important; border-color: rgba(var(--sv-text-3-rgb), .3) !important; }
.sh-tools { gap: 10px; }
.sh-tools .btn { min-height: 48px; padding: 0 18px; }
.sh-switch:checked { background: var(--ds-accent); border-color: var(--ds-accent); }
.sh-switch:checked::after { background: var(--sv-app-bg); }

/* ---- sidebar ----------------------------------------------------------------------------------------------------------------------------------------- */
.sidebar { background: var(--ds-g1); border-right: 1px solid var(--ds-line); -webkit-backdrop-filter: none; backdrop-filter: none; }
.chat-pane-new {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: var(--ds-ink) !important; color: var(--sv-app-bg) !important;
  border-radius: var(--ds-pill) !important; min-height: 48px; box-shadow: none;
}
.chat-pane-searchwrap { position: relative; flex: none; margin: 12px 0 8px; }
.chat-pane-searchwrap > .sv-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ds-ink-3); pointer-events: none; }
.chat-pane-searchwrap .chat-pane-search { margin: 0 !important; padding-left: 46px !important; min-height: 46px; background: rgba(var(--sv-text-rgb), .04) !important; border: 1px solid var(--ds-line) !important; border-radius: var(--ds-pill) !important; }
.chat-pane-chip { padding: 0 14px 0 12px; min-height: 40px; border-color: var(--ds-line); color: var(--ds-ink-2); }
.chat-pane-chip .sv-icon { --icon-size: 16px; }
.chat-pane-chip.active { background: var(--ds-accent-soft); border-color: rgba(var(--sv-text-3-rgb), .5); color: var(--ds-ink); }
.chat-pane-group { color: var(--ds-ink-3); letter-spacing: .12em; }
.chat-pane-row { border-left: 0 !important; border-radius: var(--ds-radius-md); position: relative; }
.chat-pane-row.active { background: var(--c-graphite); box-shadow: inset 0 0 0 1px var(--c-border); }
.chat-pane-open { flex-direction: row !important; align-items: center !important; gap: var(--row-gap); padding: 6px 10px 6px 14px !important; color: var(--ds-ink-2); }
.chat-pane-open > .sv-icon { color: var(--ds-ink-3); }
.chat-pane-row.active .chat-pane-open { color: var(--ds-ink); }
.chat-pane-row.active .chat-pane-open > .sv-icon { color: var(--c-white); }
.chat-pane-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; text-align: left; }
.chat-pane-open:hover { background: rgba(var(--sv-text-rgb), .04) !important; }
.chat-pane-more { color: var(--ds-ink-3); display: grid; place-items: center; }
.chat-pane-org-label { display: inline-flex; align-items: center; gap: 6px; }
.chat-pane-org-label .sv-icon { --icon-size: 16px; }
.sidebar-settings { border-top: 1px solid var(--ds-line); }
.settings-orb { background: var(--ds-g3); border: 1px solid var(--ds-line-strong); box-shadow: none; color: var(--ds-ink); }
.settings-orb:hover { box-shadow: none; transform: none; border-color: rgba(var(--sv-text-3-rgb), .6); }
.settings-orb .gear { background: var(--ds-g3); border-color: var(--ds-line-strong); }
.sidebar-logout { min-height: 40px !important; padding: 0 16px !important; flex: none !important; }
.sidebar-logout .sv-icon { --icon-size: 18px; }
.sidebar-legal { display: flex; align-items: center; gap: 6px; color: var(--ds-ink-3); }
.sidebar-legal .sv-icon { --icon-size: 16px; margin-right: 4px; }
/* Shape and colour only: whether each button is shown (hidden on desktop, shown on phones) stays with styles.css's own responsive rules. */
.drawer-close, .menu-toggle, .chat-header-menu-toggle, .menu-button {
  place-items: center; min-width: 44px; min-height: 44px; border-radius: 50%; border: 1px solid var(--ds-line); background: rgba(var(--sv-elevated-rgb), .66); color: var(--ds-ink);
}

/* ---- Settings ---------------------------------------------------------------------------------------------------------------------------------------- */
.sh-nav { background: rgba(var(--sv-composer-bg-rgb), .72); border-right: 1px solid var(--ds-line); }
.sh-nav-item { flex-direction: row !important; align-items: center !important; gap: var(--row-gap); padding: 12px 14px; border-radius: var(--ds-radius-md); color: var(--ds-ink); }
.sh-nav-item > .sv-icon:first-child { color: var(--ds-ink-2); }
.sh-nav-item > .sv-icon:last-child { margin-left: auto; --icon-size: 18px; color: var(--ds-ink-3); }
.sh-nav-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; text-align: left; flex: 1; }
.sh-nav-copy b { font-size: 15.5px; color: var(--ds-ink); }
.sh-nav-copy small { color: var(--ds-ink-3); font-size: 12.5px; }
.sh-nav-item:hover { background: rgba(var(--sv-text-rgb), .045); }
.sh-nav-item.active { background: var(--c-graphite); border-color: var(--c-border); position: relative; }
.sh-nav-item.active > .sv-icon:first-child { color: var(--c-white); }
.sh-back { display: none; align-items: center; gap: 6px; color: var(--ds-ink); }
@media (max-width: 860px) { .sh-back { display: inline-flex; } }
.sh-card { background: rgba(var(--sv-elevated-rgb), .72); border: 1px solid var(--ds-line); border-radius: var(--ds-radius-lg); box-shadow: none; }
.sh-input { background: rgba(var(--sv-text-rgb), .04); border: 1px solid var(--ds-line-strong); border-radius: var(--ds-radius-md); }
.sh-input:focus { border-color: var(--ds-accent); box-shadow: 0 0 0 3px rgba(var(--sv-text-3-rgb), .22); }
.sh-sub, .sh-hint, .sh-toggle-copy small, .sh-app-copy small, .sh-tier-copy small, .sh-dl dt { color: var(--ds-ink-3); }
.sh-label { color: var(--ds-ink-2); }
.sh-avatar { background: var(--ds-g3); box-shadow: none; }

/* ---- chat -------------------------------------------------------------------------------------------------------------------------------------------- */
.chat-message.role-user { background: rgba(var(--sv-border-rgb), .72); border-color: var(--ds-line-strong); }
.chat-message.role-assistant { background: rgba(var(--sv-composer-bg-rgb), .78); border-color: var(--ds-line); }
.composer { background: rgba(var(--sv-composer-bg-rgb), .78); border: 1px solid var(--ds-line-strong); border-radius: var(--ds-radius-lg); }
.composer:focus-within { border-color: rgba(var(--sv-text-3-rgb), .55); box-shadow: 0 0 0 3px rgba(var(--sv-text-3-rgb), .14); }
.composer-circle, .composer-pill { background: rgba(var(--sv-text-rgb), .06); border: 1px solid var(--ds-line); color: var(--ds-ink); }
.composer-action[data-action="send"], .composer-action[data-action="voice"] { background: var(--ds-ink); color: var(--sv-app-bg); box-shadow: none; }
.attach-menu-icon { background: rgba(var(--sv-text-rgb), .07); }
.attach-menu-icon .sv-icon { --icon-size: 18px; }
.attachment-icon .sv-icon { --icon-size: 22px; color: var(--ds-ink-2); }
.activity-button { background: rgba(var(--sv-elevated-rgb), .66); border-color: var(--ds-line-strong); }
.activity-button.has-activity .activity-dot { background: var(--ds-accent); }
.badge.status-running { background: rgba(var(--sv-text-3-rgb), .16); color: var(--sv-text-2); }
.toast.ok { border-color: rgba(var(--sv-text-3-rgb), .6); }
.sh-pbar i { background: linear-gradient(90deg, transparent, var(--ds-accent), var(--sv-text-2), var(--ds-accent), transparent); }
.skeleton::after { background: linear-gradient(90deg, transparent, rgba(var(--sv-text-rgb), .08), transparent); }
.chat-pane-open { justify-content: flex-start !important; }
.notif-bell-icon { display: inline-grid; place-items: center; }
.btn > .sv-icon { --icon-size: 18px; }
.sh-textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.chat-menu-item { display: flex; align-items: center; gap: 12px; }
.chat-menu-item .sv-icon { color: var(--ds-ink-3); }
.chat-pane-hit .chat-pane-badge { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- approved Settings design: one grouped card holding the rows (mobile and desktop) ---- */
.sh-nav { background: transparent; }
.sh-nav-list { display: flex; flex-direction: column; gap: 2px; padding: 8px; background: rgba(var(--sv-composer-bg-rgb), .72); border: 1px solid var(--ds-line); border-radius: var(--ds-radius-lg); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.sh-nav-item.active { border: 1px solid var(--ds-line-strong); }
.sh-nav-title { font-size: 34px; margin: 0 0 14px 6px; }
/* ---- approved Chat design: white underline on the active tab ---- */
.savannah-tab-btn { background: none; border: 0; color: var(--ds-ink-3); border-bottom: 2px solid transparent; }
.savannah-tab-btn.active, .savannah-tab-btn[aria-selected="true"] { color: var(--ds-ink); border-bottom-color: var(--c-white); }
.chat-message.healing { border-color: rgba(var(--sv-text-3-rgb), .38); }
.chat-message.healing .chat-message-meta { color: var(--ds-accent); }
.healing-note { margin: 6px 0 0; min-height: 0; }
.healing-note:empty { display: none; }

/* ---- brand: the founder's feather logo (transparent version of the supplied artwork) is shown as supplied: contain, no crop, no filter, no recolour, no blend, no frame. ---- */
.sidebar-brand-logo { width: 32px; height: 42px; object-fit: contain; flex: none; }
.chat-empty-mark { width: auto; height: 96px; object-fit: contain; filter: none; opacity: 1; }

/* ---- Aura Lumina build report (in chat) + Phoenix Vault: neutral tokens only ---- */
.build-shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 6px; }
.build-shot { display: flex; flex-direction: column; gap: 6px; padding: 8px; text-align: left; background: var(--c-charcoal); color: var(--c-silver); border: 1px solid var(--c-border); border-radius: 14px; cursor: pointer; }
.build-shot:hover, .build-shot:focus-visible { background: var(--c-graphite); border-color: var(--c-grey); outline: none; }
.build-shot-img { width: 100%; max-height: 220px; object-fit: contain; object-position: top; border-radius: 10px; background: var(--c-deep); }
.build-shot-missing { display: grid; place-items: center; min-height: 80px; color: var(--c-grey); font-size: var(--sv-type-tool-label-size); }
.build-shot-meta { color: var(--c-white); font-size: var(--sv-type-tool-label-size); }
.build-shot-status { font-size: var(--sv-type-tool-description-size); }
.build-shot-controls { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.build-shot-select, .build-shot-route, .vault-filter { background: var(--c-charcoal); color: var(--c-white); border: 1px solid var(--c-border); border-radius: 12px; padding: 8px 10px; min-height: 44px; min-width: 44px; }
.vault-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 12px 0; }
.vault-filters label { display: flex; flex-direction: column; gap: 4px; color: var(--c-silver); font-size: var(--sv-type-tool-label-size); }
.vault-build { margin: 16px 0; padding-top: 12px; border-top: 1px solid var(--c-border); }
.vault-build-title { margin: 0 0 4px; color: var(--c-white); }
.vault-compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vault-compare-grid figure { margin: 0; }
.vault-compare-img { width: 100%; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-deep); }
@media (max-width: 640px) { .vault-compare-grid { grid-template-columns: 1fr; } }
.vault-diff-stats { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 10px 0; font-size: var(--sv-type-tool-label-size); }
.vault-diff-stats dt { color: var(--c-grey); }
.vault-diff-stats dd { margin: 0; color: var(--c-white); overflow-wrap: anywhere; }
.vault-diff-figure { margin: 10px 0 0; }

/* ---- code, diffs and logs keep a monospace face so columns line up; every other piece of text is Newsreader ---- */
pre, code, kbd, samp, .terminal, .code-block, .log-view { font-family: var(--font-code); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; tab-size: 2; }

/* ---- open conversation (approved reference): ordinary assistant replies are plain text on the canvas, no card. Structured content (build reports, diagnostics, approvals) keeps its own card. ---- */
.chat-message.role-assistant, .chat-message.role-assistant.streaming {
  background: none; border: 0; border-radius: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  padding: 2px 2px 6px; max-width: 100%; align-self: stretch;
}
.chat-message.role-user { border-radius: 18px 18px 6px 18px; }
.chat-message.streaming { border-style: solid; }
/* Stop stays reachable while a real reply is being generated, as a small text control (the touch target stays 44 px) instead of a boxed button. */
.chat-message .chat-message-actions .chat-stream-stop { min-height: 44px; min-width: 44px; padding: 0 10px; background: none; border: 0; box-shadow: none; color: var(--text-secondary); text-decoration: underline; text-underline-offset: 3px; }
.chat-message.streaming .chat-message-actions { margin-top: 0; }

/* Settings directory: a search box, then eight sections. Every title is its own full-width, single-column row (never a grid). Approved palette tokens only. */
.sh-dir-search { width: 100%; min-height: 48px; margin: 4px 0 14px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--ds-line); background: rgba(var(--sv-composer-bg-rgb), .72); color: var(--text-primary); font: inherit; }
.sh-dir-search::placeholder { color: var(--text-secondary); }
.sh-dir-heading { margin: 22px 4px 8px; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-secondary); }
.sh-dir-list { display: flex; flex-direction: column; gap: 2px; }
.sh-dir-list > .sh-dir-row { width: 100%; min-height: 56px; text-align: left; }
.sh-dir-row .sh-nav-copy { display: flex; flex-direction: column; min-width: 0; }
.sh-dir-row .sh-nav-copy > small { color: var(--text-secondary); }
.sh-dir-chip { margin-top: 2px; font-size: .74rem; letter-spacing: .02em; color: var(--text-secondary); font-style: italic; }
.sh-cap-state { margin: 0 0 6px; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-secondary); }
.sh-cap-summary { margin: 0 0 10px; line-height: 1.55; color: var(--text-primary); }

/* Settings pages: Ghost Code graph, Time Machine, Audit Logs. Approved palette tokens only (currentColor / text tokens; no new colours). */
.gc-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.gc-stage { width: 100%; overflow: hidden; }
.gc-svg { width: 100%; height: auto; max-height: 460px; display: block; color: var(--text-primary); }
.gc-edge { stroke: var(--text-secondary); stroke-opacity: .45; fill: none; }
.gc-edge.heuristic { stroke-dasharray: 4 4; }
.gc-node { fill: var(--text-primary); fill-opacity: .85; stroke: var(--text-secondary); stroke-width: 1; cursor: pointer; }
.gc-node:hover, .gc-node:focus, .gc-node.selected { fill-opacity: 1; stroke: var(--text-primary); stroke-width: 2.5; outline: none; }
.gc-label { fill: var(--text-secondary); font-size: 10px; pointer-events: none; }
.gc-list { margin: 4px 0 10px; padding-left: 18px; }
.gc-link { background: none; border: 0; padding: 4px 0; color: var(--text-primary); text-decoration: underline; text-underline-offset: 3px; min-height: 32px; font: inherit; cursor: pointer; text-align: left; }
.tm-list { list-style: none; margin: 8px 0 14px; padding: 0; }
.tm-list li { padding: 6px 0; border-bottom: 1px solid var(--ds-line); overflow-wrap: anywhere; }
.tm-list code { color: var(--text-secondary); }
.tm-status, .tm-diff { max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; color: var(--text-secondary); }
.al-list { display: flex; flex-direction: column; }
.al-row { padding: 8px 0; border-bottom: 1px solid var(--ds-line); overflow-wrap: anywhere; }
.ar-preview { width: 100%; min-height: 220px; max-height: 420px; margin-top: 10px; border: 1px solid var(--ds-line); border-radius: var(--ds-radius-md); background: var(--bg-canvas); }

/* Shared links + public shared viewer */
.share-fresh { margin: var(--space-3, 12px) 0; }
.share-fresh .toolbar { display: flex; gap: 8px; }
.share-fresh input { flex: 1; min-width: 0; }
.share-link-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--ds-line); }
.share-link-meta { color: var(--text-secondary); font-size: var(--text-sm, 13px); overflow-wrap: anywhere; }
.shared-thread { display: flex; flex-direction: column; gap: 20px; margin-top: 24px; }
.shared-msg .shared-who { font-size: var(--text-sm, 13px); font-weight: 400; color: var(--text-secondary); margin: 0 0 4px; text-transform: none; }
.shared-msg .shared-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-primary); }
.shared-msg.user .shared-body { border-left: 2px solid var(--ds-line); padding-left: 12px; }

/* Cloud Workspace editor */
.cw { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 16px; align-items: start; }
.cw-tree { border: 1px solid var(--ds-line); border-radius: 12px; padding: 8px 0; max-height: 60vh; overflow: auto; }
.cw-row { display: block; }
.cw-item { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text-primary); padding: 6px 8px; min-height: 36px; cursor: pointer; font: inherit; }
.cw-item:hover, .cw-item:focus-visible { background: var(--ds-line); outline: none; }
.cw-item.protected { color: var(--text-secondary); cursor: default; }
.cw-editor { width: 100%; min-height: 50vh; font-family: var(--font-mono); font-variant-ligatures: none; tab-size: 2; font-size: var(--sv-type-tool-label-size); line-height: 1.5; resize: vertical; white-space: pre; overflow: auto; }
@media (max-width: 760px) { .cw { grid-template-columns: 1fr; } .cw-tree { max-height: 30vh; } }
.gc-3d { cursor: grab; touch-action: none; }
.gc-3d:active { cursor: grabbing; }
.gc-3d:focus-visible { outline: 2px solid var(--text-secondary); outline-offset: 2px; }
.cw-pane h3 { text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; }
