:root {
  color-scheme: dark;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef6fb;
  --muted: #93a8b8;
  --line: rgba(162, 187, 204, 0.22);
  --panel: #121c26;
  --soft: #182635;
  --blue: #65a7ff;
  --green: #59c3a6;
  --gold: #e0a44e;
  --rose: #e36d87;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.38);
  --page-bg:
    linear-gradient(180deg, rgba(6, 12, 19, 0.98), rgba(10, 17, 26, 0.98) 42%, #0d141d),
    linear-gradient(135deg, rgba(89, 195, 166, 0.16), transparent 28%, rgba(227, 109, 135, 0.12) 74%, transparent);
  --hero-line: rgba(162, 187, 204, 0.2);
  --hero-bg:
    linear-gradient(135deg, rgba(18, 28, 38, 0.94), rgba(15, 23, 33, 0.78)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='480' viewBox='0 0 900 480'%3E%3Cg fill='none' stroke='%2365a7ff' stroke-opacity='.22'%3E%3Cpath d='M45 405 C175 255 268 314 392 174 S663 49 849 107' stroke-width='18'/%3E%3Cpath d='M86 333 C217 216 315 262 421 140 S633 38 820 65' stroke-width='6'/%3E%3Cpath d='M108 210 H788' stroke-width='2' stroke-dasharray='8 18'/%3E%3Cpath d='M108 284 H788' stroke-width='2' stroke-dasharray='8 18'/%3E%3Cpath d='M108 358 H788' stroke-width='2' stroke-dasharray='8 18'/%3E%3C/g%3E%3Cg fill='%2359c3a6' fill-opacity='.28'%3E%3Ccircle cx='236' cy='272' r='16'/%3E%3Ccircle cx='397' cy='169' r='16'/%3E%3Ccircle cx='593' cy='96' r='16'/%3E%3C/g%3E%3C/svg%3E");
  --glass: rgba(12, 21, 31, 0.76);
  --card-bg: rgba(18, 28, 38, 0.86);
  --empty-bg: rgba(18, 28, 38, 0.7);
  --focus-shadow: rgba(101, 167, 255, 0.18);
  --chart-track: #233344;
}

body[data-theme="light"] {
  color-scheme: light;
  --ink: #172027;
  --muted: #61707c;
  --line: #d9e2ea;
  --panel: #ffffff;
  --soft: #f4f7f9;
  --blue: #1c5d99;
  --green: #287d6f;
  --gold: #b67718;
  --rose: #b84b62;
  --shadow: 0 18px 48px rgba(24, 41, 56, 0.12);
  --page-bg:
    linear-gradient(180deg, rgba(236, 243, 248, 0.95), rgba(248, 250, 252, 0.95) 40%, #ffffff),
    linear-gradient(135deg, rgba(42, 125, 111, 0.12), transparent 28%, rgba(184, 75, 98, 0.08) 74%, transparent);
  --hero-line: rgba(23, 32, 39, 0.08);
  --hero-bg:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(246, 250, 251, 0.78)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='480' viewBox='0 0 900 480'%3E%3Cg fill='none' stroke='%231c5d99' stroke-opacity='.15'%3E%3Cpath d='M45 405 C175 255 268 314 392 174 S663 49 849 107' stroke-width='18'/%3E%3Cpath d='M86 333 C217 216 315 262 421 140 S633 38 820 65' stroke-width='6'/%3E%3Cpath d='M108 210 H788' stroke-width='2' stroke-dasharray='8 18'/%3E%3Cpath d='M108 284 H788' stroke-width='2' stroke-dasharray='8 18'/%3E%3Cpath d='M108 358 H788' stroke-width='2' stroke-dasharray='8 18'/%3E%3C/g%3E%3Cg fill='%23287d6f' fill-opacity='.22'%3E%3Ccircle cx='236' cy='272' r='16'/%3E%3Ccircle cx='397' cy='169' r='16'/%3E%3Ccircle cx='593' cy='96' r='16'/%3E%3C/g%3E%3C/svg%3E");
  --glass: rgba(255, 255, 255, 0.78);
  --card-bg: rgba(255, 255, 255, 0.88);
  --empty-bg: rgba(255, 255, 255, 0.7);
  --focus-shadow: rgba(28, 93, 153, 0.14);
  --chart-track: #e8eef3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page-bg);
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  padding: 0 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.theme-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--soft);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: end;
  min-height: 300px;
  padding: 42px;
  border: 1px solid var(--hero-line);
  border-radius: 8px;
  background: var(--hero-bg);
  background-size: cover;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.8rem, 8vw, 6.3rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.intro {
  max-width: 650px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  backdrop-filter: blur(14px);
}

.hero-panel div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.hero-panel div:last-child {
  border-bottom: 0;
}

.metric {
  font-size: 2rem;
  font-weight: 800;
}

.metric-label,
.insight-label {
  color: var(--muted);
  font-size: 0.86rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(4, minmax(145px, 1fr));
  gap: 12px;
  margin: 22px 0;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  padding: 0 14px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--focus-shadow);
}

.department-field {
  position: relative;
}

.department-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 8px;
}

.icon-button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
}

.icon-button.is-active {
  color: var(--blue);
  border-color: var(--blue);
  background: var(--soft);
}

.department-search-input {
  margin-top: 2px;
}

.insights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.insights article,
.distribution,
.course-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-bg);
}

.insights article {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.insights strong {
  font-size: 1.4rem;
}

.content-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.distribution {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h2 {
  margin: 0;
  font-size: 1.05rem;
}

.results-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

#resetButton {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: var(--soft);
  cursor: pointer;
}

.grade-chart {
  display: grid;
  gap: 16px;
}

.bell-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 210px;
}

.bell-chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.bell-axis,
.bell-grid {
  stroke: var(--chart-track);
  stroke-width: 1.5;
}

.bell-grid {
  opacity: 0.65;
}

.bell-area {
  fill: url("#bellFill");
}

.bell-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bell-point {
  fill: var(--panel);
  stroke: var(--blue);
  stroke-width: 3;
}

.bell-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-anchor: middle;
}

.bell-count {
  fill: var(--ink);
  font-size: 10px;
  font-weight: 850;
  text-anchor: middle;
}

.chart-legend {
  display: grid;
  gap: 9px;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px 42px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.legend-row strong {
  color: var(--ink);
}

.legend-percent {
  color: var(--ink);
  font-weight: 800;
}

.course-list {
  display: grid;
  gap: 10px;
}

.course-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 88px;
  padding: 14px;
  border-left: 6px solid var(--dept-color, var(--blue));
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.course-card:hover {
  transform: translateY(-2px);
  border-color: rgba(101, 167, 255, 0.38);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.course-card.is-active {
  border-color: rgba(101, 167, 255, 0.62);
  box-shadow: 0 12px 34px rgba(101, 167, 255, 0.14);
}

.course-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.course-code {
  color: var(--dept-color, var(--blue));
  font-weight: 850;
  font-size: 1.05rem;
}

.course-title {
  overflow-wrap: anywhere;
  font-weight: 720;
}

.course-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.grade-pill {
  display: grid;
  place-items: center;
  min-width: 58px;
  height: 42px;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 850;
  background: var(--blue);
}

.grade-pill.grade-a {
  background: var(--green);
}

.grade-pill.grade-b {
  background: var(--blue);
}

.grade-pill.grade-c {
  background: var(--gold);
}

.grade-pill.grade-d {
  background: var(--rose);
}

.dept-chip {
  display: inline-grid;
  place-items: center;
  width: max-content;
  min-width: 48px;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--dept-color, var(--blue));
  background: var(--dept-bg, rgba(28, 93, 153, 0.1));
  font-size: 0.78rem;
  font-weight: 850;
}

.empty {
  padding: 30px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--empty-bg);
  text-align: center;
}

.course-detail {
  display: grid;
  gap: 12px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.course-detail h3 {
  margin: 0;
  color: var(--dept-color, var(--blue));
  font-size: 1rem;
}

.course-detail p {
  margin: 0;
  line-height: 1.5;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-grid span {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.78rem;
}

.detail-grid strong {
  color: var(--ink);
  font-size: 1rem;
}

@media (max-width: 920px) {
  .hero,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .insights {
    grid-template-columns: repeat(2, 1fr);
  }

  .distribution {
    position: static;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .hero {
    min-height: auto;
    padding: 24px;
  }

  .toolbar,
  .insights {
    grid-template-columns: 1fr;
  }

  .course-card {
    grid-template-columns: 1fr;
  }

  .grade-pill {
    width: 58px;
  }
}
