/* StashJS website — design tokens, base, components. No inline styles are used (strict CSP). */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #0b0d0c;
  --surface: #111413;
  --elevated: #171b19;
  --hover: #1d2220;

  /* Text */
  --text: #e8ece9;
  --muted: #98a39d;
  --faint: #6f7a74;

  /* Borders */
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);

  /* Accent & semantic */
  --accent: #34d399;
  --accent-strong: #10b981;
  --accent-ink: #04130c;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --danger: #f87171;
  --warn: #fbbf24;

  /* Type */
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Spacing (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  --radius: 8px;
  --radius-lg: 12px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
code, pre, kbd { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-strong); color: var(--accent-ink); }

.skip-link {
  position: absolute; left: var(--s4); top: -64px; z-index: 100;
  padding: var(--s2) var(--s4); background: var(--accent-strong); color: var(--accent-ink);
  border-radius: var(--radius); font-weight: 600;
}
.skip-link:focus { top: var(--s4); }

.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }
.section { padding-block: clamp(56px, 9vw, 112px); border-top: 1px solid var(--line); }
.eyebrow { font: 500 12px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.h2 { font-size: clamp(30px, 4.4vw, 48px); line-height: 1.08; letter-spacing: -0.03em; font-weight: 600; margin-top: var(--s3); }
.h3 { font-size: 18px; line-height: 1.35; font-weight: 600; letter-spacing: -0.01em; }
.lead { font-size: clamp(16px, 1.6vw, 19px); color: var(--muted); max-width: 60ch; }
.section-head { display: grid; gap: var(--s4); margin-bottom: var(--s7); max-width: 760px; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code.inline { font-size: 0.88em; padding: 2px 6px; border-radius: 4px; background: var(--elevated); border: 1px solid var(--line); color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s5); border-radius: var(--radius);
  border: 1px solid transparent; font: 600 15px/1 var(--font-sans); cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent-strong); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); border-color: rgba(255, 255, 255, 0.24); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(248, 113, 113, 0.35); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.1); }
.btn-sm { min-height: 32px; padding: 0 var(--s3); font-size: 13px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(11, 13, 12, 0.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); height: 64px; }
.brand { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 650; font-size: 18px; letter-spacing: -0.02em; }
.brand .icon { width: 22px; height: 22px; color: var(--accent); }
.brand b { color: var(--accent); font-weight: 650; }
.nav { display: none; gap: var(--s1); }
.nav a { padding: var(--s2) var(--s3); border-radius: var(--radius); color: var(--muted); font-size: 14px; transition: color 0.15s var(--ease), background-color 0.15s var(--ease); }
.nav a:hover { color: var(--text); background: var(--hover); }
.header-actions { display: flex; align-items: center; gap: var(--s3); }
.lang { display: inline-flex; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.lang button { min-width: 36px; min-height: 28px; padding: 0 var(--s2); border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: 600 12px var(--font-mono); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--elevated); color: var(--text); }
.lang button:hover { color: var(--text); }
@media (min-width: 900px) { .nav { display: flex; } }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(48px, 8vw, 104px); }
.hero-grid { display: grid; gap: var(--s7); align-items: start; }
@media (min-width: 960px) { .hero-grid { grid-template-columns: 1.1fr 0.9fr; gap: var(--s8); } }
.hero h1 { font-size: clamp(40px, 6.4vw, 76px); line-height: 1.02; letter-spacing: -0.04em; font-weight: 650; margin-block: var(--s5) var(--s5); text-wrap: balance; }
.hero h1 .accent { color: var(--accent); }
.badge { display: inline-flex; align-items: center; gap: var(--s2); padding: 6px var(--s3); border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font: 500 12px var(--font-mono); }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cta-row { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s6); }
.facts { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s6); margin-top: var(--s7); padding-top: var(--s5); border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.facts b { display: block; color: var(--text); font: 600 15px var(--font-mono); margin-bottom: 2px; }

/* ---------- Cards, forms ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(20px, 3vw, 28px); }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.field { display: grid; gap: var(--s2); }
.field label { font-size: 14px; font-weight: 500; }
.field .hint { font-size: 13px; color: var(--faint); }
.input {
  width: 100%; min-height: 44px; padding: 0 var(--s3); border-radius: var(--radius);
  background: var(--bg); color: var(--text); border: 1px solid var(--line-strong);
  font: 400 15px var(--font-mono); transition: border-color 0.15s var(--ease);
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: rgba(255, 255, 255, 0.24); }
.input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.form-row { display: grid; gap: var(--s2); }
@media (min-width: 520px) { .form-row.inline { grid-template-columns: 1fr auto; } }
.form-error { min-height: 20px; margin-top: var(--s2); font-size: 13px; color: var(--danger); }
.tokens { display: grid; gap: var(--s2); margin-block: var(--s4); }
.token { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.token .role { font: 600 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 6px; border-radius: 4px; background: var(--elevated); }
.token .role.adm { color: var(--warn); }
.token .role.wrt { color: var(--accent); }
.token code { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border: 1px solid rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.06); border-radius: var(--radius); color: #e8d9a8; font-size: 13.5px; }
.notice .icon { color: var(--warn); margin-top: 2px; }

/* ---------- Code ---------- */
.code { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s3) var(--s2) var(--s4); background: var(--surface); border-bottom: 1px solid var(--line); font: 500 12px var(--font-mono); color: var(--muted); }
.code pre { margin: 0; padding: var(--s4); overflow-x: auto; font-size: 13.5px; line-height: 1.7; color: #d4ddd8; tab-size: 2; }
.tk-c { color: var(--faint); font-style: italic; }
.tk-s { color: #f2d48a; }
.tk-k { color: var(--accent); }

/* ---------- Steps ---------- */
.steps { display: grid; gap: var(--s4); counter-reset: step; }
.step { position: relative; padding-left: 52px; }
.step::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius); border: 1px solid var(--line-strong); font: 600 14px var(--font-mono); color: var(--accent); }
.step p { color: var(--muted); font-size: 15px; margin-top: var(--s1); }
.split { display: grid; gap: var(--s7); align-items: start; }
@media (min-width: 960px) { .split { grid-template-columns: 0.8fr 1.2fr; gap: var(--s8); } }

/* ---------- Bento features ---------- */
.bento { display: grid; gap: var(--s3); grid-template-columns: repeat(6, 1fr); }
.tile { grid-column: span 6; display: flex; flex-direction: column; gap: var(--s4); padding: var(--s5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease); }
.tile:hover { border-color: var(--line-strong); background: var(--elevated); }
.tile p { color: var(--muted); font-size: 15px; margin-top: var(--s2); }
.tile .glyph { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); }
@media (min-width: 720px) {
  .tile { grid-column: span 3; }
  .tile.w4 { grid-column: span 4; }
  .tile.w2 { grid-column: span 2; }
}
@media (min-width: 1000px) {
  .tile { grid-column: span 2; }
  .tile.w4 { grid-column: span 4; }
  .tile.w6 { grid-column: span 6; flex-direction: row; align-items: center; }
}

/* ---------- Docs ---------- */
.docs { display: grid; gap: var(--s5); }
@media (min-width: 960px) { .docs { grid-template-columns: 260px 1fr; gap: var(--s6); } }
.tabs { display: flex; gap: var(--s1); overflow-x: auto; padding-bottom: var(--s2); }
@media (min-width: 960px) { .tabs { flex-direction: column; overflow: visible; position: sticky; top: 88px; align-self: start; } }
.tab { flex: none; text-align: left; min-height: 44px; padding: 0 var(--s4); border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--muted); font: 500 14px var(--font-sans); cursor: pointer; white-space: nowrap; transition: background-color 0.15s var(--ease), color 0.15s var(--ease); }
.tab:hover { color: var(--text); background: var(--hover); }
.tab[aria-selected="true"] { color: var(--text); background: var(--elevated); border-color: var(--line-strong); box-shadow: inset 2px 0 0 var(--accent); }
.panel { display: grid; gap: var(--s4); min-width: 0; }
.panel p { color: var(--muted); max-width: 70ch; }
.callout { padding: var(--s4); border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 14px; }
.callout b { color: var(--text); }

/* ---------- Live demo ---------- */
.demo-grid { display: grid; gap: var(--s3); }
@media (min-width: 860px) { .demo-grid { grid-template-columns: 1fr 1fr; } }
.pane { display: grid; gap: var(--s4); align-content: start; }
.pane-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding-bottom: var(--s4); border-bottom: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--radius); font: 700 13px var(--font-mono); background: var(--accent-soft); color: var(--accent); }
.avatar.b { background: rgba(251, 191, 36, 0.12); color: var(--warn); }
.who { display: flex; gap: var(--s3); align-items: center; }
.who p { font-size: 12.5px; color: var(--faint); font-family: var(--font-mono); }
.chip { padding: 3px 8px; border-radius: 999px; background: var(--elevated); font: 500 11.5px var(--font-mono); color: var(--muted); }
.status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--faint); }
.status[data-state="online"]::before { background: var(--accent); }
.status[data-state="connecting"]::before { background: var(--warn); }
.status[data-state="offline"]::before { background: var(--danger); }
.feed { display: grid; gap: var(--s2); min-height: 180px; max-height: 280px; overflow-y: auto; align-content: start; }
.msg { padding: var(--s3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); font-size: 14px; overflow-wrap: anywhere; }
.msg .meta { display: block; margin-top: 4px; font: 400 11.5px var(--font-mono); color: var(--faint); }
.msg .who-tag { font: 600 12px var(--font-mono); margin-right: var(--s2); }
.msg .who-tag.a { color: var(--accent); }
.msg .who-tag.b { color: var(--warn); }
.empty { display: grid; place-items: center; min-height: 160px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--faint); font-size: 14px; text-align: center; padding: var(--s4); }
.demo-start { display: grid; place-items: center; gap: var(--s4); padding: var(--s8) var(--s4); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); }
.demo-start p { color: var(--muted); max-width: 52ch; }
.demo-note { margin-top: var(--s4); display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--s3); font-size: 13px; color: var(--faint); }

/* ---------- Limits table, FAQ ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: var(--s4); text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { width: 38%; font-weight: 500; color: var(--muted); }
.table td { font-family: var(--font-mono); font-size: 14px; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow-x: auto; }
.table tr:last-child th, .table tr:last-child td { border-bottom: 0; }
.faq { display: grid; gap: var(--s2); margin-top: var(--s6); }
.faq details { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.faq summary { cursor: pointer; padding: var(--s4); font-weight: 500; list-style: none; display: flex; justify-content: space-between; gap: var(--s3); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font: 500 18px var(--font-mono); }
.faq details[open] summary::after { content: "–"; }
.faq details p { padding: 0 var(--s4) var(--s4); color: var(--muted); font-size: 15px; }

/* ---------- Footer, toast, 404 ---------- */
.footer { padding-block: var(--s7); border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s5); }
.footer nav { display: flex; flex-wrap: wrap; gap: var(--s5); }
.footer a:hover { color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: var(--s5); z-index: 90; transform: translate(-50%, 16px); display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-radius: var(--radius); background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s var(--ease), transform 0.2s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #1a0505; }
.notfound { min-height: 100vh; display: grid; place-content: center; justify-items: start; gap: var(--s4); padding: var(--s5); max-width: 560px; margin: auto; }
.notfound h1 { font-size: clamp(32px, 6vw, 48px); letter-spacing: -0.03em; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
