@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&family=Noto+Serif+SC:wght@500;700&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-soft: #f0f3f5;
  --text: #182026;
  --muted: #64717d;
  --line: #dce2e6;
  --accent: #1f7a5f;
  --accent-dark: #145c47;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(24, 32, 38, 0.08);
  --chat-sand: #f9efe1;
  --chat-ink: #13211a;
  --chat-moss: #0f6a52;
  --chat-moss-dark: #0b4d3c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 900px at 12% 8%, #fff7e8 0, rgba(255, 247, 232, 0) 55%),
    radial-gradient(900px 700px at 85% 12%, #e6f5ef 0, rgba(230, 245, 239, 0) 55%),
    var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", "Space Grotesk", sans-serif;
}

a {
  color: inherit;
}

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

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.site-footer {
  padding: 0 28px 28px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.site-footer-copy {
  margin: 0 0 8px;
}

.site-footer a {
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.module-tab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.module-tab:hover,
.module-tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.module-view {
  display: none;
}

.module-view.is-active {
  display: block;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.15;
  font-family: "Noto Serif SC", "Noto Sans SC", serif;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  font-family: "Noto Serif SC", "Noto Sans SC", serif;
}

h3 {
  margin-bottom: 10px;
  font-size: 17px;
}

.term-box,
.field {
  display: grid;
  gap: 7px;
}

.term-box label,
.field span,
.check-field span,
.elective-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 560px) 1fr;
  gap: 22px;
  align-items: start;
}

.panel,
.results {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.results {
  min-height: 560px;
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.time-slider-section {
  display: grid;
  gap: 18px;
}

.time-slider-field {
  display: grid;
  gap: 9px;
}

.time-slider-field > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.time-slider-field output {
  color: var(--text);
  font-weight: 900;
}

.time-range {
  width: 100%;
  height: 15px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to right,
    var(--range-color) 0,
    var(--range-color) calc((100% - 72px) / 7),
    transparent calc((100% - 72px) / 7),
    transparent calc((100% - 72px) / 7 + 12px)
  );
  cursor: pointer;
  appearance: none;
}

.time-range-early {
  --range-color: #b9d7fb;
}

.time-range-afternoon {
  --range-color: #ffd11f;
}

.time-range::-webkit-slider-thumb {
  width: 23px;
  height: 23px;
  border: 0;
  border-radius: 999px;
  background: #ffa3a8;
  cursor: grab;
  appearance: none;
}

.time-range::-moz-range-thumb {
  width: 23px;
  height: 23px;
  border: 0;
  border-radius: 999px;
  background: #ffa3a8;
  cursor: grab;
}

.time-range:active::-webkit-slider-thumb {
  cursor: grabbing;
}

.time-range:active::-moz-range-thumb {
  cursor: grabbing;
}

.range-scale {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.qa-widget {
  position: fixed;
  left: var(--qa-left, 16px);
  bottom: 32px;
  z-index: 30;
  --qa-width-adjust: 1px;
  width: calc(min(360px, calc(100vw - 56px)) + var(--qa-width-adjust));
  height: 360px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(15, 106, 82, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.qa-widget.is-hidden {
  display: none;
}

.qa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.qa-status {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--chat-moss-dark);
  background: rgba(15, 106, 82, 0.12);
}

.qa-status[data-state="busy"] {
  color: #8a4b00;
  background: rgba(250, 181, 79, 0.25);
}

.qa-messages {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 2px 2px 8px;
}

.qa-message {
  display: flex;
}

.qa-message-user {
  justify-content: flex-end;
}

.qa-bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 14px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.qa-message-assistant .qa-bubble {
  background: var(--chat-sand);
  color: var(--chat-ink);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.qa-message-user .qa-bubble {
  background: var(--chat-moss);
  color: #fff;
}

.qa-bubble p {
  margin: 0 0 6px;
}

.qa-bubble p:last-child {
  margin-bottom: 0;
}

.qa-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.qa-input textarea {
  min-height: 64px;
  max-height: 96px;
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
}

.qa-input button {
  min-width: 74px;
  border-radius: 12px;
}

.qa-hint {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .qa-widget {
    bottom: 16px;
    width: calc(100vw - 56px);
    height: 320px;
  }
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding-top: 22px;
}

.check-field input {
  width: 18px;
  height: 18px;
}

.elective-section {
  display: grid;
  gap: 12px;
}

.elective-toolbar,
.elective-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.elective-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.elective-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  padding: 0;
  background: #5267f5;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  line-height: 0;
  text-align: center;
}

.icon-button:hover {
  background: #4053d6;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.elective-groups {
  display: grid;
  gap: 14px;
}

.elective-group {
  display: grid;
  gap: 8px;
}

.elective-group-name {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.elective-count {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.elective-count input {
  width: 50px;
  height: 34px;
  border-color: #5267f5;
  border-radius: 10px;
  background: #5267f5;
  color: #fff;
  padding: 5px 4px;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
}

.elective-count input::-webkit-outer-spin-button,
.elective-count input::-webkit-inner-spin-button {
  margin: 0;
}

.elective-courses {
  min-height: 112px;
}

#targetCourses.is-course-drop-target,
.elective-courses.is-course-drop-target,
#timePreferenceExcludedCourses.is-course-drop-target {
  border-color: #5267f5;
  box-shadow: 0 0 0 3px rgba(82, 103, 245, 0.18);
}

.teacher-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.teacher-section summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.teacher-section-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.teacher-preference-cards {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.empty-teacher-state {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.teacher-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef0f2;
}

.teacher-card-heading {
  padding: 14px 16px 8px;
}

.teacher-course-code {
  color: #111820;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.05;
}

.teacher-course-name {
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.3;
}

.teacher-pools {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  padding: 12px;
}

.teacher-drop-zone {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 150px;
  border: 2px solid transparent;
  border-radius: 22px;
  padding: 14px;
  transition: border-color 120ms ease, transform 120ms ease;
}

.teacher-drop-zone-preferred {
  background: #ffa3a8;
}

.teacher-drop-zone-pool {
  background: #b9d7fb;
}

.teacher-drop-zone-blocked {
  background: #fff3bc;
}

.teacher-drop-zone.is-drag-over {
  border-color: #5267f5;
  transform: translateY(-1px);
}

.teacher-zone-title {
  color: #111820;
  font-size: 16px;
  font-weight: 900;
}

.teacher-pill-list {
  display: grid;
  gap: 8px;
}

.teacher-pill {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 2px;
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.82);
  color: #111820;
  cursor: grab;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  touch-action: manipulation;
}

.teacher-rating-badge {
  grid-column: 1;
  display: inline-grid;
  place-items: center;
  width: 20px;
  min-width: 20px;
  line-height: 1;
}

.teacher-rating-badge-warning {
  color: #b7791f;
}

.teacher-pill-name {
  grid-column: 2;
  overflow-wrap: anywhere;
  text-align: center;
}

.teacher-pill:hover {
  background: #fff;
  color: #111820;
}

.teacher-pill:active {
  cursor: grabbing;
}

.teacher-pill.is-selected {
  outline: 3px solid #5267f5;
  outline-offset: 2px;
  background: #fff;
}

.empty-pool {
  display: block;
  border: 1px dashed rgba(17, 24, 32, 0.25);
  border-radius: 999px;
  padding: 8px 10px;
  color: rgba(17, 24, 32, 0.52);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.course-browser {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.course-browser summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.course-browser input {
  margin: 12px 0;
}

.course-browser-hint {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.course-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.course-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--surface-soft);
  cursor: grab;
  touch-action: manipulation;
  user-select: none;
}

.course-item:active {
  cursor: grabbing;
}

.course-item.is-selected {
  border-color: #5267f5;
  box-shadow: 0 0 0 3px rgba(82, 103, 245, 0.18);
  background: #fff;
}

.course-drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  border: 1px solid #5267f5;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(24, 32, 38, 0.18);
  color: #111820;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 900;
}

.course-code {
  font-weight: 800;
}

.course-name,
.course-extra {
  color: var(--muted);
  font-size: 12px;
}

.message {
  margin: 14px 0;
  color: var(--danger);
  font-weight: 700;
}

.schedule-results {
  display: grid;
  gap: 18px;
  margin-top: 16px;
}

.schedule-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.schedule-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  background: var(--surface-soft);
}

.score {
  color: var(--accent-dark);
  font-weight: 800;
  white-space: nowrap;
}

.weekly-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.weekly-table {
  width: max(100%, 1180px);
  border-collapse: collapse;
  table-layout: fixed;
}

.time-table-col {
  width: 120px;
}

.day-table-col {
  width: 151px;
}

.weekly-table th,
.weekly-table td {
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
  font-size: 13px;
}

.weekly-table th:last-child,
.weekly-table td:last-child {
  border-right: 0;
}

.weekly-table th {
  background: #fbfcfc;
  text-align: left;
}

.time-col {
  width: 120px;
  color: var(--muted);
  font-weight: 700;
}

.meeting-block {
  display: grid;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
  border-left: 4px solid var(--course-color, var(--accent));
  border-radius: 4px;
  background: var(--course-bg, #e9f5f0);
  padding: 8px;
}

.meeting-block + .meeting-block {
  margin-top: 8px;
}

.meeting-title {
  font-weight: 800;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meeting-detail {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.course-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px 14px;
}

.course-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 960px) {
  .app-shell {
    padding: 18px;
  }

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

  .toolbar {
    display: grid;
    align-items: stretch;
  }

  .workspace {
    display: grid;
  }

  .teacher-pools {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .two-col {
    grid-template-columns: 1fr;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .weekly-table {
    min-width: 760px;
  }

  .schedule-card {
    overflow-x: auto;
  }
}
