:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563EB;
  --primary-strong: #1E40AF;
  --primary-soft: #eff6ff;
  --accent: #16A34A;
  --accent-strong: #15803d;
  --border: #e2e8f0;
  --ring: rgba(37, 99, 235, 0.25);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111c2e;
  --surface-2: #0f1a2b;
  --text: #e6edf6;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-strong: #60a5fa;
  --primary-soft: #16233b;
  --accent: #22c55e;
  --accent-strong: #4ade80;
  --border: #1e293b;
  --ring: rgba(59, 130, 246, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
}
.theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 17px;
  display: grid; place-items: center;
  transition: border-color .2s, transform .15s;
}
.theme-toggle:hover { border-color: var(--primary); transform: translateY(-1px); }

/* ---------- Hero ---------- */
.hero { padding: 48px 0 8px; text-align: center; }
.hero .eyebrow {
  display: inline-block;
  font-size: 13px; font-weight: 600;
  letter-spacing: .04em;
  color: var(--primary-strong);
  background: var(--primary-soft);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}
h1 {
  font-size: clamp(30px, 6vw, 42px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  font-weight: 800;
}
.hero p.lede {
  font-size: 18px;
  color: var(--muted);
  margin: 0 auto;
  max-width: 540px;
}

/* ---------- Converter card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin: 28px 0;
}
.tabs {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 22px;
  gap: 4px;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .2s, background .2s;
}
.tab[aria-selected="true"] {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"]:hover { color: #fff; }

.panel { display: none; }
.panel.is-active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to {opacity:1; transform:none;} }

.field-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color .18s, box-shadow .18s;
  overflow: hidden;
}
.input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}
.input-wrap input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 600;
  padding: 12px 14px;
  width: 100%;
  min-width: 0;
}
.input-wrap .unit {
  padding: 0 14px 0 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.colon {
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 2px;
}
.hint { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* Results */
.result {
  margin-top: 22px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
}
.result-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.result-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.result-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(34px, 9vw, 46px);
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}
.result-sub {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.sub-item { display: flex; flex-direction: column; gap: 2px; }
.sub-item .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.sub-item .v {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
}

/* Copy button */
.btn-copy {
  appearance: none;
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .2s, transform .12s, border-color .2s;
  white-space: nowrap;
}
.btn-copy:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-copy:active { transform: scale(.97); }
.btn-copy.copied { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-copy svg { width: 15px; height: 15px; }

/* ---------- Content sections ---------- */
.section { padding: 30px 0; }
.section h2 {
  font-size: 26px;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  font-weight: 750;
}
.section h3 {
  font-size: 19px;
  margin: 22px 0 8px;
  font-weight: 700;
}
.section p { color: var(--text); margin: 0 0 12px; }
.section p.muted { color: var(--muted); }
.section ul { padding-left: 22px; margin: 0 0 12px; }
.section li { margin: 4px 0; }

.callout {
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text);
  margin: 14px 0;
}
.callout strong { color: var(--primary-strong); }

/* ---------- Chart table ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.chart-cell {
  appearance: none;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  transition: border-color .18s, transform .12s, box-shadow .18s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chart-cell:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.chart-cell:active { transform: scale(.98); }
.chart-cell .m { font-weight: 600; font-size: 14px; }
.chart-cell .d {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
  font-size: 15px;
}
.chart-cell.copied { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }

/* ---------- FAQ accordion ---------- */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--surface);
  overflow: hidden;
}
.faq-q {
  width: 100%;
  text-align: left;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 650;
  font-size: 16px;
  padding: 16px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.faq-q .chev { transition: transform .2s; color: var(--muted); flex: none; }
.faq-item[open] .faq-q .chev { transform: rotate(180deg); }
.faq-a {
  padding: 0 18px 16px;
  color: var(--muted);
  margin: 0;
}
.faq-a strong { color: var(--text); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 30px;
  padding: 30px 0 40px;
  background: var(--surface-2);
}
.footer-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 22px;
}
.footer-cols h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 0 0 10px;
}
.footer-cols ul { list-style: none; padding: 0; margin: 0; }
.footer-cols li { margin: 6px 0; }
.footer-cols a { color: var(--text); font-size: 15px; }
.footer-bottom {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  padding: 14px 0 0;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb span.sep { margin: 0 7px; }

/* ---------- Responsive ---------- */
@media (max-width: 520px) {
  body { font-size: 16px; }
  .card { padding: 18px; }
  .field-row { flex-direction: column; }
  .colon { display: none; }
  .result-main { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Ad slots (empty state = spacer, filled state = real ad) ---------- */
.ad-slot {
  margin: 2rem auto;
  max-width: 728px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px dashed #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  text-align: center;
}
.ad-slot[data-filled] { border-style: solid; border-color: #e2e8f0; background: transparent; }
.ad-slot .ad-label {
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.55;
}
.site-footer .ad-slot { margin: 1.25rem auto; max-width: 100%; }
@media (max-width: 520px) {
  .ad-slot { margin: 1.5rem auto; border-radius: 0; }
}
