/* Astryx — Shifted (web). All values per web/DESIGN.md; primitives from design-tokens/tokens.json. */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --canvas: #FFFBEB;
  --canvas-muted: #FAF3DC;
  --surface: #FFFFFF;
  --surface-muted: #F7F1DE;
  --ink: #211D14;
  --ink-secondary: #6B675A;
  --ink-disabled: #A8A294;
  --hairline: #E9E2CC;
  --hairline-strong: #CFC7A8;
  --primary: #9333EA;
  --primary-hover: #7E22CE;
  --primary-soft: #F3E8FF;
  --on-primary: #FFFFFF;
  --secondary: #0284C7;
  --secondary-hover: #0369A1;
  --secondary-soft: #E0F2FE;
  --highlight: #B45309;
  --highlight-fill: #F59E0B;
  --highlight-soft: #FEF3C7;
  --success: #15803D;
  --success-soft: #DCFCE7;
  --warning: #B45309;
  --warning-soft: #FEF3C7;
  --error: #B91C1C;
  --error-soft: #FEE2E2;
  --overlay: rgba(33, 29, 20, 0.5);
  --shadow-low: 0 2px 4px rgba(120,53,15,0.06), 0 4px 8px rgba(120,53,15,0.08);
  --shadow-med: 0 2px 4px rgba(120,53,15,0.06), 0 8px 20px rgba(120,53,15,0.12);
  --shadow-high: 0 4px 8px rgba(120,53,15,0.10), 0 16px 32px rgba(120,53,15,0.16);
  --ring-selected: inset 0 0 0 2px rgba(120,53,15,0.22);
  --ring-primary: inset 0 0 0 2px rgba(147,51,234,0.45);
  --focus-halo: 0 0 0 3px rgba(168,85,247,0.25);
  --radius-inner: 4px;
  --radius-element: 8px;
  --radius-container: 12px;
  --radius-large: 16px;
  --radius-page: 24px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --canvas: #161310;
  --canvas-muted: #292219;
  --surface: #201B16;
  --surface-muted: #292219;
  --ink: #F5EFE3;
  --ink-secondary: #ADA696;
  --ink-disabled: #6E695C;
  --hairline: #3A342A;
  --hairline-strong: #57503F;
  --primary: #A855F7;
  --primary-hover: #C084FC;
  --primary-soft: #581C87;
  --on-primary: #FFFFFF;
  --secondary: #38BDF8;
  --secondary-hover: #7DD3FC;
  --secondary-soft: #0C4A6E;
  --highlight: #FCD34D;
  --highlight-fill: #F59E0B;
  --highlight-soft: #78350F;
  --success: #86EFAC;
  --success-soft: #166534;
  --warning: #FCD34D;
  --warning-soft: #92400E;
  --error: #FCA5A5;
  --error-soft: #7F1D1D;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow-low: 0 2px 4px rgba(0,0,0,0.30), 0 4px 8px rgba(0,0,0,0.35);
  --shadow-med: 0 2px 4px rgba(0,0,0,0.30), 0 8px 20px rgba(0,0,0,0.45);
  --shadow-high: 0 4px 8px rgba(0,0,0,0.35), 0 16px 32px rgba(0,0,0,0.55);
  --ring-selected: inset 0 0 0 2px rgba(245,239,227,0.25);
  --ring-primary: inset 0 0 0 2px rgba(168,85,247,0.55);
  --focus-halo: 0 0 0 3px rgba(168,85,247,0.35);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Outfit', 'Segoe UI', system-ui, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 20px;
  transition: background 0.25s ease, color 0.25s ease;
}

::selection { background: var(--primary-soft); }

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

code, .mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.logo {
  width: 34px; height: 34px; border-radius: var(--radius-element);
  background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
  box-shadow: var(--shadow-low);
}
.topbar .brand-name { font-size: 16px; font-weight: 600; letter-spacing: -0.3px; }
.topbar .brand-sub { color: var(--ink-secondary); font-size: 12px; font-weight: 500; }
.topbar .spacer { flex: 1; }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 500; font-size: 14px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--hairline-strong); border-radius: var(--radius-element);
  padding: 8px 14px; cursor: pointer;
}
.theme-toggle:hover { box-shadow: var(--shadow-low); }

/* ---------- Layout ---------- */
.shell {
  display: grid; grid-template-columns: 232px minmax(0, 1fr);
  max-width: 1360px; margin: 0 auto;
}
.sidebar {
  position: sticky; top: 59px; align-self: start;
  height: calc(100vh - 59px); overflow-y: auto;
  padding: 24px 16px 48px 24px;
}
.sidebar .nav-group {
  font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--ink-disabled); margin: 24px 8px 8px;
}
.sidebar .nav-group:first-child { margin-top: 0; }
.sidebar a {
  display: block; padding: 7px 10px; margin-bottom: 2px;
  color: var(--ink-secondary); font-weight: 500; font-size: 14px;
  border-radius: var(--radius-element);
}
.sidebar a:hover { background: var(--surface-muted); text-decoration: none; color: var(--ink); }
.sidebar a.active { background: var(--surface); color: var(--ink); box-shadow: var(--ring-selected); }

.main { padding: 40px 48px 96px; min-width: 0; }
section { padding-top: 64px; scroll-margin-top: 80px; }
section:first-child { padding-top: 8px; }

.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--primary); margin-bottom: 10px;
}
h1.display {
  font-size: 57px; line-height: 64px; font-weight: 600; letter-spacing: -1.5px;
  margin-bottom: 16px;
}
h2.section-title {
  font-size: 32px; line-height: 40px; font-weight: 600; letter-spacing: -0.8px;
  margin-bottom: 8px;
}
.section-lede { color: var(--ink-secondary); font-size: 16px; line-height: 24px; max-width: 640px; margin-bottom: 28px; }
h3.sub-title { font-size: 16px; font-weight: 600; line-height: 24px; margin: 32px 0 12px; }
.spec-note { color: var(--ink-secondary); font-size: 12px; margin-top: 10px; }
.spec-note code { color: var(--ink); }

/* ---------- Generic surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-container); box-shadow: var(--shadow-low);
  padding: 24px;
}
.demo-well {
  background: var(--canvas-muted); border: 1px solid var(--hairline);
  border-radius: var(--radius-container); padding: 24px;
}
.demo-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.demo-stack { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 500; font-size: 14px; line-height: 20px;
  border-radius: var(--radius-element); padding: 10px 18px;
  border: 1px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--hairline-strong); }
.btn-secondary:hover { box-shadow: var(--shadow-low); }
.btn-ghost { background: transparent; color: var(--ink-secondary); }
.btn-ghost:hover { background: var(--surface-muted); color: var(--ink); }
.btn-destructive { background: var(--error); color: #fff; }
[data-theme="dark"] .btn-destructive { color: #2A0A0A; }
.btn-highlight { background: var(--highlight-fill); color: #2A1A02; }
.btn-highlight:hover { filter: brightness(1.06); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-lg { padding: 13px 22px; font-size: 16px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn:focus-visible, .theme-toggle:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: var(--focus-halo);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; line-height: 16px;
  padding: 3px 10px; border-radius: var(--radius-full);
  background: var(--surface-muted); color: var(--ink-secondary);
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: var(--radius-full); background: currentColor; }
.badge-nyx { background: var(--primary-soft); color: var(--primary-hover); }
[data-theme="dark"] .badge-nyx { color: #E9D5FF; }
.badge-ryuki { background: var(--secondary-soft); color: var(--secondary-hover); }
[data-theme="dark"] .badge-ryuki { color: #E0F2FE; }
.badge-nosmile99 { background: var(--highlight-soft); color: var(--highlight); }
[data-theme="dark"] .badge-nosmile99 { color: #FDE68A; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-info { background: var(--secondary-soft); color: var(--secondary-hover); }
[data-theme="dark"] .badge-info { color: #E0F2FE; }
.badge-outline { background: transparent; border: 1px solid var(--hairline-strong); color: var(--ink-secondary); }

/* ---------- Avatars ---------- */
.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-full);
  display: inline-grid; place-items: center;
  font-size: 13px; font-weight: 600; color: #fff; flex: none;
}
.avatar-nyx { background: #A855F7; }
.avatar-ryuki { background: #38BDF8; color: #062A3F; }
.avatar-nosmile99 { background: #F59E0B; color: #2A1A02; }
.avatar-lg { width: 44px; height: 44px; font-size: 17px; }
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }

/* ---------- Color ramps ---------- */
.ramp { margin-bottom: 20px; }
.ramp-name { font-weight: 600; font-size: 14px; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; }
.ramp-name .mono { color: var(--ink-secondary); font-weight: 400; font-size: 12px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.swatch {
  border-radius: var(--radius-element); border: 1px solid var(--hairline);
  overflow: hidden; cursor: pointer; background: var(--surface);
}
.swatch .chip { height: 44px; }
.swatch .meta { padding: 6px 8px; }
.swatch .step { font-size: 12px; font-weight: 600; }
.swatch .hex { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-secondary); text-transform: uppercase; }
.semantic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.semantic-chip {
  border-radius: var(--radius-container); border: 1px solid var(--hairline);
  padding: 16px; min-height: 96px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
  cursor: pointer;
}
.semantic-chip .role { font-weight: 600; font-size: 14px; }
.semantic-chip .hex { font-family: 'JetBrains Mono', monospace; font-size: 11px; opacity: 0.75; text-transform: uppercase; }
.semantic-chip .src { font-size: 11px; opacity: 0.6; }

/* ---------- Type specimens ---------- */
.type-row {
  display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 24px;
  padding: 18px 0; border-bottom: 1px solid var(--hairline); align-items: baseline;
}
.type-row:last-child { border-bottom: none; }
.type-meta { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--ink-secondary); line-height: 18px; }
.t-display { font-size: 57px; line-height: 64px; font-weight: 600; letter-spacing: -1.5px; }
.t-headline-lg { font-size: 32px; line-height: 40px; font-weight: 600; letter-spacing: -0.8px; }
.t-headline { font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -0.6px; }
.t-title-lg { font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.3px; }
.t-title { font-size: 16px; line-height: 24px; font-weight: 600; }
.t-body-lg { font-size: 16px; line-height: 24px; }
.t-body { font-size: 14px; line-height: 20px; }
.t-label { font-size: 14px; line-height: 20px; font-weight: 500; }
.t-caption { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-secondary); }

/* ---------- Spacing / radius / elevation demos ---------- */
.space-row { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.space-bar { height: 14px; background: var(--primary); border-radius: var(--radius-inner); opacity: 0.85; }
.space-row .mono { color: var(--ink-secondary); font-size: 12px; width: 110px; }
.radius-tile {
  background: var(--surface); border: 1px solid var(--hairline-strong);
  height: 84px; display: grid; place-items: end start; padding: 10px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-secondary);
}
.shadow-tile {
  background: var(--surface); border-radius: var(--radius-container);
  padding: 20px; min-height: 96px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
}
.shadow-tile .name { font-weight: 600; }
.shadow-tile .mono { font-size: 11px; color: var(--ink-secondary); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field label { font-weight: 500; font-size: 14px; }
.field .helper { font-size: 12px; color: var(--ink-secondary); }
.field .error-text { font-size: 12px; color: var(--error); font-weight: 500; }
.input, .select, .textarea {
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-element); padding: 10px 12px; width: 100%;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-disabled); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-halo); }
.input-error { border-color: var(--error); }
.input-error:focus { border-color: var(--error); box-shadow: 0 0 0 3px rgba(220,38,38,0.18); }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check-row input[type="checkbox"], .check-row input[type="radio"] {
  appearance: none; width: 20px; height: 20px; flex: none; cursor: pointer;
  border: 1.5px solid var(--hairline-strong); background: var(--surface);
  display: grid; place-items: center; transition: background 0.12s ease, border-color 0.12s ease;
}
.check-row input[type="checkbox"] { border-radius: 6px; }
.check-row input[type="radio"] { border-radius: var(--radius-full); }
.check-row input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }
.check-row input[type="checkbox"]:checked::after { content: "✓"; color: #fff; font-size: 13px; font-weight: 700; line-height: 1; }
.check-row input[type="radio"]:checked { border-color: var(--primary); }
.check-row input[type="radio"]:checked::after { content: ""; width: 10px; height: 10px; border-radius: var(--radius-full); background: var(--primary); }
.switch { position: relative; width: 46px; height: 27px; flex: none; cursor: pointer; }
.switch input { appearance: none; width: 100%; height: 100%; border-radius: var(--radius-full); background: var(--hairline-strong); cursor: pointer; transition: background 0.15s ease; margin: 0; }
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: var(--radius-full); background: #fff; box-shadow: var(--shadow-low);
  transition: transform 0.15s ease;
}
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(19px); }

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--surface-muted); border: 1px solid var(--hairline);
  border-radius: var(--radius-container);
}
.tab {
  font: inherit; font-weight: 500; font-size: 14px; cursor: pointer;
  padding: 7px 14px; border: none; background: transparent; color: var(--ink-secondary);
  border-radius: var(--radius-element);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--ring-selected); }
.tab-panel { padding-top: 20px; color: var(--ink-secondary); font-size: 16px; line-height: 24px; }

/* ---------- Table ---------- */
.table-wrap { border: 1px solid var(--hairline); border-radius: var(--radius-container); overflow: hidden; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--surface-muted); color: var(--ink-secondary);
  font-size: 12px; font-weight: 500; text-align: left; padding: 10px 16px;
}
tbody td { padding: 12px 16px; border-top: 1px solid var(--hairline); vertical-align: middle; }
tbody tr:hover { background: var(--canvas-muted); }
.cell-main { font-weight: 500; }
.cell-sub { color: var(--ink-secondary); font-size: 12px; }

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: var(--radius-container); padding: 14px 16px; font-size: 14px;
}
.alert .alert-title { font-weight: 600; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-error { background: var(--error-soft); color: var(--error); }
.alert-info { background: var(--secondary-soft); color: var(--secondary-hover); }
[data-theme="dark"] .alert-info { color: #E0F2FE; }
.alert .alert-body { color: var(--ink); opacity: 0.85; }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: var(--radius-full); background: var(--surface-muted); overflow: hidden; border: 1px solid var(--hairline); }
.progress > div { height: 100%; border-radius: var(--radius-full); background: var(--primary); }
.progress .bar-sky { background: var(--secondary); }
.progress .bar-amber { background: var(--highlight-fill); }
.progress .bar-green { background: #22C55E; }

/* ---------- Dialog & toast ---------- */
dialog {
  margin: auto; /* global margin reset kills the UA showModal centering — restore it */
  border: 1px solid var(--hairline); border-radius: var(--radius-large);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-high); padding: 28px; max-width: 440px; width: calc(100% - 48px);
}
dialog::backdrop { background: var(--overlay); }
.toast-zone { position: fixed; bottom: 24px; right: 24px; z-index: 80; display: grid; gap: 10px; }
.toast {
  background: var(--ink); color: var(--canvas);
  border-radius: var(--radius-container); box-shadow: var(--shadow-med);
  padding: 12px 16px; font-size: 14px; display: flex; gap: 10px; align-items: center;
  animation: toast-in 0.22s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Kanban pattern ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.kb-col { background: var(--canvas-muted); border: 1px solid var(--hairline); border-radius: var(--radius-container); padding: 12px; display: grid; gap: 10px; }
.kb-col-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; padding: 2px 4px; }
.kb-count { font-size: 12px; color: var(--ink-secondary); font-weight: 500; }
.kb-card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-element); box-shadow: var(--shadow-low); padding: 12px;
  display: grid; gap: 8px;
}
.kb-card .kb-title { font-weight: 500; line-height: 20px; }
.kb-card .kb-meta { display: flex; align-items: center; gap: 8px; justify-content: space-between; }

/* ---------- Brand cards ---------- */
.brand-card .brand-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.brand-card .brand-name { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
.brand-card .brand-role { color: var(--ink-secondary); font-size: 12px; font-weight: 500; }

/* ---------- Principle cards ---------- */
.principle .p-num {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--primary); font-weight: 500;
}
.principle h3 { font-size: 16px; font-weight: 600; margin: 8px 0 6px; }
.principle p { color: var(--ink-secondary); }

.footer {
  margin-top: 96px; padding-top: 24px; border-top: 1px solid var(--hairline);
  color: var(--ink-secondary); font-size: 12px; display: grid; gap: 4px;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 24px 20px 64px; }
  h1.display { font-size: 40px; line-height: 46px; letter-spacing: -1px; }
  .grid-2, .grid-3, .kanban { grid-template-columns: 1fr; }
  .type-row { grid-template-columns: 1fr; gap: 6px; }
}
