@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #14213d;
  --ink-2: #3d4a66;
  --muted: #6b7690;
  --bg: #f1f4f8;
  --panel: #ffffff;
  --line: #d9e1eb;
  --line-2: #ebf0f5;
  --signal: #f2a900;
  --signal-ink: #8a5d00;
  --signal-tint: #fff6dc;
  --ok: #157a56;
  --ok-bg: #e5f3ec;
  --bad: #bf3a33;
  --bad-bg: #fbecea;
  --on-ink: #ffffff;
  --on-ink-muted: #a9b8d0;
  --r-lg: 18px;
  --r-md: 10px;
  --r-sm: 6px;
  --font: "Vazirmatn", Tahoma, system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.8 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.35; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.125rem; font-weight: 750; }
h3 { font-size: 0.95rem; font-weight: 700; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--ink); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: var(--r-sm); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 20px;
  border: 1px solid transparent; border-radius: var(--r-md);
  font-weight: 700; font-size: 0.95rem; text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-ink { background: var(--ink); color: var(--on-ink); }
.btn-ink:hover:not(:disabled) { background: #22325a; }
.btn-signal { background: var(--signal); color: var(--ink); }
.btn-signal:hover:not(:disabled) { background: #ffb81a; }
.btn-line { background: var(--panel); border-color: var(--line); color: var(--ink); }
.btn-line:hover:not(:disabled) { border-color: var(--ink-2); }
.btn-quiet { background: none; color: var(--ink-2); padding-inline: 10px; }
.btn-quiet:hover:not(:disabled) { color: var(--ink); background: var(--line-2); }
.btn-lg { min-height: 52px; padding-inline: 28px; font-size: 1.05rem; }
.btn svg { width: 18px; height: 18px; flex: none; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 0.875rem; font-weight: 600; color: var(--ink-2); }
.input, .textarea, .select {
  width: 100%; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(242, 169, 0, .35); }
.textarea { resize: vertical; line-height: 1.9; }
.select { padding-block: 8px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-shell {
  width: min(960px, 100%);
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; overflow: hidden;
}
.login-scope-side {
  background: var(--ink); color: var(--on-ink);
  display: grid; place-items: center; align-content: center; gap: 28px; padding: 48px 32px;
}
.login-scope-side p { color: var(--on-ink-muted); text-align: center; max-width: 30ch; font-size: 0.95rem; }
.login-form-side { padding: 56px 48px; display: grid; align-content: center; gap: 28px; }
.wordmark { font-weight: 850; letter-spacing: .06em; direction: ltr; unicode-bidi: isolate; line-height: 1; }
.wordmark i { font-style: normal; color: var(--signal); }
.login-form-side .wordmark { font-size: 2.6rem; }
.expansion { direction: ltr; text-align: right; color: var(--muted); font-size: 0.875rem; margin-top: 10px; }
.tagline { font-size: 1.05rem; color: var(--ink-2); margin-top: 6px; }
.login-form { display: grid; gap: 16px; }
.form-error { color: var(--bad); font-size: 0.9rem; min-height: 1.6em; }

/* radar scope: the brand's one recurring motif */
.scope {
  --size: 280px; --period: 4s;
  position: relative; width: var(--size); aspect-ratio: 1; border-radius: 50%;
  background:
    linear-gradient(transparent calc(50% - .5px), rgba(242, 169, 0, .22) 0 calc(50% + .5px), transparent 0),
    linear-gradient(90deg, transparent calc(50% - .5px), rgba(242, 169, 0, .22) 0 calc(50% + .5px), transparent 0),
    repeating-radial-gradient(circle, transparent 0 calc(var(--size) / 8 - 1px), rgba(242, 169, 0, .25) 0 calc(var(--size) / 8));
  box-shadow: inset 0 0 0 1px rgba(242, 169, 0, .4);
  overflow: hidden;
}
.scope::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 290deg, rgba(242, 169, 0, .5) 360deg);
  animation: sweep var(--period) linear infinite;
}
.blip {
  position: absolute; width: 8px; height: 8px; margin: -4px; border-radius: 50%;
  background: var(--signal); box-shadow: 0 0 10px var(--signal);
  opacity: .15; animation: blip var(--period) linear infinite;
}
@keyframes sweep { to { transform: rotate(1turn); } }
@keyframes blip { 0% { opacity: 1; transform: scale(1.3); } 55% { opacity: .15; transform: scale(1); } 100% { opacity: .15; } }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  height: 64px; padding-inline: 24px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand .wordmark { font-size: 1.25rem; }
.brand .scope { --size: 26px; --period: 3s; background: none; box-shadow: inset 0 0 0 1.5px var(--ink); }
.brand .scope::before { background: conic-gradient(from 0deg, transparent 0 250deg, rgba(242, 169, 0, .9) 360deg); animation: none; transform: rotate(50deg); }
.tabs { display: flex; gap: 4px; height: 100%; margin-inline-start: 12px; }
.tab {
  position: relative; background: none; border: 0; padding: 0 14px; cursor: pointer;
  color: var(--muted); font-weight: 600;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 750; }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; inset-inline: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--signal);
}
.account { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }
.user-name { font-weight: 700; }

main { width: min(1280px, 100%); margin: 0 auto; padding: 28px 24px 64px; }
.panel { display: grid; gap: 20px; }
.lead { color: var(--ink-2); max-width: 70ch; }
.surface { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); }

/* ---------- presets ---------- */
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.preset {
  display: flex; align-items: center; gap: 14px; text-align: start;
  padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: border-color .15s;
}
.preset:hover { border-color: var(--ink-2); }
.preset[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.preset svg { width: 30px; height: 30px; flex: none; color: var(--ink-2); }
.preset[aria-pressed="true"] svg { color: var(--signal-ink); }
.preset b { display: block; font-weight: 750; line-height: 1.5; }
.preset small { color: var(--muted); font-size: 0.8rem; }
.preset-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.preset-head p { color: var(--ink-2); margin-top: 4px; }

/* ---------- class chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  --c: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 1px 10px 1px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 11%, white);
  color: color-mix(in srgb, var(--c) 78%, black);
  font-size: 0.82rem; font-weight: 650; line-height: 1.9; white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.chip-lg { font-size: 1.05rem; padding: 4px 14px 4px 16px; }

/* ---------- run view ---------- */
.run { display: grid; gap: 16px; }
.strip {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px 40px;
  padding: 22px 28px 26px; border-radius: var(--r-lg);
  background:
    repeating-radial-gradient(circle at 4% 130%, transparent 0 34px, rgba(242, 169, 0, .08) 34px 35px),
    var(--ink);
  color: var(--on-ink);
}
.clock { display: flex; align-items: baseline; gap: 10px; }
.clock .scope { --size: 30px; --period: 1.2s; align-self: center; background: none; box-shadow: inset 0 0 0 1.5px rgba(242, 169, 0, .6); }
.clock .scope::before { animation-play-state: paused; opacity: 0; }
.is-running .clock .scope::before { animation-play-state: running; opacity: 1; }
.clock-num { font-size: 3.4rem; font-weight: 800; color: var(--signal); line-height: 1; font-variant-numeric: tabular-nums; min-width: 4ch; }
.clock-unit { color: var(--on-ink-muted); font-weight: 600; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 12px 20px; margin: 0; }
.metrics div { border-inline-start: 1px solid rgba(255, 255, 255, .14); padding-inline-start: 14px; }
.metrics dt { color: var(--on-ink-muted); font-size: 0.8rem; }
.metrics dd { margin: 0; font-size: 1.35rem; font-weight: 750; line-height: 1.5; font-variant-numeric: tabular-nums; }
.metrics dd small { display: block; font-size: 0.78rem; font-weight: 600; color: var(--on-ink-muted); line-height: 1.4; }
.metrics dd small.gain { color: var(--signal); }
.progress { position: absolute; inset-inline: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .08); }
.progress span { display: block; height: 100%; width: 0; background: var(--signal); transition: width .25s ease-out; }
.run:not(.has-truth) [data-truth], .run.has-truth [data-notruth] { display: none; }

.run-note { padding: 12px 16px; border-radius: var(--r-md); background: var(--signal-tint); color: var(--signal-ink); font-weight: 600; }
.run-note.is-error { background: var(--bad-bg); color: var(--bad); }

.run-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.table-wrap { max-height: 640px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th {
  position: sticky; top: 0; z-index: 1; background: #f7f9fc; text-align: start;
  font-size: 0.8rem; font-weight: 650; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px 14px; border-top: 1px solid var(--line-2); vertical-align: top; }
tbody tr:first-child td { border-top: 0; }
td.idx { color: var(--muted); width: 3.5em; font-variant-numeric: tabular-nums; }
td.msg { line-height: 1.8; min-width: 16em; }
td.mark { width: 2.5em; text-align: center; font-weight: 800; }
td.conf { width: 7.5em; }
tr.is-wrong td { background: var(--bad-bg); }
tr.is-wrong td.mark { color: var(--bad); }
tr.is-right td.mark { color: var(--ok); }
tr.landed td { animation: land 1.1s ease-out; }
@keyframes land { from { background-color: var(--signal-tint); } }
.pending { display: inline-block; width: 7em; height: 0.9em; border-radius: 999px; vertical-align: middle; background: var(--line-2); }
.is-running .pending { background: linear-gradient(90deg, var(--line-2) 30%, var(--line) 50%, var(--line-2) 70%) 0 0 / 300% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -300% 0; } }
.review { display: inline-block; margin-inline-start: 6px; font-size: 0.72rem; font-weight: 700; color: var(--signal-ink); background: var(--signal-tint); border-radius: 4px; padding: 0 6px; }

.meter { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.meter i { flex: 1; height: 5px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.meter i::before { content: ""; display: block; height: 100%; width: var(--v, 0%); background: var(--ink-2); border-radius: inherit; }
.meter.is-low i::before { background: var(--signal); }

.dist { padding: 18px 20px; display: grid; gap: 14px; position: sticky; top: 84px; }
.dist ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.dist li { display: grid; gap: 4px; font-size: 0.88rem; }
.dist .row { display: flex; justify-content: space-between; gap: 8px; }
.dist .row b { font-weight: 650; }
.dist .bar { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.dist .bar span { display: block; height: 100%; width: 0; background: var(--c); border-radius: inherit; transition: width .3s ease-out; }
.footnote { color: var(--muted); font-size: 0.8rem; }

/* ---------- message test ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.compose { padding: 24px; display: grid; gap: 16px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; }
.example {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 4px 12px; border: 1px dashed var(--line); border-radius: 999px; background: none;
  font-size: 0.82rem; color: var(--ink-2); cursor: pointer;
}
.example:hover { border-color: var(--ink-2); color: var(--ink); }
.compose-actions { display: flex; align-items: center; gap: 12px; }
.kbd { font-size: 0.78rem; color: var(--muted); }
.result { border-top: 1px solid var(--line); padding-top: 18px; display: grid; gap: 12px; }
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.latency { color: var(--ink-2); font-size: 0.9rem; }
.latency b { font-size: 1.4rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.result .meter { max-width: 320px; }
.alts { display: grid; gap: 8px; }
.alt { display: grid; grid-template-columns: minmax(0, 14em) minmax(0, 1fr); align-items: center; gap: 12px; max-width: 480px; }
.alt .chip { justify-self: start; overflow: hidden; text-overflow: ellipsis; }

/* ---------- class editor ---------- */
.editor-box { padding: 20px; display: grid; gap: 14px; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.badge { font-size: 0.72rem; font-weight: 700; color: var(--signal-ink); background: var(--signal-tint); padding: 1px 8px; border-radius: 999px; vertical-align: middle; margin-inline-start: 6px; }
.editor { display: grid; gap: 12px; }
.editor .select { width: auto; max-width: 100%; font-size: 0.88rem; }
.class-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 520px; overflow: auto; }
.class-row {
  --c: var(--muted);
  display: grid; grid-template-columns: 1fr auto; gap: 6px 8px;
  padding: 10px 12px; border: 1px solid var(--line-2); border-inline-start: 3px solid var(--c); border-radius: var(--r-md);
}
.class-row .input { padding: 6px 10px; font-size: 0.9rem; }
.class-row .name { font-weight: 700; }
.class-row .desc { grid-column: 1 / -1; font-size: 0.85rem; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: none; border-radius: var(--r-sm); color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--bad-bg); color: var(--bad); }
.icon-btn svg { width: 16px; height: 16px; }
.editor-empty { color: var(--muted); font-size: 0.88rem; padding: 12px; border: 1px dashed var(--line); border-radius: var(--r-md); }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 0.85rem; }

/* ---------- file flow ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; align-items: start; }
.step { padding: 20px; display: grid; gap: 14px; }
.step-title { display: flex; align-items: center; gap: 10px; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ink); color: var(--on-ink); font-size: 0.85rem; font-weight: 800;
}
.step-run { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.step-run .step-title { margin-inline-end: auto; }
.drop {
  display: grid; justify-items: center; gap: 6px; text-align: center; cursor: pointer;
  padding: 28px 16px; border: 2px dashed var(--line); border-radius: 14px; background: #fafbfd;
  transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.is-over { border-color: var(--signal); background: var(--signal-tint); }
.drop:focus-within { border-color: var(--ink-2); }
.drop svg { width: 34px; height: 34px; color: var(--ink-2); }
.drop strong { font-weight: 700; }
.drop span { color: var(--muted); font-size: 0.85rem; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.file-info { display: grid; gap: 4px; padding: 12px 14px; border-radius: var(--r-md); background: var(--ok-bg); font-size: 0.88rem; }
.file-info b { font-weight: 700; word-break: break-all; }
.file-info.is-error { background: var(--bad-bg); color: var(--bad); }
.link { font-size: 0.88rem; color: var(--ink-2); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .run-body, .split, .steps { grid-template-columns: minmax(0, 1fr); }
  .dist { position: static; }
  .presets { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 0 12px; padding: 10px 16px 0; }
  .tabs { order: 3; width: 100%; height: 48px; margin: 0; overflow-x: auto; }
  .tab { flex: 1; white-space: nowrap; }
  main { padding: 20px 16px 48px; }
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .preset { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; }
  .preset svg { width: 22px; height: 22px; }
  .preset b { font-size: 0.9rem; }
  .strip { grid-template-columns: minmax(0, 1fr); padding: 18px 18px 22px; }
  .clock-num { font-size: 2.6rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  td.conf, th.conf { display: none; }
  td.msg { min-width: 12em; }
  td, th { padding: 8px 10px; }
  .login-shell { grid-template-columns: minmax(0, 1fr); }
  .login-scope-side { padding: 32px 16px; }
  .login-scope-side .scope { --size: 180px; }
  .login-form-side { padding: 32px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
