/* UniRouter AI — Design System
   Neutral grayscale + single accent (#4F8CFF). No gradients, no glow. */

:root {
  --bg: #0a0a0b;
  --surface: #111114;
  --surface-2: #16161a;
  --surface-3: #1d1d22;
  --border: #26262b;
  --border-soft: #1c1c20;

  --text: #ededef;
  --text-2: #a1a1aa;
  --text-3: #71717a;

  --accent: #4f8cff;
  --accent-hover: #6a9dff;
  --accent-soft: rgba(79, 140, 255, 0.12);

  --ok: #3fb68b;
  --warn: #e5a54b;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;

  --content: 1200px;
  --radius: 10px;
  --radius-lg: 14px;
  --section-gap: 128px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { background: var(--bg); overflow-x: hidden; }

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
code { font-family: var(--font-mono); font-size: 0.92em; color: var(--text); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }

.container {
  width: 100%;
  max-width: calc(var(--content) + 64px);
  margin: 0 auto;
  padding: 0 32px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 11, 0.86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.site-header__inner {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 40px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.logo__mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--text);
  display: grid;
  place-items: center;
}

.logo__mark span {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--bg);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
  transition: color 0.15s ease;
}

.nav a:hover, .nav a[aria-current="page"] { color: var(--text); }

.header-actions { display: flex; align-items: center; gap: 12px; }

/* ---------- Language switcher ---------- */
.lang { position: relative; }

.lang summary {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.lang summary::-webkit-details-marker { display: none; }
.lang summary:hover, .lang[open] summary { color: var(--text); }

.lang__menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 60;
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.lang__menu a {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

.lang__menu a:hover { background: var(--surface-3); color: var(--text); }
.lang__menu a[aria-current] { color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }

.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  place-items: center;
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 14px;
  height: 1.5px;
  background: var(--text);
  position: relative;
  content: "";
}

.nav-toggle span::before { position: absolute; top: -5px; }
.nav-toggle span::after { position: absolute; top: 5px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn--primary { background: var(--text); color: var(--bg); }
.btn--primary:hover { background: #ffffff; }

.btn--secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn--secondary:hover { border-color: var(--text-3); }

.btn--sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn--lg { height: 48px; padding: 0 24px; font-size: 15px; }

.link-arrow {
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
}

.link-arrow:hover { color: var(--accent-hover); }

/* ---------- Typography ---------- */
.eyebrow {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 16px;
}

.h1 {
  font-size: clamp(38px, 5.2vw, 64px);
  line-height: 1.12;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.h1 .dim { color: var(--text-3); }

.h2 {
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.h3 {
  font-size: 18px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lead {
  font-size: 18px;
  line-height: 1.7;
  color: var(--text-2);
  max-width: 640px;
}

.body { font-size: 16px; color: var(--text-2); }

/* ---------- Sections ---------- */
.section { padding: var(--section-gap) 0; }
.section + .section { border-top: 1px solid var(--border-soft); }

.section-head { max-width: 720px; margin-bottom: 56px; }
.section-head .lead { margin-top: 18px; }

.section-head--row {
  max-width: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}

.section-head--row > div { max-width: 720px; }

/* ---------- Hero ---------- */
.hero { padding: 112px 0 0; text-align: center; }
.hero .lead { margin: 24px auto 0; }

.hero__actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.hero__frame { margin-top: 80px; text-align: start; }

/* ---------- Product frame (mock UI) ---------- */
.frame {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.frame__bar {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-3);
}

.frame__bar-left { display: flex; align-items: center; gap: 16px; }

.frame__dots { display: flex; gap: 6px; }
.frame__dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-3); }

.frame__body { padding: 28px; }

.sample-tag {
  font-size: 12px;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
}

/* Dashboard inside hero frame */
.dash {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 28px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 28px;
}

.kpi { padding: 18px 20px; }
.kpi + .kpi { border-inline-start: 1px solid var(--border-soft); }
.kpi__label { font-size: 13px; color: var(--text-3); }
.kpi__value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi__meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 18px;
}

.panel-title span:last-child { font-size: 12px; color: var(--text-3); font-weight: 400; }

/* Budget vs actual bars */
.bars { display: flex; flex-direction: column; gap: 18px; }

.bar-row__meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.bar-row__meta span:last-child { color: var(--text-2); font-variant-numeric: tabular-nums; }

.bar-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  border-radius: 4px;
  background: var(--accent);
}

.bar-fill--warn { background: var(--warn); }

.legend {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 20px;
}

.legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-inline-end: 6px;
  vertical-align: 0;
}

/* Request ledger list */
.ledger { display: flex; flex-direction: column; }

.ledger__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}

.ledger__row:last-child { border-bottom: none; }
.ledger__task { color: var(--text); }
.ledger__cost { text-align: end; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ledger__meta { color: var(--text-3); font-size: 12px; grid-column: 1 / -1; }

/* ---------- Pillars ---------- */
.pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.section--pillars { padding: 96px 0 0; }
.section--pillars .pillars { border-bottom: none; }

.pillar { padding: 40px 32px 44px; }
.pillar:first-child { padding-inline-start: 0; }
.pillar + .pillar { border-inline-start: 1px solid var(--border-soft); }
.pillar__num { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.pillar .h3 { margin: 14px 0 10px; }
.pillar p { font-size: 15px; color: var(--text-2); }

/* ---------- Access: models + code ---------- */
.access {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 56px;
  align-items: start;
}

.model-list { border-top: 1px solid var(--border-soft); }

.model-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 4px 16px;
  padding: 18px 0;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  background: none;
  text-align: start;
  cursor: pointer;
  transition: padding 0.15s ease;
}

.model-item__name { font-size: 16px; font-weight: 500; color: var(--text-2); transition: color 0.15s ease; }
.model-item__vendor { font-size: 13px; color: var(--text-3); }
.model-item__use { grid-column: 1 / -1; font-size: 14px; color: var(--text-3); }

.model-item:hover .model-item__name { color: var(--text); }
.model-item.is-active .model-item__name { color: var(--text); }
.model-item.is-active { box-shadow: inset 2px 0 0 var(--accent); padding-inline-start: 16px; }
[dir="rtl"] .model-item.is-active { box-shadow: inset -2px 0 0 var(--accent); }

.model-more { display: inline-block; margin-top: 24px; }

.vendors {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 40px;
  font-size: 16px;
  color: var(--text-2);
}

.code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: sticky;
  top: 96px;
}

.code__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 8px;
  height: 48px;
  border-bottom: 1px solid var(--border-soft);
}

.tabs { display: flex; gap: 2px; }

.tab {
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
}

.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface-3); color: var(--text); }

.code pre {
  margin: 0;
  padding: 24px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.75;
  color: #d4d4d8;
  overflow-x: auto;
  white-space: pre;
}

.code__foot {
  padding: 14px 24px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-3);
}

.tok-c { color: #5b5b66; }
.tok-s { color: #9ecbff; }
.tok-k { color: #c4b5fd; }
.tok-h { color: var(--text); }

/* ---------- Cost console ---------- */
.console {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.console__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px 10px 10px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.console__body { padding: 32px; }

.pane { display: none; }
.pane.is-active { display: block; }

.pane-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
}

.caption { font-size: 12px; color: var(--text-3); margin-top: 24px; }

/* Ranked unit cost list */
.rank { display: flex; flex-direction: column; }

.rank__row {
  display: grid;
  grid-template-columns: 1fr 200px 96px;
  align-items: center;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-soft);
}

.rank__row:last-child { border-bottom: none; }
.rank__name { font-size: 15px; }
.rank__meta { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.rank__cost { text-align: end; font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: start;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-3);
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

.table th:first-child, .table td:first-child { padding-inline-start: 0; }
.table th:last-child, .table td:last-child { padding-inline-end: 0; }
.table tbody tr:last-child td { border-bottom: none; }
.table .r { text-align: end; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table .zero { color: var(--text-3); }
.table tfoot td { border-top: 1px solid var(--border); border-bottom: none; font-weight: 600; }

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.status--warn::before { background: var(--warn); }

/* ---------- Steps ---------- */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin-top: 64px;
}

.step__num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.step .h3 { margin-bottom: 8px; }
.step p { font-size: 15px; color: var(--text-2); }

/* ---------- Control & data ---------- */
.split {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 56px;
}

.feature-list { border-top: 1px solid var(--border-soft); }

.feature-list li {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border-soft);
}

.feature-list strong { font-weight: 500; font-size: 16px; }
.feature-list p { font-size: 15px; color: var(--text-2); }

/* ---------- CTA ---------- */
.cta { text-align: center; }
.cta .lead { margin: 20px auto 0; }
.cta .hero__actions { margin-top: 36px; }
.cta__mail { margin-top: 20px; font-size: 14px; color: var(--text-3); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border-soft);
  padding: 56px 0 40px;
  font-size: 14px;
  color: var(--text-3);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
}

.footer-grid h4 { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 14px; }
.footer-grid ul { display: flex; flex-direction: column; gap: 10px; }
.footer-grid a:hover { color: var(--text); }
.footer-grid .logo { color: var(--text); margin-bottom: 14px; }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
}

/* ---------- Sub-page hero ---------- */
.page-hero { padding: 96px 0 80px; }
.page-hero .lead { margin-top: 20px; }
.page-hero + .section { padding-top: 0; }

.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 48px 32px;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
}

.modal.is-open { display: flex; }

.modal__dialog {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.modal__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.modal__head p { font-size: 14px; color: var(--text-3); margin-top: 4px; }

.modal__close {
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal__close:hover { color: var(--text); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }

.field input, .field select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }

.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  z-index: 300;
  display: none;
  padding: 12px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 14px;
}

.toast.is-visible { display: block; }

.dash > *, .access > *, .pane-grid > *, .split > * { min-width: 0; }

/* ---------- Script-specific typography ---------- */
.code pre, .mono, code { direction: ltr; unicode-bidi: isolate; }
.code pre { text-align: left; }
:lang(ar) .h1, :lang(ar) .h2, :lang(ar) .h3,
:lang(th) .h1, :lang(th) .h2, :lang(th) .h3 { letter-spacing: 0; }
:lang(ar) .h1, :lang(th) .h1 { line-height: 1.3; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .dash, .access, .pane-grid, .split { grid-template-columns: 1fr; }
  .code { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  :root { --section-gap: 88px; }
  .container { padding: 0 20px; }
  .nav-toggle { display: grid; }
  .header-actions { margin-inline-start: auto; }
  .header-actions .btn { display: none; }
  .lang__menu { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 20px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border-soft);
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 12px 0; font-size: 16px; }
  .hero { padding-top: 72px; }
  .hero__frame { margin-top: 56px; }
  .kpis, .pillars, .steps, .levels { grid-template-columns: 1fr; }
  .kpi + .kpi { border-inline-start: none; border-top: 1px solid var(--border-soft); }
  .pillar { padding: 32px 0; }
  .pillar + .pillar { border-inline-start: none; border-top: 1px solid var(--border-soft); }
  .rank__row { grid-template-columns: 1fr 80px; }
  .rank__row .bar-track { display: none; }
  .feature-list li { grid-template-columns: 1fr; gap: 6px; }
  .console__body, .frame__body { padding: 20px; }
  .footer-grid { grid-template-columns: 1fr; }
}
