/* OD-LAYOUT-PRIMITIVES v1 — structure only: display, flex/grid, overflow, wrapping, ratio, geometry.
       Put this @layer first; product CSS outside the layer wins ordinary layout rules.
       Native hidden and closed-dialog states take precedence over component display rules. */
    @layer od-layout {
      [hidden]:not([hidden="until-found" i]) { display: none !important; }
      dialog:not([open]) { display: none !important; }

      :where(.od-stack,.od-row,.od-row-top,.od-cluster,.od-grid,.od-field,.od-stat,.od-cell,.od-tile) > :where(*) { min-width: 0; }

      /* containers */
      .od-stack   { display: flex; flex-direction: column; gap: var(--od-gap, 8px); }
      .od-row     { display: flex; align-items: center; gap: var(--od-gap, 8px); }
      .od-row-top { display: flex; align-items: flex-start; gap: var(--od-gap, 8px); }
      .od-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--od-gap, 8px); }
      .od-fill    { flex: 1 1 0; min-width: 0; }
      .od-fixed   { flex: none; }
      .od-grid    { display: grid; gap: var(--od-gap, 12px); grid-template-columns: repeat(var(--od-cols, 3), minmax(0, 1fr)); }

      /* stacked information: each piece is its own line — never sibling inline spans */
      .od-stat, .od-field, .od-cell { display: grid; gap: var(--od-gap, 2px); }
      :where(.od-stat,.od-field,.od-cell) > :where(*) { display: block; }
      .od-tile { display: grid; grid-template-rows: auto 1fr; }
      :where(.od-tile) > :where(*) { display: block; }

      /* media keeps its intrinsic ratio by default; never a distorted or cropped
         cover by accident. height:auto lets the ratio win over an <img height="…">
         attribute. Cropping to a uniform box is an explicit opt-in: set --od-ratio
         AND add .od-media-cover together (per the core rule, only where a crop is
         deliberate — tile thumbs, decorative fills — never on full-frame content). */
      .od-media { display: block; width: 100%; height: auto; aspect-ratio: var(--od-ratio, auto); }
      .od-media-cover { object-fit: cover; }

      /* functional inline SVG icons opt into bounded geometry; content SVGs keep their own */
      .od-icon { display: inline-block; inline-size: var(--od-icon-size, 1em); block-size: var(--od-icon-size, 1em); flex: none; }

      /* data text only — authored copy is rewritten to its budget instead */
      .od-truncate { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
      .od-clamp-2, .od-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
      .od-clamp-2 { -webkit-line-clamp: 2; }
      .od-clamp-3 { -webkit-line-clamp: 3; }
      .od-lines-2 { min-height: calc(2 * 1.4em); }   /* block-level reservation for a shared baseline */
      .od-nowrap  { white-space: nowrap; }           /* 数字+单位 · 价格+起 · 日期+星期 */
      .od-keep    { word-break: keep-all; overflow-wrap: anywhere; } /* CJK labels break at spaces / <wbr> first */

      /* screen skeleton (optional): bars take their own space, the middle scrolls — no padding guessed for chrome */
      .od-screen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
      .od-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }

      /* horizontal rail: the next item peeks at the edge; trailing room survives overflow */
      .od-rail { display: flex; gap: var(--od-gap, 8px); overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
                 padding-inline: var(--od-rail-pad, 16px); scroll-padding-inline: var(--od-rail-pad, 16px); }
      .od-rail::-webkit-scrollbar { display: none; }
      :where(.od-rail) > :where(*) { flex: none; scroll-snap-align: start; }
      :where(.od-rail) > :where(:last-child) { margin-inline-end: var(--od-rail-pad, 16px); }

      .od-spacer { flex: none; visibility: hidden; pointer-events: none; }
      .od-touch  { min-width: 44px; min-height: 44px; }
    }
    :root [hidden]:where(:not([hidden="until-found" i])) { display: none; }
    /* /OD-LAYOUT-PRIMITIVES v1 */

    :root {
      color-scheme: light;
      --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;

      --bg: #f3f6fa;
      --surface: #ffffff;
      --surface-2: #edf2f8;
      --surface-3: #e2e9f2;
      --text: #172033;
      --text-2: #506078;
      --text-3: #5d6c83;
      --border: #d9e1ec;
      --border-strong: #bfcbdb;

      --primary: #1e5c9e;
      --primary-solid: #1d5a9c;
      --primary-solid-hover: #174b83;
      --primary-weak: #e8f0fa;
      --primary-weak-2: #d8e7f8;
      --primary-border: #b9d2ee;
      --focus: #1f6fc4;
      --focus-ring: rgba(31, 111, 196, 0.16);

      --success: #196c4f;
      --success-weak: #e3f4ec;
      --warning: #8a5a00;
      --warning-weak: #fdf3dd;
      --danger: #b0313a;
      --danger-hover: #92232b;
      --danger-weak: #fbeaec;
      --danger-border: #ecc4c8;

      --required-bg: #e8f0fa;
      --required-border: #c5dbf3;
      --required-text: #1b4f86;
      --elective-bg: #e4f4ef;
      --elective-border: #bfe2d7;
      --elective-text: #17624f;
      --general-bg: #fdf2dc;
      --general-border: #efd9ae;
      --general-text: #795200;

      --shadow: 0 1px 2px rgba(15, 32, 56, 0.04), 0 8px 24px rgba(15, 32, 56, 0.05);
      --shadow-toast: 0 12px 40px rgba(15, 32, 56, 0.16);

      --radius-sm: 8px;
      --radius-md: 12px;
      --radius-lg: 14px;
      --header-height: 72px;
    }

    :root[data-theme="dark"] {
      color-scheme: dark;
      --bg: #0e1622;
      --surface: #151f2e;
      --surface-2: #1b2838;
      --surface-3: #243348;
      --text: #e9eff8;
      --text-2: #b3c1d4;
      --text-3: #94a5bc;
      --border: #2b3b52;
      --border-strong: #40536e;

      --primary: #8abdf5;
      --primary-solid: #2d6ba6;
      --primary-solid-hover: #3a7fbe;
      --primary-weak: #1a2d44;
      --primary-weak-2: #203a58;
      --primary-border: #315579;
      --focus: #8ac3ff;
      --focus-ring: rgba(138, 195, 255, 0.22);

      --success: #6cc9a6;
      --success-weak: #163a2f;
      --warning: #e0b15e;
      --warning-weak: #3a2f18;
      --danger: #f09196;
      --danger-hover: #d97379;
      --danger-weak: #3a2025;
      --danger-border: #6a343a;

      --required-bg: #1b3049;
      --required-border: #2e5075;
      --required-text: #c5defa;
      --elective-bg: #17352f;
      --elective-border: #2b5a4f;
      --elective-text: #b3e6d7;
      --general-bg: #382e19;
      --general-border: #5b4724;
      --general-text: #f2d79f;

      --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.18);
      --shadow-toast: 0 12px 40px rgba(0, 0, 0, 0.35);
    }

    *,
    *::before,
    *::after {
      box-sizing: border-box;
    }

    html {
      -webkit-text-size-adjust: 100%;
      scroll-behavior: auto;
    }

    body {
      margin: 0;
      min-height: 100vh;
      overflow-x: hidden;
      background: var(--bg);
      color: var(--text);
      font-family: var(--font);
      font-size: 16px;
      line-height: 1.6;
    }

    h1, h2, h3, h4, p, ul, ol {
      margin: 0;
    }

    ul, ol {
      padding: 0;
      list-style: none;
    }

    button, input, select, textarea {
      font: inherit;
      color: inherit;
    }

    button {
      cursor: pointer;
    }

    a {
      color: var(--primary);
    }

    img, svg {
      max-width: 100%;
    }

    .od-icon {
      vertical-align: -0.125em;
    }

    :focus-visible {
      outline: 2px solid var(--focus);
      outline-offset: 2px;
    }

    ::selection {
      background: var(--primary-weak-2);
    }

    .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;
    }

    .skip-link {
      position: absolute;
      left: 16px;
      top: -64px;
      z-index: 100;
      padding: 10px 16px;
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-sm);
      background: var(--surface);
      color: var(--text);
      font-size: 14px;
      font-weight: 600;
      text-decoration: none;
      box-shadow: var(--shadow);
    }

    .skip-link:focus {
      top: 12px;
    }

    /* ---------- Header ---------- */

    .app-header {
      position: sticky;
      top: 0;
      z-index: 30;
      border-bottom: 1px solid var(--border);
      background: var(--surface);
    }

    .header-inner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 20px;
      width: min(1280px, 100%);
      min-height: var(--header-height);
      margin: 0 auto;
      padding: 12px 28px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 0;
    }

    .brand-mark {
      display: grid;
      place-items: center;
      flex: none;
      width: 40px;
      height: 40px;
      border-radius: 10px;
      background: var(--primary-solid);
      color: #ffffff;
      font-size: 18px;
      font-weight: 700;
      letter-spacing: 0.02em;
    }

    .brand-text {
      display: flex;
      flex-direction: column;
      min-width: 0;
      line-height: 1.2;
    }

    .brand-title {
      font-size: 15px;
      font-weight: 700;
      letter-spacing: 0.01em;
      white-space: nowrap;
    }

    .brand-sub {
      margin-top: 3px;
      color: var(--text-3);
      font-size: 11.5px;
      white-space: nowrap;
    }

    .header-controls {
      display: flex;
      align-items: center;
      gap: 10px;
      flex: none;
    }

    .icon-button {
      display: inline-grid;
      place-items: center;
      flex: none;
      width: 40px;
      height: 40px;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: 9px;
      background: var(--surface);
      color: var(--text-2);
      transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
    }

    .icon-button:hover {
      background: var(--surface-2);
      color: var(--text);
      border-color: var(--border-strong);
    }

    .icon-sun {
      display: none;
    }

    [data-theme="dark"] .icon-sun {
      display: block;
    }

    [data-theme="dark"] .icon-moon {
      display: none;
    }

    /* ---------- Page shell ---------- */

    .app-main {
      width: min(1280px, 100%);
      margin: 0 auto;
      padding: 36px 28px 56px;
    }

    .page-head {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 24px;
      flex-wrap: wrap;
      margin: 0 0 24px;
    }

    .page-head-right {
      display: flex;
      align-items: flex-end;
      gap: 16px;
      flex: none;
    }

    .campus-art {
      display: block;
      width: 148px;
      height: 64px;
      color: var(--border-strong);
      flex: none;
    }

    .eyebrow {
      margin: 0 0 6px;
      color: var(--primary);
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.12em;
    }

    .page-head h1 {
      margin: 0;
      font-size: clamp(27px, 3vw, 34px);
      line-height: 1.2;
      font-weight: 700;
      letter-spacing: -0.025em;
    }

    .page-sub {
      max-width: 68ch;
      margin: 8px 0 0;
      color: var(--text-2);
      font-size: 15px;
    }

    .semester-chip {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      min-height: 36px;
      padding: 0 13px;
      border: 1px solid var(--border);
      border-radius: 999px;
      background: var(--surface);
      color: var(--text-2);
      font-size: 13px;
      font-weight: 600;
      white-space: nowrap;
    }

    .semester-chip .od-icon {
      color: var(--primary);
    }

    .stat-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 16px;
      margin: 0 0 28px;
    }

    .stat-card {
      display: flex;
      flex-direction: column;
      gap: 7px;
      min-width: 0;
      padding: 20px;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface);
    }

    /* Full-width Summary Band for Student View */
    .summary-band {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      margin: 0 0 28px;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface);
      overflow: hidden;
    }

    .summary-col {
      display: flex;
      flex-direction: column;
      gap: 7px;
      min-width: 0;
      padding: 20px 24px;
    }

    .summary-col + .summary-col {
      border-left: 1px solid var(--border);
    }

    .stat-label {
      color: var(--text-2);
      font-size: 13px;
      font-weight: 600;
    }

    .stat-value {
      color: var(--text);
      font-size: 30px;
      font-weight: 700;
      line-height: 1.12;
      letter-spacing: -0.025em;
      font-variant-numeric: tabular-nums;
    }

    .stat-unit {
      margin-left: 5px;
      color: var(--text-3);
      font-size: 13.5px;
      font-weight: 500;
      letter-spacing: 0;
    }

    .stat-foot {
      color: var(--text-3);
      font-size: 12.5px;
    }

    /* ---------- Shared controls ---------- */

    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      min-height: 40px;
      padding: 0 16px;
      border: 1px solid transparent;
      border-radius: var(--radius-sm);
      background: transparent;
      color: var(--text);
      font-size: 14px;
      font-weight: 600;
      line-height: 1.2;
      white-space: nowrap;
      text-decoration: none;
      transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
    }

    .btn.primary {
      border-color: var(--primary-solid);
      background: var(--primary-solid);
      color: #ffffff;
    }

    .btn.primary:hover {
      border-color: var(--primary-solid-hover);
      background: var(--primary-solid-hover);
    }

    .btn.secondary {
      border-color: var(--border-strong);
      background: var(--surface);
      color: var(--text);
    }

    .btn.secondary:hover {
      border-color: var(--text-3);
      background: var(--surface-2);
    }

    .btn.ghost {
      border-color: transparent;
      background: transparent;
      color: var(--text-2);
    }

    .btn.ghost:hover {
      background: var(--surface-2);
      color: var(--text);
    }

    .btn.danger {
      border-color: var(--danger);
      background: var(--danger);
      color: #ffffff;
    }

    .btn.danger:hover {
      border-color: var(--danger-hover);
      background: var(--danger-hover);
    }

    .btn.danger-ghost {
      border-color: var(--danger-border);
      background: transparent;
      color: var(--danger);
    }

    .btn.danger-ghost:hover {
      background: var(--danger-weak);
    }

    .btn:disabled,
    .btn.is-blocked {
      cursor: not-allowed;
      opacity: 0.58;
    }

    .btn.secondary.is-blocked {
      border-color: var(--border);
      background: var(--surface-2);
      color: var(--text-3);
    }

    .btn.secondary.is-blocked:hover {
      border-color: var(--border);
      background: var(--surface-2);
      color: var(--text-3);
    }

    .btn-sm {
      min-height: 36px;
      padding: 0 12px;
      font-size: 13px;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 2px 8px;
      border: 1px solid transparent;
      border-radius: 999px;
      font-size: 11.5px;
      font-weight: 650;
      line-height: 1.4;
      white-space: nowrap;
    }

    .badge-neutral {
      border-color: var(--border);
      background: var(--surface-2);
      color: var(--text-2);
    }

    .badge.type-required {
      border-color: var(--required-border);
      background: var(--required-bg);
      color: var(--required-text);
    }

    .badge.type-elective {
      border-color: var(--elective-border);
      background: var(--elective-bg);
      color: var(--elective-text);
    }

    .badge.type-general {
      border-color: var(--general-border);
      background: var(--general-bg);
      color: var(--general-text);
    }

    .progress {
      position: relative;
      width: 100%;
      height: 5px;
      overflow: hidden;
      border-radius: 999px;
      background: var(--surface-3);
    }

    .progress > span {
      display: block;
      height: 100%;
      border-radius: inherit;
      background: var(--primary-solid);
    }

    .progress.is-near > span {
      background: var(--warning);
    }

    .progress.is-full > span {
      background: var(--danger);
    }

    .progress-sm {
      width: 88px;
      height: 5px;
    }

    /* ---------- Tabs and panel headings ---------- */

    .tabbar-wrap {
      margin: 0 0 24px;
      border-bottom: 1px solid var(--border);
    }

    .tabbar {
      display: flex;
      align-items: center;
      gap: 28px;
    }

    .tab-btn {
      position: relative;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      min-height: 46px;
      padding: 0 2px;
      border: 0;
      background: transparent;
      color: var(--text-2);
      font-size: 15px;
      font-weight: 600;
    }

    .tab-btn:hover {
      color: var(--text);
    }

    .tab-btn[aria-selected="true"] {
      color: var(--primary);
    }

    .tab-btn[aria-selected="true"]::after {
      content: "";
      position: absolute;
      right: 0;
      bottom: -1px;
      left: 0;
      height: 2px;
      border-radius: 2px;
      background: var(--primary);
    }

    .tab-count {
      display: inline-grid;
      place-items: center;
      min-width: 22px;
      height: 22px;
      padding: 0 6px;
      border-radius: 999px;
      background: var(--surface-2);
      color: var(--text-2);
      font-size: 11.5px;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
    }

    .tab-btn[aria-selected="true"] .tab-count {
      background: var(--primary-weak);
      color: var(--primary);
    }

    .panel-head {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 18px;
      flex-wrap: wrap;
      margin: 0 0 18px;
    }

    .panel-head h2 {
      font-size: 20px;
      line-height: 1.3;
      font-weight: 700;
      letter-spacing: -0.01em;
    }

    .panel-head p {
      margin-top: 4px;
      color: var(--text-2);
      font-size: 13.5px;
    }

    .panel-summary {
      color: var(--text-3);
      font-size: 13px;
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }

    /* ---------- Filters and form controls ---------- */

    .filter-bar {
      display: grid;
      grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(136px, 1fr)) auto;
      align-items: end;
      gap: 12px;
      margin: 0 0 20px;
      padding: 16px;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface);
    }

    .filter-bar-admin {
      grid-template-columns: minmax(180px, 240px) minmax(180px, 240px) auto;
      justify-content: start;
      background: var(--surface-2);
    }

    .filter-field {
      display: flex;
      flex-direction: column;
      gap: 6px;
      min-width: 0;
    }

    .filter-label {
      color: var(--text-2);
      font-size: 12.5px;
      font-weight: 600;
    }

    .filter-reset {
      align-self: end;
    }

    .search-control {
      position: relative;
      display: block;
      min-width: 0;
    }

    .search-control .od-icon {
      position: absolute;
      top: 50%;
      left: 12px;
      z-index: 1;
      transform: translateY(-50%);
      color: var(--text-3);
      pointer-events: none;
    }

    .search-control input {
      padding-left: 38px;
    }

    .input,
    .select,
    .textarea,
    .search-control input {
      width: 100%;
      min-height: 42px;
      padding: 9px 12px;
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-sm);
      background: var(--surface);
      color: var(--text);
      font-size: 14.5px;
      line-height: 1.5;
      transition: border-color 150ms ease, box-shadow 150ms ease;
    }

    .textarea {
      min-height: 96px;
      resize: vertical;
    }

    .input::placeholder,
    .textarea::placeholder {
      color: var(--text-3);
      opacity: 1;
    }

    .input:focus,
    .select:focus,
    .textarea:focus,
    .search-control input:focus {
      outline: none;
      border-color: var(--focus);
      box-shadow: 0 0 0 3px var(--focus-ring);
    }

    .input[aria-invalid="true"],
    .select[aria-invalid="true"],
    .textarea[aria-invalid="true"] {
      border-color: var(--danger);
    }

    .field {
      display: flex;
      flex-direction: column;
      gap: 6px;
      min-width: 0;
    }

    .field label {
      color: var(--text-2);
      font-size: 13px;
      font-weight: 600;
    }

    .required-mark {
      color: var(--danger);
      font-weight: 700;
    }

    .field-hint {
      color: var(--text-3);
      font-size: 12px;
      line-height: 1.45;
    }

    .field-error {
      color: var(--danger);
      font-size: 12.5px;
      line-height: 1.45;
    }

    /* ---------- Single-column Course Catalog ---------- */

    .course-catalog {
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface);
      overflow: hidden;
    }

    .course-row {
      display: flex;
      align-items: center;
      gap: 16px;
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
      transition: background-color 150ms ease;
    }

    .course-row:last-child {
      border-bottom: 0;
    }

    .course-row:hover {
      background: var(--surface-2);
    }

    .course-row:focus-visible {
      outline: 2px solid var(--focus);
      outline-offset: -2px;
    }

    .course-subject-icon {
      display: grid;
      place-items: center;
      flex: none;
      width: 36px;
      height: 36px;
      border-radius: 8px;
      border: 1px solid transparent;
    }

    .course-subject-icon.type-required {
      background: var(--required-bg);
      border-color: var(--required-border);
      color: var(--required-text);
    }

    .course-subject-icon.type-elective {
      background: var(--elective-bg);
      border-color: var(--elective-border);
      color: var(--elective-text);
    }

    .course-subject-icon.type-general {
      background: var(--general-bg);
      border-color: var(--general-border);
      color: var(--general-text);
    }

    .course-main {
      flex: 1 1 0;
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .course-top-line {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 8px;
      min-width: 0;
    }

    .course-title {
      font-size: 15px;
      font-weight: 600;
      line-height: 1.4;
      color: var(--text);
    }

    .course-code {
      padding: 1px 6px;
      border: 1px solid var(--border);
      border-radius: 5px;
      background: var(--surface-2);
      color: var(--text-2);
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      font-size: 11px;
      font-weight: 600;
      white-space: nowrap;
    }

    .course-dept-credit {
      color: var(--text-3);
      font-size: 12.5px;
      white-space: nowrap;
    }

    .course-desc-line {
      color: var(--text-2);
      font-size: 13px;
      line-height: 1.45;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .course-meta-line {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 14px;
      color: var(--text-3);
      font-size: 12px;
      line-height: 1.4;
    }

    .course-meta-item {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      white-space: nowrap;
    }

    .course-capacity-col {
      flex: none;
      width: 148px;
      display: flex;
      flex-direction: column;
      gap: 5px;
    }

    .course-capacity-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      font-size: 12px;
      color: var(--text-2);
      font-variant-numeric: tabular-nums;
    }

    .course-capacity-top strong {
      color: var(--text);
      font-weight: 600;
    }

    .capacity-pct {
      color: var(--text-3);
      font-weight: 600;
      white-space: nowrap;
    }

    .capacity-pct.is-near {
      color: var(--warning);
    }

    .capacity-pct.is-full {
      color: var(--danger);
    }

    .progress-compact {
      width: 110px;
      height: 4px;
    }

    .course-seats-text {
      font-size: 11.5px;
      color: var(--text-3);
      white-space: nowrap;
    }

    .course-seats-text.is-full {
      color: var(--danger);
    }

    .course-action-col {
      flex: none;
      width: 108px;
      display: flex;
      justify-content: flex-end;
      align-items: center;
    }

    .btn-enroll-outline {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      height: 32px;
      padding: 0 14px;
      border: 1px solid var(--primary-solid);
      border-radius: 8px;
      background: var(--surface);
      color: var(--primary-solid);
      font-size: 13px;
      font-weight: 600;
      white-space: nowrap;
      transition: background-color 150ms ease, color 150ms ease;
    }

    .btn-enroll-outline:hover {
      background: var(--primary-weak);
    }

    .status-text-selected {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      color: var(--success);
      font-size: 13px;
      font-weight: 600;
      white-space: nowrap;
    }

    .status-text-blocked {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 4px 0;
      border: 0;
      background: transparent;
      color: var(--danger);
      font-size: 12.5px;
      font-weight: 600;
      white-space: nowrap;
      cursor: pointer;
    }

    .status-text-blocked.is-muted {
      color: var(--text-3);
    }

    /* ---------- Timetable ---------- */

    .timetable-card {
      padding: 16px;
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      background: var(--surface);
    }

    .tt-grid {
      display: grid;
      grid-template-columns: 52px repeat(7, minmax(0, 1fr));
      gap: 6px;
      align-items: start;
    }

    .tt-corner {
      grid-column: 1;
      grid-row: 1;
      padding-bottom: 4px;
      color: var(--text-3);
      font-size: 11.5px;
      text-align: center;
    }

    .tt-dayhead {
      grid-row: 1;
      padding: 4px 0 8px;
      color: var(--text-2);
      font-size: 12.5px;
      font-weight: 650;
      text-align: center;
      white-space: nowrap;
    }

    .tt-dayhead.is-weekend {
      color: var(--text-3);
    }

    .tt-times {
      grid-column: 1;
      grid-row: 2;
      display: grid;
      grid-template-rows: repeat(12, 64px);
      gap: 4px;
    }

    .tt-time {
      display: flex;
      align-items: flex-start;
      justify-content: center;
      padding-top: 5px;
      color: var(--text-3);
      font-size: 11px;
      font-variant-numeric: tabular-nums;
    }

    .tt-day-col {
      grid-row: 2;
      display: grid;
      grid-template-rows: repeat(12, 64px);
      gap: 4px;
      border-radius: 8px;
      background-color: var(--surface);
      background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 64px,
        var(--border) 64px,
        var(--border) 65px,
        transparent 65px,
        transparent 68px
      );
    }

    .tt-day-col.is-weekend {
      background-color: var(--surface-2);
    }

    .tt-course {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
      padding: 6px 7px;
      overflow: hidden;
      border: 1px solid transparent;
      border-radius: 7px;
    }

    .tt-course.type-required {
      border-color: var(--required-border);
      background: var(--required-bg);
    }

    .tt-course.type-elective {
      border-color: var(--elective-border);
      background: var(--elective-bg);
    }

    .tt-course.type-general {
      border-color: var(--general-border);
      background: var(--general-bg);
    }

    .tt-course-name {
      display: -webkit-box;
      overflow: hidden;
      color: var(--text);
      font-size: 12px;
      font-weight: 650;
      line-height: 1.3;
      overflow-wrap: anywhere;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
    }

    .tt-course-room {
      overflow: hidden;
      color: var(--text-2);
      font-size: 10.5px;
      line-height: 1.35;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .agenda {
      display: none;
      flex-direction: column;
      gap: 12px;
    }

    .agenda-day {
      padding: 15px;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface);
    }

    .agenda-day-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 10px;
    }

    .agenda-day-head h3 {
      font-size: 15px;
      font-weight: 700;
    }

    .agenda-day-head span {
      color: var(--text-3);
      font-size: 12px;
      font-variant-numeric: tabular-nums;
    }

    .agenda-items {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .agenda-course {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 14px;
      padding: 10px 12px;
      border: 1px solid transparent;
      border-radius: 9px;
    }

    .agenda-course.type-required {
      border-color: var(--required-border);
      background: var(--required-bg);
    }

    .agenda-course.type-elective {
      border-color: var(--elective-border);
      background: var(--elective-bg);
    }

    .agenda-course.type-general {
      border-color: var(--general-border);
      background: var(--general-bg);
    }

    .agenda-course-main {
      display: flex;
      flex-direction: column;
      gap: 3px;
      min-width: 0;
    }

    .agenda-course-main strong {
      font-size: 14px;
      font-weight: 650;
      line-height: 1.4;
      overflow-wrap: anywhere;
    }

    .agenda-course-main span {
      color: var(--text-2);
      font-size: 12px;
    }

    .agenda-period {
      flex: none;
      color: var(--text-2);
      font-size: 12px;
      font-weight: 600;
      white-space: nowrap;
      font-variant-numeric: tabular-nums;
    }

    /* ---------- Selected course list ---------- */

    .selected-card {
      margin-top: 18px;
      padding: 20px;
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      background: var(--surface);
    }

    .selected-head {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 16px;
      flex-wrap: wrap;
      margin-bottom: 6px;
    }

    .selected-head h3 {
      font-size: 17px;
      font-weight: 700;
    }

    .selected-head span {
      color: var(--text-3);
      font-size: 12.5px;
      font-variant-numeric: tabular-nums;
    }

    .selected-list {
      display: flex;
      flex-direction: column;
    }

    .selected-row {
      display: grid;
      grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.1fr) auto;
      align-items: center;
      gap: 16px;
      padding: 14px 0;
      border-top: 1px solid var(--border);
    }

    .selected-row:first-child {
      border-top: 0;
    }

    .selected-info {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }

    .selected-info strong {
      font-size: 14.5px;
      font-weight: 650;
      line-height: 1.4;
      overflow-wrap: anywhere;
    }

    .selected-info span {
      color: var(--text-3);
      font-size: 12px;
    }

    .selected-secondary {
      display: flex;
      align-items: center;
      gap: 14px;
      flex-wrap: wrap;
      color: var(--text-2);
      font-size: 12.5px;
    }

    .selected-secondary span {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      min-width: 0;
    }

    .selected-secondary .od-icon {
      color: var(--text-3);
    }

    /* ---------- Teacher ---------- */

    .teacher-course-list {
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .teacher-course {
      padding: 20px;
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      background: var(--surface);
    }

    .teacher-course-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 18px;
      margin-bottom: 10px;
    }

    .teacher-course-head h3 {
      font-size: 18px;
      line-height: 1.4;
      font-weight: 700;
      letter-spacing: -0.012em;
      overflow-wrap: anywhere;
    }

    .teacher-course-head p {
      margin-top: 3px;
      color: var(--text-3);
      font-size: 12.5px;
    }

    .teacher-meta {
      display: flex;
      align-items: center;
      gap: 16px;
      flex-wrap: wrap;
      color: var(--text-2);
      font-size: 13px;
    }

    .teacher-meta span {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .teacher-meta .od-icon {
      color: var(--text-3);
    }

    .teacher-metrics {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 12px;
      margin: 16px 0 12px;
    }

    .metric {
      display: flex;
      flex-direction: column;
      gap: 2px;
      padding: 11px 13px;
      border: 1px solid var(--border);
      border-radius: 9px;
      background: var(--surface-2);
      min-width: 0;
    }

    .metric > span {
      color: var(--text-3);
      font-size: 11.5px;
      font-weight: 600;
    }

    .metric strong {
      font-size: 20px;
      line-height: 1.25;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }

    .metric-sub {
      color: var(--text-3);
      font-size: 12px;
      font-weight: 500;
    }

    .teacher-actions {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-top: 14px;
    }

    .teacher-action-buttons {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-left: auto;
    }

    .panel-head-actions {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 14px;
    }

    .roster {
      margin-top: 16px;
      padding-top: 16px;
      border-top: 1px solid var(--border);
    }

    .roster-title {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 16px;
      margin-bottom: 8px;
    }

    .roster-title h4 {
      font-size: 14.5px;
      font-weight: 700;
    }

    .roster-title span {
      color: var(--text-3);
      font-size: 12px;
      font-variant-numeric: tabular-nums;
    }

    .roster-list {
      display: flex;
      flex-direction: column;
    }

    .roster-row {
      display: grid;
      grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr) minmax(0, 1.1fr) auto;
      gap: 14px;
      align-items: center;
      padding: 10px 0;
      border-bottom: 1px solid var(--border);
      font-size: 13px;
      color: var(--text-2);
    }

    .roster-row:last-child {
      border-bottom: 0;
    }

    .roster-head {
      color: var(--text-3);
      font-size: 11.5px;
      font-weight: 600;
      padding-top: 4px;
      padding-bottom: 7px;
    }

    .roster-name {
      color: var(--text);
      font-weight: 600;
    }

    .roster-date {
      justify-self: end;
      color: var(--text-3);
      font-variant-numeric: tabular-nums;
    }

    .roster-empty {
      padding: 18px 0 6px;
      color: var(--text-3);
      font-size: 13px;
    }

    /* ---------- Admin ---------- */

    .content-panel {
      padding: 22px;
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      background: var(--surface);
    }

    .admin-table-meta {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin: 0 0 10px;
      color: var(--text-3);
      font-size: 12.5px;
      font-variant-numeric: tabular-nums;
    }

    .table-wrap {
      width: 100%;
      overflow: visible;
    }

    .data-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13.5px;
    }

    .data-table th {
      padding: 10px 10px;
      border-bottom: 1px solid var(--border);
      color: var(--text-3);
      font-size: 11.5px;
      font-weight: 650;
      text-align: left;
      white-space: nowrap;
    }

    .data-table td {
      padding: 14px 10px;
      border-bottom: 1px solid var(--border);
      color: var(--text-2);
      vertical-align: middle;
    }

    .data-table tbody tr:last-child td {
      border-bottom: 0;
    }

    .cell-course {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }

    .cell-course strong {
      color: var(--text);
      font-size: 14px;
      font-weight: 650;
      line-height: 1.4;
      overflow-wrap: anywhere;
    }

    .cell-course span {
      color: var(--text-3);
      font-size: 11.5px;
      font-variant-numeric: tabular-nums;
    }

    .cell-stack {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 3px;
      min-width: 0;
    }

    .cell-enroll {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
      font-variant-numeric: tabular-nums;
    }

    .cell-enroll-count {
      color: var(--text);
      font-weight: 600;
      white-space: nowrap;
    }

    .cell-enroll-pct {
      color: var(--text-3);
      font-size: 11.5px;
      white-space: nowrap;
    }

    .table-actions {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
    }

    /* ---------- Empty states and notices ---------- */

    .empty-state {
      padding: 42px 24px;
      border: 1px dashed var(--border-strong);
      border-radius: var(--radius-lg);
      background: var(--surface);
      text-align: center;
    }

    .empty-icon {
      display: grid;
      place-items: center;
      width: 48px;
      height: 48px;
      margin: 0 auto 12px;
      border-radius: 12px;
      background: var(--primary-weak);
      color: var(--primary);
    }

    .empty-state h3 {
      font-size: 17px;
      font-weight: 700;
    }

    .empty-state p {
      max-width: 46ch;
      margin: 6px auto 0;
      color: var(--text-2);
      font-size: 13.5px;
      line-height: 1.6;
    }

    .empty-state .btn {
      margin-top: 16px;
    }

    .notice {
      display: flex;
      align-items: flex-start;
      gap: 9px;
      margin: 0 0 20px;
      padding: 12px 14px;
      border: 1px solid var(--general-border);
      border-radius: var(--radius-sm);
      background: var(--general-bg);
      color: var(--general-text);
      font-size: 13px;
      line-height: 1.55;
    }

    .notice .od-icon {
      margin-top: 2px;
      flex: none;
    }

    /* ---------- Dialogs ---------- */

    .dialog {
      display: flex;
      flex-direction: column;
      width: min(820px, calc(100vw - 32px));
      max-height: min(90vh, 860px);
      padding: 0;
      overflow: hidden;
      border: 1px solid var(--border);
      border-radius: 16px;
      background: var(--surface);
      color: var(--text);
      box-shadow: 0 24px 80px rgba(12, 24, 44, 0.22);
    }

    .dialog::backdrop {
      background: rgba(9, 19, 34, 0.52);
    }

    .dialog-sm {
      width: min(480px, calc(100vw - 32px));
    }

    .dialog-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 18px;
      padding: 22px 22px 16px;
      border-bottom: 1px solid var(--border);
    }

    .dialog-head .eyebrow {
      margin-bottom: 4px;
    }

    .dialog-head h2 {
      font-size: 21px;
      line-height: 1.3;
      font-weight: 700;
      letter-spacing: -0.015em;
    }

    .dialog-body {
      overflow-y: auto;
      padding: 20px 22px;
      min-height: 0;
    }

    .dialog-foot {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 10px;
      padding: 16px 22px;
      border-top: 1px solid var(--border);
      background: var(--surface);
    }

    .confirm-message {
      font-size: 15px;
      line-height: 1.65;
      overflow-wrap: anywhere;
    }

    .confirm-note {
      margin-top: 8px;
      color: var(--text-2);
      font-size: 13px;
      line-height: 1.6;
    }

    .form-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 16px;
    }

    .field-span-3 {
      grid-column: 1 / -1;
    }

    /* ---------- Toasts ---------- */

    .toast-region {
      position: fixed;
      right: 20px;
      bottom: 20px;
      z-index: 90;
      display: flex;
      flex-direction: column;
      gap: 8px;
      width: min(380px, calc(100vw - 32px));
      pointer-events: none;
    }

    .toast {
      display: flex;
      align-items: flex-start;
      gap: 9px;
      padding: 12px 14px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--surface);
      color: var(--text);
      font-size: 13.5px;
      line-height: 1.5;
      box-shadow: var(--shadow-toast);
      pointer-events: auto;
      animation: toast-in 180ms ease-out both;
    }

    .toast .od-icon {
      margin-top: 2px;
    }

    .toast-success .toast-icon {
      color: var(--success);
    }

    .toast-error .toast-icon {
      color: var(--danger);
    }

    .toast-info .toast-icon {
      color: var(--primary);
    }

    .toast.is-leaving {
      opacity: 0;
      transform: translateY(4px);
      transition: opacity 160ms ease-in, transform 160ms ease-in;
    }

    .toast-message {
      min-width: 0;
      overflow-wrap: anywhere;
    }

    @keyframes toast-in {
      from {
        opacity: 0;
        transform: translateY(6px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    /* ---------- Footer ---------- */

    .app-footer {
      width: min(1280px, 100%);
      margin: 0 auto;
      padding: 0 28px 32px;
      color: var(--text-3);
      font-size: 12px;
    }

    .app-footer p {
      padding-top: 18px;
      border-top: 1px solid var(--border);
    }

    /* ---------- Responsive ---------- */

    @media (hover: hover) {
      .btn.primary:disabled:hover,
      .btn.is-blocked:hover {
        border-color: var(--border);
        background: var(--surface-2);
        color: var(--text-3);
      }

      .data-table tbody tr:hover {
        background: var(--surface-2);
      }
    }

    @media (max-width: 1100px) {
      .data-table thead {
        display: none;
      }

      .data-table,
      .data-table tbody,
      .data-table tr,
      .data-table td {
        display: block;
        width: 100%;
      }

      .data-table tr {
        margin-bottom: 12px;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: 11px;
        background: var(--surface);
      }

      .data-table tr:last-child {
        margin-bottom: 0;
      }

      .data-table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 18px;
        padding: 6px 0;
        border: 0;
      }

      .data-table td::before {
        content: attr(data-label);
        flex: none;
        min-width: 78px;
        color: var(--text-3);
        font-size: 11.5px;
        font-weight: 600;
      }

      .data-table td > * {
        min-width: 0;
      }

      .data-table td[data-label="操作"] {
        padding-top: 11px;
        margin-top: 4px;
        border-top: 1px solid var(--border);
      }

      .data-table td[data-label="操作"]::before {
        align-self: center;
      }

      .table-actions {
        justify-content: flex-end;
        flex: 1;
      }
    }

    @media (max-width: 960px) {
      .timetable-desktop {
        display: none;
      }

      .agenda {
        display: flex;
      }
    }

    @media (max-width: 900px) {
      .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .filter-field-search {
        grid-column: 1 / -1;
      }

      .filter-bar .filter-reset {
        grid-column: 1 / -1;
        justify-self: start;
      }
    }

    @media (max-width: 760px) {
      .app-header {
        position: static;
      }

      .header-inner {
        flex-wrap: wrap;
        gap: 12px;
        padding: 14px 20px;
      }

      .header-controls {
        width: 100%;
        justify-content: space-between;
      }

      .app-main {
        padding: 26px 20px 44px;
      }

      .app-footer {
        padding: 0 20px 28px;
      }

      .tabbar {
        gap: 22px;
      }

      .filter-bar {
        padding: 14px;
      }

      .campus-art {
        display: none;
      }

      .course-row {
        flex-wrap: wrap;
        gap: 12px;
        padding: 14px 16px;
      }

      .course-main {
        flex: 1 1 calc(100% - 52px);
      }

      .course-capacity-col {
        width: auto;
        flex: 1 1 160px;
        margin-left: 52px;
      }

      .course-action-col {
        width: auto;
      }
    }

    @media (max-width: 640px) {
      .brand-sub {
        display: none;
      }

      .stat-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 22px;
      }

      .stat-card {
        padding: 16px 18px;
      }

      .summary-band {
        grid-template-columns: 1fr;
        margin-bottom: 22px;
      }

      .summary-col {
        padding: 16px 18px;
      }

      .summary-col + .summary-col {
        border-left: 0;
        border-top: 1px solid var(--border);
      }

      .stat-value {
        font-size: 27px;
      }

      .course-capacity-col {
        margin-left: 0;
      }

      .filter-bar,
      .filter-bar-admin {
        grid-template-columns: minmax(0, 1fr);
      }

      .filter-field,
      .filter-bar .filter-reset {
        grid-column: 1 / -1;
      }

      .panel-head {
        align-items: flex-start;
      }

      .selected-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 14px;
      }

      .selected-secondary {
        grid-column: 1 / -1;
        grid-row: 2;
      }

      .selected-row .btn {
        grid-column: 2;
        grid-row: 1;
      }

      .teacher-metrics {
        grid-template-columns: 1fr;
      }

      .roster-head {
        display: none;
      }

      .roster-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 4px 14px;
        padding: 11px 0;
      }

      .roster-name {
        grid-column: 1;
      }

      .roster-row > :nth-child(2) {
        grid-column: 2;
        justify-self: end;
      }

      .roster-row > :nth-child(3) {
        grid-column: 1 / -1;
        color: var(--text-3);
      }

      .roster-date {
        grid-column: 2;
        justify-self: end;
      }

      .dialog {
        max-height: 92vh;
      }

      .dialog-head,
      .dialog-body,
      .dialog-foot {
        padding-right: 18px;
        padding-left: 18px;
      }

      .form-grid {
        grid-template-columns: minmax(0, 1fr);
      }

      .field-span-3 {
        grid-column: 1;
      }

      .toast-region {
        right: 16px;
        bottom: 16px;
        left: 16px;
        width: auto;
      }

      .data-table td {
        gap: 12px;
      }

      .table-actions {
        justify-content: flex-start;
      }

      .btn {
        min-height: 44px;
      }

      .btn-sm {
        min-height: 40px;
      }
    }

    @media (max-width: 430px) {
      .app-main {
        padding-right: 16px;
        padding-left: 16px;
      }

      .header-inner {
        padding-right: 16px;
        padding-left: 16px;
      }

      .app-footer {
        padding-right: 16px;
        padding-left: 16px;
      }

      .teacher-course,
      .content-panel,
      .selected-card {
        padding: 16px;
      }

      .page-head h1 {
        font-size: 26px;
      }

      .agenda-course {
        flex-direction: column;
        gap: 4px;
      }

      .agenda-period {
        align-self: flex-start;
      }

      .data-table td {
        flex-direction: column;
        gap: 3px;
      }

      .data-table td::before {
        min-width: 0;
      }

      .table-actions {
        width: 100%;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
      }
    }
  
/* ===== INK & SEAL ===== */
/* ============================================================
   INK & SEAL — 明德教务 · 砚墨朱印
   Visual override for the functional A prototype.
   ============================================================ */

:root {
  --font-serif: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", STSong, Georgia, serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, Monaco, "Liberation Mono", monospace;

  --bg: #f7f5f0;
  --surface: #fffdf9;
  --surface-2: #efebe3;
  --surface-3: #e4ddd2;

  --text: #1f1c19;
  --text-2: #5c5348;
  --text-3: #8c8275;

  --border: #ded8ce;
  --border-strong: #beab95;

  --primary: #9e2a2b;
  --primary-solid: #9e2a2b;
  --primary-solid-hover: #852223;
  --primary-weak: #f8ebeb;
  --primary-weak-2: #f2dcdc;
  --primary-border: #e2bcbd;
  --focus: #9e2a2b;
  --focus-ring: rgba(158, 42, 43, 0.15);

  --success: #2d6a4f;
  --success-weak: #eaf2ec;
  --warning: #995d13;
  --warning-weak: #fdf5ea;
  --danger: #b3261e;
  --danger-hover: #8f1d17;
  --danger-weak: #fce8e6;
  --danger-border: #e2b4b0;

  --required-bg: #f4eae2;
  --required-border: #dcbcab;
  --required-text: #743516;
  --elective-bg: #e5ede7;
  --elective-border: #b8d2bf;
  --elective-text: #23533e;
  --general-bg: #f7f1dd;
  --general-border: #e4d3a2;
  --general-text: #684e12;

  --shadow: none;
  --shadow-toast: 0 4px 16px rgba(31, 28, 25, 0.08);

  --radius-sm: 2px;
  --radius-md: 2px;
  --radius-lg: 3px;
  --radius-full: 2px;
  --header-height: 64px;
}

:root[data-theme="dark"] {
  --bg: #121110;
  --surface: #1a1816;
  --surface-2: #151312;
  --surface-3: #23201d;
  --text: #ede9e1;
  --text-2: #b5aba0;
  --text-3: #787066;
  --border: #2f2b26;
  --border-strong: #4a433b;
  --primary: #c94a4c;
  --primary-solid: #c94a4c;
  --primary-solid-hover: #db5a5c;
  --primary-weak: #2a1617;
  --primary-weak-2: #3a1a1c;
  --primary-border: #5a2a2c;
  --focus: #e07172;
  --focus-ring: rgba(201, 74, 76, 0.22);
  --success: #529e77;
  --success-weak: #16281e;
  --warning: #c78b3a;
  --warning-weak: #2f200c;
  --danger: #e05d55;
  --danger-hover: #ef6f67;
  --danger-weak: #331514;
  --danger-border: #6a2a27;
  --required-bg: #2e1d14;
  --required-border: #5a3a28;
  --required-text: #edc5ac;
  --elective-bg: #16281e;
  --elective-border: #2b5a4f;
  --elective-text: #b3e6d7;
  --general-bg: #2f2412;
  --general-border: #5b4724;
  --general-text: #f2d79f;
  --shadow: none;
  --shadow-toast: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* ---------- base ---------- */

body { background: var(--bg); color: var(--text); font-family: var(--font); }

h1, h2, h3, h4,
.page-head h1,
.panel-head h2,
.course-title,
.teacher-course-head h3,
.dialog-head h2,
.selected-head h3,
.empty-state h3,
.brand-title {
  font-family: var(--font-serif);
  letter-spacing: 0;
}

.eyebrow,
.filter-label,
.course-code,
.capacity-pct,
.course-seats-text,
.stat-label,
.selected-info span,
.roster-head,
.data-table th,
.semester-chip,
.brand-sub,
.course-dept-credit {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ---------- header ---------- */

.app-header { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: none; }
.header-inner { min-height: 64px; padding-top: 8px; padding-bottom: 8px; }

.brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid var(--primary);
  border-radius: 2px;
  background: transparent;
  color: var(--primary);
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 3px var(--primary-border);
}

.brand-title { font-size: 15px; font-weight: 700; }
.brand-sub { margin-top: 2px; font-size: 9px; letter-spacing: 0.1em; color: var(--text-3); }

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 2px;
  border-color: var(--border);
  background: var(--surface);
}

/* ---------- page head ---------- */

.app-main { padding: 24px 28px 44px; }
.page-head { margin-bottom: 16px; }
.page-head .eyebrow { margin-bottom: 5px; color: var(--text-3); font-size: 10px; letter-spacing: 0.08em; }
.page-head h1 { font-size: clamp(26px, 2.6vw, 32px); font-weight: 700; line-height: 1.2; }
.page-sub { margin-top: 4px; color: var(--text-2); font-size: 12px; }
.page-head-right { gap: 14px; }
.campus-art { color: var(--text-3); opacity: 0.55; }

.semester-chip {
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--primary);
  border-radius: 2px;
  background: transparent;
  color: var(--primary);
  font-size: 10px;
  font-weight: 600;
  box-shadow: inset 0 0 0 2px var(--bg), inset 0 0 0 3px var(--primary-border);
  transform: rotate(-0.7deg);
}

.semester-chip .od-icon { color: var(--primary); }

/* ---------- summary band ---------- */

.summary-band {
  border: 1px solid var(--border);
  border-top: 1px solid var(--border-strong);
  border-radius: 2px;
  background: var(--surface);
  margin-bottom: 18px;
}

.summary-col { padding: 13px 18px 12px; gap: 3px; }
.summary-col + .summary-col { border-left: 1px solid var(--border); }

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.stat-label::before { content: ""; width: 5px; height: 5px; background: var(--primary); flex: none; }

.stat-value {
  margin-top: 2px;
  font-family: var(--font-serif);
  font-size: 29px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stat-unit { margin-left: 4px; color: var(--text-3); font-family: var(--font-mono); font-size: 10px; font-weight: 500; }
.stat-foot { color: var(--text-3); font-size: 10px; }

.summary-col .progress { height: 3px; margin: 6px 0 2px; border-radius: 0; background: var(--surface-3); }
.summary-col .progress > span { border-radius: 0; background: var(--primary); }

.progress { border-radius: 0; background: var(--surface-3); }
.progress > span { border-radius: 0; background: var(--success); }
.progress.is-near > span { background: var(--warning); }
.progress.is-full > span { background: var(--danger); }

/* ---------- tabs ---------- */

.tabbar-wrap { margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tabbar { gap: 4px; align-items: flex-end; }

.tab-btn {
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
}

.tab-btn[aria-selected="true"] {
  position: relative;
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-serif);
  font-weight: 700;
}

.tab-btn[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  left: -1px;
  height: 2px;
  background: var(--primary);
}

.tab-count {
  min-width: 18px;
  height: 18px;
  border-radius: 2px;
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 9px;
}

.tab-btn[aria-selected="true"] .tab-count { background: var(--primary-weak); color: var(--primary); }

/* ---------- panel head ---------- */

.panel-head { margin-bottom: 10px; }
.panel-head h2 { font-size: 18px; font-weight: 700; }
.panel-head p { margin-top: 2px; color: var(--text-3); font-size: 10.5px; }
.panel-summary { color: var(--text-3); font-size: 9.5px; }

/* ---------- filters ---------- */

.filter-bar {
  gap: 8px;
  margin-bottom: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface-2);
}

.filter-label { color: var(--text-3); font-size: 9px; font-weight: 500; }

.input,
.select,
.textarea,
.search-control input {
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface);
  color: var(--text);
  font-size: 11.5px;
}

.input:focus,
.select:focus,
.textarea:focus,
.search-control input:focus {
  border-color: var(--text-2);
  box-shadow: 0 0 0 2px rgba(74, 63, 53, 0.1);
}

.search-control input { padding-left: 30px; }
.search-control .od-icon { left: 9px; color: var(--text-3); }
.filter-bar .btn { min-height: 32px; }

.btn {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 2px;
  font-size: 11.5px;
  font-weight: 500;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover { border-color: var(--primary-solid-hover); background: var(--primary-solid-hover); }

.btn.secondary { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--text-2); }
.btn.ghost { color: var(--text-3); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger-ghost { border-color: var(--danger-border); color: var(--danger); }
.btn.secondary.is-blocked { border-color: var(--border); background: var(--surface-2); color: var(--text-3); }
.btn.secondary.is-blocked:hover { background: var(--surface-2); color: var(--text-3); }

/* ---------- ledger header ---------- */

.ledger-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 7px 20px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.ledger-head span:nth-child(1) { width: 36px; flex: none; }
.ledger-head span:nth-child(2) { flex: 1 1 0; min-width: 0; }
.ledger-head span:nth-child(3) { width: 148px; flex: none; }
.ledger-head span:nth-child(4) { width: 108px; flex: none; text-align: right; }
.ledger-head + .course-catalog { border-top: 0; border-radius: 0 0 2px 2px; }

/* ---------- course rows ---------- */

.course-catalog { border: 1px solid var(--border); border-radius: 2px; background: var(--surface); }

.course-row {
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.course-row:last-child { border-bottom: 0; }
.course-row:hover { background: #fbf8f2; }
:root[data-theme="dark"] .course-row:hover { background: var(--surface-2); }

.course-subject-icon {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 2px;
}

.course-subject-icon.type-required { background: var(--required-bg); border-color: var(--required-border); color: var(--required-text); }
.course-subject-icon.type-elective { background: var(--elective-bg); border-color: var(--elective-border); color: var(--elective-text); }
.course-subject-icon.type-general { background: var(--general-bg); border-color: var(--general-border); color: var(--general-text); }

.course-main { gap: 3px; }
.course-top-line { gap: 7px; }

.course-title {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
}

.badge {
  min-height: 16px;
  padding: 0 5px;
  border-radius: 2px;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.badge.type-required { border-color: var(--required-border); background: var(--required-bg); color: var(--required-text); }
.badge.type-elective { border-color: var(--elective-border); background: var(--elective-bg); color: var(--elective-text); }
.badge.type-general { border-color: var(--general-border); background: var(--general-bg); color: var(--general-text); }

.course-code {
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--text-3);
  font-size: 9px;
  font-weight: 500;
  line-height: 15px;
}

.course-dept-credit { color: var(--text-3); font-size: 9.5px; }
.course-desc-line { color: var(--text-2); font-size: 10.5px; }
.course-meta-line { gap: 3px 12px; color: var(--text-3); font-size: 9.5px; }
.course-meta-item { gap: 4px; }

.course-capacity-col { width: 148px; gap: 4px; }
.course-capacity-top { font-size: 9.5px; color: var(--text-3); }
.course-capacity-top strong { color: var(--text); font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.capacity-pct { font-size: 9px; }
.progress-compact { width: 100%; height: 3px; border-radius: 0; }
.progress-compact > span { border-radius: 0; }
.course-seats-text { font-size: 9px; }

.course-action-col { width: 108px; }

.btn-enroll-outline {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--primary);
  border-radius: 2px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.btn-enroll-outline:hover { background: var(--primary-solid-hover); color: #fff; }

.status-text-selected {
  gap: 4px;
  color: var(--success);
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 600;
}

.status-text-blocked {
  gap: 4px;
  color: var(--danger);
  font-size: 10px;
  font-weight: 600;
}

.status-text-blocked.is-muted { color: var(--text-3); }

/* ---------- timetable ---------- */

.timetable-card { border: 1px solid var(--border); border-radius: 2px; background: var(--surface); }

.tt-dayhead {
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 700;
}

.tt-dayhead.is-weekend { background: var(--surface-2); color: var(--text-3); }
.tt-time { color: var(--text-3); font-family: var(--font-mono); font-size: 8.5px; }

.tt-day-col {
  border-radius: 0;
  background-color: var(--surface);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 61px,
    var(--border) 61px,
    var(--border) 62px,
    transparent 62px,
    transparent 66px
  );
}

.tt-day-col.is-weekend { background-color: var(--surface-2); }

.tt-course { border-radius: 2px; border-left-width: 3px; padding: 5px 6px; }
.tt-course.type-required { border-color: var(--required-border); border-left-color: var(--required-text); background: var(--required-bg); }
.tt-course.type-elective { border-color: var(--elective-border); border-left-color: var(--elective-text); background: var(--elective-bg); }
.tt-course.type-general { border-color: var(--general-border); border-left-color: var(--general-text); background: var(--general-bg); }
.tt-course-name { font-family: var(--font-serif); font-size: 10.5px; font-weight: 700; }
.tt-course-room { color: var(--text-2); font-size: 8.5px; }
.tt-course-time { color: var(--text-3); font-family: var(--font-mono); font-size: 8px; }
.tt-legend { border-top: 1px solid var(--border); color: var(--text-3); font-size: 9px; }
.legend-key { border-radius: 0; }
.legend-key.type-elective { background: var(--elective-text); }
.legend-key.type-general { background: var(--general-text); }

.agenda-day, .selected-card { border: 1px solid var(--border); border-radius: 2px; background: var(--surface); }
.agenda-course { border-radius: 2px; }
.agenda-course.type-required { border-color: var(--required-border); border-left-color: var(--required-text); background: var(--required-bg); }
.agenda-course.type-elective { border-color: var(--elective-border); border-left-color: var(--elective-text); background: var(--elective-bg); }
.agenda-course.type-general { border-color: var(--general-border); border-left-color: var(--general-text); background: var(--general-bg); }
.selected-row { border-top: 1px solid var(--border); }
.selected-info strong { font-family: var(--font-serif); }
.selected-secondary { color: var(--text-3); font-size: 10px; }

/* ---------- teacher ---------- */

.teacher-course { border: 1px solid var(--border); border-radius: 2px; background: var(--surface); }
.teacher-course-head h3 { font-size: 18px; font-weight: 700; }
.teacher-course-head p { color: var(--text-3); font-size: 10px; }
.teacher-meta { color: var(--text-3); font-size: 10px; }
.teacher-metrics { border: 1px solid var(--border); border-radius: 2px; gap: 0; background: var(--surface); }
.metric { padding: 8px 11px; border-left: 1px solid var(--border); background: var(--surface-2); }
.metric:first-child { border-left: 0; }
.metric > span { color: var(--text-3); font-family: var(--font-mono); font-size: 8.5px; }
.metric strong { font-family: var(--font-serif); font-size: 18px; }
.metric-sub { color: var(--text-3); font-size: 9px; }
.teacher-course .progress { height: 3px; border-radius: 0; }
.roster { border-top: 1px solid var(--border); }
.roster-title h4 { font-family: var(--font-serif); font-size: 12px; }
.roster-row { border-bottom: 1px solid var(--border); font-size: 10.5px; }
.roster-head { color: var(--text-3); font-size: 9px; }
.roster-name { font-weight: 600; }
.roster-date { font-family: var(--font-mono); }

/* ---------- admin ---------- */

.content-panel { border: 1px solid var(--border); border-radius: 2px; background: var(--surface); }
.filter-bar-admin { background: var(--surface-2); border-color: var(--border); }
.admin-table-meta { color: var(--text-3); font-size: 9.5px; }
.data-table { font-size: 10.5px; }
.data-table th { padding: 7px 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); font-size: 8.5px; font-weight: 500; letter-spacing: 0.04em; }
.data-table td { padding: 9px 8px; border-bottom: 1px solid var(--border); }
.cell-course strong { font-family: var(--font-serif); font-size: 11.5px; }
.cell-course span { font-size: 8.5px; }
.cell-enroll-count { font-family: var(--font-mono); }
.cell-enroll-pct { font-size: 8.5px; }
.data-table tbody tr:hover { background: #fbf8f2; }
:root[data-theme="dark"] .data-table tbody tr:hover { background: var(--surface-2); }

/* ---------- dialog ---------- */

.dialog { border: 1px solid var(--border-strong); border-radius: 2px; background: var(--surface); box-shadow: 0 18px 48px rgba(31, 28, 25, 0.22); }
.dialog::backdrop { background: rgba(18, 17, 16, 0.55); backdrop-filter: none; }
.dialog-head { padding: 18px 20px 13px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.dialog-head h2 { font-size: 19px; font-weight: 700; }
.dialog-body { padding: 16px 20px; }
.dialog-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.field label { color: var(--text-2); font-size: 10.5px; font-weight: 500; }
.field-hint { color: var(--text-3); font-size: 9.5px; }
.field-error { color: var(--danger); font-size: 9.5px; }
.required-mark { color: var(--primary); }
.form-grid { gap: 12px 14px; }
.textarea { min-height: 80px; }

/* ---------- toasts / empty ---------- */

.toast { border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 2px; background: var(--surface); box-shadow: var(--shadow-toast); font-size: 11.5px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--primary); }

.empty-state { border: 1px dashed var(--border-strong); border-radius: 2px; background: var(--surface); }
.empty-state h3 { font-size: 16px; font-weight: 700; }
.empty-state p { color: var(--text-3); font-size: 11px; }
.app-footer { color: var(--text-3); font-size: 9.5px; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .ledger-head { display: none; }
  .course-row { padding: 12px 16px; }
  .course-capacity-col { width: 140px; }
}

@media (max-width: 760px) {
  .header-inner { padding: 8px 18px; }
  .app-main { padding: 20px 18px 40px; }
  .page-head h1 { font-size: 26px; }
  .semester-chip { transform: none; }
  .summary-band { grid-template-columns: 1fr; }
  .summary-col { padding: 12px 16px; }
  .summary-col + .summary-col { border-left: 0; border-top: 1px solid var(--border); }
  .tabbar { gap: 2px; }
  .tab-btn { padding: 7px 10px; font-size: 11px; }
}

@media (max-width: 640px) {
  .course-row { padding: 11px 14px; }
  .course-main { flex: 1 1 calc(100% - 50px); }
  .course-capacity-col { width: auto; margin-left: 50px; }
  .course-title { font-size: 14.5px; }
  .course-desc-line { display: none; }
  .course-meta-item:nth-child(3) { display: none; }
  .btn { min-height: 40px; }
  .btn-enroll-outline { height: 34px; }
}

.data-table th { font-size: 9.5px; }

/* Teacher / admin summary: one ruled band instead of three floating cards */
#teacherStats.stat-grid,
#adminStats.stat-grid {
  gap: 0;
  border: 1px solid var(--border);
  border-top: 1px solid var(--border-strong);
  border-radius: 2px;
  background: var(--surface);
  overflow: hidden;
}

#teacherStats .stat-card,
#adminStats .stat-card {
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 13px 18px;
}

#teacherStats .stat-card:first-child,
#adminStats .stat-card:first-child { border-left: 0; }

@media (max-width: 760px) {
  #teacherStats .stat-card,
  #adminStats .stat-card { border-left: 0; border-top: 1px solid var(--border); }
  #teacherStats .stat-card:first-child,
  #adminStats .stat-card:first-child { border-top: 0; }
}


/* ===== V3 DECISION DESK ===== */
/* ============================================================
   v3 — 选课决策台
   Three-pane workspace, plan rail, preview, state machine.
   ============================================================ */

.app-main,
.header-inner,
.app-footer { width: min(1440px, 100%); }

.app-main { padding: 24px 24px 48px; }

.page-head { margin-bottom: 16px; }

.workspace {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.workspace-main { min-width: 0; }

/* ---------- filter rail ---------- */

.filter-rail {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface);
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.rail-title { font-family: var(--font-serif); font-size: 14px; font-weight: 700; }
.rail-close { display: none; border: 0; background: transparent; color: var(--text-3); font-size: 18px; line-height: 1; }

.filter-rail .filter-field { gap: 4px; }
.filter-rail .filter-label { font-size: 8.5px; }
.filter-rail .input,
.filter-rail .select { min-height: 32px; font-size: 11px; }

.filter-check {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 2px;
  color: var(--text-2);
  font-size: 10.5px;
  cursor: pointer;
}

.filter-check input { accent-color: var(--primary); width: 13px; height: 13px; }

.filter-reset { margin-top: 4px; width: 100%; }

/* ---------- catalog head ---------- */

.catalog-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.catalog-head h2 { font-family: var(--font-serif); font-size: 17px; font-weight: 700; }
.catalog-head p { margin-top: 2px; color: var(--text-3); font-size: 10px; }

.catalog-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.catalog-tools .panel-summary { font-size: 9px; }
.sort-control { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-family: var(--font-mono); font-size: 8.5px; }
.sort-control .select { width: 78px; min-height: 28px; padding: 3px 22px 3px 6px; font-size: 10px; }
.filter-toggle { display: none; }

/* ---------- course rows in 3-pane width ---------- */

.course-row {
  position: relative;
  gap: 12px;
  padding: 11px 14px 11px 16px;
  border-bottom: 1px solid var(--border);
}

.course-row::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--row-accent, var(--border-strong));
}

.course-row.type-required { --row-accent: var(--required-text); }
.course-row.type-elective { --row-accent: var(--elective-text); }
.course-row.type-general { --row-accent: var(--general-text); }

.course-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.course-subject-icon { width: 32px; height: 32px; }

.course-title { font-size: 14.5px; }
.course-desc-line { font-size: 10px; }
.course-meta-line { font-size: 9px; gap: 2px 10px; }
.course-capacity-col { width: 120px; }
.course-capacity-top { font-size: 9px; }
.course-capacity-top strong { font-size: 10.5px; }
.course-action-col { width: 112px; flex-direction: column; align-items: flex-end; gap: 3px; }

.row-reason {
  max-width: 112px;
  color: var(--text-3);
  font-size: 8.5px;
  line-height: 1.35;
  text-align: right;
}

.row-reason.is-danger { color: var(--danger); }
.row-reason.is-warning { color: var(--warning); }
.row-reason.is-success { color: var(--success); }

.row-drop {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 9px;
  line-height: 1.2;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.course-row[data-status="selected"] .status-text-selected { font-size: 10.5px; }
.course-row[data-status="full"] .status-text-blocked { color: var(--danger); }
.course-row[data-status="conflict"] .status-text-blocked { color: var(--danger); }
.course-row[data-status="credit"] .status-text-blocked { color: var(--warning); }

/* ---------- plan rail ---------- */

.plan-rail {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 15px 14px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface);
}

.plan-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}

.plan-head h2 { font-family: var(--font-serif); font-size: 15px; font-weight: 700; }
.plan-head span { color: var(--text-3); font-family: var(--font-mono); font-size: 9px; }

.budget {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.budget-ring { width: 72px; height: 72px; flex: none; transform: rotate(-90deg); }
.budget-track { fill: none; stroke: var(--border); stroke-width: 5; }
.budget-value { fill: none; stroke: var(--primary); stroke-width: 5; stroke-linecap: butt; transition: stroke-dashoffset 200ms ease; }

.budget-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.budget-copy strong { color: var(--text); font-family: var(--font-serif); font-size: 25px; line-height: 1; font-weight: 700; }
.budget-copy strong span { color: var(--text-3); font-family: var(--font-mono); font-size: 9px; font-weight: 500; }
.budget-copy em { color: var(--text-3); font-size: 9px; font-style: normal; line-height: 1.45; }

.plan-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.5;
}

.plan-summary b { color: var(--text); font-weight: 600; }
.plan-summary .is-danger { color: var(--danger); }
.plan-summary .is-warning { color: var(--warning); }

.plan-preview { padding-top: 10px; border-top: 1px solid var(--border); }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.preview-head span { color: var(--text-3); font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .04em; }
.preview-close { border: 0; background: transparent; color: var(--text-3); font-size: 14px; line-height: 1; padding: 0 2px; cursor: pointer; }
.preview-course { display: flex; flex-direction: column; gap: 1px; margin-bottom: 4px; }
.preview-course strong { color: var(--text); font-family: var(--font-serif); font-size: 13px; font-weight: 700; line-height: 1.35; }
.preview-course span { color: var(--text-3); font-family: var(--font-mono); font-size: 8.5px; }
.preview-line { color: var(--text-2); font-size: 9.5px; line-height: 1.45; }
.preview-line.is-danger { color: var(--danger); }
.preview-line.is-warning { color: var(--warning); }
.preview-line.is-success { color: var(--success); }
.preview-blocked { margin-top: 7px; padding: 6px 8px; border: 1px dashed var(--border-strong); color: var(--text-3); font-size: 9px; line-height: 1.45; }

.preview-enroll { width: 100%; margin-top: 7px; }

.mini-tt {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(12, 7px);
  gap: 1px;
  margin: 8px 0 6px;
  padding: 2px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.mini-col { display: grid; grid-template-rows: repeat(12, 7px); gap: 1px; min-width: 0; }
.mini-block { display: block; min-width: 0; background: var(--required-bg); border-left: 2px solid var(--required-text); }
.mini-block.type-elective { background: var(--elective-bg); border-left-color: var(--elective-text); }
.mini-block.type-general { background: var(--general-bg); border-left-color: var(--general-text); }
.mini-block.is-ghost { background: transparent; border: 1px dashed var(--success); }
.mini-block.is-ghost.is-conflict { border-color: var(--danger); background: rgba(179, 38, 30, 0.08); }

.plan-selected { display: flex; flex-direction: column; gap: 2px; }
.plan-day {
  margin-top: 4px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .06em;
}
.plan-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0 5px 6px; border-bottom: 1px solid var(--border); }
.plan-item:last-child { border-bottom: 0; }
.plan-item-main { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.plan-item-main strong { color: var(--text); font-family: var(--font-serif); font-size: 10.5px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-item-main span { color: var(--text-3); font-family: var(--font-mono); font-size: 8px; line-height: 1.4; }
.plan-item .row-drop { flex: none; }
.plan-empty { padding: 6px 0; color: var(--text-3); font-size: 9px; line-height: 1.5; }

.plan-cta { width: 100%; justify-content: center; }
.plan-note { color: var(--text-3); font-size: 8.5px; line-height: 1.4; text-align: center; }

.mobile-plan-bar { display: none; }

/* ---------- responsive ---------- */

@media (max-width: 1280px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 300px; }
  .filter-rail {
    grid-column: 1 / -1;
    position: static;
    display: grid;
    grid-template-columns: minmax(160px, 1.4fr) repeat(3, minmax(90px, 1fr)) auto auto;
    align-items: end;
    gap: 8px;
  }
  .rail-head { display: none; }
  .filter-rail .filter-check { align-self: center; }
  .filter-reset { width: auto; }
}

@media (max-width: 1080px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 280px; }
  .course-capacity-col { width: 108px; }
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .filter-rail { display: none; position: static; grid-column: auto; }
  #studentView.filters-open .filter-rail { display: flex; }
  .filter-rail .rail-close { display: inline-block; }
  .filter-toggle { display: inline-flex; }
  .plan-rail { position: static; }
  .mobile-plan-bar {
    display: flex;
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: 16px;
    z-index: 50;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(31, 28, 25, .12);
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-2);
  }
  .app-main { padding-bottom: 84px; }
  #studentView[data-tab="schedule"] .workspace { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .app-main { padding: 18px 16px 84px; }
  .catalog-head { align-items: flex-start; flex-direction: column; gap: 6px; }
  .catalog-tools { width: 100%; justify-content: space-between; }
  .course-row { flex-wrap: wrap; gap: 8px; padding: 11px 12px 11px 14px; }
  .course-main { flex: 1 1 calc(100% - 44px); }
  .course-capacity-col { width: auto; flex: 1 1 140px; margin-left: 44px; }
  .course-action-col { width: auto; flex-direction: row; align-items: center; gap: 8px; margin-left: auto; }
  .row-reason { max-width: 140px; text-align: left; }
  .course-desc-line { display: none; }
  .course-meta-item:nth-child(3) { display: none; }
  .budget-copy strong { font-size: 22px; }
}

@media (max-width: 420px) {
  .brand-sub { display: none; }
  .course-title { font-size: 14px; }
}

@media (max-width: 640px) {
  .course-main { flex: 1 1 calc(100% - 44px); }
  .course-capacity-col { flex: 1 1 100%; margin-left: 0; }
  .course-action-col {
    width: 100%;
    margin-left: 0;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
  }
  .row-reason { max-width: none; flex: 1; text-align: left; }
  .course-top-line { gap: 5px; }
  .course-dept-credit { font-size: 8.5px; }
}

@media (max-width: 900px) {
  #studentView.filters-open .filter-rail {
    align-items: stretch;
    gap: 10px;
    padding: 13px 12px;
  }
  #studentView.filters-open .filter-rail .filter-check { align-self: flex-start; }
  #studentView.filters-open .filter-reset { width: 100%; }
}

@media (max-width: 900px) {
  #studentView.filters-open .filter-rail .rail-head { display: flex; }
}

@media (max-width: 640px) {
  .course-action-col {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 4px 10px;
  }
  .row-reason { flex: 1 1 100%; max-width: none; text-align: left; }
}

/* Schedule tab: full-width timetable + plan rail, no filter rail */
#studentView[data-tab="schedule"] .workspace { grid-template-columns: minmax(0, 1fr) 320px; }
#studentView[data-tab="schedule"] .filter-rail { display: none; }

@media (max-width: 1080px) {
  #studentView[data-tab="schedule"] .workspace { grid-template-columns: minmax(0, 1fr) 280px; }
}

@media (max-width: 900px) {
  #studentView[data-tab="schedule"] .workspace { grid-template-columns: minmax(0, 1fr); }
}


    .roster-pager {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-top: 10px;
      padding-top: 9px;
      border-top: 1px solid var(--border);
      color: var(--text-3);
      font-family: var(--font-mono);
      font-size: 9px;
    }
    .roster-pager .btn { min-height: 28px; }

    .admin-tabs { display: flex; gap: 2px; margin: 0 0 10px; border-bottom: 1px solid var(--border); }
    .admin-tabs .tab-btn { min-height: 32px; padding: 6px 12px; }
    .admin-view-note { margin: -4px 0 10px; color: var(--text-3); font-family: var(--font-mono); font-size: 9px; }
    .admin-conflict-view { border: 1px solid var(--border); background: var(--surface); }
    .conflict-list { display: flex; flex-direction: column; }
    .conflict-card { display: grid; grid-template-columns: 100px minmax(0, 1fr) 24px minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
    .conflict-card:last-child { border-bottom: 0; }
    .conflict-time { color: var(--danger); font-family: var(--font-mono); font-size: 9px; line-height: 1.5; white-space: nowrap; }
    .conflict-course { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
    .conflict-course strong { font-family: var(--font-serif); font-size: 13px; font-weight: 700; line-height: 1.35; }
    .conflict-course span { color: var(--text-3); font-family: var(--font-mono); font-size: 8.5px; line-height: 1.45; overflow-wrap: anywhere; }
    .conflict-mark { color: var(--danger); font-family: var(--font-serif); font-size: 18px; text-align: center; }
    .data-table tr.is-full { background: rgba(179, 38, 30, 0.05); }
    .data-table tr.is-near { background: rgba(153, 93, 19, 0.05); }
    @media (max-width: 640px) {
      .conflict-card { grid-template-columns: 1fr; gap: 6px; padding: 11px 12px; }
      .conflict-mark { text-align: left; font-size: 14px; }
    }

    .plan-close { display: none; border: 0; background: transparent; color: var(--text-3); font-size: 18px; line-height: 1; cursor: pointer; }
    .plan-backdrop { display: none; position: fixed; inset: 0; z-index: 70; background: rgba(18, 17, 16, 0.55); }

    @media (max-width: 900px) {
      .plan-rail {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        top: auto;
        z-index: 80;
        max-height: 82vh;
        overflow-y: auto;
        padding: 16px 18px 24px;
        border: 1px solid var(--border-strong);
        border-bottom: 0;
        border-radius: 6px 6px 0 0;
        box-shadow: 0 -12px 40px rgba(31, 28, 25, .18);
        transform: translateY(100%);
        visibility: hidden;
        transition: transform 240ms ease, visibility 240ms;
      }
      #studentView.plan-open .plan-rail { transform: translateY(0); visibility: visible; }
      #studentView.plan-open .plan-backdrop { display: block; }
      .plan-close { display: grid; place-items: center; width: 28px; height: 28px; margin-left: auto; }
      .plan-head { padding-right: 0; }
      body.plan-lock { overflow: hidden; }
    }

    .status-text-waitlist {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      color: var(--warning);
      font-size: 11px;
      font-weight: 600;
    }

    .btn-waitlist-outline {
      border: 1px solid var(--warning);
      color: var(--warning);
      background: transparent;
      border-radius: 2px;
      min-height: 32px;
      padding: 0 12px;
      font-size: 11px;
      font-weight: 600;
      cursor: pointer;
    }

    .btn-waitlist-outline:hover { background: rgba(153, 93, 19, .08); }

    .plan-waitlist {
      margin-top: 12px;
      padding-top: 12px;
      border-top: 1px solid var(--border);
    }

    .plan-waitlist-title {
      font-family: var(--mono, monospace);
      font-size: 10px;
      letter-spacing: .08em;
      color: var(--text-3);
      margin-bottom: 6px;
    }

    .teacher-waitlist,
    .cell-waitlist {
      color: var(--warning);
      font-size: 11px;
      font-weight: 600;
    }

    .round-control {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 16px;
      margin-bottom: 16px;
      border: 1px solid var(--border);
      background: var(--surface);
    }

    .round-control-main {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    #selectionNotice {
      margin-bottom: 16px;
    }

    #roundControl .is-success { color: var(--success); }
    #roundControl .is-warning { color: var(--warning); }

    .course-row[data-status="closed"] .status-text-blocked { color: var(--warning); }

/* ===== AUTH GATE ===== */
/* Login page, current-user chip and logout — 砚墨朱印. */

body.auth-gate .app-header,
body.auth-gate .app-main,
body.auth-gate .app-footer,
body.auth-gate .skip-link { display: none; }

.login-view {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 40px 20px;
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(158, 42, 43, 0.035) 31px 32px),
    var(--bg);
}

.login-card {
  width: min(430px, 100%);
  padding: 30px 32px 22px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 2px;
  background: var(--surface);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.login-brand .brand-mark { width: 38px; height: 38px; font-size: 19px; }

.login-head { margin-top: 20px; }
.login-head .eyebrow { margin-bottom: 6px; color: var(--text-3); font-size: 9.5px; letter-spacing: 0.1em; }
.login-head h1 { font-family: var(--font-serif); font-size: 27px; line-height: 1.15; }

.login-sub {
  margin-top: 7px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.65;
}

.login-form { display: grid; gap: 13px; margin-top: 20px; }
.login-field { display: grid; gap: 5px; }
.login-label { color: var(--text-3); font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; }
.login-field .input { min-height: 40px; font-size: 13px; }

.login-error {
  padding: 8px 10px;
  border: 1px solid var(--danger-border);
  background: var(--danger-weak);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.login-submit {
  width: 100%;
  min-height: 42px;
  margin-top: 2px;
  font-size: 14px;
  letter-spacing: 0.12em;
}

.login-demo { margin-top: 20px; padding-top: 14px; border-top: 1px dashed var(--border); }
.login-demo-title { margin-bottom: 7px; color: var(--text-3); font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; }
.login-demo-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.login-demo-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--text-3); font-size: 11px; }
.login-demo-list code { color: var(--text-2); font-family: var(--font-mono); font-size: 10px; }

.login-foot {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-align: center;
}

/* ---------- account chip / logout ---------- */

.account-controls { display: inline-flex; align-items: center; gap: 8px; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11px;
  white-space: nowrap;
}

.user-chip-name {
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 12.5px;
  font-weight: 700;
}

.user-chip-role {
  padding-left: 8px;
  border-left: 1px solid var(--border);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.logout-btn { min-height: 34px; padding: 0 12px; border-radius: 2px; font-size: 11px; }

@media (max-width: 760px) {
  .account-controls { margin-right: auto; }
  .user-chip,
  .logout-btn { min-height: 40px; }
}

@media (max-width: 430px) {
  .login-view { padding: 24px 14px; }
  .login-card { padding: 24px 20px 18px; }
  .login-head h1 { font-size: 24px; }
  .login-demo-list li { flex-direction: column; gap: 1px; }
}

/* ---------- admin user management ---------- */

.admin-users-view { padding: 12px 14px 14px; border: 1px solid var(--border); background: var(--surface); }
.user-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 10px; padding: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.user-toolbar .filter-field { margin: 0; }
.user-search-field { flex: 1 1 260px; max-width: 380px; }
.user-add-btn { margin-left: auto; }
.user-table .cell-user { display: grid; gap: 2px; min-width: 0; }
.user-table .cell-user strong { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.user-table .cell-user > span { color: var(--text-3); font-family: var(--font-mono); font-size: 8.5px; }
.user-self-tag { display: inline-block; padding: 1px 6px; border: 1px solid var(--primary); border-radius: 999px; color: var(--primary); font-family: var(--font-mono); font-size: 8.5px; font-weight: 500; white-space: nowrap; }
.user-link-id { color: var(--text-3); font-family: var(--font-mono); font-size: 8.5px; }
.user-muted { color: var(--text-3); font-size: 10.5px; }
.user-created { color: var(--text-2); font-family: var(--font-mono); font-size: 9.5px; white-space: nowrap; }
.user-role-student { border-color: var(--general-border); background: var(--general-bg); color: var(--general-text); }
.user-role-teacher { border-color: var(--elective-border); background: var(--elective-bg); color: var(--elective-text); }
.user-role-admin { border-color: var(--primary); background: var(--primary-weak); color: var(--primary); }
.user-status.is-active { border-color: var(--border); background: var(--success-weak); color: var(--success); }
.user-status.is-disabled { border-color: var(--danger-border); background: var(--danger-weak); color: var(--danger); }
.user-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border); color: var(--text-3); font-family: var(--font-mono); font-size: 9px; }
.user-pager .btn { min-height: 28px; }
.user-active-field { gap: 4px; }
.password-target { margin-bottom: 12px; }
.password-form-grid { grid-template-columns: minmax(0, 1fr); }

@media (max-width: 760px) {
  .admin-users-view { padding: 10px; }
  .user-toolbar { padding: 10px; }
  .user-search-field { flex-basis: 100%; max-width: none; }
  .user-add-btn { width: 100%; margin-left: 0; }
  .user-pager { flex-wrap: wrap; justify-content: center; }
}
