:root {
  --bg: #f8fafc;
  --bg-alt: #eef2f7;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #dbeafe;
  --radius: 16px;
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --bg-alt: #0f172a;
    --surface: #131c2e;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #1e293b;
    --accent: #3b82f6;
    --accent-strong: #60a5fa;
    --accent-soft: #172554;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120;
  --bg-alt: #0f172a;
  --surface: #131c2e;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #1e293b;
  --accent: #3b82f6;
  --accent-strong: #60a5fa;
  --accent-soft: #172554;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
}
.brand svg { width: 28px; height: 28px; fill: var(--accent); }
.nav { display: flex; gap: 20px; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}
.nav a:hover { color: var(--text); }

/* Hero */
.hero {
  padding: 48px 0 32px;
  text-align: center;
  background:
    radial-gradient(ellipse at top, var(--accent-soft), transparent 60%);
}
h1 {
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  line-height: 1.15;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.lead {
  color: var(--muted);
  font-size: 1.1rem;
  margin: 0 0 28px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 32px 20px;
  max-width: 640px;
  margin: 0 auto;
}
.result-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.result-main {
  margin: 8px 0 4px;
  font-size: clamp(2.6rem, 10vw, 4.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--accent);
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 12px;
}
.result-main .unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}
.result-tag {
  display: inline-block;
  margin: 8px 0 4px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
  font-size: 0.95rem;
}
.result-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.result-physical {
  margin: 22px auto 0;
  padding: 18px 16px;
  border-top: 1px solid var(--border);
}
.result-second {
  margin: 6px 0 2px;
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 10px;
}
.result-second .unit {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}
.result-sub {
  margin: 4px 0 0;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
}
.result-explain {
  margin: 12px auto 0;
  max-width: 520px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-alt);
  color: var(--muted);
  font-size: 0.88rem;
  text-align: left;
}
.result-explain strong { color: var(--text); }
.result-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.copy-msg {
  min-height: 1.4em;
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--accent);
}

.ad-slot {
  margin: 28px auto 0;
  max-width: 728px;
  min-height: 90px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

/* Sections */
.section { padding: 56px 0; }
.section-alt { background: var(--bg-alt); }
h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  margin: 0 0 24px;
  letter-spacing: -0.01em;
}
h3 { font-size: 1.15rem; margin: 28px 0 10px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-help {
  font-size: 0.8rem;
  color: var(--muted);
}
.privacy {
  margin: 20px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Prose */
.prose { max-width: 780px; }
.prose p, .prose li { color: var(--text); }
.prose ol { padding-left: 20px; margin: 0; }
.prose li { margin-bottom: 6px; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

.howto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.howto-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.howto-item h3 { margin-top: 0; }

details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 18px;
  margin-bottom: 10px;
}
summary {
  cursor: pointer;
  font-weight: 600;
  padding: 16px 0;
  list-style: none;
  position: relative;
  padding-right: 28px;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--accent);
}
details[open] summary::after { content: "−"; }
details p { margin: 0 0 16px; color: var(--muted); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.footer-inner p { margin: 0; }
.footer-links a { color: var(--muted); }

@media (max-width: 560px) {
  .nav { display: none; }
  .hero { padding-top: 32px; }
  .result-card { padding: 24px 16px; }
}
