:root {
  --font-head: "Inter Tight", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  /* Accents */
  --orange: #f97316;
  --orange-dark: #ea580c;
  --blue: #3b82f6;
  --blue-deep: #1d4ed8;
  --cyan: #06b6d4;

  /* Dark theme surfaces */
  --bg: #0b0f14;
  --surface-1: #10161f;
  --surface-2: #131b25;
  --border: #1f2937;

  /* Typography */
  --text: #e5e7eb;
  --text-muted: #9aa4b2;
  --heading: #f8fafc;

  /* Radii & shadows */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 16px 28px rgba(0, 0, 0, 0.28);
  --shadow-card: 0 10px 18px rgba(0, 0, 0, 0.22);
  --max-width: 1120px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-feature-settings: "tnum" 1, "lnum" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: var(--font-head);
  letter-spacing: -0.01em;
}

.hero {
  background: var(--surface-2);
  color: var(--heading);
  padding: clamp(2rem, 6vw, 4rem) 1.25rem 2rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.hero__content { max-width: 680px; margin: 0 auto; }

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem 0;
}

.hero p {
  font-size: clamp(1rem, 2.3vw, 1.15rem);
  line-height: 1.6;
  margin: 0;
  color: var(--text-muted);
}

.shell {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 1.5rem 6rem; /* extra bottom for mobile bar */
}

.tabs {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.tab-button {
  flex: 1;
  max-width: 220px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.975rem;
  font-weight: 600;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.tab-button:hover,
.tab-button:focus-visible {
  outline: none;
  transform: translateY(-1px);
  border-color: var(--blue);
}

.tab-button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.tab-panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(1.25rem, 3vw, 2rem);
}

.tab-panel[hidden] { display: none; }

.intro h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--heading);
}

.intro p {
  margin-top: 0.5rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.preset-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 1.25rem 0 1.5rem;
  font-weight: 600;
  color: var(--text-muted);
}

.preset-group span { margin-right: 0.25rem; }

.preset {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.preset:hover,
.preset:focus-visible {
  outline: none;
  transform: translateY(-1px);
  border-color: var(--blue);
}

.preset.reset { border-color: var(--orange); color: var(--orange); }

.layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr);
}

.control-grid { display: grid; gap: 1rem; }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: var(--surface-2);
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.card legend {
  font-size: 1rem;
  font-weight: 700;
  color: var(--heading);
  padding: 0;
}

.card-body {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-body > *:first-child { grid-column: 1 / -1; }
.helper-text { grid-column: 1 / -1; }

.helper-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.45rem;
  color: var(--text);
}

.field input,
.field select {
  width: 100%;
  font-size: 0.975rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text);
  transition: border 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field input::placeholder { color: var(--text-muted); }

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

input[type="range"] {
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--surface-1);
  border: 3px solid var(--orange);
  border-radius: 50%;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--surface-1);
  border: 3px solid var(--orange);
  border-radius: 50%;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

output { display: inline-block; margin-left: 0.75rem; font-weight: 600; color: var(--blue); }

.toggle-card legend label { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; }
.toggle-card input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--orange); }
.toggle-card.disabled .card-body { opacity: 0.45; pointer-events: none; }

/* Collapse untoggled sections to reduce scrolling */
fieldset.toggle-card:not(:has(input[type="checkbox"]:checked)) .card-body { display: none; }

.custom-field { display: none; }
.custom-field.active { display: block; }

.summary {
  display: grid;
  gap: 1rem;
  position: sticky;
  top: 1rem;
}

.summary-card {
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.summary-card.plan { border: 1px dashed var(--border); }
.summary-card .empty { margin: 0.5rem 0 0; color: var(--text-muted); font-size: 0.95rem; }
.plan-list { margin: 1rem 0 0; padding-left: 1.2rem; color: var(--text-muted); line-height: 1.5; font-size: 0.95rem; }
.summary-card h3 { margin-top: 0; color: var(--heading); font-size: 1.35rem; }
.summary-card .total { font-size: clamp(2rem, 4vw, 2.6rem); font-weight: 800; margin: 0.5rem 0 0; color: var(--orange); }
.summary-details { margin-top: 1.5rem; display: grid; gap: 1rem; }
.summary-details .item { background: var(--surface-1); border-radius: var(--radius-sm); padding: 0.9rem 1rem; border: 1px solid var(--border); }
.summary-details .item-header { display: flex; justify-content: space-between; align-items: center; color: var(--text); font-weight: 700; }
.summary-details .item p { margin: 0.35rem 0 0; color: var(--text-muted); font-size: 0.9rem; }
.summary-card.tips ul { margin: 0.9rem 0 0; padding-left: 1.1rem; color: var(--text-muted); line-height: 1.5; font-size: 0.95rem; }

.glossary { display: grid; gap: 1.25rem; margin-top: 2rem; }
.glossary div { background: var(--surface-2); border-radius: var(--radius-md); padding: 1rem 1.2rem; border: 1px solid var(--border); }
.glossary dt { margin: 0; font-weight: 700; color: var(--heading); }
.glossary dd { margin: 0.4rem 0 0; color: var(--text-muted); line-height: 1.6; }

.footer { text-align: center; color: var(--text-muted); padding: 2rem 1rem 3rem; font-size: 0.95rem; }
.footer a,
.footer a:visited { color: var(--cyan); }
.footer a:hover,
.footer a:focus-visible { color: #22d3ee; text-decoration: underline; outline: none; }

/* Mobile sticky total bar */
.mobile-total {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 20px rgba(0,0,0,0.25);
  z-index: 1000;
}

.mobile-total strong { color: var(--orange); font-size: 1.05rem; }
.mobile-total__link { color: var(--blue); text-decoration: none; font-weight: 700; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .summary { position: static; }
}

@media (max-width: 720px) {
  .tabs { flex-direction: column; }
  .tab-button { max-width: 100%; }
  .preset-group { flex-direction: column; align-items: flex-start; }
  .preset { width: 100%; }
  .card { padding: 0.9rem; }
  .card-body { grid-template-columns: 1fr; }
  .mobile-total { display: flex; }
}
