/* ============================================================================
   base.css — shared foundation for every OmniSolverSpeech page.
   Reset · layout primitives · nav · buttons · cards · forms · badges/pills ·
   status pills · icons · skeletons · toasts · footer (omnisolvercode structure).
   References ONLY tokens.css custom properties — no raw hex here (CONTRACT §11).
   Mobile-first; ≥44px targets; hover disabled on coarse pointers.
   ============================================================================ */

/* ---- reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html:focus-within { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html:focus-within { scroll-behavior: auto; } }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-lo); }
ul, ol { list-style: none; padding: 0; }
h1, h2, h3, h4 { line-height: var(--lh-tight); font-weight: 700; letter-spacing: var(--tracking-tight); text-wrap: balance; }
p { text-wrap: pretty; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-xs); }

/* ---- layout primitives ---------------------------------------------------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--s-5); }
.container-wide { max-width: var(--maxw-wide); }
.section { padding-block: var(--s-10); }
.stack > * + * { margin-top: var(--s-4); }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: var(--tracking-caps);
  text-transform: uppercase; color: var(--accent-lo);
}
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.text-2 { color: var(--text-2); }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- icons ---------------------------------------------------------------- */
.icon { width: 20px; height: 20px; flex: 0 0 auto; color: inherit; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 26px; height: 26px; }
.icon-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent-lo); flex: 0 0 auto;
}
.icon-badge--teal { background: var(--accent-2-soft); color: var(--accent-2); }

/* ---- buttons -------------------------------------------------------------- */
.btn {
  --btn-bg: var(--card); --btn-fg: var(--text); --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-5);
  font-size: var(--fs-base); font-weight: 600; line-height: 1;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-bd); border-radius: var(--r-pill);
  cursor: pointer; text-align: center; white-space: nowrap;
  touch-action: manipulation; user-select: none;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn .icon { width: 18px; height: 18px; }

.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--text-inv); --btn-bd: transparent; box-shadow: var(--sh-1); }
.btn-secondary { --btn-bg: var(--card); --btn-fg: var(--text); --btn-bd: var(--line-strong); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--text-2); --btn-bd: transparent; }
.btn-danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-bd: transparent; }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--s-4); font-size: var(--fs-sm); }
.btn-lg { min-height: 52px; padding: 0 var(--s-7); font-size: var(--fs-md); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r-sm);
  color: var(--text-2); background: transparent; border: 1px solid transparent;
  touch-action: manipulation;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn--sm { width: 36px; height: 36px; }

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--accent-lo); box-shadow: var(--glow-accent); }
  .btn-secondary:hover { border-color: var(--accent); color: var(--accent-lo); }
  .btn-ghost:hover { color: var(--text); background: var(--bg-2); }
  .btn-danger:hover { background: var(--danger); color: var(--text-inv); }
  .icon-btn:hover { background: var(--bg-2); color: var(--text); }
}

/* ---- pills / badges ------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 3px var(--s-3); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.5;
  background: var(--bg-2); color: var(--text-2); border: 1px solid var(--line-soft);
}
.pill .icon { width: 13px; height: 13px; }
.pill--accent { background: var(--accent-soft); color: var(--accent-lo); border-color: var(--line-accent); }
.pill--teal { background: var(--accent-2-soft); color: var(--accent-2); border-color: transparent; }
.pill--ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* status pill: done→ok, failed→danger, needs_review→warn, in-flight→accent */
.status-pill {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 4px var(--s-3); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.4;
  background: var(--accent-soft); color: var(--accent-lo);
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.status-pill[data-status="done"] { background: var(--ok-soft); color: var(--ok); }
.status-pill[data-status="failed"] { background: var(--danger-soft); color: var(--danger); }
.status-pill[data-status="needs_review"] { background: var(--warn-soft); color: var(--warn); }
.status-pill.is-live .dot { animation: osp-pulse 1.4s var(--ease) infinite; }
@keyframes osp-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .status-pill.is-live .dot { animation: none; } }

/* certainty tags for tasks */
.certainty { font-size: var(--fs-xs); font-weight: 600; padding: 2px var(--s-2); border-radius: var(--r-xs); }
.certainty--explicit { background: var(--ok-soft); color: var(--ok); }
.certainty--likely { background: var(--accent-soft); color: var(--accent-lo); }
.certainty--unclear { background: var(--warn-soft); color: var(--warn); }

/* ---- cards ---------------------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card-pad { padding: var(--s-6); }
.card-hd { display: flex; align-items: center; gap: var(--s-3); }
.card-title { font-size: var(--fs-md); font-weight: 700; }

/* ---- forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.input, .textarea, .select {
  width: 100%; min-height: 44px; padding: 0 var(--s-4);
  font-size: var(--fs-base); color: var(--text);
  background: var(--card-2); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textarea { min-height: 96px; padding: var(--s-3) var(--s-4); line-height: var(--lh-snug); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group .icon { position: absolute; left: var(--s-3); color: var(--text-muted); pointer-events: none; }
.input-group .input { padding-left: calc(var(--s-4) + 24px); }
.form-error { font-size: var(--fs-sm); color: var(--danger); min-height: 1em; }

/* ---- nav ------------------------------------------------------------------ */
.nav {
  position: sticky; top: 0; z-index: var(--z-nav);
  height: var(--nav-h);
  background: var(--bg); /* solid fallback */
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line-soft);
}
@supports (backdrop-filter: blur(1px)) {
  @media (hover: hover) and (pointer: fine) {
    .nav { backdrop-filter: saturate(140%) blur(12px); }
  }
}
.nav-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }
.nav-brand { display: inline-flex; align-items: center; gap: var(--s-3); color: var(--text); font-weight: 700; }
.nav-brand:hover { color: var(--text); }
.nav-logo-text { font-size: var(--fs-md); letter-spacing: var(--tracking-tight); }
.nav-logo-accent { color: var(--accent); }
.nav-links { display: none; align-items: center; gap: var(--s-2); }
.nav-links a { color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); }
.nav-actions { display: flex; align-items: center; gap: var(--s-2); }
.nav-toggle { display: inline-flex; }
@media (hover: hover) and (pointer: fine) {
  .nav-links a:hover { color: var(--text); background: var(--bg-2); }
}
@media (min-width: 900px) {
  .nav-links { display: flex; }
  .nav-toggle { display: none; }
}
.lang-tag {
  min-width: 40px; height: 36px; padding: 0 var(--s-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em;
  color: var(--text-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--card);
}

/* mobile nav sheet */
.nav-sheet {
  position: fixed; inset: var(--nav-h) 0 auto 0; z-index: var(--z-pop);
  background: var(--card); border-bottom: 1px solid var(--line);
  box-shadow: var(--sh-3);
  padding: var(--s-4) var(--s-5) var(--s-6);
  display: none; flex-direction: column; gap: var(--s-1);
}
.nav-sheet.is-open { display: flex; }
.nav-sheet a { color: var(--text); font-weight: 600; padding: var(--s-3) var(--s-2); border-radius: var(--r-sm); }
.nav-sheet a:hover { background: var(--bg-2); }
.nav-sheet .btn { margin-top: var(--s-3); }
@media (min-width: 900px) { .nav-sheet { display: none !important; } }

/* ---- skeletons ------------------------------------------------------------ */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--bg-2); border-radius: var(--r-sm);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
  transform: translateX(-100%); animation: osp-shimmer 1.5s infinite;
}
@keyframes osp-shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }
.skeleton-line { height: 12px; margin-bottom: var(--s-2); }
.skeleton-line.w-60 { width: 60%; } .skeleton-line.w-80 { width: 80%; } .skeleton-line.w-40 { width: 40%; }

/* ---- empty states --------------------------------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--s-3); padding: var(--s-9) var(--s-5); color: var(--text-2);
}
.empty .icon-badge { width: 56px; height: 56px; border-radius: var(--r-lg); }
.empty h3 { color: var(--text); font-size: var(--fs-lg); }
.empty p { max-width: 42ch; }

/* ---- toasts --------------------------------------------------------------- */
.toast-host {
  position: fixed; z-index: var(--z-toast);
  left: 50%; bottom: calc(var(--s-5) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; gap: var(--s-2);
  width: min(92vw, 420px); pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer;
  padding: var(--s-3) var(--s-4);
  background: var(--ink-panel); color: var(--text-inv);
  border-radius: var(--r-md); box-shadow: var(--sh-3);
  font-size: var(--fs-sm); font-weight: 500;
  opacity: 0; transform: translateY(10px);
  transition: opacity var(--t-mid) var(--ease-out), transform var(--t-mid) var(--ease-out);
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--danger); }
.toast--success { background: var(--ok); }

/* ---- divider / misc ------------------------------------------------------- */
.divider { height: 1px; background: var(--line-soft); border: 0; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: osp-spin .7s linear infinite;
}
@keyframes osp-spin { 100% { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ============================================================================
   FOOTER — structure mirrors omnisolvercode (footer / footer-ext), themed for
   the calm light system on a dark ink panel (SPEC §7).
   ============================================================================ */
.footer { background: var(--ink-panel); color: var(--text-inv); padding-top: var(--s-10); margin-top: var(--s-10); }
.footer a { color: rgba(244,245,249,0.72); }
.footer a:hover { color: var(--text-inv); }
.footer-grid { display: grid; grid-template-columns: 1fr; gap: var(--s-7); padding-bottom: var(--s-8); }
.footer-brand { max-width: 380px; }
.footer-logo-row { display: flex; align-items: center; gap: var(--s-3); }
.footer-logo-text { font-size: var(--fs-md); font-weight: 700; color: var(--text-inv); letter-spacing: var(--tracking-tight); }
.footer-brand .footer-desc { margin-top: var(--s-3); font-size: var(--fs-sm); line-height: var(--lh-body); color: rgba(244,245,249,0.62); }
.footer-pay-row { margin-top: var(--s-5); }
.footer-pay-label { display: block; font-size: var(--fs-xs); color: rgba(244,245,249,0.5); margin-bottom: var(--s-2); text-transform: uppercase; letter-spacing: .06em; }
.footer-pay-icons { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.pay-sbp-card {
  display: inline-flex; align-items: center; gap: var(--s-3);
  min-width: 140px; height: 42px; padding: 0 var(--s-4) 0 var(--s-2);
  background: var(--ink-panel-2); border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-sm); color: var(--text-inv);
}
.pay-sbp-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 24px; background: var(--ok); border-radius: var(--r-xs);
  color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .04em;
}
.pay-sbp-name { font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; color: rgba(244,245,249,0.86); }
.footer-legal-req { margin-top: var(--s-4); font-size: var(--fs-xs); line-height: 1.55; color: rgba(244,245,249,0.5); }
.footer-legal-req a { text-decoration: underline; text-underline-offset: 2px; color: rgba(244,245,249,0.6); }
.footer-col { display: flex; flex-direction: column; gap: var(--s-2); }
.footer-col-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: rgba(244,245,249,0.5); margin-bottom: var(--s-1); }
.footer-col a { font-size: var(--fs-sm); }
.footer-bottom {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3);
  padding: var(--s-5) 0 calc(var(--s-6) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: var(--fs-xs); color: rgba(244,245,249,0.5);
}
.footer-bottom-links { display: flex; gap: var(--s-4); flex-wrap: wrap; }
.footer-bottom-links a { font-size: var(--fs-xs); }

@media (min-width: 720px) {
  .footer-grid { grid-template-columns: 1.5fr repeat(2, 1fr); }
}
@media (min-width: 1000px) {
  .footer-grid { grid-template-columns: 1.6fr repeat(4, 1fr); gap: var(--s-8); }
}

/* ---- responsive section rhythm ------------------------------------------- */
@media (min-width: 720px) { .section { padding-block: var(--s-11); } }
