:root {
  color-scheme: light;
  --bg: #f3efe6;
  --bg-2: #e7f3f1;
  --surface: #fffdf8;
  --ink: #1c1915;
  --muted: #4a453c;
  --line: #e4d9c8;
  --accent: #0c5552;
  --accent-ink: #f4fffe;
  --accent-soft: #e5f4f2;
  --spark: #c2410c;
  --shadow: 0 10px 28px rgba(55, 40, 16, 0.06);
  --ad: #efe4d4;
  --radius: 18px;
  --wrap: 1080px;
  --focus: #0c5552;
  --theme-color: #f3efe6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141311;
    --bg-2: #1a2c2a;
    --surface: #24211c;
    --ink: #f6f1e8;
    --muted: #e4dccf;
    --line: #4a433a;
    --accent: #9af0ea;
    --accent-ink: #082321;
    --accent-soft: #1b3331;
    --spark: #ffb089;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    --ad: #2c2823;
    --focus: #9af0ea;
    --theme-color: #141311;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3efe6;
  --bg-2: #e7f3f1;
  --surface: #fffdf8;
  --ink: #1c1915;
  --muted: #4a453c;
  --line: #e4d9c8;
  --accent: #0c5552;
  --accent-ink: #f4fffe;
  --accent-soft: #e5f4f2;
  --spark: #c2410c;
  --shadow: 0 10px 28px rgba(55, 40, 16, 0.06);
  --ad: #efe4d4;
  --focus: #0c5552;
  --theme-color: #f3efe6;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141311;
  --bg-2: #1a2c2a;
  --surface: #24211c;
  --ink: #f6f1e8;
  --muted: #e4dccf;
  --line: #4a433a;
  --accent: #9af0ea;
  --accent-ink: #082321;
  --accent-soft: #1b3331;
  --spark: #ffb089;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  --ad: #2c2823;
  --focus: #9af0ea;
  --theme-color: #141311;
}

* { box-sizing: border-box; }
html { overflow-x: clip; }
body {
  margin: 0;
  overflow-x: clip;
  background:
    radial-gradient(1200px 420px at 10% -10%, var(--bg-2), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Avenir Next", system-ui, sans-serif;
  font-size: 1.05rem;
  line-height: 1.55;
}
img, svg { max-width: 100%; }
h1, h2, h3 {
  font-family: Palatino, "Palatino Linotype", "Iowan Old Style", Georgia, serif;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.7rem); margin: 0 0 0.4rem; }
h2 { font-size: 1.45rem; margin: 0 0 0.75rem; }
p { margin: 0 0 0.8rem; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.skip {
  position: absolute;
  inset-inline-start: 0.75rem;
  top: 0.75rem;
  transform: translateY(-150%);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  z-index: 5;
}
.skip:focus { transform: none; }
.wrap { width: min(var(--wrap), calc(100% - 1.5rem)); margin: 0 auto; padding: 1rem 0 2.5rem; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
html.consent-known #consent { display: none; }

.banner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--spark);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin: 0 0 0.9rem;
  box-shadow: var(--shadow);
}
.banner h2 { font-size: 1.05rem; margin: 0 0 0.35rem; font-family: inherit; }
.banner-actions, .precision, .unit-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.hint { color: var(--muted); font-size: 0.92rem; margin: 0.2rem 0 0; }
.checks { display: grid; gap: 0.7rem; margin-top: 0.8rem; }
.checks label { display: grid; grid-template-columns: 1.25rem 1fr; gap: 0.45rem 0.6rem; align-items: start; }
.checks input { margin-top: 0.3rem; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
  text-decoration: none;
  margin-inline-end: auto;
  font-family: Palatino, Georgia, serif;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.logo { width: 2rem; height: 2rem; color: var(--accent); display: block; }
.search { position: relative; flex: 1 1 100%; min-width: 0; max-width: 100%; }
.top { max-width: 100%; }
.lang, .theme { position: relative; }
.theme-btn {
  width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
}
.theme-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-icon { display: none; }
html[data-theme="auto"] .theme-icon-auto,
html[data-theme="light"] .theme-icon-light,
html[data-theme="dark"] .theme-icon-dark { display: block; }
.lang-btn, .btn, .text-link, input, select {
  font: inherit;
}
.lang-btn, .theme-btn, .btn {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.text-link {
  background: none;
  border: 0;
  color: var(--accent);
  padding: 0;
  min-height: 44px;
  cursor: pointer;
  text-decoration: underline;
}
.lang-btn { display: flex; align-items: center; gap: 0.45rem; max-width: 100%; min-width: 0; }
.lang-btn span { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 430px) {
  .lang-btn span { max-width: 6.25rem; }
}
.flag { width: 20px; height: 14px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }
.menu, .search-results {
  position: absolute;
  z-index: 4;
  margin: 0.35rem 0 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-height: min(24rem, 70vh);
  overflow: auto;
}
.menu {
  position: fixed;
  z-index: 30;
  right: auto;
  left: 0.5rem;
  top: 0.5rem;
  width: min(18rem, calc(100vw - 1rem));
  max-width: calc(100vw - 1rem);
  margin: 0;
}
.menu a, .menu button, .search-results a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  text-decoration: none;
  min-height: 44px;
  cursor: pointer;
}
.menu a:hover, .menu a[aria-current="page"], .menu button:hover, .menu button[aria-checked="true"], .search-results a:hover, .search-results a[aria-selected="true"] {
  background: var(--accent-soft);
}
input::placeholder { color: var(--muted); opacity: 1; }
.search input[type="search"] { width: 100%; }
.search-results { left: 0; right: 0; top: 100%; width: auto; max-width: 100%; }
.search-empty { padding: 0.6rem 0.7rem; color: var(--muted); }

input, select {
  width: 100%;
  min-height: 48px;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
label { font-size: 0.92rem; color: var(--muted); }
.field { display: grid; gap: 0.25rem; flex: 1 1 12rem; }

.lead { color: var(--muted); font-size: 1.08rem; max-width: 40rem; }
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.95rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.card:hover { border-color: var(--accent); }
.card strong { font-size: 1.02rem; }
.card span { color: var(--muted); font-size: 0.92rem; }
.icon {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.icon svg { width: 1.45rem; height: 1.45rem; }
.pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pills a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.pills a:hover { border-color: var(--accent); }

.layout { display: grid; gap: 1.25rem; }
.primary, .sidebar { min-width: 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.unit-row { align-items: end; }
.swap { flex: 0 0 auto; align-self: end; }
.result {
  font-family: Palatino, Georgia, serif;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  line-height: 1.25;
  margin: 0.9rem 0;
  overflow-wrap: anywhere;
}
.formula { color: var(--muted); overflow-wrap: anywhere; }
.precision { align-items: center; margin: 0.4rem 0 0.8rem; }
.precision legend { padding: 0 0.3rem; color: var(--muted); }
.precision label { display: flex; gap: 0.35rem; align-items: center; color: var(--ink); }
#digits { width: 5rem; min-height: 44px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem; list-style: none; padding: 0; margin: 0 0 0.8rem; color: var(--muted); }
.crumbs li:not(:last-child)::after { content: "/"; margin-inline-start: 0.5rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 0.55rem 0.35rem; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
caption { text-align: start; font-weight: 650; margin-bottom: 0.4rem; }
.faq { display: grid; gap: 0.8rem; }
.faq article { border-top: 1px solid var(--line); padding-top: 0.7rem; }
.lang-list { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.lang-list a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  padding: 0.4rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
}
.home-categories { margin-bottom: 2rem; }
.home-popular { margin-bottom: 0.5rem; }
.footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); }
.footer nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 1.25rem;
  row-gap: 0.35rem;
  margin: 0 0 0.5rem;
}
.footer nav a,
.footer nav button {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  appearance: none;
  color: var(--accent);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  text-decoration: underline;
  text-underline-offset: 0.12em;
  cursor: pointer;
}
.ad-slot {
  position: static;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: var(--ad);
  color: var(--muted);
  padding: 0.45rem 0.7rem;
  margin: 0 0 1rem;
}
.ad-label { margin: 0; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }
.ad-mid { min-height: 100px; }
.ad-bottom { min-height: 90px; }
.ad-slot[hidden] { display: none !important; }

@media (min-width: 800px) {
  .search { flex: 1 1 16rem; }
  .cards { grid-template-columns: repeat(3, 1fr); gap: 0.9rem; }
  .wrap { width: min(var(--wrap), calc(100% - 3rem)); }
}
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
  .cards { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
