:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #f0f3f7;
  --border: #dce1e8;
  --text: #1a2230;
  --text-muted: #5c6675;
  --accent: #2f6feb;
  --accent-strong: #1e4fc4;
  --accent-soft: #e7f0ff;
  --success: #167a4c;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 6px 18px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
}

:root[data-theme="dark"] {
  --bg: #0f141c;
  --surface: #18202c;
  --surface-alt: #212b39;
  --border: #2c3849;
  --text: #eef2f7;
  --text-muted: #9aa6b6;
  --accent: #5c92ff;
  --accent-strong: #7aa6ff;
  --accent-soft: #1d2b45;
  --success: #4cc98a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141c;
    --surface: #18202c;
    --surface-alt: #212b39;
    --border: #2c3849;
    --text: #eef2f7;
    --text-muted: #9aa6b6;
    --accent: #5c92ff;
    --accent-strong: #7aa6ff;
    --accent-soft: #1d2b45;
    --success: #4cc98a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
}

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

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  z-index: 100;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { font-size: 22px; }
.brand-name { font-size: 18px; letter-spacing: -0.01em; }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  display: grid;
  place-items: center;
  transition: background .15s ease, transform .1s ease;
}
.theme-toggle:hover { background: var(--accent-soft); }
.theme-toggle:active { transform: scale(0.94); }

/* Intro */
.intro { padding: 34px 0 8px; }
h1 {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.lead { font-size: 1.05rem; color: var(--text-muted); margin: 0; max-width: 62ch; }
.lead strong { color: var(--text); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin: 22px 0;
}
.card h2 {
  font-size: 1.2rem;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.muted { color: var(--text-muted); margin: 0 0 16px; font-size: 0.95rem; }

/* Table */
.table-scroll { width: 100%; overflow-x: auto; }
.course-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 460px;
}
.course-table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 8px 10px;
}
.col-credits { width: 130px; }
.col-grade { width: 150px; }
.col-action { width: 44px; }
.course-table td { padding: 5px 8px; vertical-align: middle; }

.course-table input,
.course-table select,
.prior-grid input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.98rem;
  font-family: inherit;
}
.course-table input:focus,
.course-table select:focus,
.prior-grid input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.course-table select { cursor: pointer; }

.remove-row {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.remove-row:hover { background: #fdecec; color: #c0392b; border-color: #f0c0c0; }
:root[data-theme="dark"] .remove-row:hover { background: #3a2226; color: #ff8a8a; border-color: #5a2e34; }

/* Buttons */
.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(0.97); }
.btn-secondary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-secondary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }

/* Results */
.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
}
.result-tile {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.result-tile--accent {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.result-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}
.result-value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.result-tile--accent .result-value { color: var(--accent-strong); }

/* Prior grid */
.prior-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }

/* Scale table */
.scale-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  min-width: 320px;
}
.scale-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.scale-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.scale-table td:first-child, .scale-table td:nth-child(3) { font-weight: 600; }

/* FAQ */
.faq details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 16px;
  margin-bottom: 10px;
  background: var(--surface-alt);
}
.faq details[open] { background: var(--surface); }
.faq summary {
  cursor: pointer;
  font-weight: 600;
  padding: 12px 0;
  list-style: none;
  position: relative;
  padding-right: 28px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--text-muted);
  font-weight: 400;
}
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0 0 14px; color: var(--text-muted); }
.faq details p strong { color: var(--text); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 30px;
  padding: 24px 0 40px;
}
.site-footer p { margin: 0; color: var(--text-muted); font-size: 0.9rem; text-align: center; }
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 520px) {
  .results, .prior-grid { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .result-value { font-size: 1.7rem; }
}
