/* Cheat Sheet Conversion: shared styles. Every color derives from --hue, which each page sets for its category. */
:root {
  color-scheme: light;
  --hue: 205;
  --bg: hsl(var(--hue) 40% 95%);
  --surface: hsl(var(--hue) 45% 99%);
  --surface-2: hsl(var(--hue) 38% 92%);
  --ink: hsl(var(--hue) 40% 12%);
  --muted: hsl(var(--hue) 16% 35%);
  --line: hsl(var(--hue) 28% 83%);
  --accent: hsl(var(--hue) 78% 32%);
  --accent-ink: #ffffff;
  --accent-soft: hsl(var(--hue) 70% 89%);
  --font-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: hsl(var(--hue) 30% 8%);
    --surface: hsl(var(--hue) 28% 12%);
    --surface-2: hsl(var(--hue) 26% 17%);
    --ink: hsl(var(--hue) 30% 93%);
    --muted: hsl(var(--hue) 16% 68%);
    --line: hsl(var(--hue) 22% 22%);
    --accent: hsl(var(--hue) 78% 68%);
    --accent-ink: hsl(var(--hue) 60% 8%);
    --accent-soft: hsl(var(--hue) 45% 21%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* header and footer */
.site-header { max-width: 720px; margin: 0 auto; padding-block: 18px 6px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none;
}
.mark { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); display: inline-block; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: 0.9375rem; font-weight: 500; }
.site-header nav a:hover { color: var(--ink); text-decoration: underline; }
.site-footer { max-width: 720px; margin: 0 auto; padding-block: 28px 40px; color: var(--muted); font-size: 0.875rem; display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; border-top: 1px solid var(--line); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-footer a { color: var(--muted); }

.wrap { max-width: 720px; margin: 0 auto; padding-block: 20px 28px; display: flex; flex-direction: column; gap: 22px; }
h1 { font-family: var(--font-display); font-size: 1.875rem; line-height: 1.15; letter-spacing: -0.015em; margin: 0; text-wrap: balance; }
h2 { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.25; margin: 0; text-wrap: balance; }
h3 { font-family: var(--font-display); font-size: 1.0625rem; margin: 0; }
p { margin: 0; }
.lead { color: var(--muted); font-size: 1.0625rem; }

#app, #converter { display: flex; flex-direction: column; gap: 22px; min-width: 0; }

/* category strip */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  font: 500 0.875rem var(--font-body); color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; cursor: pointer;
}
.tab::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: hsl(var(--tab-hue, 205) 72% 52%); }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tab[aria-selected="true"]::before { background: var(--accent-ink); }

/* converter card */
.card { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 11rem); gap: 10px; }
.field label { grid-column: 1 / -1; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.num, .out, select {
  font: 500 1.375rem var(--font-display); color: var(--ink);
  background: var(--surface-2); border: 1px solid transparent; border-radius: 8px;
  padding: 12px 14px; min-width: 0; width: 100%; font-variant-numeric: tabular-nums;
}
.out { overflow-x: auto; white-space: nowrap; min-height: 54px; color: var(--accent); }
select { font: 500 0.9375rem var(--font-body); cursor: pointer; }
.num:focus { border-color: var(--accent); }
.swap-row { display: flex; align-items: center; gap: 12px; }
.swap-row::before, .swap-row::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.swap { display: inline-flex; align-items: center; gap: 6px; font: 500 0.8125rem var(--font-body); color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.result-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.formula { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.copy { font: 500 0.8125rem var(--font-body); color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.copy:hover { border-color: var(--accent); }

/* every-unit list on the home page */
.list-title { margin-top: 4px; }
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: baseline; width: 100%; text-align: left; font: inherit; color: inherit; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 11px 16px; cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row[aria-current="true"] { background: var(--accent-soft); }
.row .name { min-width: 0; }
.row .sym { font-weight: 600; margin-right: 8px; }
.row .full { color: var(--muted); font-size: 0.875rem; }
.row .val { font-variant-numeric: tabular-nums; font-weight: 500; text-align: right; overflow-wrap: anywhere; max-width: 14rem; }
.note { color: var(--muted); font-size: 0.8125rem; }

/* article pages */
.section { display: flex; flex-direction: column; gap: 10px; max-width: 68ch; }
.section ul { margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 6px; }
.formula-box { background: var(--surface-2); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.formula-box .big { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; color: var(--accent); overflow-wrap: anywhere; }
.formula-box .small { color: var(--muted); font-size: 0.9375rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: baseline; }
th { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 600; white-space: nowrap; }
td.note-cell { color: var(--muted); font-size: 0.9375rem; }
.faq { display: flex; flex-direction: column; gap: 16px; max-width: 68ch; }
.faq div { display: flex; flex-direction: column; gap: 4px; }
.links { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.links a { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; text-decoration: none; color: var(--ink); font-weight: 600; }
.links a span { color: var(--muted); font-weight: 400; font-size: 0.875rem; }
.links a:hover { border-color: var(--accent); }
.updated { color: var(--muted); font-size: 0.875rem; }

@media (max-width: 440px) {
  .field { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .tab, .row, .copy, .links a { transition: background-color 0.12s, color 0.12s, border-color 0.12s; }
}
