    :root {
      color-scheme: light;
      --bg: #f6f7f9;
      --card: #ffffff;
      --ink: #1f2937;
      --muted: #6b7280;
      --brand: #1a73e8;
      --brand-ink: #ffffff;
      --danger-bg: #fdeaea;
      --danger: #b3261e;
      --ok: #188038;
      --radius: 16px;
    }
    * { box-sizing: border-box; }
    html, body { margin: 0; padding: 0; }
    body {
      background: var(--bg);
      color: var(--ink);
      font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
      line-height: 1.6;
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
    }
    .card {
      background: var(--card);
      width: 100%;
      max-width: 440px;
      padding: 32px 24px;
      border-radius: var(--radius);
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
      text-align: center;
    }
    h1 {
      font-size: 2rem;
      margin: 0 0 4px;
      letter-spacing: 0.08em;
    }
    .tagline { color: var(--muted); margin: 0 0 24px; }
    p { margin: 12px 0; }
    .email {
      font-size: 1.05rem;
      font-weight: 600;
      word-break: break-all;
    }
    button {
      display: block;
      width: 100%;
      min-height: 52px;
      margin: 16px auto;
      padding: 12px 16px;
      font: inherit;
      font-size: 1.05rem;
      font-weight: 600;
      color: var(--brand-ink);
      background: var(--brand);
      border: 0;
      border-radius: 12px;
      cursor: pointer;
      touch-action: manipulation;
    }
    button:active { opacity: 0.85; }
    button.secondary {
      color: var(--brand);
      background: transparent;
      border: 1px solid var(--brand);
    }
    .ok { color: var(--ok); font-weight: 600; }
    .reject { color: var(--danger); font-weight: 600; }
    .error-box {
      background: var(--danger-bg);
      color: var(--danger);
      border-radius: 10px;
      padding: 10px 12px;
      font-size: 0.95rem;
    }
    .view.hidden { display: none; }
    .hidden { display: none !important; }
    .spinner {
      display: inline-block;
      width: 18px;
      height: 18px;
      margin-right: 8px;
      border: 3px solid var(--brand);
      border-top-color: transparent;
      border-radius: 50%;
      vertical-align: -3px;
      animation: spin 0.8s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    .browse { margin-top: 24px; border-top: 1px solid #eceff1; padding-top: 16px; text-align: left; }
    .browse-title { margin: 0 0 6px; font-size: 1.15rem; }
    .browse-kid { margin-bottom: 14px; }
    .browse-kid-name { margin: 10px 0 4px; font-size: 1.05rem; }
    .browse details {
      margin-left: 16px;
      padding-left: 10px;
      border-left: 2px solid #e6e9ed;
    }
    .browse-subject, .browse-unit { margin: 2px 0; }
    .browse-subject > summary, .browse-unit > summary { cursor: pointer; font-weight: 600; }
    .browse-unit > summary { font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    .browse-file-actions { flex: none; display: inline-flex; align-items: center; gap: 6px; }
    .browse-delete { margin: 0; }
    .browse-manifest { margin: 2px 0 4px; font-size: 0.85rem; color: var(--muted); }
    .browse-files { margin: 4px 0 8px; padding-left: 18px; list-style: none; }
    .browse-file { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 0; font-size: 0.95rem; }
    .browse-file-name { word-break: break-all; }
    .badge { flex: none; font-size: 0.75rem; font-weight: 600; border-radius: 8px; padding: 1px 8px; white-space: nowrap; }
    .badge-on { color: var(--ok); background: #e6f4ea; }
    .badge-off { color: var(--muted); background: #eef0f3; }
    .browse-note { color: var(--muted); font-size: 0.9rem; margin: 4px 0 8px; }
    .footnote { color: var(--muted); font-size: 0.85rem; margin-top: 20px; }
    .upload { margin-top: 24px; border-top: 1px solid #eceff1; padding-top: 16px; text-align: left; }
    .upload-title { margin: 0 0 6px; font-size: 1.15rem; }
    .upload-note { color: var(--muted); font-size: 0.9rem; margin: 0 0 12px; }
    .field { margin: 10px 0; }
    .field > label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 0.95rem; }
    .field input[type="text"],
    .field input[type="number"],
    .field select,
    .field textarea {
      width: 100%;
      font: inherit;
      font-size: 1rem;
      padding: 10px 12px;
      border: 1px solid #cfd6dd;
      border-radius: 10px;
      background: #fff;
      color: var(--ink);
    }
    /* A textarea is only ever as wide as the browser's intrinsic default (a
       ~20-column box) unless the shared field rule above covers it, so the
       詞語表 / 額外要求 boxes rendered as a narrow strip on both pages. Keep it
       hand-resizable for long lists, and never let the padding widen the box. */
    .field textarea { resize: vertical; min-height: 72px; box-sizing: border-box; }
    .field input[type="text"]::placeholder { color: var(--muted); }
    .field-row { display: flex; gap: 12px; }
    .field-row .field { flex: 1; }
    .kind-options label { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; font-weight: 600; }
    .check-line { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-weight: 600; }
    .upload-status { margin: 12px 0 0; font-size: 0.95rem; word-break: break-all; }
    .upload-status.ok { color: var(--ok); }
    .upload-status.error { color: var(--danger); }
    .upload-status.pending { color: var(--muted); }
    /* P3 — the upload status box: its own bordered, coloured element so the
       realtime per-file OCR outcome catches the eye (not the muted line). */
    .upload-progress {
      margin: 12px 0 0; padding: 12px 14px;
      border: 2px solid var(--brand); border-radius: 12px;
      background: #eaf2fe; text-align: left;
    }
    .upload-progress.pending { border-color: var(--brand); background: #eaf2fe; }
    .upload-progress.done { border-color: var(--ok); background: #e6f4ea; }
    .upload-progress.failed { border-color: var(--danger); background: var(--danger-bg); }
    .upload-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    .upload-progress-pct { font-weight: 700; color: var(--brand); flex: none; }
    .upload-progress-note { color: var(--ink); font-size: 0.9rem; text-align: right; }
    .upload-progress-files { list-style: none; margin: 8px 0 0; padding: 0; }
    .upload-progress-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 0.95rem; }
    .upload-progress-name { flex: 1; word-break: break-all; }
    .upload-progress-mark { flex: none; font-weight: 600; }
    .upload-progress-mark.ok, .upload-progress-state.ok { color: var(--ok); }
    .upload-progress-mark.pending, .upload-progress-state.pending { color: var(--muted); }
    .upload-progress-mark.error, .upload-progress-state.error { color: var(--danger); }
    /* C19 — the chosen files render as an ordered list (list order IS page
       order) with a per-file 移除; the caps line sits under it. */
    .upload-file-list { list-style: none; margin: 6px 0 0; padding: 0; }
    .upload-file-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 0.95rem; border-bottom: 1px solid #f0f2f4; }
    .upload-file-name { word-break: break-all; }
    .upload-file-remove { flex: none; }
    .btn-upload { margin: 14px 0 0; }
    .modal-overlay {
      position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
      display: flex; align-items: center; justify-content: center;
      padding: 20px; z-index: 50;
    }
    .modal-overlay.hidden { display: none; }
    .modal-card {
      background: var(--card); color: var(--ink); border-radius: var(--radius);
      box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
      max-width: 420px; width: 100%; padding: 20px 22px; text-align: left;
    }
    .modal-card h3 { margin: 0 0 10px; }
    .modal-summary {
      margin: 0 0 6px; padding: 10px 12px; background: #f4f6f8;
      border-radius: 10px; font-size: 0.92rem; white-space: pre-line;
      word-break: break-all;
    }
    .modal-card .btn-row { display: flex; gap: 10px; margin-top: 8px; }
    .modal-card button { flex: 1; margin: 0; min-height: 44px; }
    /* ---- P4 preview modal (OCR markdown / 生成紀錄) -------------------- */
    .preview-card { max-width: 760px; }
    .preview-body {
      margin: 0 0 6px; padding: 12px 14px; background: #f4f6f8;
      border-radius: 10px; max-height: 60vh; overflow: auto;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 0.9rem; line-height: 1.6; white-space: pre-wrap;
      word-break: break-word;
    }
    .preview-body table { border-collapse: collapse; width: 100%; white-space: normal; }
    .preview-body th, .preview-body td { border: 1px solid #cfd6dd; padding: 4px 8px; }
    .preview-body pre { white-space: pre-wrap; background: #eceff1; padding: 8px; border-radius: 8px; overflow: auto; }
    .preview-body code { font-family: inherit; }
    .preview-body blockquote {
      margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--brand);
      color: var(--muted);
    }
    .preview-status { margin: 8px 0 0; color: var(--danger); font-size: 0.9rem; }
    .preview-status.hidden { display: none; }
    .wizard { margin-top: 24px; border-top: 1px solid #eceff1; padding-top: 16px; text-align: left; }
    .unit-list { margin: 4px 0 6px; }
    .unit-item { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0; font-size: 0.95rem; }
    .unit-item input { margin-top: 5px; }
    .unit-term { color: var(--muted); font-size: 0.8rem; margin-left: 4px; }
    .banner-warn {
      background: #fff4e0; color: #8a5300; border: 1px solid #f3d9a4;
      border-radius: 10px; padding: 10px 12px; font-size: 0.92rem;
      margin: 8px 0;
    }
    .wizard-result {
      margin-top: 12px; padding: 12px; border-radius: 12px;
      background: #f4f6f8; font-size: 0.95rem; word-break: break-all;
    }
    .wizard-result p { margin: 6px 0; }
    #wizard-result .btn-row { display: flex; gap: 10px; margin-top: 10px; }
    #wizard-result button { flex: 1; width: auto; margin: 0; min-height: 44px; }
    #wizard-warnings ul { margin: 6px 0 0; padding-left: 20px; }
    #worksheet-warnings ul { margin: 6px 0 0; padding-left: 20px; }
    .history { margin-top: 20px; border-top: 1px dashed #e6e9ed; padding-top: 12px; }
    .history-filters { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 4px; }
    .history-filter { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--muted); }
    .history-filter select { width: auto; }
    .history-list { list-style: none; margin: 4px 0 0; padding: 0; }
    .history-item {
      display: block; padding: 8px 0; border-bottom: 1px solid #f0f2f4;
      font-size: 0.92rem;
    }
    .history-name { font-weight: 600; word-break: break-all; }
    .history-meta { color: var(--muted); margin-top: 2px; }
    .history-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
    .history-links button { margin: 0; min-height: 30px; padding: 4px 12px; font-size: 0.85rem; width: auto; }
    .history-pager { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
    .history-page-label { font-size: 0.9rem; color: var(--muted); }
    .btn-row button { margin: 0; }
    /* ---- U3 風格參照庫 panel (a family-curated library under 材料) -------- */
    .style-refs { margin-top: 20px; border-top: 1px dashed #e6e9ed; padding-top: 12px; }
    .style-refs-list { list-style: none; margin: 4px 0 8px; padding: 0; }
    .style-ref-item {
      display: flex; align-items: flex-start; justify-content: space-between;
      gap: 10px; padding: 6px 0; border-bottom: 1px solid #f0f2f4;
      font-size: 0.92rem;
    }
    .style-ref-meta { min-width: 0; word-break: break-all; }
    .style-ref-actions { flex: none; display: inline-flex; align-items: center; gap: 6px; }

    /* ---- S5.5 loading / progress / download feedback -------------------- */
    .muted-line { color: var(--muted); font-size: 0.92rem; margin: 6px 0; }
    .mini {
      display: inline-block; width: auto; min-height: 0; margin: 4px 0 0;
      padding: 4px 14px; font-size: 0.85rem; border-radius: 8px;
    }
    .browse-status.pending {
      background: transparent; color: var(--muted); font-size: 0.9rem;
      padding: 0; border-radius: 0;
    }
    .wizard-progress {
      margin-top: 12px; padding: 12px 14px; border-radius: 12px;
      background: #f4f6f8; font-size: 0.95rem; text-align: left;
    }
    .progress-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    .progress-current { color: var(--ink); font-weight: 600; }
    .progress-pct { font-weight: 700; color: var(--brand); flex: none; }
    .progress-elapsed { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }
    .progress-bar {
      height: 10px; margin: 8px 0 12px; border-radius: 6px;
      background: #e6e9ed; overflow: hidden;
    }
    .progress-fill {
      height: 100%; width: 0; border-radius: 6px;
      background: var(--brand); transition: width 0.4s ease;
    }
    .wizard-progress .progress-stages { list-style: none; margin: 0; padding: 0; }
    .progress-stage {
      display: flex; align-items: center; gap: 8px; padding: 4px 0;
      color: var(--muted); font-size: 0.92rem;
    }
    .progress-stage.current { color: var(--ink); font-weight: 600; }
    .progress-stage.failed { color: var(--danger); font-weight: 600; }
    .progress-glyph { flex: none; width: 20px; text-align: center; line-height: 1; }
    .progress-stage-detail { color: var(--muted); font-size: 0.85rem; }
    .stage-spinner {
      display: inline-block; width: 13px; height: 13px;
      border: 2px solid var(--brand); border-top-color: transparent;
      border-radius: 50%; vertical-align: -2px;
      animation: spin 0.8s linear infinite;
    }
    .btn-download.loading { color: var(--muted); cursor: default; }
    .btn-download.loading .spinner {
      width: 14px; height: 14px; border-width: 2px; margin-right: 6px;
      border-color: var(--muted); border-top-color: transparent;
      vertical-align: -2px;
    }
    .btn-download.dl-error { color: var(--danger); border-color: var(--danger); }
    #wizard-progress-actions { display: flex; gap: 10px; margin-top: 10px; }
    #wizard-progress-actions button { flex: 1; width: auto; margin: 0; min-height: 44px; }
    #wizard-progress-actions.hidden { display: none; }

    /* ---- S5.5 responsive: laptop grid, mobile keeps single column ------- */
    @media (min-width: 860px) {
      body { align-items: flex-start; }
      .card { max-width: 1100px; }
      .welcome-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
        gap: 0 28px;
        align-items: start;
      }
      .welcome-grid .browse,
      .welcome-grid .upload { border-top: 0; margin-top: 0; }
      .welcome-grid .wizard {
        grid-column: 1 / -1;
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid #eceff1;
      }
      .welcome-grid .field-row { flex-wrap: wrap; }
    }

    /* ---- C16 shared nav (new markup added with the page split) ----------- */
    .app-nav {
      display: flex;
      gap: 8px;
      justify-content: center;
      margin: 4px 0 20px;
    }
    .app-nav-link {
      display: inline-block;
      padding: 8px 18px;
      border-radius: 999px;
      border: 1px solid var(--brand);
      color: var(--brand);
      text-decoration: none;
      font-weight: 600;
      font-size: 0.95rem;
    }
    .app-nav-current {
      background: var(--brand);
      color: var(--brand-ink);
    }
    .app-nav-switch {
      display: inline-flex;
      align-items: center;
      gap: 2px;
      padding: 2px;
      border-radius: 999px;
      background: var(--bg);
      border: 1px solid var(--brand);
    }
    .app-switch-option {
      display: inline-block;
      padding: 5px 12px;
      border-radius: 999px;
      color: var(--brand);
      text-decoration: none;
      font-weight: 600;
      font-size: 0.85rem;
    }
    .app-nav-switch-current {
      background: var(--brand);
      color: var(--brand-ink);
    }
