/* ═══════════════════════════════════════════════════════════════
   TRACE: Obsidian
   The navigation is the product's route (Build, Check, Export),
   drawn as a trace line. Graphite layers, fine lines, one accent.
   ═══════════════════════════════════════════════════════════════ */

@font-face { font-family: 'Geist'; src: url('fonts/geist.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('fonts/geist-mono.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('fonts/vazirmatn.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

/* ── TOKENS ── */
:root {
  --bg: #090B0D; --card: #0F1215; --card2: #171B20; --card3: #0B0E11;
  --border: rgba(255,255,255,.08); --border2: rgba(255,255,255,.15); --sheen: rgba(255,255,255,.05);
  --text: #ECEFF2; --muted: #A8B0BA; --muted2: #8C96A1;
  --accent: #5EEAD4; --accent-lo: rgba(94,234,212,.12); --on-accent: #04201C;
  --green: #7EE2A8; --amber: #F2C14E; --amber-lo: rgba(242,193,78,.09); --red: #F2836B; --red-lo: rgba(242,131,107,.1);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 18px 44px -18px rgba(0,0,0,.75);
  --scrim: rgba(5,7,9,.6);
  --sans: 'Geist', 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --ease: cubic-bezier(.23,1,.32,1);
  --glide: cubic-bezier(.32,.72,0,1);
  --lit: rgba(255,255,255,.022); --glow: rgba(94,234,212,.055); --edge: rgba(94,234,212,.34);
  --r-s: 8px; --r-m: 10px; --r-l: 16px;
  color-scheme: dark;
}
body.light {
  --bg: #EDF0F2; --card: #FFFFFF; --card2: #F4F6F7; --card3: #F1F4F5;
  --border: rgba(14,26,34,.1); --border2: rgba(14,26,34,.2); --sheen: rgba(255,255,255,.7);
  --text: #10181F; --muted: #46525D; --muted2: #586570;
  --accent: #0A7468; --accent-lo: rgba(10,116,104,.09); --on-accent: #FFFFFF;
  --green: #0E6B3B; --amber: #845600; --amber-lo: rgba(132,86,0,.08); --red: #AD3019; --red-lo: rgba(173,48,25,.07);
  --shadow: 0 1px 2px rgba(14,26,34,.06), 0 18px 40px -22px rgba(14,26,34,.28);
  --scrim: rgba(14,26,34,.35);
  --lit: rgba(255,255,255,0); --glow: rgba(10,116,104,.07); --edge: rgba(10,116,104,.34);
  color-scheme: light;
}

/* ── BASE ── */
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--sans); }
html[lang="fa"] body { font-family: 'Vazirmatn', 'Geist', system-ui, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 30px); line-height: 1.15; font-weight: 500; letter-spacing: -.024em; text-wrap: balance; }
html[lang="fa"] h1 { letter-spacing: 0; }
h2 { font-size: 16px; font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.wrap { max-width: 1180px; margin-inline: auto; padding-block: 0 72px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: rise 220ms var(--ease); }
@keyframes rise { from { opacity: .4; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ── HEADER AND ROUTE ── */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top, 0px); }
.top-in { max-width: 1180px; margin-inline: auto; min-height: 68px; display: flex; align-items: center; gap: 20px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 600; letter-spacing: -.02em; }
.brand svg { color: var(--accent); }
.route { flex: 1; display: flex; justify-content: center; align-items: center; min-width: 0; }
.step { display: flex; flex-direction: column; justify-content: center; min-height: 48px; padding-inline: 14px; border-radius: var(--r-s); text-align: start; white-space: nowrap; transition: background-color 160ms var(--ease); }
.step b { font-size: 13px; font-weight: 500; color: var(--muted); transition: color 160ms var(--ease); }
.step span { font-family: var(--mono); font-size: 12px; color: var(--muted2); font-variant-numeric: tabular-nums; }
.step.active { background: var(--card2); box-shadow: inset 0 0 0 1px var(--border), inset 0 1px 0 var(--sheen); }
.step.active b { color: var(--text); }
.step.active span { color: var(--accent); }
.link { width: clamp(14px, 4vw, 44px); height: 1px; flex: none; position: relative; overflow: hidden; background: var(--border2); }
.link::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 260ms var(--ease); }
[dir="rtl"] .link::after { transform-origin: right; }
.link.on::after { transform: scaleX(1); }
.gap { width: clamp(6px, 2vw, 18px); flex: none; }
.tools { display: flex; align-items: center; gap: 2px; }
.icon { display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding-inline: 8px; flex: none; border-radius: var(--r-s); color: var(--muted); font-size: 13px; font-weight: 500; transition: background-color 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease); }
.icon:active { transform: scale(.96); }
.icon.danger-ico { color: var(--muted); }
kbd { font: 500 12px var(--mono); color: var(--muted2); border: 1px solid var(--border2); border-radius: 5px; padding: 1px 5px; }

/* ── SHARED PARTS ── */
.head { padding-block: 34px 22px; }
.head p { margin-top: 6px; color: var(--muted); font-size: 15px; max-width: 60ch; text-wrap: pretty; }
.shell { padding: 5px; border-radius: var(--r-l); background: var(--card3); box-shadow: inset 0 0 0 1px var(--border); }
.core { border-radius: var(--r-l); background: var(--card); box-shadow: inset 0 1px 0 var(--sheen), 0 0 0 1px var(--border); }
.shell > .core { border-radius: calc(var(--r-l) - 5px); }
.clip { overflow: hidden; }
.minw { min-width: 0; }
.pad { padding: 20px; }
.form { display: grid; gap: 18px; min-width: 0; }
.form.inner { padding-block: 10px 6px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding-inline: 15px; border-radius: var(--r-s); border: 1px solid var(--border2); background: transparent; font-weight: 500; white-space: nowrap; transition: background-color 160ms var(--ease), border-color 160ms var(--ease), transform 120ms var(--ease), filter 160ms var(--ease); }
.btn:active { transform: scale(.97); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }
.btn.wide { width: 100%; }
.btn.file { cursor: pointer; margin: 0; color: var(--text); font-size: 14px; }
.btn.file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.btn.sm { min-height: 36px; padding-inline: 11px; font-size: 13px; }
.mini-btn { min-height: 32px; padding-inline: 9px; border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 500; transition: background-color 160ms var(--ease), color 160ms var(--ease); }
.mini-btn.quiet { color: var(--muted2); justify-self: center; }
label, .lbl { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.inp { display: block; width: 100%; min-height: 44px; padding: 11px 12px; border-radius: var(--r-s); border: 1px solid var(--border); background: var(--card3); color: var(--text); font: 400 13px/1.55 var(--mono); outline: 0; resize: vertical; transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease); }
input.inp:not(.ltr), select.inp:not(.ltr) { font-family: inherit; font-size: 14px; }
select.inp { appearance: auto; padding-block: 9px; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-lo); }
.inp.invalid { border-color: var(--red); }
.inp::placeholder { color: var(--muted2); }
.field-err { margin-top: 6px; font-size: 13px; color: var(--red); }
.err-msg { display: none; }
.err-msg.show { display: block; }
.hint { margin-top: 5px; font-size: 12px; color: var(--muted2); }
.inline { display: flex; gap: 2px; align-items: center; }
.inline .inp { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.brow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.brow.end { justify-content: flex-end; margin-top: 12px; }
.row-actions, .presets { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; margin-inline-start: -6px; }
.presets button { min-height: 32px; padding-inline: 7px; border-radius: 6px; font: 400 12px var(--mono); color: var(--muted); transition: background-color 160ms var(--ease), color 160ms var(--ease); }
.seg { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--r-m); background: var(--card3); box-shadow: inset 0 0 0 1px var(--border); }
.seg button { flex: 1; min-height: 38px; padding-inline: 10px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; transition: background-color 160ms var(--ease), color 160ms var(--ease); }
.seg button.active { background: var(--card); color: var(--text); box-shadow: 0 0 0 1px var(--border2), inset 0 1px 0 var(--sheen); }
.subtabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.sub { min-height: 44px; padding-inline: 13px; margin-bottom: -1px; color: var(--muted); font-size: 14px; font-weight: 500; border-bottom: 2px solid transparent; transition: color 160ms var(--ease), border-color 160ms var(--ease); }
.sub.active { color: var(--text); border-bottom-color: var(--accent); }
.subpanel { display: none; }
.subpanel.active { display: block; }
.subpanel > * + * { margin-top: 12px; }
.bulk-panel { display: none; }
.bulk-panel.active { display: block; }
.bulk-panel .brow { margin-top: 10px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin: 0; color: var(--text); cursor: pointer; font-size: 14px; }
.switch.tight { padding-top: 22px; }
.switch b { font-weight: 500; display: block; }
.switch small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.switch input { appearance: none; flex: none; position: relative; width: 38px; height: 22px; margin: 0; border-radius: 11px; background: var(--border2); cursor: pointer; transition: background-color 160ms var(--ease); }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform 180ms var(--ease); }
.switch input:checked { background: var(--accent); }
.switch input.warn-switch:checked { background: var(--amber); }
.switch input:checked::after { transform: translateX(16px); background: var(--card); }
[dir="rtl"] .switch input:checked::after { transform: translateX(-16px); }
.warn-note { padding: 10px 12px; border-radius: var(--r-s); background: var(--amber-lo); color: var(--amber); font-size: 13px; text-wrap: pretty; }
.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.ctl { width: 120px; }

/* ── BUILD ── */
.build { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; min-width: 0; }
.detect { margin-top: 10px; font-size: 13px; color: var(--muted); }
.detect.ok { color: var(--accent); }
.detect.bad { color: var(--red); }
.parts { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 5px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); direction: ltr; }
.tok { display: grid; gap: 5px; text-align: left; min-width: 0; max-width: 100%; }
.tok i { font: 500 15px var(--mono); padding-bottom: 5px; border-bottom: 1px solid var(--border2); overflow-wrap: anywhere; transition: border-color 160ms var(--ease); }
.tok small { font: 500 12px var(--sans); color: var(--muted2); }
.sep { font: 400 15px var(--mono); color: var(--muted2); padding-top: 1px; }
details.more summary { list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 44px; font-weight: 500; color: var(--muted); cursor: pointer; border-radius: var(--r-s); }
details.more summary::-webkit-details-marker { display: none; }
details.more svg { transition: transform 180ms var(--ease); }
details.more[open] svg { transform: rotate(180deg); }
.out { position: sticky; top: 88px; }
.out-in { display: grid; gap: 14px; }
.count { font: 500 52px/1 var(--mono); letter-spacing: -.05em; font-variant-numeric: tabular-nums; margin-block: 6px; text-align: start; }
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 8px; }
.out-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { font: 500 12px var(--mono); color: var(--muted); }
.out-list { max-height: 280px; overflow: auto; border-block: 1px solid var(--border); }
.out-list.empty { padding-block: 22px; text-align: center; color: var(--muted2); font-size: 13px; }
.out-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 5px 2px; cursor: pointer; transition: background-color 140ms var(--ease); }
.out-row + .out-row { border-top: 1px solid var(--border); }
.out-row.copied { background: var(--accent-lo); }
.out-row-info { display: flex; align-items: center; justify-content: space-between; flex: 1; gap: 10px; min-width: 0; }
.out-row-remark { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.out-row-host { font: 400 12px var(--mono); color: var(--muted); direction: ltr; white-space: nowrap; }
.out-row-copy { display: none; }
.out-more { padding-block: 10px; text-align: center; color: var(--muted); font-size: 12px; }
.out-more span { color: var(--accent); cursor: pointer; }
.btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.qrw { display: none; }
.qrw.open { display: grid; justify-items: center; gap: 8px; }
.qrw canvas { border-radius: var(--r-s); max-width: 100%; }
.qr-nav { align-items: center; gap: 10px; }
.stats-line { display: flex; gap: 16px; justify-content: center; }
.stats-line b { font-family: var(--mono); font-weight: 500; color: var(--text); }

/* ── CHECK ── */
.map { padding: 18px 20px 14px; }
.tally { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-bottom: 16px; }
.tally span { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.tally b { font: 500 15px var(--mono); color: var(--text); }
.tally-line { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; }
.tally-line b { font: 500 16px var(--mono); }
.scale { position: relative; height: 50px; direction: ltr; border-bottom: 1px solid var(--border2); }
.scale i { position: absolute; bottom: 0; width: 2px; margin-left: -1px; border-radius: 1px 1px 0 0; transform-origin: bottom; }
.scale.final i { animation: tick 240ms var(--ease) backwards; }
@keyframes tick { from { opacity: 0; transform: scaleY(0); } }
.scale i.ok { height: 40px; background: var(--green); }
.scale i.warn { height: 26px; box-shadow: inset 0 0 0 1px var(--amber); }
.scale i.bad { height: 14px; background: var(--red); }
.scale .void { position: absolute; inset-block: 0; right: 0; width: 14%; background: repeating-linear-gradient(135deg, transparent 0 4px, var(--border) 4px 5px); }
.axis { position: relative; height: 24px; direction: ltr; font: 400 12px var(--mono); color: var(--muted2); }
.axis span { position: absolute; top: 7px; transform: translateX(-50%); white-space: nowrap; }
.axis span:first-child { transform: none; }
.axis span:last-child { transform: translateX(-100%); }
.result { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; min-height: 56px; padding: 8px 16px; text-align: start; transition: background-color 140ms var(--ease); }
button.result { cursor: pointer; }
.result + .result, .result-help + .result { border-top: 1px solid var(--border); }
.result b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result small { display: block; font: 400 12px var(--mono); color: var(--muted); direction: ltr; text-align: left; }
[dir="rtl"] .result small { text-align: right; }
.result-help { padding: 0 16px 14px 48px; color: var(--muted); font-size: 13px; max-width: 72ch; text-wrap: pretty; }
[dir="rtl"] .result-help { padding: 0 48px 14px 16px; }
.st { font: 500 13px var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
html[lang="fa"] .st.txt { font-family: inherit; }
.ok { color: var(--green); }
.warn { color: var(--amber); }
.bad { color: var(--red); }
.ping-progress { padding: 12px 16px; color: var(--muted); font-size: 13px; }
.results:empty, #cfgPingResults:empty { display: none; }
.check-row, .diff-row { display: grid; grid-template-columns: 20px minmax(120px, 200px) minmax(0, 1fr); gap: 10px; align-items: start; padding-block: 7px; font-size: 13px; }
.check-row + .check-row, .diff-row + .diff-row { border-top: 1px solid var(--border); }
.diff-row { grid-template-columns: minmax(100px, 160px) minmax(0, 1fr); }
.diff-row.changed { color: var(--red); }
.row-val { font-family: var(--mono); color: var(--muted); overflow-wrap: anywhere; direction: ltr; text-align: start; }
.diff-row.changed .row-val { color: inherit; }
.score { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.score b { font: 500 30px/1 var(--mono); }
.score small { display: block; color: var(--muted); font-size: 13px; }
.notice { font-size: 13px; color: var(--muted); padding-bottom: 8px; }
.notice.good { color: var(--green); }
.notice.bad-note { color: var(--red); }

/* ── EXPORT ── */
.exp { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.fmts { display: grid; gap: 4px; }
.fmt { display: grid; gap: 1px; min-height: 44px; padding: 11px 13px; border-radius: var(--r-m); text-align: start; transition: background-color 160ms var(--ease); }
.fmt b { font-weight: 500; }
.fmt small { font-size: 13px; color: var(--muted); }
.fmt.active { background: var(--card2); box-shadow: inset 0 0 0 1px var(--border2), inset 0 1px 0 var(--sheen); }
.code-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding-block: 9px; padding-inline: 16px 9px; border-bottom: 1px solid var(--border); }
.code { margin: 0; padding: 14px 16px; max-height: 460px; overflow: auto; font: 400 13px/1.7 var(--mono); direction: ltr; text-align: left; counter-reset: l; }
.code.plain { white-space: pre-wrap; overflow-wrap: anywhere; }
.code .ln { display: block; white-space: pre; counter-increment: l; }
.code .ln::before { content: counter(l); display: inline-block; width: 2.6em; color: var(--muted2); user-select: none; }
.code em { font-style: normal; color: var(--accent); }
.code u { text-decoration: none; color: var(--muted); }
.note { padding: 11px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.note.warn-text { color: var(--amber); }
.nodes { display: grid; gap: 6px; max-height: 200px; overflow: auto; }
.node { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; border-radius: var(--r-s); background: var(--card3); font-size: 13px; }
.node span:last-child { font: 400 12px var(--mono); color: var(--muted); direction: ltr; }
#balOutWrap { display: grid; gap: 6px; }

/* ── LIBRARY ── */
.lib-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.lib-tools .inp { flex: 1; min-width: 200px; }
.lib-tools .btn { position: relative; }
.list:not(.core) { max-height: 50vh; overflow: auto; }
.hist-item { display: flex; align-items: center; gap: 8px; min-height: 62px; padding-block: 8px; padding-inline: 16px 8px; }
.hist-item + .hist-item { border-top: 1px solid var(--border); }
.hist-item.pick { cursor: pointer; transition: background-color 140ms var(--ease); border-radius: var(--r-s); }
.item-main { flex: 1; min-width: 0; }
.item-main b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main small { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main small.mono { font-size: 12px; direction: ltr; text-align: start; }
.item-main input { width: 100%; padding: 0; border: 0; background: transparent; font-weight: 500; outline-offset: 3px; }
.tag { flex: none; margin-inline-start: 6px; font: 500 12px var(--mono); color: var(--muted); padding: 1px 6px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--border2); }
.tag.on { color: var(--accent); }
.text-act { min-height: 44px; padding-inline: 9px; border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 500; transition: background-color 160ms var(--ease), color 160ms var(--ease); }
.empty-state { padding: 32px 20px; text-align: center; color: var(--muted); text-wrap: pretty; }
.danger { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-top: 28px; padding-block: 16px; border-top: 1px solid var(--border); }
.danger p { color: var(--muted); font-size: 13px; max-width: 54ch; }
.hold { position: relative; overflow: hidden; color: var(--red); border-color: var(--red); touch-action: none; user-select: none; }
.hold::before { content: attr(data-label); position: absolute; inset: -1px; display: grid; place-items: center; background: var(--red); color: var(--card); clip-path: inset(0 100% 0 0); transition: clip-path 160ms var(--ease); }
[dir="rtl"] .hold::before { clip-path: inset(0 0 0 100%); }
.hold.down::before { clip-path: inset(0 0 0 0); transition: clip-path 1200ms linear; }

/* ── OVERLAYS ── */
.modal { position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; padding: 16px; background: var(--scrim); visibility: hidden; opacity: 0; transition: opacity 130ms var(--ease), visibility 0s linear 130ms; }
.modal.open { visibility: visible; opacity: 1; transition: opacity 180ms var(--ease); }
.modal-box { display: grid; gap: 14px; width: min(460px, 100%); max-height: 80vh; overflow: auto; padding: 20px; border-radius: var(--r-l); background: var(--card); box-shadow: 0 0 0 1px var(--border2), var(--shadow); }
#toast { position: fixed; z-index: 9; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px); min-height: 48px; padding-block: 8px; padding-inline: 16px 8px; border-radius: 12px; background: var(--card2); box-shadow: 0 0 0 1px var(--border2), var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: transform 240ms var(--ease), opacity 180ms var(--ease); }
#toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
#toast.err #toastMsg { color: var(--red); }
#toastMsg { text-wrap: pretty; padding-inline-end: 8px; }
#toastAct { min-height: 36px; padding-inline: 10px; border-radius: 6px; color: var(--accent); font-weight: 500; flex: none; }
dialog#palette { width: min(560px, calc(100vw - 32px)); margin: 12vh auto auto; padding: 0; border: 0; border-radius: 14px; background: var(--card); color: var(--text); box-shadow: 0 0 0 1px var(--border2), var(--shadow); }
dialog#palette::backdrop { background: var(--scrim); }
dialog#palette .inp { min-height: 54px; padding-inline: 16px; border: 0; border-bottom: 1px solid var(--border); border-radius: 14px 14px 0 0; background: transparent; font: 400 15px var(--sans); box-shadow: none; }
.pal { padding: 6px; max-height: 320px; overflow: auto; }
.pal-item { display: flex; width: 100%; align-items: center; min-height: 44px; padding-inline: 10px; border-radius: 7px; text-align: start; }
.pal-item.on { background: var(--accent-lo); }

/* ── HOVER (pointer devices only) ── */
@media (hover: hover) and (pointer: fine) {
  .icon:hover, .mini-btn:hover, .text-act:hover, .presets button:hover { background: var(--card2); color: var(--text); }
  .step:hover { background: var(--card2); }
  .step:hover b { color: var(--text); }
  .btn:hover { background: var(--card2); }
  .btn.pri:hover { background: var(--accent); filter: brightness(1.08); }
  .seg button:hover, .sub:hover { color: var(--text); }
  button.tok:hover i::after { background: var(--accent); }
  button.result:hover, .fmt:hover, .pal-item:hover, .hist-item.pick:hover, .out-row:hover { background: var(--card2); }
}

/* ── RESPONSIVE ── */
@media (max-width: 1000px) {
  .build, .exp { grid-template-columns: minmax(0, 1fr); }
  .out { position: static; }
  .fmts { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
@media (max-width: 760px) {
  .wrap { padding-block-end: 112px; }
  .route { position: fixed; z-index: 6; inset: auto 0 0; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); background: var(--card); border-top: 1px solid var(--border); }
  .step { flex: 1; align-items: center; padding-inline: 2px; min-height: 52px; }
  .link, .gap, .pal-btn { display: none; }
  .top-in { justify-content: space-between; min-height: 58px; }
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .count { font-size: 42px; }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .check-row { grid-template-columns: 20px minmax(0, 1fr); }
  .check-row .row-val { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}

/* ── DEPTH ── */
body::after { content: ""; position: fixed; inset: 0 0 auto; height: 460px; z-index: -1; pointer-events: none; background: radial-gradient(60% 100% at 50% 0, var(--glow), transparent 72%); }
.top { background: color-mix(in srgb, var(--bg) 76%, transparent); -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%); }
.core { background-image: linear-gradient(180deg, var(--lit), transparent 120px); }
.shell { box-shadow: inset 0 0 0 1px var(--border), var(--shadow); }
.shell:not(.out) { position: relative; }
.btn.pri { background-image: linear-gradient(180deg, rgba(255,255,255,.14), transparent); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 8px 22px -12px var(--accent); }
.inp { box-shadow: inset 0 1px 2px rgba(0,0,0,.12); }
.count { background: linear-gradient(180deg, var(--text) 40%, var(--muted)); -webkit-background-clip: text; background-clip: text; color: transparent; }
::selection { background: var(--accent-lo); }
* { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }

/* ── SLIDING SELECTION ── */
.thumb { position: absolute; top: 0; left: 0; z-index: 0; pointer-events: none; }
.thumb.ready { transition: transform 300ms var(--glide), width 300ms var(--glide), opacity 160ms var(--ease); }
@media (min-width: 761px) { .route { position: relative; } }
.seg, .subtabs { position: relative; }
.step, .seg button, .sub { position: relative; z-index: 1; }
.route .thumb { border-radius: var(--r-s); background: var(--card2); box-shadow: inset 0 0 0 1px var(--border), inset 0 1px 0 var(--sheen); }
.step.active { background: none; box-shadow: none; }
.seg .thumb { border-radius: 7px; background: var(--card); box-shadow: 0 0 0 1px var(--border2), inset 0 1px 0 var(--sheen), 0 2px 6px -2px rgba(0,0,0,.35); }
.seg button.active { background: none; box-shadow: none; }
.subtabs .thumb { border-radius: 2px; background: var(--accent); }
.sub.active { border-bottom-color: transparent; }

/* ── TRACE LINE ── */
.link { overflow: visible; }
.link::before { content: ""; position: absolute; z-index: 1; top: -1px; left: 0; width: 12px; height: 3px; border-radius: 2px; background: var(--text); opacity: 0; }
.link.pulse::before { animation: signal 420ms var(--glide); }
[dir="rtl"] .link.pulse::before { animation-name: signal-rtl; }
@keyframes signal { 0% { opacity: 0; transform: translateX(-8px); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateX(clamp(14px, 4vw, 44px)); } }
@keyframes signal-rtl { 0% { opacity: 0; transform: translateX(clamp(14px, 4vw, 44px)); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateX(-8px); } }
.step.busy span { animation: breathe 1100ms ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }

/* ── ENTRANCES ── */
.tab-panel.active { animation: none; }
@keyframes panel-in { from { opacity: 0; transform: translateX(var(--from, 0)); } }
@keyframes lift-in { from { opacity: 0; transform: translateY(8px); } }
.tab-panel.active .head, .tab-panel.active .subtabs { animation: panel-in 240ms var(--ease) backwards; }
.tab-panel.active .stack > *, .tab-panel.active .out, .subpanel.active > *, .tab-panel.active .danger { animation: panel-in 300ms var(--ease) backwards; }
.tab-panel.active .stack > :nth-child(1), .subpanel.active > :nth-child(1) { animation-delay: 40ms; }
.tab-panel.active .stack > :nth-child(2), .subpanel.active > :nth-child(2) { animation-delay: 80ms; }
.tab-panel.active .out, .subpanel.active > :nth-child(3) { animation-delay: 120ms; }
.top { animation: drop-in 420ms var(--ease) backwards; }
@keyframes drop-in { from { opacity: 0; transform: translateY(-10px); } }
.brand .draw { stroke-dasharray: 1; animation: draw 720ms var(--glide) backwards 80ms; }
.brand .node-dot { transform-box: fill-box; transform-origin: center; animation: pop 260ms var(--ease) backwards 620ms; }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.4); } }

/* ── LINK BREAKDOWN ── */
.parts.fresh .tok, .parts.fresh .sep { animation: lift-in 280ms var(--ease) backwards; animation-delay: calc(var(--i, 0) * 28ms); }
.tok i { position: relative; border-bottom-color: transparent; }
.tok i::after { content: ""; position: absolute; inset: auto 0 -1px; height: 1px; background: var(--border2); transform-origin: left; transition: background-color 160ms var(--ease); }
.parts.fresh .tok i::after { animation: rule 380ms var(--glide) backwards; animation-delay: calc(var(--i, 0) * 28ms + 60ms); }
@keyframes rule { from { transform: scaleX(0); } }

/* ── OUTPUT ── */
.out-row.fresh, .result.fresh { animation: lift-in 260ms var(--ease) backwards; }
.out-row-copy { display: block; opacity: 0; color: var(--muted); transform: translateX(-4px); transition: opacity 140ms var(--ease), transform 140ms var(--ease); }
.btn.sheen { position: relative; overflow: hidden; }
.btn.sheen::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.4) 50%, transparent 65%); animation: sheen 620ms var(--glide); }
@keyframes sheen { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.btn.swap { animation: swap 240ms var(--ease); }
@keyframes swap { from { filter: blur(3px); opacity: .55; } }

/* ── LATENCY MAP ── */
.scale.final i { animation: tick 300ms var(--ease) backwards; }
.scale { overflow: hidden; }
.sweep { position: absolute; inset-block: 0; left: 0; width: 22%; background: linear-gradient(90deg, transparent, var(--accent-lo)); border-right: 1px solid var(--accent); animation: sweep 1500ms linear infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(460%); } }

/* ── SMALL REVEALS ── */
.reveal { display: grid; grid-template-rows: 0fr; max-height: 0; visibility: hidden; opacity: 0; transition: grid-template-rows 280ms var(--glide), opacity 180ms var(--ease), visibility 0s linear 280ms, max-height 0s linear 280ms; }
.reveal + details.more { transition: margin-top 280ms var(--glide); }
.reveal:not(.open) + details.more { margin-top: -18px; }
.reveal.open { grid-template-rows: 1fr; max-height: 400px; visibility: visible; opacity: 1; transition-delay: 0s; }
.reveal-in { min-height: 0; overflow: hidden; padding: 4px; margin: -4px; }
details.more[open] .form.inner { animation: lift-in 240ms var(--ease); }
.warn-note { transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
@starting-style { .warn-note { opacity: 0; transform: translateY(-4px); } }
.result-help { animation: lift-in 200ms var(--ease); }

/* ── OVERLAYS ── */
.modal-box { transform: translateY(6px) scale(.97); transition: transform 180ms var(--ease); }
.modal.open .modal-box { transform: none; }
#toast { overflow: hidden; }
#toastBar { position: absolute; inset: auto 0 0; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; }
[dir="rtl"] #toastBar { transform-origin: right; }
#toastBar.run { animation: drain 6000ms linear; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ── THEME ── */
.theme-btn svg { grid-area: 1 / 1; transition: transform 300ms var(--glide), opacity 180ms var(--ease); }
.theme-btn .moon { opacity: 0; transform: rotate(-60deg) scale(.7); }
body.light .theme-btn .moon { opacity: 1; transform: none; }
body.light .theme-btn .sun { opacity: 0; transform: rotate(60deg) scale(.7); }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 1; animation: theme-in 560ms cubic-bezier(.45,.05,.25,1); }
@keyframes theme-in { from { clip-path: circle(0 at var(--vt-x, 100%) var(--vt-y, 0)); } to { clip-path: circle(var(--vt-r, 150vmax) at var(--vt-x, 100%) var(--vt-y, 0)); } }

/* ── POINTER LIGHT ── */
@media (hover: hover) and (pointer: fine) {
  .shell::before { content: ""; position: absolute; inset: 0; z-index: 1; padding: 1px; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 220ms var(--ease); background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 0), var(--edge), transparent 70%); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
  .shell:hover::before { opacity: 1; }
  .out-row:hover .out-row-copy { opacity: 1; transform: none; }
}
@media (hover: none) { .out-row-copy { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .thumb.ready { transition: none; }
  .sweep { display: none; }
  .reveal { transition: none; }
}

/* ── REVIEW PASS ── */
.group { padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: -6px; }
.form > .group:first-child { padding-top: 0; border-top: 0; }
.detect { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 32px; }
.mini-btn.accent { color: var(--accent); }
.text-act.main { color: var(--accent); }
.empty-card { display: grid; justify-items: center; gap: 14px; padding: 44px 20px; text-align: center; color: var(--muted); }
.empty-state { border-radius: var(--r-l); }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; max-width: 1180px; margin-inline: auto; padding-block: 18px 26px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); border-top: 1px solid var(--border); color: var(--muted2); font-size: 13px; }
.foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--border2); }
.wrap { padding-block-end: 44px; }
@media (hover: hover) and (pointer: fine) { .foot a:hover { color: var(--accent); } }
@media (max-width: 760px) {
  /* A blurred or animated header would trap the fixed bottom route inside it */
  .top { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg); animation: none; }
  .wrap { padding-block-end: 28px; }
  .foot { margin-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
}
