/* Uboros web app — LIGHT THEME shared design tokens */
:root {
  --bg: #F4F4F6;                       /* light grey app background */
  --surface: #FFFFFF;                  /* cards on top of bg */
  --surface-2: #FAFAFB;                /* subtle elevation */
  --surface-3: #F0F0F3;                /* deeper grey for headers/strips */
  --text: #0F0F12;                     /* near black */
  --text-2: #4A4A52;                   /* medium grey */
  --text-3: #8A8A92;                   /* muted grey */
  --accent: #16A34A;                   /* legacy green accent, darker for white contrast */
  --accent-light: #22C55E;
  --accent-glow: rgba(22, 163, 74, 0.16);
  --accent-bg: #ECFDF5;                /* very light green callout */
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  /* v45bl: --warn used to be amber #D97706 → unreadable on sage-soft
     backgrounds (the smart-add card). Per operator: "only dark red for
     errors/warnings". Aligns warn with danger thematically; warn stays
     slightly less harsh (red-700 vs red-600) so they're still
     distinguishable when used side by side. */
  --warn: #B91C1C;
  --warn-bg: #FEF2F2;
  --info: #0EA5E9;
  --info-bg: #F0F9FF;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --max-width: 1280px;
  --gutter: clamp(20px, 4vw, 48px);
  --radius: 12px;
  --radius-sm: 8px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  min-height: 100vh;
}
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--gutter); }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
code { font-family: 'JetBrains Mono', 'SF Mono', monospace; font-size: 0.9em; background: var(--surface-3); padding: 2px 6px; border-radius: 4px; color: var(--text-2); }

/* v45cw: scoped to text-like form controls. Originally `input, textarea,
   select { width: 100% }` matched radio + checkbox inputs too — stretching
   them to fill their flex parents and squeezing siblings. Legacy code
   worked around this with `style="display:none"` on radios (see
   briefs.html, dashboard.html). The `:not([type=...])` exclusions let new
   code use radios + checkboxes inline without per-page CSS overrides. */
input:not([type="radio"]):not([type="checkbox"]):not([type="submit"]):not([type="button"]):not([type="file"]),
textarea,
select {
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:not([type="radio"]):not([type="checkbox"]):not([type="submit"]):not([type="button"]):not([type="file"]):focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* Credential / settings forms — give the actual <form class="form"> a
   uniform vertical rhythm so fields don't crowd each other and the
   submit button never sits flush against the last field. Scoped to the
   <form> element so the <div class="form"> layouts (settings/admin that
   set their own inline flex) are untouched. */
form.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Header / nav */
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
header .container {
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 32px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 17px; letter-spacing: -0.01em;
  color: var(--text);
}
.brand-dot {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: url(/favicon.png?v=24) center/cover no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  flex-shrink: 0;
}
nav.main {
  display: flex; gap: 22px; align-items: center;
}
nav.main a {
  font-size: 14px;
  color: var(--text-2);
  font-weight: 500;
  padding: 6px 2px;
  border-bottom: 1.5px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
nav.main a:hover { color: var(--text); }
nav.main a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
/* v45az: compact ? icon for the Help link. Visually distinct from
   primary nav items — circle border, no underline-on-hover. */
nav.main a.nav-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  margin-left: 6px;
  border: 1px solid var(--border, rgba(0,0,0,0.12));
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
}
nav.main a.nav-help:hover {
  color: var(--text);
  border-color: var(--text-2);
  background: var(--surface-2);
}

/* Connection status bar */
.conn-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 60px;
  z-index: 200;  /* sits above any in-page button wrapper; dropdown menus use 1000+ */
}
.conn-bar .container {
  padding-top: 10px; padding-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.conn-bar .label {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600;
  margin-right: 6px;
}
.conn-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  white-space: nowrap;
}
.conn-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3);
}
.conn-chip.real { background: var(--sage-soft); color: var(--sage); border-color: var(--sage-soft-2); }
.conn-chip.real .dot { background: var(--sage); box-shadow: 0 0 6px var(--accent-glow); }
.conn-chip.stub { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.conn-chip.stub .dot { background: var(--warn); }
.conn-chip.skipped { background: var(--surface-2); color: var(--ink-lo); border-color: var(--rule); }
.conn-chip.skipped .dot { background: var(--ink-lo); }
.conn-chip.missing { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.conn-chip.missing .dot { background: var(--danger); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.005em;
  transition: filter 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.btn.ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger.ghost { background: var(--surface); color: var(--danger); border-color: rgba(220, 38, 38, 0.4); }
.btn.sm { padding: 7px 14px; font-size: 12px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.card h3 {
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600; margin-bottom: 10px;
}
.card .stat {
  font-size: 32px; font-weight: 800; letter-spacing: -0.025em;
  color: var(--text); line-height: 1;
}
.card .stat-sub {
  margin-top: 6px; font-size: 12px; color: var(--text-2);
}

/* Section blocks (dashboard stage sections) */
.stage-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.stage-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.stage-head .num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-bg); border: 1.5px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--accent);
  flex-shrink: 0;
}
.stage-head .title {
  font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
}
.stage-head .seg-tag {
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600;
  margin-left: auto;
}
.stage-head .seg-tag.preparation { color: var(--accent); }
.stage-head .seg-tag.performance { color: var(--info); }
.stage-body {
  font-size: 14px; color: var(--text-2); line-height: 1.55;
}

/* Page heading */
.page-title {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin: 24px 0 16px;
  gap: 24px; flex-wrap: wrap;
}
.page-title h1 {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 800; letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--text);
}
.page-title .subtitle { font-size: 14px; color: var(--text-2); margin-top: 6px; }

/* Pills / status */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.pill.connected, .pill.ok { background: var(--sage-soft); color: var(--sage); border-color: var(--sage-soft-2); }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.pill.info { background: var(--surface-2); color: var(--ink-md); border-color: var(--rule); }
.pill .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}

/* Tables */
table.data {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.data th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  font-weight: 600;
  padding: 10px 14px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border-strong);
}
table.data td {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--surface-2); }
table.data .muted { color: var(--text-2); }
.metric.up { color: var(--accent); font-weight: 600; }
.metric.down { color: var(--danger); font-weight: 600; }
.metric.neutral { color: var(--text-2); }

/* Wizard (kept for onboarding/setup) */
.wizard {
  max-width: 720px;
  margin: 32px auto;
  padding: 0 var(--gutter);
}
.wizard-progress {
  display: flex; gap: 5px; margin-bottom: 24px;
}
.wizard-progress .seg {
  flex: 1; height: 3px;
  background: var(--surface-3);
  border-radius: 2px;
}
.wizard-progress .seg.done { background: var(--accent); }
.wizard-progress .seg.current { background: var(--accent-light); }
.wizard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
}
.wizard-card .step-eyebrow {
  display: inline-block;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); font-weight: 700;
  background: var(--accent-bg);
  padding: 3px 10px; border-radius: 999px;
  margin-bottom: 14px;
}
.wizard-card h2 {
  font-size: 24px; font-weight: 800; letter-spacing: -0.025em;
  line-height: 1.15;
}
.wizard-card p.lede {
  margin-top: 10px; color: var(--text-2); font-size: 14px;
}
.wizard-card .form { margin-top: 24px; display: flex; flex-direction: column; gap: 14px; }
.wizard-card label {
  display: block;
  font-size: 12px; font-weight: 500; color: var(--text);
  margin-bottom: 6px;
}
.wizard-card label .hint { color: var(--text-3); font-weight: 400; margin-left: 6px; }
.wizard-card .field { display: flex; flex-direction: column; }
.wizard-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border);
  gap: 12px; flex-wrap: wrap;
}
.wizard-actions .right { display: flex; gap: 10px; align-items: center; }

.test-result {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  margin-top: 6px;
  min-height: 18px;
}
.test-result.ok { color: var(--accent); }
.test-result.err { color: var(--danger); }
.test-result .icon { font-weight: 700; }

/* Asset gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.gallery .item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.gallery .item .thumb {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.gallery .item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery .item .meta {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.gallery .item .meta .ftype {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); font-weight: 700;
}
.gallery .item .meta .hook { margin-top: 5px; color: var(--text); font-size: 13px; line-height: 1.35; }

.gallery .item.add-own {
  border: 2px dashed var(--border-strong);
  background: var(--surface-2);
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.gallery .item.add-own:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.gallery .item.add-own .icon {
  font-size: 36px; color: var(--text-3);
}
.gallery .item.add-own .label {
  font-size: 13px; color: var(--text-2); margin-top: 6px;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

/* ── Banner — the single canonical notice/callout component ──────────
   One standard for every inline notice across the app. Variants map to
   the design-system semantic tokens (sage / warn / danger), so they're
   dark-mode-correct and never drift between pages.
     (default)  neutral info — sage left-rule on surface
     .info      muted/neutral — for low-priority guidance
     .ok        success — sage
     .warn      caution — bronze (governance/attention)
     .danger    error — brick red
   Optional leading icon: wrap the glyph in <span class="banner-ico">. */
.banner {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--sage);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-md);
}
.banner strong { color: var(--ink-hi); font-weight: 600; }
.banner-ico { flex: 0 0 auto; font-size: 15px; line-height: 1.45; }
.banner.info   { border-left-color: var(--ink-lo); background: var(--surface-2);   color: var(--ink-md); }
.banner.ok     { border-left-color: var(--sage);   background: var(--sage-soft);   color: var(--sage-ink); }
.banner.warn   { border-left-color: var(--warn);   background: var(--warn-soft);   color: var(--warn); }
.banner.danger { border-left-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.banner.ok strong, .banner.warn strong, .banner.danger strong, .banner.info strong { color: inherit; }

/* ── Inline status message — the ✓ / ✗ / ⚠ one-liners under list rows ──
   Replaces dozens of ad-hoc <span style="color:var(--danger);font-size:11px">
   so success/error/caution text reads identically everywhere. */
.msg { font-size: 11.5px; line-height: 1.4; overflow-wrap: anywhere; }
.msg.ok    { color: var(--sage); }
.msg.err   { color: var(--danger); }
.msg.warn  { color: var(--warn); }
.msg.muted { color: var(--ink-lo); }
.msg.mono  { font-family: var(--font-mono); font-size: 11px; }

/* Loading */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Hero (landing) */
.hero {
  padding: clamp(64px, 12vh, 120px) 0 60px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(36px, 5.5vw, 70px);
  font-weight: 800; letter-spacing: -0.04em;
  line-height: 1.0;
  max-width: 14ch;
  margin: 0 auto;
  color: var(--text);
}
.hero h1 .accent { color: var(--accent); }
.hero p { margin: 22px auto 28px; color: var(--text-2); font-size: clamp(15px, 1.2vw, 19px); max-width: 60ch; }
.hero .btn { font-size: 15px; padding: 14px 32px; }

/* Sections */
.section { padding: 48px 0; }

/* Footer */
footer {
  margin-top: 60px;
  padding: 32px 0 48px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
}

/* Responsive */
@media (max-width: 768px) {
  nav.main { display: none; }
  .page-title { flex-direction: column; align-items: flex-start; }
}

[x-cloak] { display: none !important; }

/* ============================================================
   Modals — canonical overlay + panel.
   Every modal in the app uses .modal-overlay + .modal-panel so
   centering, scroll behavior, and mobile responsiveness stay
   consistent. Pair with <template x-teleport="body"> so the
   overlay always anchors to the viewport (not whatever parent
   element happens to wrap the trigger).
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(2px);
          backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto; /* scroll the dim layer if content exceeds viewport on mobile */
}
.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  /* Center within the flex overlay regardless of any inherited text-align */
  margin: auto;
}
.modal-panel.wide   { max-width: 720px; }
.modal-panel.narrow { max-width: 420px; }
.modal-panel h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none; /* override .card h3 uppercase */
  color: var(--text);
}
.modal-panel .modal-subtitle {
  margin: 0 0 18px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}
.modal-panel .modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
  flex-wrap: wrap;
}
/* Mobile — tighter padding, near-full-height, stack actions full-width */
@media (max-width: 640px) {
  .modal-overlay { padding: 12px; align-items: flex-start; }
  .modal-panel {
    max-height: calc(100vh - 24px);
    padding: 20px 16px;
    border-radius: 10px;
  }
  .modal-panel .modal-actions { flex-direction: column-reverse; }
  .modal-panel .modal-actions .btn { width: 100%; }
}

/* Simple chart bars (sparklines for performance) */
.bar-row {
  display: flex; align-items: center; gap: 8px;
}
.bar-track {
  flex: 1; height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.bar-fill.warn { background: var(--warn); }
.bar-fill.danger { background: var(--danger); }

/* Help / Connect AI page additions */
.container.narrow { max-width: 760px; }
h1.page-title { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0 12px; }
.h2 { font-size: 20px; font-weight: 700; margin: 32px 0 12px; letter-spacing: -0.01em; }
.bullets { margin: 8px 0 0 18px; line-height: 1.7; color: var(--text-1); }
.bullets li { margin-bottom: 4px; }
.code-block {
  background: #0f1115; color: #e6e8ec;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; line-height: 1.55;
  padding: 16px; border-radius: 10px;
  white-space: pre; overflow-x: auto;
  margin: 8px 0;
}
.data-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.data-table th, .data-table td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.data-table th { color: var(--text-2); font-weight: 600; }

/* v45ce: accessibility helper. .sr-only hides content visually while
   keeping it readable by screen readers. Used for icon-only buttons,
   loading-spinner status text, and skip-link targets. */
.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;
}
