:root {
  --bg-accent: radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.92), transparent 34%),
    radial-gradient(circle at 84% 12%, rgba(226, 239, 234, 0.65), transparent 40%),
    linear-gradient(145deg, #edf2ef 0%, #e5ece9 44%, #d9e3e2 100%);
  --panel: rgba(255, 255, 255, 0.86);
  --text: #17302b;
  --muted: #4b5e5b;
  --line: rgba(23, 48, 43, 0.13);
  --brand: #1f7a63;
  --brand-dark: #0f4f44;
  --warm: #9f6a1b;
  --danger: #b24031;
  --shadow: 0 16px 38px rgba(16, 42, 37, 0.12);
  --radius: 24px;
  --section-gap: clamp(18px, 2vw, 24px);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background: var(--bg-accent);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: clamp(18px, 4vw, 40px) 0 max(40px, env(safe-area-inset-bottom));
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}

.confetti-piece {
  position: absolute;
  top: -10vh;
  width: 12px;
  height: 20px;
  border-radius: 4px;
  opacity: 0.95;
  animation: confetti-fall linear forwards;
  will-change: transform, opacity;
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0.95;
  }

  100% {
    transform: translate3d(var(--drift-x, 0px), 120vh, 0) rotate(var(--rotate-end, 540deg));
    opacity: 0;
  }
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.8fr);
  gap: var(--section-gap);
  align-items: stretch;
  margin-bottom: var(--section-gap);
}

.hero-copy,
.hero-card,
.panel,
.semester-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: clamp(20px, 3vw, 28px);
}

.brand-strip {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(31, 122, 99, 0.1);
  border: 1px solid rgba(31, 122, 99, 0.18);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-wordmark {
  display: grid;
  gap: 2px;
}

.brand-name {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.94rem;
}

.brand-subtitle {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.hero-card {
  padding: 28px;
  background: linear-gradient(180deg, rgba(31, 122, 99, 0.92), rgba(15, 79, 68, 0.95));
  color: #f7fbf8;
}

.hero-card ul {
  padding-left: 18px;
  margin: 16px 0 0;
}

.hero-card li + li {
  margin-top: 10px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--warm);
}

h1,
h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  line-height: 1.05;
}

h1 {
  font-size: clamp(1.7rem, 3.8vw, 3rem);
  max-width: 16ch;
  line-height: 1.12;
}

h2 {
  font-size: clamp(1.3rem, 2vw, 1.8rem);
}

.hero-text,
.note,
.trend-note {
  color: var(--muted);
  line-height: 1.6;
}

.layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--section-gap);
}

.panel {
  padding: 24px;
}

.controls-panel .section-title {
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 500;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(15, 109, 86, 0.2);
  border-color: var(--brand);
}

.controls-actions,
.semester-actions,
.semester-header,
.semester-header-actions,
.trend-header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.controls-actions {
  margin-top: 18px;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.icon-btn,
.remove-course-btn {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.primary-btn,
.ghost-btn,
.danger-btn {
  min-height: 46px;
  padding: 12px 18px;
  font-weight: 700;
}

.primary-btn {
  color: #f9fdfa;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}

.ghost-btn {
  background: rgba(15, 109, 86, 0.1);
  color: var(--brand-dark);
}

.danger-btn {
  background: rgba(178, 64, 49, 0.12);
  color: var(--danger);
}

.icon-btn {
  width: 40px;
  height: 40px;
  font-size: 1.4rem;
  background: rgba(178, 64, 49, 0.1);
  color: var(--danger);
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.icon-btn:hover,
.remove-course-btn:hover,
.summary-jump:hover {
  transform: translateY(-1px);
}

.summary-jump {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(15, 109, 86, 0.18), rgba(15, 109, 86, 0.08));
  color: var(--brand-dark);
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(15, 109, 86, 0.08);
}

.summary-jump-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(15, 109, 86, 0.18);
  font-size: 0.95rem;
  line-height: 1;
}

.add-semester-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.remove-course-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: none;
  border-radius: 999px;
  box-shadow: none;
  background: rgba(178, 64, 49, 0.12);
  color: var(--danger);
  font-weight: 700;
}

.remove-course-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(178, 64, 49, 0.18);
  font-size: 0.88rem;
  line-height: 1;
}

.remove-course-text {
  white-space: nowrap;
}

.summary-grid,
.trend-stats,
.semester-summary {
  display: grid;
  gap: 14px;
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric-card,
.trend-stat-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}

.class-card {
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.82);
}

@property --ring-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.class-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(
    from var(--ring-angle),
    #ff3b30,
    #ff9500,
    #ffcc00,
    #34c759,
    #32ade6,
    #5856d6,
    #af52de,
    #ff2d55,
    #ff3b30
  );
  animation: class-card-ring-flow 2.8s linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.class-card > * {
  position: relative;
  z-index: 1;
}

.class-card strong {
  font-size: 1.45rem;
}

@keyframes class-card-ring-flow {
  to {
    --ring-angle: 1turn;
  }
}

.metric-card.accent {
  background: linear-gradient(135deg, rgba(15, 109, 86, 0.92), rgba(213, 128, 47, 0.92));
  color: #fffef9;
}

.metric-label,
.summary-label {
  display: block;
  font-size: 0.85rem;
  color: inherit;
  opacity: 0.78;
}

.metric-card strong,
.trend-stat-card strong,
.semester-summary strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  font-family: "Fraunces", serif;
}

.scale-table {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  margin-top: 18px;
}

.scale-row,
.course-row {
  display: grid;
  gap: 12px;
  align-items: center;
}

.scale-row {
  grid-template-columns: 0.7fr 1fr 0.7fr 1.3fr;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.66);
}

.scale-row + .scale-row {
  border-top: 1px solid var(--line);
}

.scale-table .optional-band {
  display: none;
}

.scale-table.show-optional .optional-band {
  display: grid;
}

.scale-head,
.course-head {
  font-weight: 700;
  background: rgba(15, 109, 86, 0.12);
}

.trend-panel,
.semester-section {
  margin-top: 32px;
}

.trend-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(250px, 0.8fr);
  gap: 20px;
  margin-top: 20px;
}

.trend-stage {
  position: relative;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(240, 248, 245, 0.85));
}

#trendChart {
  display: block;
  width: 100%;
  height: auto;
}

.trend-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.trend-stats {
  grid-template-columns: 1fr;
}

.summary-return-wrap {
  margin-top: 18px;
}

.scale-toggle-btn {
  margin-top: 14px;
}

.summary-return-jump {
  color: #f9fdfa;
  background: linear-gradient(135deg, rgba(15, 79, 68, 0.95), rgba(31, 122, 99, 0.9));
}

.summary-return-jump .summary-jump-icon {
  background: rgba(255, 255, 255, 0.2);
}

.bottom-summary-jump-wrap {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.bottom-summary-jump {
  background: linear-gradient(135deg, rgba(9, 79, 63, 0.95), rgba(15, 109, 86, 0.82));
  color: #f9fdfa;
}

.bottom-summary-jump .summary-jump-icon {
  background: rgba(255, 255, 255, 0.18);
}

.semester-container {
  display: grid;
  gap: 20px;
  margin-top: 18px;
}

.semester-card {
  padding: 24px;
}

.semester-topbar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
}

.semester-topbar > div:first-child {
  flex: 1 1 240px;
}

.semester-config-grid {
  display: grid;
  grid-template-columns: minmax(0, 280px);
  gap: 14px;
  margin-top: 18px;
}

.semester-label-input[readonly] {
  background: rgba(15, 109, 86, 0.06);
  color: var(--brand-dark);
  font-weight: 700;
}

.course-table {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

.course-row {
  grid-template-columns: minmax(120px, 1.4fr) 0.75fr 0.75fr 0.8fr 0.75fr minmax(120px, 0.95fr);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
}

.course-row + .course-row {
  border-top: 1px solid var(--line);
}

.course-row output {
  font-weight: 700;
  text-align: center;
}

.course-row > * {
  min-width: 0;
}

.semester-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.semester-summary > div {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.78);
}

.site-footer {
  margin-top: 32px;
  padding: 20px 16px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer p {
  margin: 0;
}

.predictor-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 29, 26, 0.46);
  backdrop-filter: blur(4px);
}

.predictor-popup-overlay[hidden] {
  display: none;
}

.predictor-popup {
  position: relative;
  width: min(460px, 100%);
  padding: 24px 22px 22px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  background: linear-gradient(150deg, rgba(255, 251, 243, 0.98), rgba(232, 242, 237, 0.96));
  box-shadow: 0 22px 50px rgba(24, 32, 28, 0.28);
}

.predictor-popup-kicker {
  margin: 0 0 8px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--warm);
  font-weight: 700;
}

.predictor-popup h2 {
  font-size: clamp(1.3rem, 2.3vw, 1.6rem);
}

.predictor-popup-text {
  margin: 12px 0 0;
  line-height: 1.55;
  color: var(--muted);
}

.predictor-popup-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  min-width: 130px;
  text-decoration: none;
}

.predictor-popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: rgba(31, 29, 26, 0.08);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.predictor-popup-close:hover {
  background: rgba(31, 29, 26, 0.16);
}

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

  .semester-config-grid {
    grid-template-columns: minmax(0, 280px);
  }

  .hero-copy {
    order: 1;
  }

  .hero-card {
    order: 2;
  }
}

@media (max-width: 860px) {
  .course-row {
    grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(84px, 1fr)) minmax(110px, 0.9fr);
  }

  .remove-course-btn {
    padding-inline: 12px;
  }

  .remove-course-text {
    font-size: 0.92rem;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
  }

  .hero-copy,
  .hero-card,
  .panel,
  .semester-card {
    padding: 20px;
  }

  h1 {
    max-width: none;
  }

  .controls-actions,
  .semester-header,
  .semester-header-actions,
  .trend-header {
    align-items: stretch;
  }

  .controls-actions > *,
  .semester-header-actions > *,
  .semester-actions > *,
  .summary-return-wrap .summary-jump,
  .bottom-summary-jump-wrap .summary-jump {
    width: 100%;
  }

  .summary-grid,
  .semester-summary,
  .trend-grid {
    grid-template-columns: 1fr;
  }

  .semester-config-grid {
    grid-template-columns: 1fr;
  }

  .scale-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .course-head {
    display: none;
  }

  .course-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px;
  }

  .course-row input,
  .course-row select,
  .course-row output,
  .course-row button,
  .summary-jump {
    width: 100%;
    text-align: left;
  }

  .course-row output {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(15, 109, 86, 0.06);
  }

  .trend-stage {
    min-height: 280px;
    padding: 12px;
  }

  .metric-card strong,
  .trend-stat-card strong,
  .semester-summary strong {
    font-size: 1.7rem;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100vw - 14px, 100%);
  }

  .hero-copy,
  .hero-card,
  .panel,
  .semester-card {
    padding: 16px;
    border-radius: 20px;
  }

  .predictor-popup {
    padding: 22px 16px 18px;
    border-radius: 18px;
  }

  .eyebrow,
  .section-kicker {
    letter-spacing: 0.08em;
    font-size: 0.7rem;
  }

  .brand-strip {
    width: 100%;
    border-radius: 14px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .scale-row {
    grid-template-columns: 1fr 1fr;
    font-size: 0.92rem;
  }

  .semester-topbar,
  .semester-actions,
  .semester-header,
  .semester-header-actions,
  .trend-header {
    gap: 10px;
  }

  .metric-card,
  .trend-stat-card,
  .semester-summary > div,
  .trend-stage,
  .course-table,
  .scale-table {
    border-radius: 16px;
  }

  .trend-empty {
    padding: 18px;
    font-size: 0.94rem;
  }
}

@media (hover: none) and (pointer: coarse) {
  .primary-btn:hover,
  .ghost-btn:hover,
  .danger-btn:hover,
  .icon-btn:hover,
  .remove-course-btn:hover,
  .summary-jump:hover {
    transform: none;
  }
}

