:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f1ea;
  --paper: #fffcf7;
  --ink: #1c1915;
  --muted: #4f4a43;
  --line: #e3ddd0;
  --stroke: #6d675e;
  --accent: #1d4e89;
  --accent-ink: #fffcf7;
  --accent-soft: #e7eef8;
  --weighted: #8d3e0f;
  --weighted-soft: #f8ecdf;
  --shadow: 0 16px 40px rgba(40, 32, 20, 0.06);
  --danger: #8f2d2d;
  --ok: #0e6a42;
  --focus: #1d4e89;
  --header: rgba(255, 252, 247, 0.94);
  --bar: #fffcf7;
  --year-total: #e7eef8;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121410;
  --paper: #1b1e19;
  --ink: #f4f1e8;
  --muted: #c8c0b2;
  --line: #33382e;
  --stroke: #a3aa98;
  --accent: #a9c7f5;
  --accent-ink: #121410;
  --accent-soft: #243044;
  --weighted: #f0b429;
  --weighted-soft: #332616;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --danger: #ffb4b0;
  --ok: #8fd6b0;
  --focus: #a9c7f5;
  --header: rgba(27, 30, 25, 0.94);
  --bar: #1b1e19;
  --year-total: #243044;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
}

body::before {
  content: "";
  display: block;
  height: 6px;
  background: linear-gradient(90deg, var(--accent) 0 50%, var(--weighted) 50% 100%);
}

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

::selection { background: var(--accent-soft); color: var(--ink); }

.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 0.8rem;
  z-index: 50;
  border-radius: 8px;
}
.skip:focus { top: 0.75rem; }

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

.wrap { width: min(1040px, calc(100% - 2rem)); margin-inline: auto; }
.wrap.prose { width: min(68ch, calc(100% - 2rem)); }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

.site-header { border-bottom: 1px solid var(--line); background: var(--header); }
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.8rem 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.03em;
  font-size: 1.05rem;
}
.mark { display: block; flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; }
.nav a { color: var(--ink); text-decoration: none; padding: 0.2rem 0; }
.nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
@media (max-width: 859px) {
  .header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand theme"
      "nav nav";
    align-items: center;
  }
  .brand { grid-area: brand; }
  .theme-toggle { grid-area: theme; margin-left: 0; justify-self: end; }
  .nav { grid-area: nav; }
}

@media (min-width: 860px) {
  .nav { margin-left: auto; }
}

.hero { padding: 1.45rem 0 0.35rem; }
.eyebrow {
  margin: 0 0 0.35rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
}
.hero h1,
.prose h1,
dialog h2,
.section-title,
.panel h2,
.summary-title,
.year-title {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.03em;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.05;
  margin: 0 0 0.55rem;
}
.lede { max-width: 42rem; margin: 0; font-size: 1.125rem; line-height: 1.5; color: var(--muted); }

.calculator { padding-bottom: 1rem; }
.banner,
.noscript-note {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 0.85rem;
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.85rem;
  box-shadow: var(--shadow);
}
.score { border-radius: 12px; padding: 0.75rem 0.8rem 0.7rem; min-width: 0; }
.score-uw { background: var(--accent-soft); }
.score-w { background: var(--weighted-soft); }
.score-kicker {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}
.score-uw .score-kicker { color: var(--accent); }
.score-w .score-kicker { color: var(--weighted); }
.score-value {
  font-family: var(--serif);
  font-size: clamp(2.35rem, 7vw, 5.1rem);
  line-height: 0.95;
  margin: 0.15rem 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.score-note { margin: 0; color: var(--muted); font-size: 0.88rem; }
.score-meta,
.disclaimer-inline { grid-column: 1 / -1; margin: 0; }
.disclaimer-inline { font-size: 0.92rem; }
.formula { color: var(--muted); margin: 0.85rem 0 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.btn,
.theme-toggle,
.icon-btn {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  min-height: 2.75rem;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-text { background: transparent; border-color: transparent; color: var(--accent); padding-inline: 0.15rem; }
.btn-add { margin-top: 0.35rem; }
.btn:disabled { opacity: 0.65; cursor: progress; }
.icon-btn {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
}
@media (hover: hover) {
  .btn:hover,
  .theme-toggle:hover,
  .icon-btn:hover { border-color: var(--accent); }
  .icon-btn:hover { color: var(--danger); }
  .btn-primary:hover { filter: brightness(1.08); }
  .btn-text:hover { text-decoration: underline; }
}

.status { min-height: 1.4em; color: var(--accent); margin: 0.35rem 0 0; }
#share-fallback { margin: 0.35rem 0 0.6rem; }
.field-error { color: var(--danger); margin: 0.4rem 0 0; }

.school,
.panel,
.year {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-top: 0.9rem;
}
.school,
.panel { padding: 0.95rem 1rem 1rem; }
.year { padding: 0.15rem 1rem 1rem; }
.school > summary,
.year-details > summary {
  cursor: pointer;
  list-style: none;
}
.school > summary::-webkit-details-marker,
.year-details > summary::-webkit-details-marker { display: none; }
.school > summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}
.summary-title { display: block; font-size: 1.35rem; }
.summary-aside { display: block; color: var(--muted); font-size: 0.92rem; margin-top: 0.15rem; }
.school > summary::after { content: "Hide"; color: var(--accent); font-size: 0.85rem; }
.school:not([open]) > summary::after { content: "Edit"; }
.school-grid { display: grid; gap: 0.8rem; margin-top: 0.9rem; }
@media (min-width: 900px) {
  .school-grid { grid-template-columns: 1fr 1fr; }
  .scale-editor { grid-column: 1 / -1; }
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 0;
  padding: 0.8rem 0.9rem 0.95rem;
}
legend { font-family: var(--serif); padding: 0 0.3rem; }
.help { color: var(--muted); margin: 0.35rem 0 0; font-size: 0.92rem; }
.check { display: flex; gap: 0.6rem; align-items: flex-start; margin: 0.35rem 0 0.75rem; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: 0.2rem; flex: none; }
.choices { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.choices label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  min-height: 2.75rem;
  padding: 0.3rem 0.8rem;
}
.choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choices label:has(input:disabled) { opacity: 0.55; }
.weight-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.2rem, 1fr)); gap: 0.6rem; }
.weight-grid label,
.planner-grid label,
.scale-editor h3 { font-size: 0.92rem; }
.weight-grid label,
.planner-grid label { display: flex; flex-direction: column; gap: 0.25rem; }
.scale-editor h3 { font-family: var(--serif); font-size: 1.25rem; margin: 0.2rem 0; }
.fixed-note { color: var(--muted); }

input,
select {
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  width: 100%;
  min-height: 2.75rem;
}
input[aria-invalid="true"] { border-color: var(--danger); }
.scale-table input { max-width: 7rem; }

.section-title,
.panel h2 { font-size: 1.5rem; margin: 0 0 0.35rem; }
.section-title { margin-top: 1.4rem; }

.year-details > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  padding: 0.85rem 0 0.35rem;
}
.year-title { font-size: 1.45rem; margin: 0; }
.year-nick { color: var(--muted); }
.year-gpa {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 0.92rem;
}
.year-details > summary::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(-45deg);
  align-self: center;
  flex: none;
}
.year-details[open] > summary::before { transform: rotate(45deg); }

.semester { margin-top: 0.35rem; --cols: minmax(9rem, 1.5fr) 6.2rem 6.4rem minmax(8.5rem, 0.9fr) 5.2rem 2.75rem; }
.semester-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem 0.8rem; }
.semester-top h3 { margin: 0.6rem 0 0.2rem; font-size: 1.05rem; }
.sem-gpa { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty-sem { color: var(--muted); margin: 0.4rem 0; }

.course {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  grid-template-areas:
    "name name remove"
    "letter percent ."
    "level credits ."
    "hint hint hint";
  gap: 0.45rem 0.6rem;
  align-items: end;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}
.field { position: relative; min-width: 0; }
.field label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.field-name { grid-area: name; }
.field-letter { grid-area: letter; }
.field-percent { grid-area: percent; }
.field-level { grid-area: level; }
.field-credits { grid-area: credits; }
.field-remove { grid-area: remove; align-self: end; justify-self: end; }
.row-hint { grid-area: hint; margin: 0; color: var(--muted); font-size: 0.88rem; }
.row-hint.is-error { color: var(--danger); }
.colhead { display: none; }

@media (min-width: 860px) {
  .colhead {
    display: grid;
    grid-template-columns: var(--cols);
    gap: 0.6rem;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding-top: 0.35rem;
  }
  .course {
    grid-template-columns: var(--cols);
    grid-template-areas:
      "name letter percent level credits remove"
      "hint hint hint hint hint hint";
    align-items: center;
  }
  .course .field label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

.planner-grid { display: grid; gap: 0.7rem; margin: 0.7rem 0; }
@media (min-width: 700px) {
  .planner-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.plan-base { color: var(--muted); margin-bottom: 0.2rem; }
.plan-result { font-size: 1.05rem; margin-top: 0.2rem; }
.plan-met { color: var(--ok); }
.plan-over,
.plan-invalid { color: var(--danger); }
.plan-short { color: var(--weighted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th,
td {
  text-align: left;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
caption { text-align: left; font-weight: 650; padding: 0.2rem 0 0.45rem; }
.is-total th,
.is-total td,
tfoot th,
tfoot td { font-weight: 700; background: var(--year-total); }
.scale-table { max-width: 36rem; }

.prose { padding-bottom: 1rem; }
.prose h1 { font-size: clamp(2rem, 4vw, 2.7rem); line-height: 1.1; margin: 1.4rem 0 0.6rem; }
.prose h2 { font-size: 1.55rem; margin: 2rem 0 0.55rem; }
.prose h3 { font-size: 1.12rem; margin: 1.2rem 0 0.3rem; }
.prose p,
.prose li { line-height: 1.65; }
.prose ul { padding-left: 1.2rem; }
.prose a { text-underline-offset: 0.15em; }
.faq-item + .faq-item { margin-top: 0.35rem; }

.todo-note {
  border: 1px dashed var(--weighted);
  background: var(--weighted-soft);
  border-radius: 12px;
  padding: 0.8rem 1rem;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 2.5rem;
  padding: 1.3rem 0 2rem;
  color: var(--muted);
}
.footer-nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.footer-nav a { color: var(--ink); }

.mobile-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  gap: 1rem;
  background: var(--bar);
  border-top: 1px solid var(--line);
  padding: 0.4rem 0.8rem calc(0.45rem + env(safe-area-inset-bottom));
}
.mobile-bar div { min-width: 0; }
.mobile-bar span {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.mobile-bar strong {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
@media (max-width: 859px) {
  body { padding-bottom: 4.8rem; }
}
@media (min-width: 860px) {
  .mobile-bar { display: none; }
}

dialog {
  border: none;
  border-radius: 16px;
  padding: 1.15rem 1.15rem 1rem;
  background: var(--paper);
  color: var(--ink);
  width: min(28rem, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(20, 16, 12, 0.48); }
dialog h2 { margin: 0 0 0.4rem; font-size: 1.4rem; }
dialog p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

.print-sheet { display: none; }

@media print {
  body { background: #fff; color: #000; padding: 0; }
  body::before,
  .site-header,
  .site-footer,
  .mobile-bar,
  .skip,
  main,
  dialog { display: none !important; }
  .print-sheet { display: block; }
  .print-sheet h1,
  .print-sheet h2,
  .print-sheet h3 { font-family: Georgia, "Times New Roman", serif; color: #000; }
  .print-sheet h2,
  .print-sheet h3 { break-after: avoid; }
  .print-sheet table { width: 100%; border-collapse: collapse; break-inside: avoid; }
  .print-sheet th,
  .print-sheet td { border-bottom: 1px solid #bbb; text-align: left; padding: 3px 6px; font-size: 11pt; color: #000; background: #fff; }
  .print-scores { font-size: 14pt; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
