/* converter.midgard.com.hr — light / dark via tokens.
   Theme: system by default; [data-theme] on <html> forces light or dark. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #16181d;
  --text-2: #4b5260;
  --muted: #7a8190;
  --accent: #2563eb;
  --accent-hover: #1d4fd7;
  --accent-soft: #e8efff;
  --on-accent: #ffffff;
  --bit-net: #2563eb;
  --bit-sub: #c2410c;
  --bit-host: #0f8a5f;
  --danger: #c4312b;
  --danger-soft: #fdecea;
  --toolbar-bg: rgba(255, 255, 255, 0.82);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f39;
    --border-strong: #3a404c;
    --text: #e8eaef;
    --text-2: #b3b9c5;
    --muted: #858c99;
    --accent: #6c9bff;
    --accent-hover: #8bb0ff;
    --accent-soft: #1c2742;
    --on-accent: #0b1020;
    --bit-net: #7aa5ff;
    --bit-sub: #f0a45b;
    --bit-host: #4fd1a1;
    --danger: #ff7b72;
    --danger-soft: #3a1d1d;
    --toolbar-bg: rgba(15, 17, 21, 0.8);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --surface-2: #1e222a;
  --border: #2a2f39;
  --border-strong: #3a404c;
  --text: #e8eaef;
  --text-2: #b3b9c5;
  --muted: #858c99;
  --accent: #6c9bff;
  --accent-hover: #8bb0ff;
  --accent-soft: #1c2742;
  --on-accent: #0b1020;
  --bit-net: #7aa5ff;
  --bit-sub: #f0a45b;
  --bit-host: #4fd1a1;
  --danger: #ff7b72;
  --danger-soft: #3a1d1d;
  --toolbar-bg: rgba(15, 17, 21, 0.8);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

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

[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

code { font-family: var(--mono); font-size: 0.95em; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.875rem; }

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--toolbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.toolbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  font: 700 12px/1 var(--mono);
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 0.93rem;
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-api { font-family: var(--mono); font-size: 0.85rem; }

.nav-sep {
  width: 1px;
  height: 20px;
  margin: 0 8px;
  background: var(--border-strong);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle svg { display: none; }
.theme-toggle .fill { fill: currentColor; stroke: none; }
.theme-toggle:not([data-mode]) .i-auto,
.theme-toggle[data-mode="system"] .i-auto,
.theme-toggle[data-mode="light"] .i-light,
.theme-toggle[data-mode="dark"] .i-dark { display: block; }

/* ---------- Layout ---------- */
.main {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.page-title {
  margin: 0 0 20px;
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
}

.footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}
.footer a { color: var(--muted); font-family: var(--mono); }
.footer a:hover { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  font: 500 0.93rem/1 var(--sans);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 0.83rem; }
.btn.copied { color: var(--bit-host); border-color: var(--bit-host); }
.btn.copied span, .btn-sm.copied { font-size: 0; }
.btn.copied span::after, .btn-sm.copied::after { content: "Copied"; font-size: 0.93rem; }
.btn-sm.copied::after { font-size: 0.83rem; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-left: 6px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.copied { color: var(--bit-host); opacity: 1; }
.r-row:hover .icon-btn, .kv-v:hover .icon-btn, .icon-btn:focus-visible { opacity: 1; }
@media (hover: none) { .icon-btn { opacity: 1; } }

/* ---------- Landing ---------- */
.hero {
  padding: 40px 0 36px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-ip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 16px;
}

.hero-ip code {
  font-size: clamp(2rem, 7vw, 3.4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.hero-ip code.is-v6 { font-size: clamp(1.3rem, 4.4vw, 2.4rem); }

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 0;
}

.chip {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.83rem;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.chip-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.chip-mono { font-family: var(--mono); font-size: 0.8rem; }

.hero-actions { margin: 28px 0 0; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.tile {
  display: block;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text-2);
  transition: border-color 0.12s, transform 0.12s;
}
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile h2 { margin: 0 0 6px; color: var(--text); font-size: 1rem; font-weight: 600; }
.tile h2::after { content: " →"; color: var(--accent); }
.tile p { margin: 0; font-size: 0.9rem; }

.cli { display: grid; gap: 8px; }
.cli-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  border-radius: 9px;
  background: var(--surface-2);
}
.cli-row code { overflow-wrap: anywhere; }
.cli + p { margin: 12px 0 0; }

/* ---------- Calculator form ---------- */
.calc-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: 1rem var(--mono);
}
.field input::placeholder { color: var(--muted); opacity: 0.7; }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.hint { font-size: 0.8rem; color: var(--muted); }
.hint code { font-size: 0.78rem; }

.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }

.form-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9rem;
}

/* ---------- Results ---------- */
.legend { display: flex; gap: 14px; justify-content: flex-end; margin: -4px 0 8px; font-size: 0.78rem; }
.lg::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 2px; background: currentColor; vertical-align: 0; }

.r-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.r-row:last-child { border-bottom: 0; }

.r-label { color: var(--muted); font-size: 0.88rem; }

.r-value {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.r-value code { font-size: 1rem; font-weight: 500; overflow-wrap: anywhere; }
.r-note { margin-left: 10px; color: var(--muted); font-size: 0.85rem; font-family: var(--mono); overflow-wrap: anywhere; }

.r-bin {
  font: 0.86rem/1.6 var(--mono);
  letter-spacing: 0.02em;
  text-align: right;
}

.r-sep {
  padding: 6px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.b-net { color: var(--bit-net); }
.b-sub { color: var(--bit-sub); }
.b-host { color: var(--bit-host); }
.b-dot { color: var(--muted); }
.b-grp { display: inline-block; }

/* IPv6 binary is 128 bits: give it a full-width line under the value. */
.r-row:has(.b-grp) { grid-template-columns: 110px minmax(0, 1fr); }
.r-row:has(.b-grp) .r-bin { grid-column: 2; text-align: left; font-size: 0.8rem; }

.summary { margin: 0 0 12px; color: var(--text-2); }
.summary code { font-size: 0.9em; }
.card .summary + .r-row { border-top: 1px solid var(--border); }

.kv {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 0 16px;
}
.kv-k, .kv-v { padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv-k { color: var(--muted); font-size: 0.88rem; }
.kv-v { display: flex; align-items: center; flex-wrap: wrap; gap: 0 6px; min-width: 0; }
.kv-v code { overflow-wrap: anywhere; }
.kv-v .icon-btn { margin-left: 0; }
.kv > :nth-last-child(-n + 2) { border-bottom: 0; }

.table-wrap { overflow-x: auto; margin: 0 -20px -20px; border-top: 1px solid var(--border); }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th, .tbl td { padding: 7px 20px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { color: var(--muted); text-align: right; width: 1%; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .r-row { grid-template-columns: 96px minmax(0, 1fr); }
  .r-bin, .r-row:has(.b-grp) .r-bin { grid-column: 1 / -1; text-align: left; font-size: 0.78rem; }
  .calc-form { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .main { padding-top: 20px; }
  .toolbar-inner { gap: 8px; }
  .brand-name { display: none; }
  .nav-link { padding: 6px 8px; }
  .nav-sep { margin: 0 4px; }
  .grid-2 { grid-template-columns: 1fr; }
  .calc-form { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px -16px; }
  .tbl th, .tbl td { padding: 7px 16px; }
  .r-row, .r-row:has(.b-grp) { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .r-row .r-bin { grid-column: 1; }
  .r-label { font-size: 0.8rem; }
  .r-value { flex-wrap: nowrap; }
  .r-value code { min-width: 0; }
  .r-note { flex-shrink: 0; max-width: 45%; }
  .kv { grid-template-columns: 1fr; }
  .kv-k { padding-bottom: 0; border-bottom: 0; font-size: 0.8rem; }
  .kv > :nth-last-child(2) { border-bottom: 0; }
}


/* ================= Unit converter ================= */
.brand-mark svg { width: 18px; height: 18px; stroke-width: 2.2; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.accent { color: var(--accent); }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head .card-title { margin: 0; }
.card-title .muted { font-weight: 500; font-size: 0.85rem; margin-left: 4px; }

select {
  height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8190' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  color: var(--text);
  font: 0.95rem var(--sans);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  min-width: 0;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
optgroup { font-weight: 600; color: var(--text-2); }
option { color: var(--text); }

/* Hero */
.conv-hero { padding: 8px 0 24px; text-align: center; }

.conv-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  max-width: 820px;
  margin: 0 auto 22px;
  text-align: left;
}
.conv-cat select { width: 100%; }

.conv-search { position: relative; }
.field input[type="search"] { font-family: var(--sans); }
.search-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 15;
  max-height: 360px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.08);
}
.search-pop li { display: grid; gap: 1px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.search-pop li[aria-selected="true"], .search-pop li[data-i]:hover { background: var(--surface-2); }
.search-pop li[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--accent); }
.sr-title { font-weight: 600; font-size: 0.92rem; }
.sr-sub { color: var(--muted); font-size: 0.8rem; }
.search-pop .sr-empty { color: var(--muted); font-size: 0.9rem; cursor: default; }

.conv-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  max-width: 820px;
  margin: 0 auto;
  text-align: left;
}
.conv-side { display: grid; gap: 8px; min-width: 0; }
.conv-label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }

.big-input {
  width: 100%;
  height: 72px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font: 600 clamp(1.4rem, 4.4vw, 2rem) var(--mono);
  letter-spacing: 0.01em;
  text-align: center;
  min-width: 0;
}
.big-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.big-input[aria-invalid="true"] { border-color: var(--danger); }
.big-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px var(--danger-soft); }
.unit-select { width: 100%; }

.swap-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-top: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s;
}
.swap-btn:hover { color: var(--accent); border-color: var(--accent); }
.swap-btn:active { transform: rotate(180deg); }
.swap-btn svg { width: 20px; height: 20px; }

.mode-error { max-width: 820px; margin: 12px auto 0; text-align: left; }
.mode-desc {
  max-width: 820px;
  margin: 22px auto 4px;
  font-size: clamp(1.1rem, 3vw, 1.45rem);
  font-weight: 550;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.mode-desc code { font-weight: 600; }
.conv-formula { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* All-units table */
.sig-pick { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.83rem; }
.sig-pick select { height: 30px; padding: 0 28px 0 10px; font-size: 0.85rem; background-position: right 7px center; background-size: 14px; }

.all-tbl tbody tr[data-unit] { cursor: pointer; }
.all-tbl td.u-name { white-space: normal; }
.all-tbl .val-col { text-align: right; width: 40%; }
.all-tbl td.val-col code { font-size: 0.95rem; font-weight: 500; color: var(--text); }
.all-tbl .act-col { width: 1%; padding-left: 0; }
.all-tbl .u-sym code { color: var(--text-2); }
.all-tbl .icon-btn { margin-left: 0; }
.all-tbl tr:hover .icon-btn { opacity: 1; }
.all-tbl .grp-row th {
  position: static;
  padding-top: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.all-tbl tbody tr.grp-row:hover { background: transparent; }
.all-tbl tr.is-from, .all-tbl tr.is-to,
.all-tbl tbody tr.is-from:hover, .all-tbl tbody tr.is-to:hover { background: var(--accent-soft); }
.all-tbl tr.is-to td.val-col code { color: var(--accent); font-weight: 700; }
.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: 1px;
}

/* Conversion table + about */
.conv-cards { align-items: start; }
.conv-cards .card { margin-bottom: 0; }
.conv-cards + .card { margin-top: 16px; }
.chart-tbl tbody tr { cursor: pointer; }
.chart-tbl td { padding: 6px 20px; }
.chart-tbl .num-l { text-align: right; width: 45%; }
.chart-tbl .arrow { width: 1%; padding: 6px 0; color: var(--muted); }

.conv-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.5;
}
.conv-tip { margin: 14px 0 0; line-height: 1.6; }

/* Category browser */
.cat-groups { display: grid; gap: 18px; }
.cat-head {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.cat-btn {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 0.9rem var(--sans);
  text-align: left;
  cursor: pointer;
}
.cat-btn:hover { border-color: var(--border-strong); text-decoration: none; }
.cat-btn.is-active { border-color: var(--accent); background: var(--accent-soft); }
.cat-name { font-weight: 600; }
.cat-btn.is-active .cat-name, .cat-link .cat-name { color: var(--accent); }
.cat-units { color: var(--muted); font: 0.75rem var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ================= Number bases ================= */
.base-hero { padding: 0 0 20px; text-align: center; }
.base-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  text-align: left;
}
.base-inputs .field:last-child { grid-column: 1 / -1; }
.base-inputs label .muted { font-weight: 400; font-size: 0.8rem; margin-left: 4px; }
.field .mid-input {
  height: 56px;
  padding: 0 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font: 600 clamp(1.05rem, 3.2vw, 1.45rem) var(--mono);
  letter-spacing: 0.02em;
}
.field .mid-input:focus { box-shadow: 0 0 0 4px var(--accent-soft); }
.field .mid-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px var(--danger-soft); }

.base-opts { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 16px; margin-top: 20px; }
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 14px; border-radius: 7px; color: var(--text-2); font-size: 0.9rem; font-weight: 500; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg.is-disabled { opacity: 0.5; }
.seg.is-disabled label { cursor: not-allowed; }
.base-meta { margin: 14px 0 0; color: var(--text-2); font-size: 0.9rem; }

.bit-grid { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.bit-byte { display: grid; gap: 3px; }
.bit-cells { display: flex; gap: 2px; }
.bit {
  width: 26px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font: 600 0.9rem var(--mono);
  cursor: pointer;
}
.bit.nib { margin-left: 5px; }
.bit:hover { border-color: var(--accent); }
.bit.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.bit.sign { border-color: var(--bit-sub); }
.bit.sign.on { background: var(--bit-sub); border-color: var(--bit-sub); }
.bit-idx { display: flex; justify-content: space-between; color: var(--muted); font: 0.7rem var(--mono); padding: 0 4px; }

.radix-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.radix-row select { width: 100%; }
.char-glyph { padding: 0 8px; border-radius: 6px; background: var(--surface-2); font-size: 1rem; }

/* Presets */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.presets-list { grid-template-columns: 1fr; }
.preset {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font: 0.85rem var(--sans);
  text-align: left;
  cursor: pointer;
}
.preset code { min-width: 9.5em; font-size: 0.92rem; font-weight: 700; color: var(--text); }
.preset:hover { border-color: var(--border-strong); color: var(--text); }
.preset.is-active { border-color: var(--accent); background: var(--accent-soft); }
.preset.is-active code { color: var(--accent); }

/* Text <-> bytes */
.text-io { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 12px; }
.text-io textarea {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: 0.95rem/1.5 var(--mono);
  resize: vertical;
}
.text-io textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.text-io textarea[aria-invalid="true"] { border-color: var(--danger); }
.text-kv { margin-top: 4px; }
.text-kv code { font-size: 0.88rem; }
#text-error, #float-error { margin-bottom: 12px; }

/* IEEE 754 */
.float-in { margin-bottom: 14px; }
.float-block { padding: 14px 0; border-top: 1px solid var(--border); }
.float-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.float-title { font-weight: 600; font-size: 0.93rem; }
.float-hex { font-size: 1rem; font-weight: 600; color: var(--accent); }
.float-head .icon-btn { margin-left: -6px; }
.float-block:hover .icon-btn { opacity: 1; }
.float-bits { margin-bottom: 8px; padding: 8px 12px; border-radius: 9px; background: var(--surface-2); overflow-wrap: anywhere; }
.float-bits code { font-size: 0.9rem; letter-spacing: 0.04em; line-height: 1.7; }
.float-kv { grid-template-columns: 140px minmax(0, 1fr); }
.float-legend { justify-content: flex-start; margin: 4px 0 0; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .conv-pair { grid-template-columns: 1fr; gap: 10px; }
  .swap-btn { justify-self: center; margin: 0; transform: rotate(90deg); }
  .swap-btn:active { transform: rotate(270deg); }
  .text-io { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .conv-top { grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
  .big-input { height: 60px; }
  .card-head { flex-wrap: wrap; }
  .all-tbl th:nth-child(2), .all-tbl td:nth-child(2) { display: none; }
  .all-tbl .val-col { width: auto; }
  .chart-tbl td { padding: 6px 12px; }
  .base-inputs { grid-template-columns: 1fr; }
  .bit { width: 22px; height: 30px; font-size: 0.82rem; }
  .bit.nib { margin-left: 3px; }
  .radix-row { grid-template-columns: 1fr; }
  .preset code { min-width: 8em; }
  .float-kv { grid-template-columns: 1fr; }
  .seg span { padding: 6px 10px; }
}
