:root {
  color-scheme: light;
  --bg: #f3f2ee;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #76756f;
  --line: #e6e5df;
  --line-strong: #cfcec7;
  --accent: #2a78d6;
  --accent-soft: #e4eefb;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --hl: #fff3c4;
  --flash-up: #dff3df;
  --flash-down: #f8dede;
  --shadow: 0 1px 2px rgba(20, 20, 15, 0.05), 0 8px 24px -16px rgba(20, 20, 15, 0.18);
  --radius: 14px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, ui-serif, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #222220;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #8f8e86;
    --line: #2b2b29;
    --line-strong: #44443f;
    --accent: #3987e5;
    --accent-soft: #1b2a3f;
      --hl: #4a3f12;
    --flash-up: #163a16;
    --flash-down: #472020;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

.wrap { max-width: 980px; margin: 0 auto; padding: 20px 20px 48px; }

a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- header ---------- */

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; letter-spacing: -0.01em; }
.brand-dim { color: var(--text-3); font-weight: 400; }
.mark { width: 28px; height: 28px; }
.mark-bg { fill: var(--text); }
.mark-fg { fill: none; stroke: var(--surface); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tzpick, .lang {
  display: inline-flex; align-items: center; gap: 6px; height: 35px;
  padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-2); font: inherit; font-size: 14px;
}
.tzpick:hover, .lang:hover, .tzpick:focus-within { border-color: var(--line-strong); }
.tzpick svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tzpick select { border: 0; outline: 0; background: transparent; color: inherit; font: inherit; max-width: 200px; cursor: pointer; padding: 0; }
.tzpick select option { color: #0b0b0b; background: #fcfcfb; }
.lang { cursor: pointer; font-weight: 600; color: var(--text); }

.status {
  display: inline-flex; align-items: center; gap: 8px; min-height: 35px;
  padding: 6px 12px 6px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-2); text-decoration: none; font-size: 14px;
}
.status:hover { border-color: var(--line-strong); }
.status-icon { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.status[data-state="live"] .status-icon { background: var(--good); box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.5); animation: pulse 2.4s infinite; }
.status[data-state="delayed"] .status-icon,
.status[data-state="offline"] .status-icon { background: var(--warning); border-radius: 2px; transform: rotate(45deg); }
.status[data-state="down"] .status-icon { background: var(--critical); border-radius: 2px; }
.status[data-state="closed"] .status-icon { background: transparent; border: 2px solid var(--text-3); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.45); } 70% { box-shadow: 0 0 0 7px rgba(12, 163, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); } }

/* ---------- hero ---------- */

.hero { padding: 44px 0 30px; }
.hero-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.hero h1 { margin: 0; font: italic 400 20px/1.3 var(--serif); color: var(--text-2); }
.hero-rate { margin: 0; }
.hero-num { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 14px; color: var(--text); text-decoration: none; border-radius: 10px; }
.hero-num .unit { font-size: clamp(18px, 3.4vw, 28px); color: var(--text-2); font-weight: 500; }
.hero-num .big { font-size: clamp(64px, 15vw, 128px); line-height: 1; font-weight: 680; letter-spacing: -0.035em; border-radius: 12px; padding: 0 4px; margin: 0 -4px; transition: background-color 0.9s ease; }
.hero-num:hover .big { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 0.08em; text-decoration-color: var(--accent); }
.big.up { background: var(--flash-up); transition: none; }
.big.down { background: var(--flash-down); transition: none; }
.hero-sub { margin: 10px 0 0; color: var(--text-2); font-size: 17px; }
.sep { margin: 0 6px; color: var(--text-3); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 18px; flex-wrap: wrap; row-gap: 0;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-size: 14px;
}
.chip > span { white-space: nowrap; }
.chip:hover { border-color: var(--accent); }
.chip .k { color: var(--text-2); }
.chip .arrow { font-size: 11px; }
.arrow.up { color: var(--good); }
.arrow.down { color: var(--critical); }
.hint { margin: 14px 0 0; font-size: 13px; color: var(--text-3); }

.num-link { color: inherit; text-decoration: underline dotted; text-decoration-color: var(--line-strong); text-underline-offset: 0.2em; }
.num-link:hover { text-decoration-style: solid; text-decoration-color: var(--accent); }

/* ---------- cards ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-top: 18px; scroll-margin-top: 12px; }
.card h2 { margin: 0 0 14px; font-size: 18px; letter-spacing: -0.01em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.card-head h2 { margin: 0; }
.sub { margin: 0 0 14px; color: var(--text-2); font-size: 14px; }
.note { margin: 14px 0 0; color: var(--text-3); font-size: 13px; max-width: 70ch; }
.note + .note { margin-top: 6px; }
.note[hidden] { display: none; }
.lbl { display: block; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; padding: 0; }

/* ---------- converter ---------- */

.conv { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 14px; align-items: end; }
.field { display: block; min-width: 0; }
.amt, .result {
  display: flex; align-items: baseline; gap: 10px;
  height: 58px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 26px; font-weight: 600; letter-spacing: -0.01em;
}
.amt { align-items: center; }
.amt:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.amt input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: inherit; font: inherit; font-variant-numeric: tabular-nums; padding: 0; }
.amt.bad { border-color: var(--critical); }
.code { font-size: 14px; font-weight: 600; color: var(--text-2); letter-spacing: 0.03em; }
.result { align-items: center; background: var(--surface-2); border-color: var(--line); color: var(--text); }
.result-link { flex: 1; min-width: 0; color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-link:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.14em; text-decoration-color: var(--accent); }
.curpick { position: relative; display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 7px 8px 7px 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); }
.curpick:hover { border-color: var(--accent); }
.curpick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.curpick .code { color: var(--text); font-size: 15px; }
.curpick svg { width: 14px; height: 14px; fill: none; stroke: var(--text-2); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.curpick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.curpick select option, .sel option { color: #0b0b0b; background: #fcfcfb; }
.swapbtn { width: 44px; height: 44px; margin-bottom: 7px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center; }
.swapbtn:hover { border-color: var(--accent); color: var(--accent); }
.swapbtn.sm { width: 32px; height: 32px; margin: 0; flex: none; }
.swapbtn.sm svg { width: 16px; height: 16px; }
.swapbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.formula { margin: 14px 0 0; font-size: 15px; color: var(--text-2); }
.formula strong { color: var(--text); font-weight: 600; }

/* ---------- history ---------- */

.tabs { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 14px; font-weight: 550; padding: 5px 12px; border-radius: 7px; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.tabs button:disabled { opacity: 0.4; cursor: not-allowed; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; min-width: 0; }
.stat:hover { border-color: var(--accent); }
.stat .s-label { display: block; font-size: 12px; color: var(--text-2); }
.stat .s-value { display: block; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.stat .s-meta { display: block; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chart { position: relative; margin-top: 6px; min-height: 240px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; cursor: crosshair; border-radius: 8px; }
.chart-empty { margin: 0; padding: 90px 0; text-align: center; color: var(--text-3); }
.c-grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.c-axis { fill: var(--text-3); font: 11px var(--sans); font-variant-numeric: tabular-nums; }
.c-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.c-end { fill: var(--text); font: 600 12px var(--sans); font-variant-numeric: tabular-nums; }
.c-end-dot { stroke: var(--surface); stroke-width: 2; }
.c-zero { stroke: var(--text-3); stroke-width: 1; shape-rendering: crispEdges; }
.c-lead { stroke-width: 1; opacity: 0.55; }
.c-cross { stroke: var(--text-3); stroke-width: 1; shape-rendering: crispEdges; }
.c-dot { stroke: var(--surface); stroke-width: 2; }
.tip { position: absolute; top: 8px; left: 0; pointer-events: none; z-index: 2; padding: 8px 10px; border-radius: 8px; background: var(--text); color: var(--surface); font-size: 12px; line-height: 1.35; white-space: nowrap; box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.5); }
.tip strong { display: block; font-size: 16px; font-weight: 650; }
.tip .tip-dim { opacity: 0.7; }
.tip-head { display: block; font-weight: 600; margin-bottom: 4px; }
.tip-row { display: grid; grid-template-columns: 10px 32px minmax(52px, auto) auto; gap: 8px; align-items: center; }
.tip-row strong { display: inline; font-size: 12px; text-align: right; }
.tip-row .tip-dim { text-align: right; }
.tip .sw { box-shadow: 0 0 0 1px var(--surface); }

.table-title { margin: 18px 0 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }

/* ---------- tables ---------- */

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.tablewrap.tall { max-height: 380px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.st { white-space: normal; min-width: 104px; }
#src { font-size: 13.5px; }
#src tfoot td { white-space: normal; }
#src tfoot td.nw { white-space: nowrap; }
td.num { font-weight: 550; }
.legs { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); }
td .arrow { font-size: 10px; }
thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: 0.02em; }
tbody th { font-weight: 550; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tfoot td, tfoot th { border-top: 1px solid var(--line-strong); border-bottom: 0; background: var(--surface-2); font-weight: 600; }
.r { text-align: right; }
td.dim, .dim { color: var(--text-3); }
td a { color: inherit; text-decoration: underline dotted; text-decoration-color: var(--line-strong); text-underline-offset: 0.2em; }
td a:hover { text-decoration-style: solid; text-decoration-color: var(--accent); }
tr.unused td, tr.unused th { color: var(--text-3); }
.src-name { display: block; }
.src-kind { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.badge.ok::before { background: var(--good); }
.badge.warn::before { background: var(--warning); border-radius: 2px; transform: rotate(45deg); }
.badge.bad::before { background: var(--critical); border-radius: 2px; }
.badge.info::before { background: transparent; border: 2px solid var(--text-3); }

.hl, tr.hl > td, tr.hl > th { background-color: var(--hl) !important; }
tr > td, tr > th, .card, .stat, .formula, .note { transition: background-color 0.6s ease; }
.formula.hl, .note.hl { border-radius: 6px; box-shadow: 0 0 0 6px var(--hl); }

/* ---------- about + footer ---------- */

.about ul { margin: 0; padding-left: 20px; color: var(--text-2); max-width: 75ch; }
.about li { margin: 6px 0; }
.about strong { color: var(--text); }
.foot { display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: space-between; margin-top: 22px; color: var(--text-3); font-size: 13px; }

.foot-site { flex-basis: 100%; text-align: center; margin-top: 10px; color: var(--text-2); font-weight: 600; text-decoration: none; }
.foot-site:hover { color: var(--accent); text-decoration: underline; }

/* ---------- header links ---------- */

.navlink { text-decoration: none; }
.navlink svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.saved { font-size: 13px; font-weight: 600; color: var(--good); opacity: 0; transition: opacity 0.3s ease; }
.saved.on { opacity: 1; }
.saved.bad { color: var(--critical); }

/* ---------- currencies in tables and lists ---------- */

.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ls { width: 26px; height: 10px; flex: none; }
.cur-link { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
.cur-link:hover .cur-code { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 0.2em; }
.cur-code { font-weight: 650; letter-spacing: 0.02em; }
.cur-name { color: var(--text-2); font-weight: 400; }
#tbl tr.sel > th, #tbl tr.sel > td { background: var(--accent-soft); }
#tbl tr.sel > th { box-shadow: inset 3px 0 0 var(--accent); }
.warn-note { color: var(--text-2); border-left: 3px solid var(--warning); padding-left: 10px; }

/* ---------- comparison chart legend ---------- */

.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; max-height: 156px; overflow-y: auto; padding: 2px; }
.lg { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-3); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.lg[aria-pressed="true"] { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }
.lg:hover { border-color: var(--accent); }
.lg .sw { opacity: 0.6; }

/* ---------- settings page ---------- */

.hero.slim { padding: 28px 0 6px; }
.hero.slim h1 { font: 650 30px/1.2 var(--sans); letter-spacing: -0.02em; color: var(--text); }
.formgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.sel { width: 100%; height: 42px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; }
.help { display: block; margin-top: 6px; font-size: 13px; color: var(--text-3); }
.btn { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.search { height: 36px; width: min(280px, 100%); padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }

.curlist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cur-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.curlist > li:last-child { border-bottom: 0; }
.cur-row.dragging { opacity: 0.4; }
.cur-row.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.cur-row.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.grip { display: grid; place-items: center; width: 18px; flex: none; color: var(--text-3); cursor: grab; }
.grip svg, .ib svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pos { width: 22px; flex: none; text-align: right; color: var(--text-3); font-size: 13px; }
.moves { display: inline-flex; gap: 2px; flex: none; }
.ib { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; }
.ib:hover:not(:disabled) { border-color: var(--line-strong); color: var(--text); }
.ib:disabled { opacity: 0.25; cursor: default; }
.colorpick { width: 36px; height: 30px; flex: none; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: none; cursor: pointer; }
.sample { display: inline-flex; width: 26px; flex: none; }
.cur-id { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; }
.cur-id .cur-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { flex: none; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--text); }
.onchart { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.onchart input { width: 16px; height: 16px; accent-color: var(--accent); }
.cut { padding: 4px 12px; font-size: 12px; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--line); text-align: center; }
.curgrid { list-style: none; margin: 0; padding: 2px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; max-height: 420px; overflow-y: auto; }
.addcur { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
.addcur:hover { border-color: var(--accent); }
.addcur .cur-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.addcur .plus { color: var(--text-3); font-weight: 700; }

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .wrap { padding: 14px 14px 36px; }
  .hero { padding: 30px 0 22px; }
  .card { padding: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conv { grid-template-columns: minmax(0, 1fr); }
  #swap { margin: 0 auto; transform: rotate(90deg); }
  .hero-num .unit:first-child { flex-basis: 100%; }
  .formgrid { grid-template-columns: minmax(0, 1fr); }
  .cur-name { display: none; }
  .cur-row .cur-name, .addcur .cur-name { display: inline; }
  .cur-row { flex-wrap: wrap; row-gap: 2px; }
  .grip, .pos { display: none; }
  .cur-row .colorpick { order: 1; }
  .cur-row .sample { order: 2; }
  .cur-row .cur-id { order: 3; flex: 0 0 calc(100% - 144px); }
  .cur-row [data-act="remove"] { order: 4; }
  .cur-row .moves { order: 5; }
  .cur-row .onchart { order: 6; flex: 1; }
  .cur-row [data-act="resetcolor"] { order: 7; }
  .top { align-items: flex-start; }
  .amt, .result { font-size: 22px; }
}
