/*
  深大抢课助手 · 光感简约主题
  设计取向：大气、简约、克制的现代感。
  - 浅色画布 + 大量留白
  - 发丝级分割线，极轻柔的层次阴影
  - 单一沉稳蓝色主色，克制使用
  - 清晰的字号层级，安静的微动效
*/

:root {
  color-scheme: light;

  /* 画布与表面 */
  --canvas: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f2f4f7;
  --surface-soft: #f7f8fa;

  /* 文本 */
  --ink: #141924;
  --ink-soft: #46505f;
  --muted: #7b8494;
  --faint: #a6adba;

  /* 线条 */
  --line: #ebedf1;
  --line-strong: #dfe2e8;

  /* 主色（沉稳蓝） */
  --brand: #1d55d0;
  --brand-strong: #163f9e;
  --brand-ink: #ffffff;
  --brand-tint: #eef3fe;
  --brand-tint-strong: #dfe9fd;

  /* 语义色 */
  --success: #0f8a5f;
  --success-tint: #e6f5ee;
  --gold: #a76a02;
  --gold-tint: #fbf1dc;
  --danger: #c0392b;
  --danger-strong: #9d2b20;
  --danger-tint: #fbecea;

  /* 阴影：极轻、分层 */
  --shadow-xs: 0 1px 2px rgba(20, 25, 36, 0.05);
  --shadow-sm: 0 1px 3px rgba(20, 25, 36, 0.06), 0 6px 16px rgba(20, 25, 36, 0.05);
  --shadow-md: 0 4px 10px rgba(20, 25, 36, 0.06), 0 20px 44px rgba(20, 25, 36, 0.1);

  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  --font: "Segoe UI Variable", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  --font-num: "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  font-family: var(--font);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

/* Brand */

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-lockup > span:last-child {
  display: grid;
  min-width: 0;
}

.brand-lockup strong {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand-lockup small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-lockup-light strong {
  color: #fff;
}

.brand-lockup-light small {
  color: rgba(255, 255, 255, 0.72);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  color: var(--brand-ink);
  background: var(--brand);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-lockup-light .brand-mark {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(4px);
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  transition: transform 130ms ease, background-color 150ms ease,
    border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.button:not(:disabled):active {
  transform: translateY(1px);
}

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

.button-primary {
  color: var(--brand-ink);
  background: var(--brand);
  box-shadow: var(--shadow-xs);
}

.button-primary:not(:disabled):hover {
  background: var(--brand-strong);
}

.button-secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}

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

.button-quiet {
  color: var(--ink-soft);
  background: transparent;
  border-color: transparent;
}

.button-quiet:not(:disabled):hover {
  color: var(--brand);
  background: var(--brand-tint);
}

.button-danger {
  color: #fff;
  background: var(--danger);
  box-shadow: var(--shadow-xs);
}

.button-danger:not(:disabled):hover {
  background: var(--danger-strong);
}

.button-block {
  width: 100%;
}

/* ==================================================================
   Login
   ================================================================== */

.login-page {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(380px, 44%) minmax(0, 1fr);
  background: var(--surface);
}

.login-visual {
  position: relative;
  overflow: hidden;
  background-color: #1c4fbf;
  background-image:
    linear-gradient(150deg, rgba(37, 99, 235, 0.58), rgba(21, 57, 158, 0.82)),
    url("/bg.avif");
  background-size: cover;
  background-position: center;
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 15% 12%, rgba(255, 255, 255, 0.14), transparent 60%);
  pointer-events: none;
}

.login-visual-copy {
  position: absolute;
  z-index: 1;
  right: 56px;
  bottom: 56px;
  left: 56px;
  animation: rise 640ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-visual-copy .headline {
  margin: 34px 0 0;
  max-width: 460px;
  font-size: 42px;
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: 0;
  color: #fff;
}

.login-visual-copy .headline em {
  font-style: normal;
  color: #bcd3ff;
}

.login-visual-copy p {
  max-width: 430px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14.5px;
  line-height: 1.65;
}

.login-authors {
  margin-top: 28px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  letter-spacing: 0;
}

.login-authors b {
  color: #fff;
  font-weight: 700;
}

.login-main {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px clamp(24px, 5vw, 72px);
  overflow: hidden;
}

.login-shell {
  width: min(100%, 440px);
  animation: rise 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-header {
  margin-bottom: 14px;
}

.login-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: 0;
}

.login-header > p:last-child {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 4px;
}

.field > span:first-child,
.captcha-fieldset legend > span:first-child {
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
}

.field input,
.field textarea,
.search-field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input::placeholder,
.field textarea::placeholder,
.search-field input::placeholder {
  color: var(--faint);
}

.field input {
  height: 40px;
  padding: 0 12px;
}

.field textarea {
  min-height: 68px;
  padding: 12px 15px;
  resize: vertical;
  font-family: var(--font-num);
  font-size: 12.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.field input:focus,
.field textarea:focus,
.search-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
  outline: none;
}

.input-with-action {
  position: relative;
  display: block;
}

.input-with-action input {
  padding-right: 64px;
}

.field-action {
  position: absolute;
  top: 4px;
  right: 4px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-xs);
  color: var(--brand);
  background: var(--brand-tint);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.field-action:hover {
  background: var(--brand-tint-strong);
}

.captcha-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.captcha-fieldset legend {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding: 0;
}

.captcha-progress {
  font-family: var(--font-num);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.captcha-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 25 / 8;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  cursor: default;
  user-select: none;
}

.captcha-stage[data-state="ready"] {
  cursor: crosshair;
}

.captcha-stage[data-state="unavailable"] {
  border-color: #e4c88f;
  background: var(--gold-tint);
}

.captcha-stage[data-state="error"] {
  border-color: #e8b8b3;
  background: var(--danger-tint);
}

.captcha-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.captcha-stage:not([data-state="ready"]) img {
  visibility: hidden;
}

.captcha-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 14px;
  text-align: center;
  color: var(--muted);
  background: inherit;
}

.captcha-status strong {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.35;
}

.captcha-status span {
  max-width: 360px;
  font-size: 11px;
  line-height: 1.4;
}

.captcha-stage[data-state="loading"] .captcha-status strong::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  vertical-align: -1px;
  animation: captcha-spin 700ms linear infinite;
}

@keyframes captcha-spin {
  to { transform: rotate(360deg); }
}

.captcha-stage[data-state="unavailable"] .captcha-status strong {
  color: var(--gold);
}

.captcha-stage[data-state="error"] .captcha-status strong {
  color: var(--danger);
}

.captcha-stage[data-state="ready"] .captcha-status {
  display: none;
}

.captcha-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.captcha-marker {
  position: absolute;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 2px 8px rgba(29, 85, 208, 0.4);
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 700;
  transform: translate(-50%, -50%);
  animation: pop 180ms ease-out;
}

@keyframes pop {
  from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
}

.captcha-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.captcha-webvpn-auth {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
  padding: 12px;
  border: 2px solid var(--brand);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--brand-tint);
  box-shadow: 0 4px 14px rgba(29, 85, 208, 0.16);
}

.captcha-webvpn-auth strong {
  color: var(--brand);
  font-size: 14px;
}

.captcha-webvpn-auth span {
  color: var(--ink-soft);
  font-size: 12px;
}

.captcha-webvpn-auth .button {
  align-self: flex-start;
  margin-top: 3px;
}

.captcha-actions .button {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
}

.form-message {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.form-message.is-success {
  color: var(--success);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  color: var(--ink-soft);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}

.remember-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}

.remember-row span {
  line-height: 1.5;
}

.backend-fieldset {
  min-width: 0;
  margin: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.backend-fieldset legend {
  padding: 0 6px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 700;
}

.backend-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.backend-option {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.backend-option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.backend-option input {
  margin-top: 3px;
  accent-color: var(--brand);
}

.backend-option span {
  display: grid;
  gap: 2px;
}

.backend-option strong {
  color: var(--ink);
  font-size: 13px;
}

.backend-option small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.backend-status {
  margin-top: 6px;
  color: var(--brand);
  font-size: 12px;
  line-height: 1.5;
}

.privacy-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.offline-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.offline-page {
  background: var(--canvas);
}

.offline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
}

.offline-main {
  width: min(1240px, calc(100% - 64px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

.offline-intro {
  margin-bottom: 28px;
}

.offline-intro h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.2;
}

.offline-intro p:last-child {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--ink-soft);
}

.offline-toolbar,
.offline-section {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.offline-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.offline-types {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.offline-types .is-active {
  color: var(--brand-ink);
  background: var(--brand);
  border-color: var(--brand);
}

.offline-search {
  min-width: min(340px, 100%);
}

.offline-search input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.offline-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.offline-section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.offline-section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.offline-section .course-list {
  min-height: 80px;
}

.offline-section .pagination {
  margin-top: 16px;
}

@media (max-width: 680px) {
  .offline-header {
    padding: 18px 20px;
  }

  .offline-main {
    width: min(100% - 40px, 1240px);
    padding-top: 30px;
  }

  .offline-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .offline-search {
    min-width: 0;
  }
}

/* ==================================================================
   App shell
   ================================================================== */

.app-page {
  min-height: 100dvh;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
}

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

.student-label {
  appearance: none;
  cursor: default;
  font-family: inherit;
  max-width: 176px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  color: var(--ink-soft);
  background: var(--surface-2);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-label.is-actionable {
  cursor: pointer;
  color: var(--brand);
  border-color: rgba(42, 93, 180, 0.28);
}

.student-label.is-actionable:hover {
  background: var(--brand-tint);
}

.student-label:disabled {
  cursor: wait;
  opacity: 0.72;
}

.backend-indicator {
  max-width: 170px;
  padding: 6px 11px;
  border: 1px solid rgba(42, 93, 180, 0.2);
  border-radius: 999px;
  overflow: hidden;
  color: var(--brand);
  background: var(--brand-tint);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  color: var(--success);
  background: var(--success-tint);
  border: 1px solid rgba(15, 138, 95, 0.24);
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 700;
}

.task-indicator::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 1.6s ease-in-out infinite;
}

.task-indicator.is-paused {
  color: var(--gold);
  background: var(--gold-tint);
  border-color: rgba(167, 106, 2, 0.24);
}

.task-indicator.is-paused::before {
  background: var(--gold);
  animation: none;
}

.task-indicator.is-relogin {
  color: var(--brand);
  background: var(--brand-tint);
  border-color: rgba(29, 85, 208, 0.22);
}

.task-indicator.is-relogin::before {
  background: var(--brand);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.32; }
}

.count-badge {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  margin-left: 7px;
  padding: 0 6px;
  border-radius: 11px;
  color: var(--brand-ink);
  background: var(--brand);
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 700;
}

.cart-label-short {
  display: none;
}

.workspace {
  min-height: calc(100dvh - 68px);
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.course-nav {
  position: sticky;
  top: 68px;
  height: calc(100dvh - 68px);
  padding: 28px 18px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.nav-label {
  margin: 0 10px 12px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.category-list {
  display: grid;
  gap: 3px;
}

.category-button {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background-color 140ms ease, color 140ms ease;
}

.category-button span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.category-button small {
  flex: 0 0 auto;
  color: var(--faint);
  font-family: var(--font-num);
  font-size: 9.5px;
  letter-spacing: 0;
}

.category-button:hover {
  color: var(--ink);
  background: var(--surface-3);
}

.category-button.is-active {
  color: var(--brand);
  background: var(--brand-tint);
  font-weight: 700;
}

.category-button.is-active small {
  color: var(--brand);
  opacity: 0.7;
}

.legend {
  display: grid;
  gap: 10px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.legend > span {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
}

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

.legend-ok { background: var(--brand); }
.legend-full { background: var(--gold); }
.legend-blocked { background: var(--danger); }
.legend-selected { background: var(--success); }

.course-main {
  width: min(100%, 1160px);
  margin: 0 auto;
  padding: 34px clamp(20px, 4vw, 52px) 64px;
}

/* Phase banner */

.phase-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.phase-banner::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--brand);
}

.phase-banner.is-warning::before { background: var(--gold); }
.phase-banner.is-danger::before { background: var(--danger); }

.phase-banner strong {
  font-size: 16px;
  font-weight: 700;
}

.phase-banner p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.phase-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.phase-refresh {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.session-recovery-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 12px;
  padding: 15px 18px;
  border: 1px solid rgba(29, 85, 208, 0.22);
  border-radius: var(--radius-sm);
  color: var(--brand-strong);
  background: var(--brand-tint);
}

.session-recovery-banner.is-success {
  color: var(--success);
  background: var(--success-tint);
  border-color: rgba(15, 138, 95, 0.24);
}

.session-recovery-banner.is-error {
  color: var(--danger);
  background: var(--danger-tint);
  border-color: rgba(192, 57, 43, 0.22);
}

.recovery-copy {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.recovery-copy strong {
  display: block;
  font-size: 13px;
}

.recovery-copy p {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.recovery-spinner {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

.session-recovery-banner.is-running .recovery-spinner {
  animation: spin 0.85s linear infinite;
}

.session-recovery-banner.is-success .recovery-spinner,
.session-recovery-banner.is-error .recovery-spinner {
  width: 9px;
  height: 9px;
  border: 0;
  background: currentColor;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.status-pill,
.class-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-neutral {
  color: var(--ink-soft);
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.status-warning,
.tag-full {
  color: var(--gold);
  background: var(--gold-tint);
  border-color: rgba(167, 106, 2, 0.24);
}

.status-success {
  color: var(--success);
  background: var(--success-tint);
  border-color: rgba(15, 138, 95, 0.24);
}

.tag-open {
  color: var(--brand-strong);
  background: var(--brand-tint);
  border-color: rgba(29, 85, 208, 0.24);
}

.status-danger,
.tag-conflict {
  color: var(--danger);
  background: var(--danger-tint);
  border-color: rgba(192, 57, 43, 0.22);
}

.tag-chosen {
  color: var(--success);
  background: var(--success-tint);
  border-color: rgba(15, 138, 95, 0.24);
}

.class-tag-button {
  appearance: none;
  cursor: pointer;
  font: inherit;
}

.class-tag-button:hover {
  border-color: currentColor;
  filter: brightness(0.96);
}

/* Toolbar */

.course-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.course-toolbar h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
}

.toolbar-summary {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 9px;
}

.campus-field {
  height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.campus-field:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}

.campus-field select {
  max-width: 148px;
  height: 32px;
  padding: 0 25px 0 4px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.campus-field select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.search-field input {
  width: min(30vw, 264px);
  height: 42px;
  padding: 0 15px;
}

/* Course list as cards */

.course-list {
  min-height: 360px;
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.course-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  animation: rise 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.course-group:hover {
  box-shadow: var(--shadow-sm);
}

.course-group[open] {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.course-group.is-selected {
  border-color: rgba(15, 138, 95, 0.34);
  box-shadow: 0 1px 3px rgba(15, 138, 95, 0.08), 0 8px 20px rgba(15, 138, 95, 0.06);
}

.course-group.is-selected .course-summary-main strong {
  color: var(--success);
}

.course-group summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  min-height: 78px;
  padding: 18px 22px;
  cursor: pointer;
  list-style: none;
}

.course-group summary::-webkit-details-marker {
  display: none;
}

.course-group summary:hover .course-summary-main strong {
  color: var(--brand);
}

.course-summary-main {
  min-width: 0;
}

.course-summary-main strong {
  display: block;
  overflow: hidden;
  font-size: 16px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 140ms ease;
}

.course-summary-main span {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-summary-side {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-soft);
  font-size: 12px;
}

.course-summary-side > span:first-child {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  white-space: nowrap;
}

.course-chevron {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 180ms ease, border-color 140ms ease;
}

.course-group[open] .course-chevron {
  transform: rotate(225deg);
  border-color: var(--brand);
}

.class-list {
  padding: 0 14px 14px;
}

.filtered-empty {
  margin-top: 4px;
  padding: 18px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  text-align: center;
}

.class-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.85fr) minmax(180px, 1.5fr) minmax(110px, 0.7fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 14px 14px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
  border: 1px solid transparent;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.class-row:hover {
  background: var(--surface-2);
  border-color: var(--line);
}

.class-primary,
.class-location,
.class-capacity {
  min-width: 0;
}

.class-primary strong,
.class-location strong,
.class-capacity strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13.5px;
  font-weight: 600;
}

.class-capacity strong {
  font-family: var(--font-num);
  color: var(--brand);
}

.class-primary span,
.class-location span,
.class-capacity span {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
}

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

.class-actions .class-tag {
  min-height: 28px;
}

.class-actions .button {
  min-width: 90px;
}

/* Empty / error / loading */

.empty-state,
.error-state {
  min-height: 300px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 48px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: var(--surface);
}

.empty-state strong,
.error-state strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.empty-state p,
.error-state p {
  max-width: 460px;
  margin: 8px 0 0;
  font-size: 13px;
}

.state-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.state-note {
  display: block;
  max-width: 520px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.loading-list {
  display: grid;
  gap: 14px;
}

.loading-row {
  height: 90px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-3) 50%, var(--surface) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Pagination */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
}

.pagination span {
  min-width: 92px;
  font-family: var(--font-num);
  color: var(--ink-soft);
  text-align: center;
  font-size: 13px;
}

/* ==================================================================
   Dialogs
   ================================================================== */

dialog {
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(20, 25, 36, 0.32);
  backdrop-filter: blur(3px);
}

.drawer-dialog,
.confirm-dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--ink);
}

.drawer-dialog[open],
.confirm-dialog[open] {
  animation: dialog-in 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
}

.drawer-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: min(820px, calc(100dvh - 28px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-dialog:not([open]) {
  display: none;
}

.drawer-dialog > .dialog-header,
.drawer-dialog > .dialog-footer {
  flex: 0 0 auto;
}

.cart-dialog-body,
.my-courses-dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.cart-dialog-body .cart-list,
.my-courses-dialog-body .my-courses-schedule-wrap,
.my-courses-dialog-body .my-courses-list {
  max-height: none;
  overflow-y: visible;
}

.confirm-dialog {
  width: min(500px, calc(100vw - 28px));
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 26px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
}

.dialog-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  background: var(--surface);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: background-color 140ms ease, color 140ms ease;
}

.dialog-close:hover {
  color: var(--danger);
  background: var(--danger-tint);
  border-color: transparent;
}

.cart-list,
.my-courses-list {
  min-height: 160px;
  max-height: calc(100dvh - 320px);
  overflow-y: auto;
  padding: 6px 0;
}

.cart-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 15px 26px;
  border-bottom: 1px solid var(--line);
}

.cart-item:last-child {
  border-bottom: 0;
}

.cart-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13.5px;
  font-weight: 600;
}

.cart-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.cart-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-item-actions .button {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12px;
}

.cart-priority-group {
  border-bottom: 1px solid var(--line);
}

.cart-priority-group:last-child {
  border-bottom: 0;
}

.cart-priority-group-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 26px 8px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  font-size: 12px;
}

.cart-priority-group-title span {
  color: var(--muted);
  font-size: 11px;
}

.cart-preference-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.compact-switch {
  margin: 0;
  font-size: 11px;
}

.cart-group-input {
  width: min(220px, 100%);
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 11px;
}

.cart-rank {
  margin: 0 !important;
  white-space: nowrap;
  font-family: var(--font-num);
}

.cart-preference-controls .button {
  min-height: 30px;
  padding: 4px 9px;
}

.enroll-controls {
  display: grid;
  gap: 16px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.schedule-panel {
  display: grid;
  gap: 11px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.schedule-panel[hidden] { display: none; }

.schedule-heading,
.schedule-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.schedule-heading strong { font-size: 14px; }

.schedule-note {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.schedule-panel input[type="datetime-local"] {
  width: min(100%, 280px);
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 13px;
}

.schedule-confirm {
  margin: 0;
  font-size: 12px;
}

.schedule-actions { justify-content: flex-start; }

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

.schedule-choice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.schedule-choice:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.schedule-choice input {
  margin: 2px 0 0;
  accent-color: var(--brand);
}

.schedule-choice strong,
.schedule-choice small { display: block; }
.schedule-choice strong { color: var(--ink); font-size: 12px; }
.schedule-choice small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.4; }

.school-schedule-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.school-schedule-detail[hidden],
#customScheduleField[hidden] { display: none; }

.schedule-school-time {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.school-schedule-detail .button { flex: 0 0 auto; }

.enroll-controls-head,
.mode-switcher,
.enroll-control-actions,
.risk-settings,
.enroll-settings-grid {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.enroll-controls-head {
  justify-content: space-between;
}

.enroll-controls-head strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
}

.control-hint,
.control-label {
  color: var(--muted);
  font-size: 11px;
}

.control-hint {
  max-width: 560px;
  margin: 5px 0 0;
  line-height: 1.5;
}

.mode-switcher .button.is-active {
  color: var(--brand-ink);
  border-color: var(--brand);
  background: var(--brand);
}

.setting-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
}

.setting-field input[type="number"] {
  width: 130px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  font: inherit;
}

.risk-settings {
  align-items: end;
}

.risk-confirm-row {
  color: var(--danger);
}

.threshold-field input[type="number"] {
  width: 110px;
}

.threshold-input-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.setting-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  color: var(--ink-soft);
  white-space: nowrap;
  cursor: pointer;
}

.setting-checkbox input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--brand);
}

.threshold-input-row input:disabled {
  color: var(--muted);
  background: var(--surface-soft);
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .schedule-panel { padding: 16px; }
  .schedule-choices { grid-template-columns: minmax(0, 1fr); }
  .school-schedule-detail { align-items: flex-start; flex-direction: column; }
  .schedule-actions { flex-direction: column; align-items: stretch; }
  .schedule-actions .button { width: 100%; }
  .enroll-controls {
    padding: 16px;
  }

  .enroll-controls-head,
  .enroll-control-actions,
  .mode-switcher,
  .enroll-settings-grid,
  .risk-settings {
    align-items: stretch;
  }

  .enroll-control-actions,
  .mode-switcher .button,
  .setting-field,
  .setting-field input[type="number"] {
    width: 100%;
  }

  .threshold-input-row {
    width: 100%;
  }

  .threshold-input-row input[type="number"] {
    width: auto;
    min-width: 0;
    flex: 1;
  }
}

/* My courses */

.my-course-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
}

.my-course-item:last-child {
  border-bottom: 0;
}

.my-course-item.is-pending {
  opacity: 0.5;
  border-left: 3px dashed var(--gold);
  filter: saturate(0.65);
}

.my-course-item.is-pending:hover {
  opacity: 0.8;
}

.my-course-index {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: var(--brand);
  background: var(--brand-tint);
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 13px;
}

.my-course-body strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.my-course-pending-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--gold);
  background: var(--gold-tint);
  font-size: 10px;
  font-weight: 700;
  vertical-align: 2px;
}

.my-course-meta {
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 12px;
}

.my-course-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Progress panel */

.enroll-progress {
  padding: 16px 26px 6px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.enroll-progress[hidden] {
  display: none;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}

.progress-head strong {
  font-size: 13px;
  font-weight: 700;
}

.progress-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.progress-counts {
  font-family: var(--font-num);
  font-size: 12px;
  color: var(--ink-soft);
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress-bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--brand);
  transition: width 320ms ease;
}

.progress-rows {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.progress-row .p-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 600;
}

.progress-row .p-msg {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-row .p-attempts {
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--faint);
}

.progress-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.progress-controls p {
  min-width: 0;
  margin: 0;
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.progress-controls .button {
  flex: 0 0 auto;
  min-width: 92px;
}

.dialog-footer {
  padding: 18px 26px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.dialog-footer p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.my-courses-credit-summary {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  margin: -2px 0 16px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.credit-summary-item {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 7px;
  align-items: baseline;
  min-width: 90px;
  padding: 7px 11px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
}

.credit-summary-item span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.credit-summary-item strong {
  color: var(--ink);
  font-family: var(--font-num);
  font-size: 24px;
  line-height: 1;
}

.credit-summary-item small {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
}

.credit-summary-item.is-selected {
  border-left: 3px solid var(--brand);
}

.credit-summary-item.is-pending {
  border-left: 3px dashed var(--gold);
}

.credit-summary-item.is-total {
  border: 2px solid var(--brand);
  background: var(--brand-tint);
}

.credit-summary-item.is-total strong {
  color: var(--brand-strong);
  font-size: 28px;
}

.credit-summary-plus,
.credit-summary-equals {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
}

@media (max-width: 520px) {
  .my-courses-credit-summary {
    gap: 4px;
    padding: 8px 4px;
  }

  .credit-summary-item {
    min-width: 0;
    flex: 1 1 0;
    padding: 7px 5px;
  }

  .credit-summary-item strong {
    font-size: 20px;
  }

  .credit-summary-item.is-total strong {
    font-size: 23px;
  }
}

.confirm-content {
  padding: 24px 26px;
}

.confirm-content > p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.65;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 20px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--brand);
}

.check-row span {
  font-size: 13.5px;
  color: var(--ink);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 26px 24px;
}

/* Toasts */

.toast-region {
  position: fixed;
  z-index: 200;
  right: 24px;
  bottom: 24px;
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast {
  width: min(380px, calc(100vw - 40px));
  padding: 14px 16px 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  position: relative;
  overflow: hidden;
  animation: toast-in 200ms ease-out;
}

.toast::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--brand);
}

.toast.is-error::before {
  background: var(--danger);
}

.toast.is-success::before {
  background: var(--success);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(14px); }
}

/* ==================================================================
   Responsive
   ================================================================== */

@media (max-width: 900px) {
  .login-page {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 132px;
    background-position: center 40%;
  }

  .login-visual-copy {
    right: 20px;
    bottom: 18px;
    left: 20px;
  }

  .login-visual-copy .headline {
    margin-top: 0;
    font-size: 26px;
  }

  .login-visual-copy p,
  .login-authors {
    display: none;
  }

  .login-main {
    min-height: auto;
    padding: 24px 20px 28px;
  }

  .login-header h1 {
    font-size: 26px;
  }

  .backend-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace {
    display: block;
  }

  .course-nav {
    position: sticky;
    z-index: 20;
    top: 68px;
    height: auto;
    padding: 10px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .course-nav > .nav-label,
  .legend {
    display: none;
  }

  .category-list {
    width: max-content;
    display: flex;
  }

  .category-button {
    width: auto;
    min-height: 40px;
    padding: 7px 14px;
  }

  .category-button small {
    display: none;
  }

  .class-row {
    grid-template-columns: minmax(110px, 0.85fr) minmax(150px, 1.2fr) auto;
  }

  .class-capacity {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: 96px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 36px 36px;
    gap: 8px;
    padding: 8px 12px;
  }

  .topbar .brand-lockup small,
  .student-label,
  .task-indicator {
    display: none;
  }

  .topbar .brand-lockup {
    gap: 10px;
  }

  .topbar .brand-mark {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
    font-size: 12px;
  }

  .topbar .brand-lockup strong {
    font-size: 15px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .topbar-actions .button {
    min-width: 0;
    min-height: 36px;
    padding: 7px 8px;
    font-size: 11.5px;
    white-space: nowrap;
  }

  .topbar-actions .count-badge {
    margin-left: 2px;
  }

  .cart-label-long {
    display: none;
  }

  .cart-label-short {
    display: inline;
  }

  .course-nav {
    top: 96px;
  }

  .course-main {
    padding-right: 14px;
    padding-left: 14px;
  }

  .phase-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .session-recovery-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .session-recovery-banner .button {
    width: 100%;
  }

  .phase-actions {
    width: 100%;
    justify-content: space-between;
  }

  .progress-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .progress-controls .button {
    width: 100%;
  }

  .progress-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .progress-title {
    justify-content: space-between;
  }

  .progress-counts {
    white-space: nowrap;
  }

  .course-toolbar {
    display: grid;
    gap: 14px;
    margin-top: 24px;
  }

  .toolbar-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .campus-field {
    flex: 0 0 auto;
  }

  .search-field {
    flex: 1 1 auto;
  }

  .search-field input {
    width: 100%;
  }

  .class-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .class-location {
    display: none;
  }

  .class-actions {
    min-width: 118px;
    flex-wrap: wrap;
    gap: 5px;
  }

  .toast-region {
    right: 12px;
    left: 12px;
    bottom: 12px;
  }

  .toast {
    width: 100%;
  }
}

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


/* ==================================================================
   Schedule (weekly grid) view
   ================================================================== */

.schedule-view-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 26px 0;
  border-bottom: 1px solid var(--line);
}

.schedule-view-toggle-group {
  display: flex;
  gap: 0;
}

.schedule-view-toggle-group .button {
  min-height: 34px;
  padding: 6px 16px;
  border-radius: 0;
  border: 1px solid var(--line);
  border-right-width: 0;
  font-size: 12.5px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.schedule-view-toggle-group .button:first-child {
  border-radius: var(--radius-xs) 0 0 var(--radius-xs);
}

.schedule-view-toggle-group .button:last-child {
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  border-right-width: 1px;
}

.schedule-view-toggle-group .button.is-active {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
}

.schedule-view-toggle-group .button:hover:not(.is-active) {
  background: var(--surface-3);
  color: var(--ink-soft);
}

.my-courses-schedule-wrap {
  min-height: 160px;
  max-height: calc(100dvh - 320px);
  overflow-y: auto;
  padding: 16px 26px;
}

.schedule-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.schedule-grid-wrap {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
}

.schedule-grid {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-width: 680px;
}

.schedule-corner {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-size: 10px;
  color: var(--muted);
}

.schedule-col-header {
  display: grid;
  place-items: center;
  padding: 8px 4px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.schedule-col-header.is-today {
  background: var(--brand-tint);
  color: var(--brand);
}

.schedule-row-label {
  display: grid;
  place-items: center;
  padding: 2px;
  background: var(--surface-2);
  text-align: center;
}

.schedule-row-label.is-break {
  border-top: 1px solid var(--line-strong);
}

.schedule-row-label strong {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.schedule-row-label small {
  display: block;
  margin-top: 1px;
  color: var(--faint);
  font-size: 9px;
  font-family: var(--font-num);
}

.schedule-cell {
  min-height: 30px;
  padding: 0;
  background: var(--surface);
  overflow: hidden;
}

.schedule-cell.is-break {
  border-top: 1px solid var(--line-strong);
}

.schedule-cell.is-today {
  background: var(--surface-2);
}

.schedule-course {
  border-radius: var(--radius-xs);
  padding: 4px 6px;
  font-size: 11px;
  cursor: default;
  min-width: 0;
  overflow: visible;
  border: 1px solid transparent;
}

.schedule-course strong {
  display: block;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.schedule-weeks {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-family: var(--font-num);
  opacity: 0.85;
}

.schedule-place {
  display: block;
  margin-top: 1px;
  font-size: 10px;
  opacity: 0.7;
  overflow-wrap: anywhere;
}

.schedule-teacher {
  display: block;
  margin-top: 1px;
  font-size: 10px;
  opacity: 0.6;
}

/* Course color palette — 12 distinct, soft background colors */
.schedule-course[data-color="0"],
.schedule-nonstandard-item[data-color="0"] {
  background: #e8f0fe;
  color: #1565c0;
  border-color: #c3d7f5;
}

.schedule-course[data-color="1"],
.schedule-nonstandard-item[data-color="1"] {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #c8e6c9;
}

.schedule-course[data-color="2"],
.schedule-nonstandard-item[data-color="2"] {
  background: #fff3e0;
  color: #e65100;
  border-color: #ffe0b2;
}

.schedule-course[data-color="3"],
.schedule-nonstandard-item[data-color="3"] {
  background: #fce4ec;
  color: #c2185b;
  border-color: #f8bbd0;
}

.schedule-course[data-color="4"],
.schedule-nonstandard-item[data-color="4"] {
  background: #f3e5f5;
  color: #7b1fa2;
  border-color: #e1bee7;
}

.schedule-course[data-color="5"],
.schedule-nonstandard-item[data-color="5"] {
  background: #e0f7fa;
  color: #00838f;
  border-color: #b2ebf2;
}

.schedule-course[data-color="6"],
.schedule-nonstandard-item[data-color="6"] {
  background: #fffde7;
  color: #827717;
  border-color: #fff9c4;
}

.schedule-course[data-color="7"],
.schedule-nonstandard-item[data-color="7"] {
  background: #efebe9;
  color: #4e342e;
  border-color: #d7ccc8;
}

.schedule-course[data-color="8"],
.schedule-nonstandard-item[data-color="8"] {
  background: #e8eaf6;
  color: #283593;
  border-color: #c5cae9;
}

.schedule-course[data-color="9"],
.schedule-nonstandard-item[data-color="9"] {
  background: #f1f8e9;
  color: #558b2f;
  border-color: #dcedc8;
}

.schedule-course[data-color="10"],
.schedule-nonstandard-item[data-color="10"] {
  background: #fbe9e7;
  color: #bf360c;
  border-color: #ffccbc;
}

.schedule-course[data-color="11"],
.schedule-nonstandard-item[data-color="11"] {
  background: #e0f2f1;
  color: #00695c;
  border-color: #b2dfdb;
}

/* Non-standard time list (right side) */
.schedule-nonstandard {
  flex: 0 0 220px;
  padding: 0 0 0 16px;
  border-left: 1px solid var(--line);
  max-height: calc(100dvh - 380px);
  overflow-y: auto;
}

.schedule-nonstandard-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.schedule-nonstandard-item {
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 11.5px;
  border: 1px solid transparent;
}

.schedule-nonstandard-item strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.schedule-nonstandard-meta {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 10.5px;
  opacity: 0.8;
}

.schedule-nonstandard > p:last-child {
  color: var(--muted);
  font-size: 12px;
}

/* Wide dialog for schedule view */
.drawer-dialog.is-wide-schedule {
  width: min(1180px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
}

/* Course stack (spans multiple period rows) */
.schedule-stack {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 2px;
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 100%;
  align-self: stretch;
  overflow: visible;
}

.schedule-stack > .schedule-course {
  min-height: 0;
}

/* Pending (cart, not yet enrolled) course styles */
.schedule-course.is-pending {
  opacity: 0.5;
  border-style: dashed;
  filter: saturate(0.6);
}

.schedule-course.is-pending:hover {
  opacity: 0.8;
}

.schedule-nonstandard-item.is-pending {
  opacity: 0.65;
  border-style: dashed;
}

.schedule-course.is-context-muted,
.schedule-nonstandard-item.is-context-muted {
  opacity: 0.35;
  filter: saturate(0.55);
}

.schedule-course.is-focused,
.schedule-nonstandard-item.is-focused {
  position: relative;
  z-index: 4;
  border-color: var(--brand-strong) !important;
  color: var(--brand-strong) !important;
  background: var(--brand-tint-strong) !important;
  box-shadow: 0 0 0 2px rgba(29, 85, 208, 0.22), var(--shadow-sm);
  opacity: 1 !important;
  filter: none;
}

.schedule-course.is-conflict-highlight,
.schedule-nonstandard-item.is-conflict-highlight {
  position: relative;
  z-index: 3;
  border-color: var(--danger) !important;
  color: var(--danger-strong) !important;
  background: var(--danger-tint) !important;
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.18), var(--shadow-sm);
  opacity: 1 !important;
  filter: none;
}

.schedule-pending-badge {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  color: var(--gold);
  background: var(--gold-tint);
}

/* Pending toggle switch */
.schedule-pending-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.schedule-pending-toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  position: relative;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
  margin: 0;
}

.schedule-pending-toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line-strong);
  transition: transform 140ms ease;
}

.schedule-pending-toggle input:checked {
  background: var(--brand);
  border-color: var(--brand);
}

.schedule-pending-toggle input:checked::after {
  transform: translateX(15px);
}

/* Legend */
.schedule-legend {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.legend-pending {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px dashed var(--muted);
  background: var(--surface-3);
  opacity: 0.6;
}

/* Responsive */
@media (max-width: 900px) {
  .schedule-layout {
    flex-direction: column;
  }

  .schedule-nonstandard {
    flex: 0 0 auto;
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 16px 0 0;
    max-height: none;
  }
}
/* Graduate text captchas keep their own geometry instead of click coordinates. */
.captcha-stage.is-text-captcha { aspect-ratio: auto; min-height: 116px; cursor: default; }
.captcha-stage.is-text-captcha img { width: auto; max-width: 100%; height: 80px; object-fit: contain; margin: 18px auto; }
#textCaptchaField { margin-top: 12px; }
#textCaptcha { font-family: monospace; font-size: 20px; letter-spacing: 0; }
.graduate-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 18px; }
.graduate-filters .field { min-width: 160px; max-width: 280px; }
.graduate-filters select { width: 100%; min-height: 42px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); padding: 8px 12px; font: inherit; }
@media (max-height: 500px) {
  .drawer-dialog > .dialog-header { padding: 12px 20px; }
  .drawer-dialog > .dialog-footer { max-height: 35dvh; overflow-y: auto; padding: 12px 20px; }
  .drawer-dialog > .my-courses-dialog-body { min-height: 110px; }
}
