:root {
  color-scheme: light;
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8f9fb;
  --surface-blue: #eef4ff;
  --ink: #18212f;
  --muted: #566273;
  --faint: #778294;
  --line: #d8dee7;
  --line-strong: #bcc6d3;
  --primary: #1f4fbd;
  --primary-hover: #173f9c;
  --primary-soft: #e8efff;
  --success: #087f5b;
  --success-soft: #e8f6f1;
  --warning: #9a6700;
  --warning-soft: #fff4d6;
  --danger: #b42318;
  --danger-hover: #8f1c13;
  --danger-soft: #fff0ee;
  --lecture: #087f5b;
  --practice: #6941c6;
  --lab: #c5520a;
  --conflict: #c52828;
  --header-height: 64px;
  --rail-width: 352px;
  --radius: 4px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: "Avenir Next", Avenir, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-height);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding-right: env(safe-area-inset-right);
  padding-left: env(safe-area-inset-left);
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button,
a,
input,
select {
  touch-action: manipulation;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
}

button,
input,
select {
  letter-spacing: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 3px solid #79a1ff;
  outline-offset: 2px;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  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 {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(230px, 1fr);
  align-items: center;
  min-height: var(--header-height);
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-strong);
}

.product-mark {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.product-symbol {
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
  line-height: 1;
}

.product-mark h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-nav {
  align-self: stretch;
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.primary-nav-item {
  position: relative;
  display: inline-flex;
  min-width: 138px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}

.primary-nav-item::after {
  position: absolute;
  right: 18px;
  bottom: -1px;
  left: 18px;
  height: 3px;
  background: transparent;
  content: "";
}

.primary-nav-item:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.primary-nav-item.active {
  color: var(--primary);
}

.primary-nav-item.active::after {
  background: var(--primary);
}

.header-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.language-control {
  display: inline-flex;
  height: 34px;
  align-items: center;
  gap: 3px;
  padding-left: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.language-control svg {
  width: 16px;
  height: 16px;
}

.language-control select {
  height: 32px;
  padding: 0 24px 0 4px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.status-pill {
  display: inline-flex;
  min-width: 0;
  max-width: 240px;
  height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.status-pill span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.status-pill.connected {
  border-color: #8bcdb7;
  background: var(--success-soft);
  color: #075f45;
}

.status-pill.connected .status-dot {
  background: var(--success);
}

.status-pill.warning {
  border-color: #e6c56d;
  background: var(--warning-soft);
  color: #704b00;
}

.status-pill.warning .status-dot {
  background: #c58a00;
}

.status-pill.error {
  border-color: #e4a49e;
  background: var(--danger-soft);
  color: #8f1c13;
}

.status-pill.error .status-dot {
  background: var(--danger);
}

.logout-button,
.refresh-button {
  display: inline-flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.logout-button {
  border-color: #d88880;
  color: var(--danger);
}

.logout-button:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.refresh-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.identity-strip {
  background: var(--surface-blue);
  border-bottom: 1px solid #cbd8f0;
}

.student-profile {
  display: grid;
  max-width: 1600px;
  min-height: 78px;
  grid-template-columns: auto minmax(210px, 1fr) minmax(520px, 2.1fr);
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  margin: 0 auto;
}

.student-avatar {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
}

.student-heading {
  min-width: 0;
}

.student-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-notice {
  margin-top: 3px;
  color: #704b00;
  font-size: 12px;
  font-weight: 600;
}

.student-meta {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(120px, 0.8fr) minmax(220px, 2fr) minmax(90px, 0.6fr);
  margin: 0;
  border: 1px solid #cbd8f0;
  background: rgba(255, 255, 255, 0.68);
}

.student-meta > div {
  min-width: 0;
  padding: 7px 12px;
  border-left: 1px solid #cbd8f0;
}

.student-meta > div:first-child {
  border-left: 0;
}

.student-meta dt {
  margin: 0 0 1px;
  color: #4e5f7b;
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.student-meta dd {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-meta > div:nth-child(2) dd {
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.workspace {
  display: grid;
  width: 100%;
  max-width: 1600px;
  min-height: calc(100vh - var(--header-height));
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  margin: 0 auto;
  background: var(--surface);
}

.mobile-schedule-nav,
.mobile-day-tabs {
  display: none;
}

.task-rail {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  max-height: calc(100vh - var(--header-height));
  max-height: calc(100dvh - var(--header-height));
  overflow-y: auto;
  background: var(--surface-soft);
  border-right: 1px solid var(--line-strong);
}

.rail-section {
  padding: 18px 20px 20px;
  border-bottom: 1px solid var(--line);
}

.rail-section:last-child {
  border-bottom: 0;
}

.session-authenticated .auth-section {
  display: none;
}

.rail-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.rail-heading h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.rail-index {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--faint);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
}

.privacy-note {
  max-width: 34ch;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.auth-form,
.code-form,
#searchForm {
  display: grid;
  gap: 7px;
}

.auth-form {
  margin-bottom: 12px;
}

label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

input::placeholder {
  color: #6a7584;
  opacity: 1;
}

input:hover:not(:disabled) {
  border-color: #8b98aa;
}

input:disabled {
  border-color: var(--line);
  background: #eef1f4;
  color: #737d8b;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.primary-button,
.save-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-weight: 750;
}

.primary-button:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.save-button {
  border-color: #086b4f;
  background: #086b4f;
}

.save-button:hover:not(:disabled) {
  border-color: #04513c;
  background: #04513c;
}

.primary-button:disabled,
.save-button:disabled,
.refresh-button:disabled {
  border-color: #cbd1da;
  background: #e4e7ec;
  color: #687383;
}

.wide {
  width: 100%;
}

.result-section {
  min-height: 150px;
}

.empty-state {
  padding: 13px 0;
  color: var(--muted);
  font-size: 12px;
}

.inline-state {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.inline-state.loading {
  border-color: #a9bde9;
  background: var(--primary-soft);
  color: #173f9c;
  font-weight: 700;
}

.inline-state.error {
  border-color: #e5a6a0;
  background: var(--danger-soft);
  color: #8f1c13;
  font-weight: 700;
}

.course-title {
  margin-bottom: 14px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.section-group {
  margin-top: 14px;
}

.section-group h3 {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.section-card {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  padding: 10px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.section-card:hover {
  border-color: #9da9b8;
}

.section-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.section-card input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.section-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.section-line {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.type-badge {
  flex: 0 0 auto;
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 800;
}

.type-badge.N {
  color: var(--lecture);
}

.type-badge.P {
  color: var(--practice);
}

.type-badge.L {
  color: var(--lab);
}

.section-meta,
.section-time {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
}

.section-time {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.conflict-note {
  padding: 9px 10px;
  margin-top: 10px;
  border: 1px solid #e5a6a0;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: #8f1c13;
  font-size: 11px;
  font-weight: 700;
}

.add-area {
  margin-top: 12px;
}

.selected-list {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.selected-list.empty-state {
  display: block;
}

.selected-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.selected-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: start;
  gap: 7px;
  padding: 9px;
}

.selected-title {
  font-size: 12px;
  font-weight: 850;
}

.selected-detail {
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.remove-button {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid #e2aaa5;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--danger);
  font-size: 18px;
  line-height: 1;
}

.remove-button:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.schedule-canvas {
  min-width: 0;
  background: var(--surface);
}

.surface-toolbar {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-strong);
}

.surface-toolbar h2,
.program-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.legend,
.program-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 11px;
}

.legend span,
.program-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend b,
.program-legend b {
  font-weight: 650;
}

.legend-dot,
.program-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

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

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

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

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

.schedule-wrap {
  max-width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.schedule-table {
  width: 100%;
  min-width: 890px;
  border-spacing: 0;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}

.schedule-table thead {
  position: sticky;
  top: 0;
  z-index: 4;
}

.schedule-table th,
.schedule-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

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

.schedule-table thead th {
  height: 42px;
  padding: 0 9px;
  background: #edf0f4;
  color: #344054;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}

.schedule-table thead th:first-child {
  width: 68px;
  text-align: center;
}

.schedule-table tbody tr {
  height: 69px;
}

.schedule-time {
  width: 68px;
  padding: 8px 7px;
  background: var(--surface-soft);
  color: #465264;
  font-size: 11px;
  font-weight: 750;
  text-align: center;
  vertical-align: top;
}

.schedule-cell {
  min-width: 0;
  padding: 4px;
  background: var(--surface);
  vertical-align: top;
}

.schedule-cell:hover {
  background: #fafbfd;
}

.slot-stack {
  display: grid;
  gap: 3px;
}

.event-block {
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid currentColor;
  border-radius: 3px;
  background: var(--surface);
  color: var(--lecture);
}

.event-block.P {
  color: var(--practice);
}

.event-block.L {
  color: var(--lab);
}

.event-block.conflict {
  border-color: #9f1717;
  background: var(--conflict);
  color: #ffffff;
}

.event-block strong,
.event-block small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-block strong {
  font-size: 10px;
  font-weight: 850;
}

.event-block small {
  margin-top: 1px;
  color: inherit;
  font-size: 9px;
  font-weight: 650;
}

.event-conflict-label {
  display: block;
  margin-bottom: 2px;
  color: #ffffff;
  font-size: 8px;
  font-weight: 850;
  text-transform: uppercase;
}

.program-panel {
  width: 100%;
  max-width: 1600px;
  min-height: calc(100vh - var(--header-height));
  margin: 0 auto;
  background: var(--surface);
}

.program-head {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line-strong);
}

.program-meta {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.program-state {
  max-width: 760px;
  padding: 18px 24px;
  color: var(--muted);
}

.program-state.loading {
  color: var(--primary);
  font-weight: 700;
}

.program-state.error {
  max-width: none;
  margin: 20px 24px;
  border: 1px solid #e5a6a0;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: #8f1c13;
  font-weight: 700;
}

.program-summary {
  display: flex;
  min-height: 50px;
  align-items: stretch;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.program-summary > div {
  display: flex;
  min-width: 120px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border-right: 1px solid var(--line);
}

.program-summary > div:first-child {
  padding-left: 0;
}

.program-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.program-summary strong {
  color: var(--ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.program-toolbar {
  position: sticky;
  top: var(--header-height);
  z-index: 10;
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface);
}

.semester-tabs {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.semester-tab {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.semester-tab:hover {
  border-color: #8b98aa;
  color: var(--ink);
}

.semester-tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.program-status-dot.passed {
  background: var(--success);
}

.program-status-dot.not-taken {
  background: var(--faint);
}

.program-status-dot.taken {
  background: var(--primary);
}

.program-status-dot.failed {
  background: var(--danger);
}

.semester-list {
  padding: 0 24px 32px;
}

.semester-section {
  padding-top: 26px;
}

.semester-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}

.semester-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.semester-head span {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.program-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line-strong);
}

.program-table {
  width: 100%;
  min-width: 1000px;
  border-spacing: 0;
  table-layout: fixed;
}

.program-table th,
.program-table td {
  padding: 9px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

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

.program-table tbody tr:last-child td {
  border-bottom: 0;
}

.program-table thead th {
  background: #edf0f4;
  color: #465264;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.program-table th:nth-child(1) {
  width: 108px;
}

.program-table th:nth-child(2) {
  width: 36%;
}

.program-table th:nth-child(n + 3):nth-child(-n + 7) {
  width: 72px;
}

.program-table th:nth-child(8) {
  width: 110px;
}

.program-table th:last-child {
  width: 190px;
}

.program-table td {
  color: #344054;
  font-size: 12px;
}

.program-table td strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 700;
}

.program-table td small {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 10px;
}

.program-code,
.program-grade {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.program-status {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.program-status.passed {
  border-color: #8bcdb7;
  background: var(--success-soft);
  color: #075f45;
}

.program-status.taken {
  border-color: #a9bde9;
  background: var(--primary-soft);
  color: #173f9c;
}

.program-status.failed {
  border-color: #e5a6a0;
  background: var(--danger-soft);
  color: #8f1c13;
}

.program-action-cell {
  vertical-align: middle !important;
}

.program-action-button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--primary);
  font-size: 11px;
  font-weight: 750;
}

.program-action-button:hover:not(:disabled) {
  background: var(--primary-soft);
}

.program-action-button:disabled {
  border-color: var(--line);
  background: #eef1f4;
  color: #737d8b;
}

.program-action-button > span:first-child {
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
}

.program-elective-control {
  display: grid;
  width: 100%;
  gap: 6px;
}

.program-elective-label {
  display: grid;
  min-width: 0;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.program-elective-select {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 0 28px 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.program-elective-submit {
  width: 100%;
}

.program-added {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--success);
  font-size: 11px;
  font-weight: 750;
}

.program-added-code {
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 100;
  max-width: min(420px, calc(100vw - 36px));
  padding: 11px 14px;
  border: 1px solid #2b3747;
  border-radius: var(--radius);
  background: #18212f;
  color: #ffffff;
  font-size: 12px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    transform 180ms var(--ease-out),
    opacity 180ms var(--ease-out);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (pointer: coarse) {
  .primary-nav-item,
  .logout-button,
  .refresh-button,
  .language-control,
  .language-control select,
  .semester-tab,
  .primary-button,
  .save-button,
  .program-action-button,
  .program-elective-select,
  input:not([type="radio"]) {
    min-height: 44px;
  }
}

@media (max-width: 1120px) {
  .app-header {
    grid-template-columns: minmax(190px, 1fr) auto auto;
    padding: 0 16px;
  }

  .product-mark h1 {
    max-width: 190px;
  }

  .primary-nav-item {
    min-width: 118px;
    padding: 0 12px;
  }

  .status-pill {
    max-width: 150px;
  }

  .student-profile {
    grid-template-columns: auto minmax(180px, 0.8fr) minmax(440px, 2fr);
    padding-right: 16px;
    padding-left: 16px;
  }

  .workspace {
    grid-template-columns: 324px minmax(0, 1fr);
  }

  .program-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 860px) {
  :root {
    --header-height: 112px;
  }

  .app-header {
    position: sticky;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 56px 56px;
    padding: 0 14px;
  }

  .product-mark {
    grid-column: 1;
    grid-row: 1;
  }

  .product-mark h1 {
    max-width: none;
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .status-pill {
    max-width: 132px;
  }

  .primary-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: stretch;
    border-top: 1px solid var(--line);
  }

  .primary-nav-item {
    flex: 1 1 50%;
    min-width: 0;
  }

  .student-profile {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .student-meta {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1.8fr 0.7fr;
  }

  .workspace {
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .task-rail {
    position: static;
    display: grid;
    max-height: none;
    grid-template-columns: 1fr 1fr;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }

  .rail-section {
    border-right: 1px solid var(--line);
  }

  .rail-section:nth-child(even) {
    border-right: 0;
  }

  .session-authenticated .search-section {
    grid-column: 1;
  }

  .session-authenticated .result-section {
    grid-column: 2;
  }

  .session-authenticated .selected-section {
    grid-column: 1 / -1;
  }

  .surface-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .schedule-table {
    min-width: 820px;
  }

  .program-panel {
    min-height: 0;
  }

  .program-toolbar {
    top: var(--header-height);
  }

  .primary-nav-item,
  .logout-button,
  .refresh-button,
  .language-control,
  .language-control select,
  .semester-tab,
  .primary-button,
  .save-button,
  .program-action-button,
  .program-elective-select,
  input:not([type="radio"]) {
    min-height: 44px;
  }
}

@media (max-width: 620px) {
  :root {
    --header-height: calc(108px + env(safe-area-inset-top));
  }

  body {
    font-size: 14px;
  }

  .app-header {
    grid-template-rows: 56px 52px;
    padding: env(safe-area-inset-top) 10px 0;
  }

  .product-symbol {
    flex-basis: 28px;
    width: 28px;
    height: 28px;
  }

  .product-mark {
    gap: 8px;
  }

  .product-mark h1 {
    font-size: 14px;
  }

  .header-actions {
    gap: 5px;
  }

  .status-pill {
    max-width: 88px;
    height: 44px;
    padding: 0 8px;
  }

  .language-control {
    width: 64px;
    height: 44px;
    padding-left: 5px;
  }

  .language-control svg {
    display: none;
  }

  .language-control select {
    width: 100%;
    height: 44px;
    padding-right: 17px;
    padding-left: 3px;
    font-size: 16px;
  }

  .logout-button {
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .logout-button span {
    display: none;
  }

  .primary-nav-item {
    min-height: 52px;
    padding: 0 8px;
    font-size: 12px;
  }

  .student-profile {
    min-height: 0;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 9px;
    padding: 10px;
  }

  .student-avatar {
    width: 36px;
    height: 36px;
    font-size: 12px;
  }

  .student-name {
    font-size: 13px;
  }

  .student-meta {
    grid-template-columns: 1fr 1fr;
  }

  .student-meta > div {
    padding: 6px 8px;
  }

  .student-meta > div:nth-child(3) {
    grid-column: 1 / -1;
    border-top: 1px solid #cbd8f0;
    border-left: 0;
  }

  .student-meta dt {
    font-size: 9px;
  }

  .student-meta dd {
    font-size: 11px;
  }

  .task-rail {
    display: block;
  }

  .workspace {
    display: block;
  }

  .mobile-schedule-nav {
    position: sticky;
    top: var(--header-height);
    z-index: 24;
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 52px;
    border-bottom: 1px solid var(--line-strong);
    background: var(--surface);
  }

  .mobile-schedule-tab {
    position: relative;
    display: inline-flex;
    min-width: 0;
    min-height: 52px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 750;
  }

  .mobile-schedule-tab::after {
    position: absolute;
    right: 14px;
    bottom: -1px;
    left: 14px;
    height: 3px;
    background: transparent;
    content: "";
  }

  .mobile-schedule-tab.active {
    color: var(--primary);
  }

  .mobile-schedule-tab.active::after {
    background: var(--primary);
  }

  .workspace.mobile-week .task-rail {
    display: none;
  }

  .workspace:not(.mobile-week) .schedule-canvas {
    display: none;
  }

  .rail-section {
    padding: 15px 14px 17px;
    border-right: 0;
  }

  .rail-section input:not([type="radio"]),
  .rail-section button {
    min-height: 44px;
  }

  .rail-section input:not([type="radio"]) {
    font-size: 16px;
  }

  .section-card {
    min-height: 52px;
    padding: 12px 10px;
  }

  .selected-top {
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center;
  }

  .remove-button {
    width: 44px;
    height: 44px;
  }

  .surface-toolbar {
    min-height: 0;
    padding: 12px 14px;
  }

  .surface-toolbar h2,
  .program-head h2 {
    font-size: 15px;
  }

  .legend {
    gap: 5px 10px;
  }

  .mobile-day-tabs {
    position: sticky;
    top: calc(var(--header-height) + 52px);
    z-index: 18;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 3px;
    padding: 6px;
    border-bottom: 1px solid var(--line-strong);
    background: var(--surface);
  }

  .mobile-day-tab {
    min-width: 0;
    height: 44px;
    padding: 0 2px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-day-tab.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
  }

  .schedule-table {
    width: 100%;
    min-width: 0;
  }

  .schedule-table [data-day] {
    display: none;
  }

  .schedule-table .active-day-column {
    display: table-cell;
  }

  .schedule-table thead {
    position: static;
  }

  .schedule-table thead th:first-child,
  .schedule-time {
    width: 64px;
  }

  .schedule-table tbody tr {
    height: 72px;
  }

  .event-block strong,
  .event-block small {
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
  }

  .program-head {
    min-height: 66px;
    padding: 11px 14px;
  }

  .refresh-button {
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .refresh-button span {
    display: none;
  }

  .program-state {
    padding: 16px 14px;
  }

  .program-state.error {
    margin: 14px;
  }

  .program-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 0 14px;
    overflow: visible;
  }

  .program-summary > div {
    min-width: 0;
    gap: 4px;
    padding: 8px;
    flex-direction: column;
    justify-content: center;
    text-align: center;
  }

  .program-toolbar {
    gap: 9px;
    padding: 9px 14px;
  }

  .semester-tabs {
    width: 100%;
    padding-bottom: 2px;
  }

  .semester-tab {
    min-height: 44px;
  }

  .program-legend {
    width: 100%;
    flex-wrap: nowrap;
    gap: 5px 9px;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .program-legend span {
    flex: 0 0 auto;
  }

  .semester-list {
    padding: 0 14px 24px;
  }

  .semester-section {
    padding-top: 20px;
  }

  .semester-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .program-table-wrap {
    overflow: visible;
    border: 0;
  }

  .program-table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .program-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .program-table tbody {
    display: grid;
    gap: 10px;
  }

  .program-table tbody tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
  }

  .program-table td {
    display: block;
    min-width: 0;
    padding: 9px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  .program-table td::before {
    display: block;
    margin-bottom: 2px;
    color: var(--faint);
    content: attr(data-label);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .program-table .program-code,
  .program-table .program-course-name {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .program-table .program-code {
    background: #edf0f4;
  }

  .program-table td:nth-child(5),
  .program-table td:nth-child(8) {
    border-right: 0;
  }

  .program-table td:nth-child(n + 6) {
    border-bottom: 0;
  }

  .program-table .program-action-cell {
    display: flex;
    min-height: 62px;
    grid-column: 1 / -1;
    align-items: center;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .program-table .program-action-cell::before {
    display: none;
  }

  .program-table .program-action-cell.empty-action {
    display: none;
  }

  .program-action-button {
    width: 100%;
    min-height: 44px;
  }

  .program-elective-select {
    min-height: 44px;
    font-size: 16px;
  }

  .program-table tbody tr:last-child td {
    border-bottom: 1px solid var(--line);
  }

  .program-table tbody tr:last-child td:nth-child(n + 6) {
    border-bottom: 0;
  }

  .program-status {
    max-width: 100%;
    white-space: normal;
  }

  .toast {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 20px);
  }
}

@media (orientation: landscape) and (max-height: 600px) and (min-width: 621px) and (max-width: 920px) {
  :root {
    --header-height: 64px;
  }

  .app-header {
    grid-template-columns: minmax(170px, 1fr) auto minmax(210px, 1fr);
    grid-template-rows: 64px;
    padding: 0 12px;
  }

  .product-mark,
  .primary-nav,
  .header-actions {
    grid-row: 1;
  }

  .product-mark {
    grid-column: 1;
  }

  .product-mark h1 {
    max-width: 180px;
  }

  .primary-nav {
    grid-column: 2;
    border-top: 0;
  }

  .primary-nav-item {
    min-width: 108px;
    padding: 0 10px;
  }

  .header-actions {
    grid-column: 3;
  }

  .workspace {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .task-rail {
    position: sticky;
    top: var(--header-height);
    display: block;
    max-height: calc(100dvh - var(--header-height));
    overflow-y: auto;
    border-right: 1px solid var(--line-strong);
    border-bottom: 0;
  }

  .rail-section {
    border-right: 0;
  }

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

  .program-toolbar {
    top: var(--header-height);
  }

  .primary-nav-item,
  .logout-button,
  .refresh-button,
  .language-control,
  .language-control select,
  .semester-tab,
  .primary-button,
  .save-button,
  .program-action-button,
  .program-elective-select,
  input:not([type="radio"]) {
    min-height: 44px;
  }
}

@media (orientation: landscape) and (max-height: 500px) and (max-width: 620px) {
  .app-header {
    position: static;
  }

  .mobile-schedule-nav {
    top: 0;
  }

  .mobile-day-tabs {
    top: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
