:root {
  --bg: #0f1419;
  --panel: #1a2230;
  --panel-2: #222c3c;
  --accent: #4cc9f0;
  --accent-2: #f72585;
  --text: #e6edf3;
  --muted: #8b98a9;
  --border: #2c3848;
  --good: #4ade80;
  --bad: #f87171;
}

/* 🍝 Grandma's Pasta — red-checkered trattoria tablecloth, basil + tomato + parmesan. */
body.theme-pasta {
  --bg: #c8102e;            /* tomato sauce */
  --panel: #fdf6e3;         /* fresh pasta / parmesan cream */
  --panel-2: #f6ecce;
  --accent: #c8102e;        /* tomato */
  --accent-2: #2e7d32;      /* basil */
  --text: #3a241a;          /* roasted garlic */
  --muted: #8a6d57;
  --border: #e3d3a8;
  --good: #2e7d32;
  --bad: #c8102e;
  color: var(--text);
  background-color: #c8102e;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.22) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.22) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.22) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.22) 75%);
  background-size: 64px 64px;
  background-position: 0 0, 32px 32px;
  background-attachment: fixed;
}

/* Header becomes a cream "pasta plate" with a basil dashed rim. */
body.theme-pasta header {
  background: rgba(253, 246, 227, 0.95);
  border: 3px dashed #2e7d32;
  border-radius: 20px;
  max-width: 760px;
  margin: 18px auto 0;
  padding: 16px 24px 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
/* VERY pasta: a noodle banner above and below the title. */
body.theme-pasta header h1::before,
body.theme-pasta header h1::after { content: " 🍝 "; }
body.theme-pasta header::before {
  content: "🍝🍜🍝🍜🍝🍜🍝🍜🍝🍜🍝🍜🍝🍜🍝🍜🍝🍜";
  display: block;
  font-size: 1.2rem;
  letter-spacing: 2px;
  overflow: hidden;
  white-space: nowrap;
  margin-bottom: 8px;
}
/* A simmering pot of pasta emojis pinned along the bottom of the page. */
body.theme-pasta::after {
  content: "🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝";
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 1.3rem;
  letter-spacing: 6px;
  white-space: nowrap;
  overflow: hidden;
  background: rgba(46, 125, 50, 0.92);
  padding: 4px 0;
  pointer-events: none;
}
body.theme-pasta footer { color: #fff5e1; margin-bottom: 40px; }

/* Inputs need a light fill in pasta mode (default --bg is tomato red). */
body.theme-pasta .field input[type="text"],
body.theme-pasta .distance-bar input,
body.theme-pasta .readout {
  background: #fffdf7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #182135 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  padding: 0 16px 48px;
}

header {
  text-align: center;
  padding: 28px 0 8px;
}
header h1 { margin: 0; font-size: 1.9rem; letter-spacing: -0.5px; }
.subtitle { color: var(--muted); margin: 6px 0 0; }

.theme-picker {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-picker label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.theme-picker select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.theme-picker select:focus { box-shadow: 0 0 0 1px var(--accent); }
@media (max-width: 560px) {
  .theme-picker { position: static; justify-content: center; padding-top: 14px; }
}

.tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  max-width: 1100px;
  margin: 22px auto 0;
}
.tab-btn {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab-btn:hover { color: var(--text); border-color: var(--accent); }
.tab-btn.active {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.tab-panel { display: none; max-width: 1100px; margin: 0 auto; }
.tab-panel.active { display: block; }

.distance-bar {
  max-width: 1100px;
  margin: 16px auto 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}
.distance-bar label { font-weight: 600; font-size: 0.9rem; }
.distance-bar input {
  width: 90px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.distance-bar input:focus { border-color: var(--accent); }
.distance-bar input.invalid { border-color: var(--bad); }
.dist-note { color: var(--muted); font-size: 0.8rem; flex: 1 1 200px; }

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 20px;
  margin-top: 22px;
}
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
}
.card h2 { margin: 0 0 16px; font-size: 1.15rem; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.field input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.15s;
}
.field input[type="text"]:focus { border-color: var(--accent); }
.field input.invalid { border-color: var(--bad); }

.swap { text-align: center; color: var(--accent); font-size: 1.3rem; margin: -4px 0 8px; }
.hint { color: var(--muted); font-size: 0.8rem; margin: 8px 0 0; }
.hidden { display: none; }

.radio-row { display: flex; gap: 18px; }
.radio { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 0.92rem; cursor: pointer; }

.readout {
  margin-top: 20px;
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.readout > div { display: flex; justify-content: space-between; align-items: baseline; }
.readout-label { color: var(--muted); font-size: 0.85rem; }
.readout span:last-child { font-size: 1.2rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.chart-card { display: flex; flex-direction: column; }
.chart-wrap { position: relative; flex: 1; min-height: 340px; }
.hover-readout {
  margin-top: 12px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  min-height: 1.4em;
}

.big-result {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 16px;
}
.big-result.muted { font-size: 1rem; font-weight: 400; color: var(--muted); }
.big-result.good { color: var(--good); }
.big-result.bad { color: var(--bad); }

.result-table { width: 100%; border-collapse: collapse; }
.result-table td { padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.result-table td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.result-table tr.highlight td { color: var(--accent); font-size: 1.1rem; }

footer { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 32px; }
