:root {
  --bg: #f7f6f2;
  --fg: #1d1d1b;
  --muted: #6b6a64;
  --card: #ffffff;
  --border: #dcd9cf;
  --accent: #2f6f5e;
  --accent-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161816;
    --fg: #e8e6df;
    --muted: #9b9a93;
    --card: #1f221f;
    --border: #353a35;
    --accent: #6fb59f;
    --accent-fg: #101410;
  }
}
:root[data-theme="dark"] {
  --bg: #161816;
  --fg: #e8e6df;
  --muted: #9b9a93;
  --card: #1f221f;
  --border: #353a35;
  --accent: #6fb59f;
  --accent-fg: #101410;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
h1 { font-size: 1.75rem; margin: 1.2rem 0 0.4rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 0.6rem; }
.lead { color: var(--muted); margin: 0 0 1.2rem; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

.site-header { border-bottom: 1px solid var(--border); padding: 12px 0; }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--fg); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.92rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a:focus-visible { color: var(--accent); text-decoration: underline; }

.cats { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cats a {
  display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); text-decoration: none; color: var(--fg);
}
.cats a:hover, .cats a:focus-visible { border-color: var(--accent); }

.converter {
  margin: 1rem 0 2rem; padding: 16px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--card);
}
.conv-row { display: grid; grid-template-columns: 1fr; gap: 10px; }
.conv-row label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.conv-row input, .conv-row select {
  font: inherit; font-size: 16px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; width: 100%;
}
.conv-row input:focus-visible, .conv-row select:focus-visible, .swap:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.swap {
  font: inherit; font-size: 0.95rem; padding: 9px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
}
.swap:hover { background: var(--accent); color: var(--accent-fg); }
.result { font-size: 1.1rem; margin: 16px 0; min-height: 2.2em; }
.result strong { font-size: 1.9rem; font-weight: 700; color: var(--accent); word-break: break-all; }

.units-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 0.95rem; }
.units-table caption { text-align: left; color: var(--muted); padding-bottom: 6px; }
.units-table th, .units-table td {
  text-align: left; padding: 7px 6px; border-top: 1px solid var(--border); overflow-wrap: anywhere;
}
.units-table thead th { border-top: none; color: var(--muted); font-weight: 600; }
.units-table td:last-child { font-variant-numeric: tabular-nums; }

@media (min-width: 560px) {
  .conv-row { grid-template-columns: 2fr 1.4fr auto 1.4fr; align-items: end; }
  .conv-row .swap { height: 42px; }
}

.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding: 14px 0; color: var(--muted); font-size: 0.9rem; }
.site-footer .notice { margin: 0.4rem 0 0; font-size: 0.8rem; }
