/* ConvertNow — mobile-first, theme-aware */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #12202b;
  --muted: #5c6b76;
  --border: #d8e0e6;
  --accent: #0f766e;
  --accent-hover: #0b5f59;
  --accent-soft: #d7f3ef;
  --accent-text: #0f766e;
  --shadow: 0 1px 2px rgb(16 24 32 / 5%), 0 10px 30px rgb(16 24 32 / 6%);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 64px;
  --focus: 0 0 0 3px rgb(15 118 110 / 35%);
  --danger: #b42318;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0b1118;
  --surface: #151c25;
  --surface-2: #1c2530;
  --text: #e8eef4;
  --muted: #9aa8b4;
  --border: #2a3644;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: #11332f;
  --accent-text: #5eead4;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 28px rgb(0 0 0 / 28%);
  --focus: 0 0 0 3px rgb(45 212 191 / 40%);
  --danger: #fca5a5;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  z-index: 100;
  border-radius: 8px;
}
.skip:focus { top: 12px; color: #fff; }

.wrap {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--header-h);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.03em;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}
html[data-theme="dark"] .brand-mark { color: #082422; }
.brand-now { color: var(--accent-text); }
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 4px;
  margin-left: auto;
  align-items: center;
}
.nav a, .nav summary {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 8px;
  border-radius: 8px;
  list-style: none;
  cursor: pointer;
}
.nav a:hover, .nav summary:hover, .nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-2);
}
.nav details { position: relative; }
.nav details ul {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  list-style: none;
  margin: 0;
  padding: 8px;
  min-width: 200px;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.nav details a { display: block; }

.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
  flex-shrink: 0;
}
.theme-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 9px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
  min-width: 40px;
  min-height: 36px;
}
.theme-toggle button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}
html[data-theme="dark"] .theme-toggle button[aria-pressed="true"] { color: #082422; }

main { flex: 1; padding: 28px 0 64px; }
h1, h2, h3 { letter-spacing: -0.03em; line-height: 1.2; margin: 0 0 0.55em; }
h1 { font-size: clamp(1.6rem, 3.4vw, 2.25rem); }
h2 { font-size: 1.25rem; margin-top: 2rem; }
p { margin: 0 0 1em; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 42rem; }

.hero { padding: 8px 0 8px; }
.search {
  margin: 20px 0 28px;
  position: relative;
}
.search label.sr-only { /* see sr-only */ }
.search-box {
  display: flex;
  gap: 8px;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px;
  box-shadow: var(--shadow);
}
.search-box input[type="search"],
.search-box input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  padding: 12px 12px;
  outline: none;
  box-shadow: none;
}
.search-box button[type="submit"] {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
  min-height: 48px;
  white-space: nowrap;
}
html[data-theme="dark"] .search-box button[type="submit"] { color: #082422; }
.search-box button[type="submit"]:hover { background: var(--accent-hover); }
.search-preview {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: none;
}
.search-preview.is-open { display: block; }
.search-preview .result-line { font-size: 1.15rem; font-weight: 650; }
.search-preview .hint { color: var(--muted); font-size: 0.9rem; margin: 4px 0 0; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.cat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 0 rgb(16 24 32 / 3%);
  min-height: 112px;
}
.cat-card:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  box-shadow: var(--shadow);
}
.cat-card .icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid;
  place-items: center;
}
.cat-card h2 { font-size: 1.05rem; margin: 4px 0 0; }
.cat-card p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.cat-card.coming {
  opacity: 0.78;
  cursor: default;
  border-style: dashed;
}
.cat-card.coming:hover { box-shadow: none; border-color: var(--border); }
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 999px;
  width: fit-content;
}

.crumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 16px;
}
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent-text); }
.crumb li { list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.crumb ol, .crumb ul { display: contents; padding: 0; margin: 0; }
.crumb li + li::before { content: "›"; color: var(--muted); margin-right: 2px; }

.converter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.conv-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: end;
}
.conv-field label, .field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.conv-field select, .conv-field input, select.unit-select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 52px;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}
.conv-field input { font-weight: 650; letter-spacing: -0.02em; }
.conv-swap {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  margin: 0 auto;
  display: grid;
  place-items: center;
}
.conv-swap:hover { background: var(--accent-soft); color: var(--accent-text); }
.conv-swap svg { display: block; }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  font-size: 0.92rem;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: 11px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
html[data-theme="dark"] .btn-primary { color: #082422; }
.live {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  min-height: 1.4em;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  margin-top: 18px;
}
.formula {
  font-family: var(--mono);
  font-size: 0.95rem;
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: 10px;
  overflow-wrap: anywhere;
}
.quick-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.quick-table th, .quick-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.quick-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.quick-table a { color: inherit; text-decoration: none; }
.quick-table a:hover { color: var(--accent-text); }
.related { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.related a { font-weight: 650; }
.privacy-line {
  margin-top: 22px;
  color: var(--muted);
  font-size: 0.92rem;
  padding: 12px 14px;
  background: var(--accent-soft);
  border-radius: 12px;
}
.faq details {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.faq summary { cursor: pointer; font-weight: 650; }
.faq details p { margin: 8px 0 4px; color: var(--muted); }

.recent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recent-list a { text-decoration: none; color: var(--text); display: block; padding: 8px 0; }
.recent-list a:hover { color: var(--accent-text); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 36px;
  color: var(--muted);
  font-size: 0.9rem;
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.footer-inner a { color: var(--muted); text-decoration: none; }
.footer-inner a:hover { color: var(--accent-text); }

.prose { max-width: 42rem; }
.prose h2 { margin-top: 1.6em; }
.note {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 0 10px 10px 0;
}

.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;
}

.unit-count { color: var(--muted); font-size: 0.9rem; }

/* 404 */
.err-hero { text-align: center; padding: 48px 0; }
.err-hero h1 { font-size: 3rem; }

@media (min-width: 720px) {
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .conv-grid {
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
  }
  .conv-swap { margin: 0 0 4px; }
  .nav .nav-more { display: initial; }
}
@media (min-width: 980px) {
  .cat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .wrap { width: min(1120px, calc(100% - 48px)); }
}
@media (max-width: 719px) {
  .nav-desktop { display: none; }
  .header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand theme"
      "nav nav";
    align-items: center;
    gap: 4px 12px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .brand { grid-area: brand; }
  .theme-toggle { grid-area: theme; margin-left: 0; }
  .nav { grid-area: nav; width: 100%; margin-left: 0; }
  .nav details ul { left: 0; right: auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
@media print {
  .site-header, .site-footer, .actions, .theme-toggle, .search, .skip { display: none !important; }
  body { background: #fff; color: #000; }
  .converter, .panel { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}


/* Preview, live rates, cooking weights */
.preview-banner {
  background: #7c2d12;
  color: #fff7ed;
  text-align: center;
  padding: 0.55rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
}
.rate-status {
  margin: 0.85rem 0;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: var(--panel, #f1f5f9);
  border: 1px solid var(--border, #d6dee8);
  font-size: 0.92rem;
}
.rate-status.is-stale {
  border-color: #b45309;
}
html[data-theme="dark"] .rate-status {
  background: rgba(255,255,255,0.04);
}
.ingredient-source,
[data-source] {
  font-size: 0.92rem;
  color: var(--muted, #546171);
  margin: 0.75rem 0 0;
}
.ing-picker {
  margin-bottom: 0.85rem;
}
.ing-picker .unit-select,
.ing-picker .field-label {
  width: 100%;
}
tr.group-row th {
  text-align: left;
  padding-top: 0.85rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #546171);
  background: transparent;
  border-bottom: 0;
}

main p, main li, main td, .lede, .note, .ingredient-source, [data-source], .formula {
  overflow-wrap: anywhere;
  word-break: break-word;
}
