* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #fff;
  --surface-soft: #f8f7f3;
  --text: #1d211f;
  --muted: #69706c;
  --line: #deddd7;
  --brand: #cf233d;
  --brand-dark: #95172a;
  --danger: #e51d45;
  --warning: #f49a16;
  --success-bg: #e2f4e6;
  --success-text: #14532d;
  --shadow: 0 14px 35px rgb(28 34 31 / 7%);
  --radius: 18px;
  --time-height: 62px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #151716;
    --surface: #202321;
    --surface-soft: #272a28;
    --text: #f2f1ec;
    --muted: #aaaead;
    --line: #3b3f3c;
    --success-bg: #183925;
    --success-text: #b9ebc8;
    --shadow: 0 14px 35px rgb(0 0 0 / 18%);
  }
}

html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgb(207 35 61 / 8%), transparent 24rem),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, textarea { font: inherit; }
a { color: inherit; text-underline-offset: 3px; }
button, summary { -webkit-tap-highlight-color: transparent; }

main {
  display: flex;
  width: min(100% - 28px, 1240px);
  flex-direction: column;
  margin: 0 auto;
  padding: 28px 0 40px;
}
.card {
  margin-bottom: 14px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.hero { border-top: 7px solid var(--brand); }
.hero.is-day { border-color: #e5bf00; }
.hero.is-evening { border-color: #4b90d9; }
.hero.is-intensive { border-color: var(--brand); }
.hero__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
}
.eyebrow {
  margin: 0 0 3px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(28px, 4vw, 44px); line-height: 1.05; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -.02em; }
h3 { margin-bottom: 6px; font-size: 14px; }
.intro { max-width: 640px; margin-bottom: 0; color: var(--muted); font-size: 16px; }
.school-logo {
  flex: 0 0 auto;
  display: grid;
  width: 112px;
  height: 80px;
  place-items: center;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}
.school-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.mode-switcher { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 10px; }
.mode-button {
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
}
.mode-button:hover { transform: translateY(-1px); }
.mode-button.is-active { border-color: transparent; background: var(--brand); color: #fff; box-shadow: 0 4px 15px rgb(207 35 61 / 25%); }
.mode-button[data-mode="day"].is-active { background: #e0b900; color: #342900; }
.mode-button[data-mode="eve"].is-active { background: #397fc8; }
.external-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 20px; color: var(--muted); font-size: 13px; }
.progress { margin: 16px 0; }
.progress__labels { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 13px; }
.progress__labels span { color: var(--muted); text-align: right; }
.progress__track { height: 8px; overflow: hidden; border-radius: 99px; background: var(--surface-soft); }
.progress__track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #f25d73); transition: width .25s ease; }
.toolbar, .filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.toolbar { margin: 18px 0 12px; }
button {
  min-height: 34px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgb(47 132 255 / 55%); outline-offset: 2px; }
.help { max-width: 930px; color: var(--muted); font-size: 13px; }
.help summary, .export-card summary { width: fit-content; color: var(--text); font-weight: 750; cursor: pointer; }
.help p { margin: 9px 0 0; }
.inline-info { display: inline-grid; width: 18px; height: 18px; place-items: center; border-radius: 50%; background: var(--text); color: var(--surface); font-size: 11px; font-weight: 900; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 15px; }
.section-heading > p { max-width: 510px; margin: 0; color: var(--muted); font-size: 12px; text-align: right; }
.tray-target { margin: -4px 0 8px; font-size: 11px; }
.tray-target:not(:disabled) { border-color: var(--brand); color: var(--brand); font-weight: 750; }
.tray-target:disabled { cursor: not-allowed; opacity: .48; }
.course-tray { display: flex; min-height: 52px; flex-wrap: wrap; gap: 7px; padding: 8px; border: 1px dashed var(--line); border-radius: 12px; }
.is-over { background: rgb(88 125 106 / 12%) !important; }
.empty-message { align-self: center; padding: 6px; color: var(--muted); font-size: 13px; }
.scroll-area { overflow-x: auto; scrollbar-color: var(--line) transparent; }

.curriculum-table { width: 100%; min-width: 920px; border-collapse: separate; border-spacing: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.curriculum-table th, .curriculum-table td { padding: 6px; vertical-align: top; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.curriculum-table tr:last-child th { border-bottom: 0; }
.curriculum-table th:last-child, .curriculum-table td:last-child { border-right: 0; }
.curriculum-table th { background: var(--surface-soft); font-size: 12px; text-align: left; }
.curriculum-table td { min-width: 132px; }
.curriculum-table .subject-heading { width: 150px; min-width: 150px; }
.semester-heading label { display: flex; gap: 5px; align-items: center; }
.insert-semester, .semester-target { display: block; min-height: 23px; margin-top: 5px; padding: 1px 6px; font-size: 10px; font-weight: 500; }
.semester-target:not(:disabled) { border-color: var(--brand); color: var(--brand); font-weight: 750; }
.semester-target:disabled { cursor: not-allowed; opacity: .48; }
.credits-row th { text-align: center; }

.course-pill {
  position: relative;
  display: flex;
  min-width: 0;
  gap: 7px;
  align-items: flex-start;
  justify-content: space-between;
  margin: 2px 0;
  padding: 7px;
  border: 2px solid transparent;
  border-radius: 9px;
  background: #52625a;
  color: #fff;
  font-size: 11px;
  line-height: 1.25;
  cursor: grab;
}
.course-tray .course-pill { width: min(100%, 275px); margin: 0; }
.course-pill.is-selected { outline: 3px solid var(--text); outline-offset: 1px; }
.course-pill.is-conflict { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.course-pill.is-prerequisite { border-color: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.course-pill__copy { min-width: 0; }
.course-pill__code { display: block; font-size: 11px; letter-spacing: .01em; }
.course-pill__title { display: block; margin-top: 2px; font-weight: 720; hyphens: auto; overflow-wrap: anywhere; }
.course-pill__time { display: block; margin-top: 3px; opacity: .8; font-size: 9px; }
.course-pill__actions { display: flex; flex: 0 0 auto; gap: 3px; align-items: center; }
.course-pill__actions button, .schedule-block button {
  min-width: 23px;
  min-height: 23px;
  padding: 0 5px;
  border: 0;
  border-radius: 6px;
  background: rgb(255 255 255 / 22%);
  color: inherit;
  font-size: 11px;
  line-height: 23px;
}
.course-pill__actions .info-button, .schedule-block .info-button { border: 1px solid rgb(255 255 255 / 45%); border-radius: 50%; font-weight: 900; }
.course-pill__warning { margin-right: 3px; }

.warnings { max-height: 130px; overflow: auto; }
.notice { margin: 0 0 10px; padding: 11px 13px; border-radius: 11px; background: var(--success-bg); color: var(--success-text); font-size: 13px; font-weight: 700; }
.notice--danger { background: var(--danger); color: #fff; }
.notice--warning { background: var(--warning); color: #241703; }
.notice small { display: block; margin-top: 3px; font-weight: 550; }
.filter-row { margin: 9px 0; }
.filter-row strong { margin-right: 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.filter-row button { min-height: 30px; padding: 3px 10px; font-size: 12px; }
.filter-row button.is-active { background: var(--text); color: var(--surface); }

.schedule-grid { min-width: 1080px; background: var(--surface-soft); }
.schedule-header, .semester-grid { display: grid; grid-template-columns: 96px 94px repeat(8, minmax(0, 1fr)); }
.schedule-header { position: sticky; top: 0; z-index: 20; background: var(--surface-soft); }
.day-heading { padding: 5px 0 2px; text-align: center; font-weight: 750; }
.week-heading { padding-bottom: 6px; color: var(--muted); font-size: 9px; text-align: center; }
.semester-grid { position: relative; grid-template-rows: repeat(7, minmax(var(--time-height), auto)); margin-bottom: 16px; border: 1px solid var(--line); background: var(--surface); }
.semester-label { padding: 8px; border-right: 1px solid var(--line); background: var(--surface-soft); font-weight: 750; }
.semester-label label { display: flex; gap: 4px; align-items: flex-start; }
.semester-alert { margin-top: 7px; color: var(--danger); font-size: 10px; font-weight: 850; }
.time-label { padding: 5px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-soft); color: var(--muted); font-size: 10px; }
.grid-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: linear-gradient(to right, transparent calc(50% - .5px), var(--line) 0, var(--line) calc(50% + .5px), transparent 0); }
.schedule-block {
  position: relative;
  z-index: 2;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  margin: 3px;
  padding: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  color: #fff;
  font-size: 10px;
  line-height: 1.18;
  overflow-wrap: anywhere;
  cursor: grab;
}
.schedule-block.is-selected { outline: 3px solid var(--text); }
.schedule-block.is-conflict { z-index: 10; border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.schedule-block.is-prerequisite { border-color: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.schedule-block__code { font-size: 10px; }
.schedule-block__title { font-weight: 760; }
.schedule-block__weeks, .schedule-block__time { opacity: .82; font-size: 9px; }
.schedule-block__actions { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; padding-top: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 7px 15px; margin-top: 9px; font-size: 11px; }
.legend i { display: inline-block; width: 11px; height: 11px; margin-right: 4px; border-radius: 3px; vertical-align: -1px; }
.weekend-note { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.export-card p { margin: 7px 0; color: var(--muted); font-size: 12px; }
textarea { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); color: var(--text); font-family: ui-monospace, monospace; font-size: 12px; resize: vertical; }
footer { padding: 16px 8px; color: var(--muted); font-size: 11px; }
footer p { margin-bottom: 5px; }

#course-dialog {
  width: min(600px, calc(100% - 28px));
  max-height: min(740px, calc(100dvh - 28px));
  padding: 28px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgb(0 0 0 / 28%);
}
#course-dialog::backdrop { background: rgb(13 18 15 / 65%); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: 13px; right: 13px; width: 34px; padding: 0; border-radius: 50%; font-size: 22px; }
.dialog-code { margin-bottom: 3px; color: var(--brand); font-size: 12px; font-weight: 850; letter-spacing: .08em; }
#course-dialog h2 { max-width: calc(100% - 35px); margin-bottom: 5px; font-size: 27px; }
.dialog-meta { color: var(--muted); font-size: 13px; }
.dialog-section { margin: 20px 0; padding-top: 16px; border-top: 1px solid var(--line); }
.dialog-section p { margin-bottom: 0; }
.source-link { display: inline-block; margin-top: 4px; color: var(--brand); font-weight: 700; }

@media (max-width: 700px) {
  main { width: min(100% - 16px, 1240px); padding-top: 8px; }
  .card { padding: 15px; border-radius: 14px; }
  .hero__heading { gap: 12px; }
  .school-logo { width: 80px; height: 59px; padding: 6px; }
  .intro { font-size: 14px; }
  .mode-switcher { display: grid; grid-template-columns: 1fr; }
  .mode-button { width: 100%; }
  .progress__labels, .section-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .progress__labels span, .section-heading > p { text-align: left; }
  .toolbar button { flex: 1 1 145px; }
  .course-tray .course-pill { width: 100%; }
  #course-dialog { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
