:root {
  --bg: #f5efe6;
  --bg-deep: #efe5d6;
  --surface: rgba(255, 252, 247, 0.94);
  --surface-soft: rgba(252, 247, 240, 0.96);
  --surface-raised: rgba(255, 255, 255, 0.98);
  --border: rgba(107, 89, 63, 0.14);
  --border-strong: rgba(35, 85, 73, 0.28);
  --text: #1f2933;
  --text-muted: #7a6d60;
  --text-soft: #564a3e;
  --accent: #1f7a69;
  --accent-strong: #2c9c87;
  --accent-secondary: #c96f3d;
  --selected: #f59e0b;
  --direct: #1f9d74;
  --indirect: #4f7cff;
  --future: #a78bfa;
  --danger: #ce5f5f;
  --warning: #d59b3d;
  --shadow-lg: 0 28px 60px rgba(92, 68, 42, 0.12);
  --shadow-md: 0 16px 34px rgba(92, 68, 42, 0.1);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(201, 111, 61, 0.1), transparent 34%),
    radial-gradient(circle at top right, rgba(44, 156, 135, 0.1), transparent 30%),
    linear-gradient(180deg, #fbf7f1 0%, var(--bg) 52%, var(--bg-deep) 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
}

body::before {
  top: -18rem;
  right: -12rem;
  width: 30rem;
  height: 30rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(44, 156, 135, 0.14), transparent 70%);
  animation: float-halo 18s ease-in-out infinite;
}

body::after {
  bottom: -20rem;
  left: -16rem;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(201, 111, 61, 0.14), transparent 68%);
  animation: float-halo 22s ease-in-out infinite reverse;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: none;
  border-radius: var(--radius-sm);
  min-height: 48px;
  padding: 0.8rem 1rem;
  font-weight: 700;
  color: #fffdf9;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 12px 24px rgba(31, 122, 105, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(31, 122, 105, 0.2);
}

button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 50px;
  padding: 0.85rem 0.95rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

select:focus,
input[type="text"]:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 4px rgba(44, 156, 135, 0.12);
  background: #fffdf9;
}

input::placeholder {
  color: rgba(122, 109, 96, 0.76);
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

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

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1680px;
  margin: 0 auto;
  padding: 20px clamp(10px, 1.35vw, 18px) 24px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  animation: rise-in 0.65s ease both;
}

.brand-block {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  min-width: 0;
}

.brand-mark {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  border-radius: 18px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 241, 232, 0.96));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.brand-copy {
  min-width: 0;
}

.eyebrow,
.section-kicker,
.meta-label,
.field-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.brand-copy h1,
.panel-header h2,
.comparison-header h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.03em;
}

.brand-copy h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.brand-subtitle {
  margin: 10px 0 0;
  max-width: 44rem;
  font-size: 1rem;
  color: var(--text-soft);
}

.utility-panel,
.card,
.controls-card,
.status-text,
.comparison-header {
  backdrop-filter: blur(18px);
}

.utility-panel {
  display: grid;
  gap: 16px;
  width: min(100%, 286px);
  min-width: min(100%, 286px);
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(250, 244, 236, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.utility-actions {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.header-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.header-action small {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-height: 48px;
  padding: 0;
  color: var(--accent-secondary);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  box-shadow: none;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

#clear-icon {
  color: var(--danger);
}

.utility-meta {
  display: grid;
  gap: 4px;
  padding-top: 2px;
}

.utility-meta strong {
  font-size: 1.05rem;
  color: var(--text);
}

.utility-meta span:last-child {
  color: var(--text-muted);
}

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(480px, 1.08fr);
  gap: 16px;
  align-items: start;
}

.planner-column {
  min-width: 0;
}

.card {
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(251, 245, 238, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.planner-card,
.graph-card {
  padding: 18px;
}

.planner-card {
  animation: rise-in 0.75s ease both;
}

.graph-card {
  position: sticky;
  top: 18px;
  animation: rise-in 0.85s ease both;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.panel-header-stacked {
  margin-bottom: 18px;
}

.panel-header-compact {
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  margin-top: 6px;
}

.section-subtitle {
  margin: 8px 0 0;
  max-width: 54rem;
  color: var(--text-soft);
}

.support-buttons,
.control-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.support-buttons {
  flex-shrink: 0;
}

.button-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  box-shadow: none;
}

.button-ghost {
  color: var(--text-muted);
  background: rgba(247, 241, 232, 0.7);
  border: 1px dashed rgba(107, 89, 63, 0.24);
  box-shadow: none;
}

.button-tertiary {
  color: var(--text);
  background: rgba(244, 236, 225, 0.86);
  border: 1px solid rgba(107, 89, 63, 0.14);
  box-shadow: none;
}

.button-secondary:hover,
.button-ghost:hover,
.button-tertiary:hover,
.info-btn:hover,
.course-remove-btn:hover,
.icon-btn:hover {
  border-color: var(--border-strong);
  box-shadow: none;
}

.controls-card {
  display: grid;
  gap: 18px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(252, 247, 240, 0.98), rgba(247, 239, 229, 0.94));
  border: 1px solid var(--border);
  border-radius: 22px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.program-picker-card {
  gap: 20px;
}

.onboarding-target-current,
.onboarding-target-next,
.onboarding-target-complete {
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.onboarding-target-current {
  box-shadow: 0 0 0 3px rgba(31, 122, 105, 0.16), var(--shadow-md);
  border-color: rgba(31, 122, 105, 0.28) !important;
}

.onboarding-target-next {
  box-shadow: 0 0 0 2px rgba(201, 111, 61, 0.14);
  border-color: rgba(201, 111, 61, 0.22) !important;
}

.onboarding-target-complete {
  border-color: rgba(31, 122, 105, 0.18) !important;
}

body.onboarding-focus-active .utility-panel,
body.onboarding-focus-active .picker-actions,
body.onboarding-focus-active .planner-tools {
  opacity: 0.42;
  filter: saturate(0.75);
}

body.onboarding-focus-active .graph-card {
  position: sticky;
  overflow: hidden;
}

body.onboarding-focus-active .graph-card > * {
  opacity: 0.16;
  filter: blur(2px) saturate(0.8);
  pointer-events: none;
}

body.onboarding-focus-active .graph-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.72), rgba(249, 242, 233, 0.78));
  z-index: 1;
}

body.onboarding-focus-active .graph-card::after {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(24rem, calc(100% - 3rem));
  transform: translate(-50%, -50%);
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid rgba(31, 122, 105, 0.18);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  color: var(--text-soft);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  z-index: 2;
}

body.onboarding-focus-active[data-onboarding-stage="loading"] .graph-card::after {
  content: "Loading the planner first. The prerequisite graph will unlock after you choose a program.";
}

body.onboarding-focus-active[data-onboarding-stage="step-1"] .graph-card::after {
  content: "Step 1 first: confirm the calendar year, then move to the program search.";
}

body.onboarding-focus-active[data-onboarding-stage="step-2"] .graph-card::after {
  content: "Step 2 next: click a program result and the graph will light up with real course dependencies.";
}

body.onboarding-focus-active[data-onboarding-stage="step-4"] .graph-card::after {
  content: "Comparison mode is open. Focus on choosing the second program and comparing the schedules.";
}

body.onboarding-focus-active[data-onboarding-stage="comparison-ready"] .graph-card::after {
  content: "Comparison view is active. Focus on the side-by-side schedule instead of the prerequisite graph.";
}

.picker-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.82fr);
  gap: 18px;
  align-items: start;
}

.picker-primary,
.picker-side {
  display: grid;
  gap: 16px;
}

.picker-side {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(107, 89, 63, 0.12);
  background: rgba(255, 255, 255, 0.58);
}

.picker-side-note {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.95rem;
  font-weight: 600;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-group-wide {
  grid-column: 1 / -1;
}

.field-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.field-note-error {
  color: var(--danger);
}

.program-search-results {
  display: grid;
  gap: 10px;
}

.program-result {
  justify-content: space-between;
  width: 100%;
  min-height: 54px;
  padding: 0.9rem 1rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(107, 89, 63, 0.12);
  box-shadow: none;
  text-align: left;
}

.program-result:hover {
  box-shadow: var(--shadow-md);
}

.program-result-active {
  border-color: rgba(31, 122, 105, 0.28);
  background: rgba(230, 244, 239, 0.92);
}

.program-result-name {
  display: block;
  font-weight: 700;
}

.program-result-action {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(244, 236, 225, 0.92);
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.control-actions > button {
  flex: 1 1 220px;
}

.picker-actions {
  padding-top: 2px;
}

.planner-tools {
  padding-top: 2px;
}

.compare-panel {
  display: grid;
  gap: 16px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.compare-header h3 {
  margin-top: 6px;
  font-size: 1.2rem;
}

.status-text {
  margin-top: 18px;
  min-height: 24px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.74);
  color: var(--text-muted);
  font-size: 0.94rem;
}

.status-text:empty {
  display: none;
}

.status-text.status-error {
  color: #8b3838;
  background: rgba(250, 224, 224, 0.82);
  border-color: rgba(206, 95, 95, 0.26);
}

.status-text.status-info {
  color: var(--text-soft);
  background: rgba(239, 247, 244, 0.88);
  border-color: rgba(31, 122, 105, 0.16);
}

#schedule-container,
.compare-results {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 16px;
}

.year-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
  --year-accent: #1f7a69;
  --year-soft: rgba(31, 122, 105, 0.08);
  --year-border: rgba(31, 122, 105, 0.18);
}

.year-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--year-border);
  background: var(--year-soft);
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.year-title::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--year-border);
  background: var(--year-accent);
  box-shadow: 0 0 0 4px var(--year-soft);
}

.year-block[data-year-tone="1"] {
  --year-accent: #1f7a69;
  --year-soft: rgba(31, 122, 105, 0.1);
  --year-border: rgba(31, 122, 105, 0.2);
}

.year-block[data-year-tone="2"] {
  --year-accent: #c96f3d;
  --year-soft: rgba(201, 111, 61, 0.1);
  --year-border: rgba(201, 111, 61, 0.2);
}

.year-block[data-year-tone="3"] {
  --year-accent: #6b7f31;
  --year-soft: rgba(107, 127, 49, 0.1);
  --year-border: rgba(107, 127, 49, 0.2);
}

.year-block[data-year-tone="4"] {
  --year-accent: #7a5cc8;
  --year-soft: rgba(122, 92, 200, 0.1);
  --year-border: rgba(122, 92, 200, 0.18);
}

.year-block[data-year-tone="5"] {
  --year-accent: #b35e77;
  --year-soft: rgba(179, 94, 119, 0.1);
  --year-border: rgba(179, 94, 119, 0.18);
}

.semester-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.semester-card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(252, 247, 240, 0.98));
  border: 1px solid var(--year-border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.semester-card:hover {
  transform: translateY(-2px);
  border-color: var(--year-accent);
  box-shadow: var(--shadow-md);
}

.semester-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
}

.course-card {
  position: relative;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(107, 89, 63, 0.12);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.course-card:last-child {
  margin-bottom: 0;
}

.course-card:hover,
.course-card:focus-within {
  transform: translateY(-1px);
  border-color: rgba(31, 122, 105, 0.28);
  background: #fffdf9;
}

.course-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.course-main-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.course-code {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.course-name {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.elective-card .course-code {
  color: var(--accent-strong);
}

.info-btn {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(247, 241, 232, 0.88);
  color: var(--text-soft);
  box-shadow: none;
  font-size: 0.78rem;
  font-weight: 700;
}

.course-remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 246, 246, 0.94);
  color: var(--danger);
  border: 1px solid rgba(206, 95, 95, 0.24);
  box-shadow: none;
  font-size: 0.85rem;
  line-height: 1;
}

.course-card:hover .course-remove-btn,
.course-card:focus-within .course-remove-btn {
  display: inline-flex;
}

.course-selected {
  background: rgba(255, 241, 204, 0.92);
  border-color: rgba(217, 119, 6, 0.42);
}

.course-direct {
  background: rgba(222, 247, 232, 0.96);
  border-color: rgba(31, 157, 116, 0.36);
}

.course-indirect {
  background: rgba(225, 239, 255, 0.96);
  border-color: rgba(79, 124, 255, 0.34);
}

.course-future {
  background: rgba(239, 232, 255, 0.96);
  border-color: rgba(139, 92, 246, 0.32);
}

.course-same {
  background: rgba(222, 247, 232, 0.96);
  border-color: rgba(31, 157, 116, 0.34);
}

.course-diff {
  background: rgba(255, 241, 204, 0.96);
  border-color: rgba(213, 155, 61, 0.34);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.legend > span,
.comparison-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text-soft);
  font-size: 0.82rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.legend-dot.selected {
  background: var(--selected);
}

.legend-dot.direct,
.legend-dot.same {
  background: var(--direct);
}

.legend-dot.indirect,
.legend-dot.compare-a {
  background: var(--indirect);
}

.legend-dot.future {
  background: var(--future);
}

.legend-dot.shifted {
  background: var(--warning);
}

.legend-dot.compare-b {
  background: var(--danger);
}

.graph-toggle-row,
.mini-graph-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.graph-toggle-row {
  margin-bottom: 16px;
}

.graph-toggle-row label,
.mini-graph-toolbar label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text-soft);
  font-size: 0.9rem;
}

.graph-toggle-row input,
.mini-graph-toolbar input {
  accent-color: var(--accent);
}

#graph {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  min-height: min(68vh, 780px);
  height: min(68vh, 780px);
  border-radius: 22px;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at top, rgba(44, 156, 135, 0.1), transparent 44%),
    linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(243, 235, 223, 0.98));
  overflow: hidden;
}

#graph::after {
  content: "Click on a course or zoom in!";
  position: absolute;
  left: 50%;
  bottom: 18px;
  max-width: calc(100% - 2rem);
  padding: 0.75rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(31, 122, 105, 0.18);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 3;
}

.graph-card[data-graph-tip-visible="true"] #graph::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.onboarding-focus-active .graph-card[data-graph-tip-visible="true"] #graph::after {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.graph-empty {
  max-width: 18rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.comparison-shell {
  display: grid;
  gap: 20px;
}

.comparison-header {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(249, 242, 233, 0.96));
  border: 1px solid var(--border);
  border-radius: 22px;
}

.comparison-header h3 {
  font-size: 1.28rem;
}

.comparison-copy {
  margin: 6px 0 0;
  color: var(--text-soft);
}

.comparison-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.comparison-years {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.comparison-wrap {
  display: grid;
  gap: 14px;
}

.comparison-row-label {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.comparison-row-label-primary {
  color: #2d4b91;
  background: rgba(225, 239, 255, 0.88);
  border: 1px solid rgba(79, 124, 255, 0.24);
}

.comparison-row-label-secondary {
  color: #8b4a4a;
  background: rgba(250, 232, 232, 0.92);
  border: 1px solid rgba(206, 95, 95, 0.24);
}

.comparison-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.comparison-row-primary .semester-card {
  border-color: rgba(79, 124, 255, 0.2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(241, 247, 255, 0.98));
}

.comparison-row-secondary .semester-card {
  border-color: rgba(206, 95, 95, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(252, 242, 242, 0.98));
}

.flat-program-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.semester-note {
  color: var(--warning);
  font-size: 0.85rem;
  font-weight: 600;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(73, 54, 35, 0.18);
  backdrop-filter: blur(10px);
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.modal-content {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(640px, 100%);
  max-height: min(92vh, 980px);
  overflow: auto;
  padding: 24px;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(249, 242, 233, 0.98));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.course-modal-content {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
}

.modal-primary,
.modal-side {
  min-width: 0;
}

.modal-side {
  display: grid;
  gap: 12px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  color: var(--text-muted);
  box-shadow: none;
  font-size: 1.1rem;
}

.modal-title {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.32rem;
  letter-spacing: -0.03em;
}

.modal-desc {
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 0.95rem;
  white-space: pre-line;
}

.modal-section-title {
  margin: 16px 0 10px;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modal-averages {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.modal-averages div {
  display: grid;
  gap: 6px;
  padding: 14px 10px;
  text-align: center;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.modal-averages .value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.35rem;
}

#rating-count,
#search-status,
#add-elective-status {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.modal-rating-row {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.modal-rating-row label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-soft);
  font-size: 0.86rem;
}

.modal-rating-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rating-circle {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
  color: var(--text-muted);
  box-shadow: none;
  font-size: 0.8rem;
}

.rating-circle.selected {
  color: #fffdf9;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  border-color: transparent;
}

#rating-submit,
.mini-graph-reset {
  grid-column: 1 / -1;
  width: 100%;
}

#mini-graph {
  display: grid;
  gap: 12px;
}

.mini-graph-toolbar {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mini-graph-reset {
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  box-shadow: none;
}

.mini-graph-surface {
  height: 380px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(243, 235, 223, 0.98));
}

.search-modal-content,
.compact-modal {
  width: min(480px, 100%);
}

.howto-list {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--text-soft);
}

.howto-list li + li {
  margin-top: 10px;
}

.info-callout {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
}

.info-callout strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.modal-note {
  margin-top: 18px;
  color: var(--text-muted);
}

.site-footer {
  display: grid;
  gap: 4px;
  margin-top: 24px;
  padding: 18px 20px 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

body.modal-open {
  overflow: hidden;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float-halo {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }

  50% {
    transform: translate3d(0, 20px, 0);
  }
}

@media (max-width: 1180px) {
  .app-main {
    grid-template-columns: 1fr;
  }

  .graph-card {
    position: static;
  }

  #graph {
    min-height: 520px;
    height: 520px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px 10px 20px;
  }

  .app-header,
  .panel-header {
    flex-direction: column;
  }

  .utility-panel {
    width: 100%;
  }

  .support-buttons,
  .control-actions {
    width: 100%;
  }

  .support-buttons > button,
  .control-actions > button {
    flex: 1 1 100%;
  }

  .picker-layout {
    grid-template-columns: 1fr;
  }

  .picker-side {
    padding: 14px;
  }

  .control-grid,
  .graph-toggle-row,
  .mini-graph-toolbar,
  .comparison-row,
  .modal-averages {
    grid-template-columns: 1fr;
  }

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

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

  .modal-content {
    padding: 18px;
  }

  .mini-graph-surface {
    height: 320px;
  }
}

@media (max-width: 640px) {
  .brand-mark {
    width: 52px;
    height: 52px;
  }

  .brand-copy h1 {
    font-size: 1.8rem;
  }

  .planner-card,
  .graph-card {
    padding: 16px;
  }

  .controls-card,
  .comparison-header {
    padding: 14px;
  }

  .picker-side,
  .program-result {
    padding-inline: 14px;
  }

  .semester-card {
    padding: 16px;
  }

  #graph {
    min-height: 440px;
    height: 440px;
  }

  #graph::after {
    white-space: normal;
  }
}
