/* ─────────────────────────────────────────────────────────────────
   Demo Combobulator — Shared Design System
   Inspired by AMZ-Tools (Beacon) and tr-ai-der (Confluence).
   Refined IDE chrome — one accent, one signal, monospace reserved
   for logs / kbd / tabular metadata. Nothing louder than it needs
   to be. Link this file first on every page; then layer page-specific
   rules after.
   ───────────────────────────────────────────────────────────────── */

:root {
  /* Palette — zinc base */
  --bg:          #09090b;
  --bg-elev:     #0c0c0e;
  --surface:     #111113;
  --surface-2:   #17171a;
  --border:      #26262a;
  --border-hov:  #3a3a40;
  --text:        #fafafa;
  --text-dim:    #a1a1aa;
  --text-muted:  #71717a;

  /* Accents — one primary + one signal + role colors */
  --accent:      #14b8a6;
  --accent-deep: #0f766e;
  --accent-soft: rgba(20,184,166,.12);
  --accent-ring: rgba(20,184,166,.28);
  --signal:      #f97316;
  --signal-soft: rgba(249,115,22,.14);
  --ok:          #34d399;
  --ok-soft:     rgba(52,211,153,.14);
  --warn:        #facc15;
  --warn-soft:   rgba(250,204,21,.14);
  --danger:      #f87171;
  --danger-soft: rgba(248,113,113,.14);
  --purple:      #a78bfa;
  --purple-soft: rgba(167,139,250,.12);

  /* Legacy aliases — so pages with inline `var(--green)` / `var(--blue)` */
  /* etc. keep working while we migrate */
  --bg-subtle:   var(--surface);
  --bg-card:     var(--surface);
  --surface2:    var(--surface-2);
  --border-hover:var(--border-hov);
  --text-xs:     var(--text-muted);
  --primary:     var(--accent);
  --primary-hover: var(--accent-deep);
  --success:     var(--ok);
  --warning:     var(--warn);
  --green:       var(--accent);
  --green-d:     var(--accent-deep);
  --blue:        #60a5fa;         /* distinct info/secondary accent */
  --blue-soft:   rgba(96,165,250,.12);
  --red:         var(--danger);
  --yellow:      var(--warn);
  --orange:      var(--signal);

  --radius:     8px;
  --radius-sm:  6px;
  --radius-lg:  12px;

  --font-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--text); }

/* Reduced-motion courtesy */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Keyboard focus ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Monospace utilities — use surgically, never on body content */
.mono, .font-mono, .nums, .u-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hov); }

/* ── Buttons ──────────────────────────────────────────────────── */

button {
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  color: inherit;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .12s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.75rem; }
.btn-lg { padding: 0.6875rem 1.125rem; font-size: 0.875rem; }

.btn-primary {
  background: var(--accent);
  color: #04201d;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-deep);
  color: #fff;
  box-shadow: 0 0 0 1px var(--accent), 0 4px 14px -4px rgba(20,184,166,.45);
}

.btn-secondary {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-hov);
  color: var(--text);
}

.btn-ghost {
  color: var(--text-dim);
  background: transparent;
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-elev);
}

.btn-danger {
  background: rgba(248,113,113,0.12);
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.28);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(248,113,113,0.2);
  color: #fff;
}

.btn-signal {
  background: var(--signal);
  color: #2b1504;
  font-weight: 600;
}
.btn-signal:hover:not(:disabled) {
  background: #ea580c;
  color: #fff;
  box-shadow: 0 0 0 1px var(--signal), 0 4px 14px -4px rgba(249,115,22,.4);
}

/* ── Form controls ────────────────────────────────────────────── */

input, select, textarea, .form-input {
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.625rem;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover,
.form-input:hover { border-color: var(--border-hov); }
input:focus, select:focus, textarea:focus,
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select option { background: var(--surface); color: var(--text); }
textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
input::placeholder, textarea::placeholder, .form-input::placeholder {
  color: var(--text-muted);
}
input[type='range'] {
  padding: 0; height: 4px;
  background: var(--border);
  accent-color: var(--accent);
}
input[type='range']:focus { box-shadow: none; }
input[type='color'] {
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}
/* The generic `input { width: 100% }` rule above is right for text/email/url/
   tel inputs — the design wants those to fill their container. But it's
   wrong for checkboxes and radios: stretching them to 100% inside a flex
   row collapses the sibling content to a tiny column on the far right
   (was visible on the Intent recommendations panel + the .feature-flag-row
   toggles). Reset them to their intrinsic width and disable flex-shrink
   so the layout stays predictable. */
input[type='checkbox'], input[type='radio'] {
  width: auto;
  flex: none;
  accent-color: var(--accent);
}

label, .form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 0.375rem;
}
label .hint, .form-hint-inline {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.25rem;
  font-size: 0.72rem;
}
.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}
.required { color: var(--danger); }

.form-group { margin-bottom: 1rem; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}
.form-actions {
  display: flex;
  gap: 0.625rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ── Inline code + kbd ────────────────────────────────────────── */

code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 1px 5px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
}
kbd, .kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1rem;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  font-weight: 500;
}

/* ── Cards ────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.375rem;
  margin-bottom: 1rem;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.card-title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}
.card-title.tc::before { background: var(--purple); }
.card-title.warn::before { background: var(--warn); }
.card-title.signal::before { background: var(--signal); }
.card-title .meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

/* ── Segmented tab/pill group ────────────────────────────────── */

.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  gap: 2px;
}
.segmented a,
.segmented button,
.segmented .seg-item {
  padding: 4px 11px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  border-radius: 4px;
  transition: all .12s;
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.segmented a:hover,
.segmented button:hover,
.segmented .seg-item:hover { color: var(--text); }
.segmented a.active,
.segmented button.active,
.segmented .seg-item.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border-hov) inset;
}

/* ── Status pill ─────────────────────────────────────────────── */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  padding: 3px 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.status-pill::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ok);
}
.status-pill.saving::before { background: var(--signal); animation: pulse-signal 1.2s ease-in-out infinite; }
.status-pill.error::before   { background: var(--danger); }
.status-pill.warn::before    { background: var(--warn); }
.status-pill.idle::before    { background: var(--text-muted); }

/* ── Badge ────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 99px;
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge.ok      { background: var(--ok-soft);     color: var(--ok);     border-color: rgba(52,211,153,.3); }
.badge.warn    { background: var(--warn-soft);   color: var(--warn);   border-color: rgba(250,204,21,.3); }
.badge.danger  { background: var(--danger-soft); color: var(--danger); border-color: rgba(248,113,113,.3); }
.badge.signal  { background: var(--signal-soft); color: var(--signal); border-color: rgba(249,115,22,.3); }
.badge.accent  { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-ring); }

/* ── Topbar shell (header bar used on almost every page) ─────── */

.dc-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 48px;
  z-index: 20;
  /* Some pages (recorder.html) wrap the topbar in a flex-column body
     with align-items:center — without align-self:stretch the topbar
     would shrink to content width and not span the viewport. */
  align-self: stretch;
  width: 100%;
}
/* Only claim the grid area on pages whose outer grid actually defines
   a "topbar" region. Applying it universally broke voice.html —
   .page-shell has no template-areas, so the browser created an
   implicit track and rendered the topbar at the bottom of the page. */
.admin-layout > .dc-topbar,
.shell > .dc-topbar { grid-area: topbar; }
/* ── Brand lockup ──────────────────────────────────────────────
   Universal — works inside .dc-topbar, a page-level nav, or any
   header. The topbar-only additions (padding/divider on the right)
   live in a separate .dc-topbar .brand rule below. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--text); text-decoration: none; }

.brand-mark {
  position: relative;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px var(--accent-ring), 0 0 12px -2px var(--accent-soft);
  flex-shrink: 0;
  /* No overflow clip — the orange orb is supposed to peek outside the
     top-right corner of the teal square. Clipping it was a mistake. */
}
/* Logo glyph scaled to fit inside the teal square — ~65% fill leaves
   the gradient visible around the edges. */
.brand-mark img {
  width: 14px;
  height: 14px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 0 1px rgba(0,0,0,.25));
}
.brand-mark::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 2px var(--bg);
  animation: pulse-signal 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.brand-sub {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.75rem;
  margin-left: 0.125rem;
}

/* Topbar-only additions: divider to the right of the brand, and a
   halo around the orb that matches the topbar's surface color. */
.dc-topbar .brand {
  padding-right: 0.875rem;
  border-right: 1px solid var(--border);
}
.dc-topbar .brand-mark::after {
  box-shadow: 0 0 0 2px var(--surface);
}
.dc-topbar .topbar-spacer { flex: 1; }
.dc-topbar .topbar-link {
  padding: 4px 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-radius: 4px;
  transition: all .12s;
}
.dc-topbar .topbar-link:hover { color: var(--text); background: var(--bg-elev); }
.dc-topbar .topbar-link.active {
  color: var(--text);
  background: var(--bg-elev);
  box-shadow: 0 0 0 1px var(--border) inset;
}

@keyframes pulse-signal {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ── Alerts ───────────────────────────────────────────────────── */

.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.55;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
}
.alert-error    { background: var(--danger-soft); border-color: rgba(248,113,113,0.28); color: #fca5a5; }
.alert-success  { background: var(--ok-soft);     border-color: rgba(52,211,153,0.28);  color: #6ee7b7; }
.alert-warn     { background: var(--warn-soft);   border-color: rgba(250,204,21,0.28);  color: #fde68a; }
.alert-info     { background: var(--accent-soft); border-color: var(--accent-ring);     color: var(--accent); }

/* ── Small utilities (kept for template compatibility) ───────── */

.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }
.text-xs    { font-size: 0.72rem; }
.text-sm    { font-size: 0.8125rem; }
.text-indigo, .text-accent { color: var(--accent); }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }

.flex-row    { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  background: var(--surface);
}

/* ── Log box (the ONE place a terminal aesthetic is warranted) ── */

.log-box {
  background: #050506;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.875rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.55;
}
.log-box .log-done, .log-done { color: var(--ok); }
.log-box .log-error, .log-error, .log-err { color: var(--danger); }
.log-box .log-warn, .log-warn { color: var(--warn); }
