/* Adapter: map the yellow-card skin onto the live V3 DOM.
   Does not replace feature markup. Print stays a white exam sheet. */

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

/* Work pages use the wider stage from the brief */
body.is-app .stage { max-width: 1320px; overflow: visible; }

/* Keep existing .hidden utility even if Tailwind utilities clash.
   Elements that also use .flex / .grid / .fixed inset-0 must stay
   fully hidden, or an invisible full-screen layer can eat clicks. */
.hidden,
[hidden],
.fixed.hidden,
#error-mark-modal.hidden,
#admin-account-modal.hidden,
#ai-exam-zoom-modal.hidden,
#student-analysis-drawer.hidden,
#toast-banner.hidden {
  display: none !important;
}

/* ---------- Login view sits in the poster stage ---------- */
#view-login.login {
  display: grid;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
  gap: 40px 56px;
  align-items: center;
  padding: var(--pad-login-y) var(--pad-login-x);
  min-height: 680px;
  width: 100%;
}
#view-login.login.hidden { display: none !important; }

body.is-app #view-login { display: none !important; }

#login-error:not(.hidden) {
  margin: 0;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  background: #F8E4D8;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  border-radius: 0;
}

/* ---------- App chrome (existing #top-nav) ---------- */
#top-nav {
  position: relative;
  top: auto;
  z-index: 20;
  background: var(--white);
  border-bottom: 2px solid var(--ink);
  box-shadow: none;
  width: 100%;
}
#top-nav.app-chrome { padding: 18px 32px 14px; }

body.is-app #view-student,
body.is-app #view-teacher,
body.is-app #view-admin {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 24px 32px 36px;
}

/* ---------- Tabs: text + SVG, coral underline ---------- */
#t-tab-grading, #t-tab-assign, #t-tab-aigen, #t-tab-monitor,
#t-tab-exp, #t-tab-aipaper, #t-tab-aigrade,
#a-tab-bank, #a-tab-accounts {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 12px 2px 10px;
  margin-right: 22px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--muted);
  box-shadow: none;
}
#t-tab-grading:hover, #t-tab-assign:hover, #t-tab-aigen:hover,
#t-tab-monitor:hover, #t-tab-exp:hover, #t-tab-aipaper:hover,
#t-tab-aigrade:hover, #a-tab-bank:hover, #a-tab-accounts:hover {
  color: var(--ink);
}
#t-tab-grading.tab-active, #t-tab-assign.tab-active, #t-tab-aigen.tab-active,
#t-tab-monitor.tab-active, #t-tab-exp.tab-active, #t-tab-aipaper.tab-active,
#t-tab-aigrade.tab-active, #a-tab-bank.tab-active, #a-tab-accounts.tab-active,
.tab-active {
  color: var(--ink) !important;
  font-weight: 800;
  border-bottom: 3px solid var(--coral) !important;
}

#view-teacher > div:first-child,
#view-admin > div:first-child {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--hair);
  border-radius: 0;
  box-shadow: none;
  padding: 0 0 0;
  gap: 0;
}

/* ---------- Cards: white, square, black hairline ---------- */
#view-student .bg-white.rounded-xl,
#view-student .bg-white.rounded-2xl,
#view-teacher .bg-white.rounded-xl,
#view-teacher .bg-white.rounded-2xl,
#view-admin .bg-white.rounded-xl,
#view-admin .bg-white.rounded-2xl,
#view-student .bg-white.rounded-lg.border,
#view-teacher .bg-white.rounded-lg.border,
#view-admin .bg-white.rounded-lg.border {
  border-radius: 0;
  border-color: var(--ink);
  box-shadow: none;
}

/* Indigo/slate chrome → coral / ink / soft yellow notices */
.bg-indigo-600, .bg-indigo-700,
.bg-emerald-600, .bg-emerald-700 {
  background-color: var(--coral) !important;
  color: #fff !important;
  border-color: var(--coral);
}
.hover\:bg-indigo-700:hover, .hover\:bg-indigo-600:hover,
.hover\:bg-emerald-700:hover {
  background-color: #c45d33 !important;
  color: #fff !important;
}
.bg-indigo-950 {
  background: #FFF6C9 !important;
  color: var(--ink) !important;
  border: 2px solid var(--ink) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.bg-indigo-950 .text-indigo-100,
.bg-indigo-950 .text-indigo-300,
.bg-indigo-950 .text-white,
.bg-indigo-950 .bg-indigo-500 {
  color: var(--ink) !important;
  background: transparent !important;
}
.bg-indigo-50, .bg-indigo-50\/70, .bg-indigo-50\/50,
.bg-purple-50, .bg-amber-50, .bg-amber-50\/70,
.bg-slate-50, .bg-slate-50\/70 {
  background-color: #FAFAFA !important;
}
.bg-amber-100, .bg-yellow-50, .bg-emerald-50 {
  background-color: #FFF6C9 !important;
}
.bg-rose-50, .bg-orange-50 {
  background-color: #F8E4D8 !important;
}
.text-indigo-700, .text-indigo-800, .text-indigo-600, .text-indigo-950,
.text-purple-800, .text-emerald-800, .text-emerald-700 {
  color: var(--ink) !important;
}
.text-indigo-300, .text-indigo-100 { color: var(--muted) !important; }
.text-slate-800, .text-slate-900, .font-bold.text-slate-900 { color: var(--ink); }
.text-slate-600, .text-slate-500, .text-slate-400, .text-slate-700 { color: var(--muted); }
.border-indigo-100, .border-indigo-200, .border-indigo-300,
.border-slate-200, .border-slate-100, .border-slate-300,
.border-amber-200, .border-amber-300, .border-purple-200 {
  border-color: #D0D0D0;
}
.bg-indigo-100, .bg-indigo-500, .bg-purple-100 {
  background-color: #FFF6C9 !important;
  color: var(--ink) !important;
}
.bg-slate-800, .bg-slate-900, .hover\:bg-slate-700:hover {
  background-color: var(--ink) !important;
  color: #fff !important;
}
.bg-rose-600, .bg-rose-700, .hover\:bg-rose-700:hover {
  background-color: var(--coral) !important;
  color: #fff !important;
}

/* Pill inputs; square cards already handled. Leave textareas slightly rounded-off (not tiny pills). */
#view-login input.field,
#view-student input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="number"]),
#view-teacher input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="number"]),
#view-admin input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="number"]),
#view-student select, #view-teacher select, #view-admin select,
#login-form input {
  background: #fff;
  border: 1.5px solid var(--input);
  border-radius: var(--radius-pill);
  height: 44px;
  min-height: 44px;
  padding: 0 18px;
  color: var(--body);
  box-shadow: none;
}
#view-student input[type="number"],
#view-teacher input[type="number"],
#view-admin input[type="number"] {
  box-sizing: border-box;
  height: 32px;
  min-width: 4.75rem;
  width: 4.75rem;
  padding: 0 1.35rem 0 6px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
  box-shadow: none;
}
#view-student textarea, #view-teacher textarea, #view-admin textarea,
#error-mark-modal textarea, #admin-account-modal textarea {
  background: #fff;
  border: 1.5px solid var(--input);
  border-radius: 18px;
  padding: 12px 18px;
  color: var(--body);
  box-shadow: none;
}
#view-login input.field:focus,
#view-student input:focus, #view-teacher input:focus, #view-admin input:focus,
#view-student textarea:focus, #view-teacher textarea:focus, #view-admin textarea:focus,
#view-student select:focus, #view-teacher select:focus, #view-admin select:focus,
#login-form input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: none;
}

/* Primary / ghost buttons that are not tabs */
#view-student button.bg-indigo-600,
#view-teacher button.bg-indigo-600,
#view-admin button.bg-indigo-600,
#view-student button.bg-emerald-600,
#view-teacher button.bg-emerald-600,
#login-submit-btn,
.btn-primary {
  background: var(--coral) !important;
  color: #fff !important;
  border: 0;
  border-radius: var(--radius-pill) !important;
  height: 42px;
  padding: 0 22px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  box-shadow: none !important;
}
#view-student button.border,
#view-teacher button.border,
#view-admin button.border,
#top-nav button.border {
  border-radius: var(--radius-pill);
  border-color: var(--ink);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}
#view-student button.border:hover,
#view-teacher button.border:hover,
#view-admin button.border:hover,
#top-nav button.border:hover {
  background: var(--ink);
  color: #fff;
}

/* Section titles inside panels */
#view-student h3, #view-teacher h3, #view-admin h3,
#view-student h4, #view-teacher h4, #view-admin h4 {
  color: var(--ink);
}

/* ---------- Badges ---------- */
#role-badge {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--ink);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  vertical-align: middle;
}
#role-badge.bg-emerald-100,
#role-badge[class*="emerald"] {
  background: var(--yellow) !important;
  color: var(--ink) !important;
  border-color: var(--ink);
}
#role-badge.bg-indigo-100,
#role-badge[class*="indigo"] {
  background: var(--ink) !important;
  color: #fff !important;
  border-color: var(--ink);
}
#role-badge.bg-slate-800 {
  background: var(--coral) !important;
  color: #fff !important;
  border-color: var(--coral);
}

/* ---------- Annotation legend (答卷標註，不用 emoji) ---------- */
.hl-source {
  background-color: var(--yellow);
  border-bottom: 2px solid var(--ink);
  padding: 1px 3px;
  border-radius: 0;
}
.hl-fact {
  background-color: #F8E4D8;
  border-bottom: 2px solid var(--coral);
  padding: 1px 3px;
  border-radius: 0;
}
.hl-out-of-era {
  background-color: #F1F1F1;
  color: #666;
  text-decoration: line-through;
  padding: 1px 4px;
  border-radius: 0;
  border: 0;
}
.ocr-flag {
  background-color: transparent;
  border-bottom: 2px dashed var(--coral);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  padding: 0 3px;
  border-radius: 0;
}
.ocr-fixed {
  background-color: #FFF6C9;
  border-bottom: 2px solid var(--ink);
  color: var(--ink);
  font-weight: 700;
  padding: 0 3px;
  border-radius: 0;
}

/* Four-dimension bars already exist; nudge fill to coral if they use indigo */
#student-four-dims-card .bg-indigo-500,
#student-four-dims-card .bg-indigo-600,
[id*="dim"] .bg-indigo-500 {
  background-color: var(--coral) !important;
}

/* Teacher preview banner */
#teacher-preview-banner {
  background: #FFF6C9 !important;
  border: 2px solid var(--ink) !important;
  border-radius: 0 !important;
  color: var(--ink) !important;
}

/* Toast: black card, yellow icon tile */
#toast-banner {
  background: var(--ink) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 4px !important;
  box-shadow: 0 10px 24px rgba(0,0,0,0.25) !important;
  max-width: 360px;
}
#toast-banner .text-slate-300 { color: #ddd !important; }
#toast-icon, #toast-banner .toast-glyph {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  background: var(--yellow);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}
#toast-icon .icon, #toast-banner .toast-glyph .icon {
  width: 18px;
  height: 18px;
  display: block;
}

/* Modals: dim + white card, 2px black border */
#error-mark-modal, #admin-account-modal, #ai-exam-zoom-modal {
  background: rgba(0,0,0,0.55) !important;
}
#error-mark-modal > div, #admin-account-modal > div {
  border-radius: 0 !important;
  border: 2px solid var(--ink) !important;
  box-shadow: var(--shadow);
}

/* Custom file buttons already hide the native control; reinforce */
input[type="file"].hidden,
input[type="file"].sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none;
}

/* Tables */
#view-teacher table, #view-admin table, #view-student table,
table.data {
  width: 100%;
  border-collapse: collapse;
}
#view-teacher thead th, #view-admin thead th, #view-student thead th {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--ink);
  border-bottom: 2px solid var(--ink);
  background: transparent;
  text-align: left;
  padding: 8px 6px;
}
#view-teacher tbody td, #view-admin tbody td, #view-student tbody td {
  border-bottom: 1px solid var(--hair);
  padding: 10px 6px;
  font-size: 13px;
  color: var(--ink);
}

/* Sticky teacher AI exam warning stays, but restyle */
#view-teacher .sticky {
  border-radius: 0;
}

/* Chrome links */
#btn-preview-student,
#admin-switcher button,
#top-nav button[onclick="logout()"] {
  background: none;
  border: 0;
  border-radius: 0;
  border-bottom: 1.5px solid var(--ink);
  padding: 2px 0;
  font-weight: 800;
  font-size: 13px;
  color: var(--ink);
  box-shadow: none;
}
#btn-preview-student:hover,
#admin-switcher button:hover,
#top-nav button[onclick="logout()"]:hover {
  color: var(--coral);
  border-bottom-color: var(--coral);
  background: none;
}
#admin-switcher {
  background: transparent !important;
  padding: 0;
  gap: 14px;
  display: flex;
}
#admin-switcher button {
  box-shadow: none !important;
  background: none !important;
  color: var(--ink) !important;
}

/* Decorative layers never capture clicks */
.illus-wrap, .login-art, .masthead, .chrome-deco {
  pointer-events: none;
}

/* Print: no yellow frame, no ornaments, exam CSS remains in charge */
@media print {
  body, html, .canvas {
    background: #fff !important;
    padding: 0 !important;
    min-height: 0 !important;
  }
  .masthead,
  .login-art,
  .illus-wrap,
  .chrome-deco,
  #toast-banner {
    display: none !important;
  }
  .stage {
    box-shadow: none !important;
    max-width: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Four-dimension and ratio bars: coral fill on the gray track */
.bg-emerald-500, .bg-amber-500, .bg-rose-500, .bg-green-500, .bg-green-600,
.bg-sky-500, .bg-blue-500 {
  background-color: var(--coral) !important;
}
.bg-yellow-400 { background-color: var(--yellow) !important; }
.bg-slate-200.h-2, .w-full.bg-slate-200 {
  background-color: var(--track) !important;
}

/* Status chips: 已啟用／已覆核 → yellow; keep contrast */
.bg-emerald-100, .bg-green-100 {
  background-color: var(--yellow) !important;
  color: var(--ink) !important;
  border-color: var(--ink);
}


/* QA: 四維百分比統一珊瑚，不再留 Tailwind 綠 */
#student-four-dims-card .text-emerald-600,
#student-four-dims-card .text-emerald-500,
#student-four-dims-card .text-amber-600,
#student-four-dims-card .text-rose-600,
.text-emerald-600 {
  color: #D96D3F !important;
}

/* QA: AI 改卷模擬主按鈕用正式珊瑚，避免淺珊瑚看起來像褪色 */
#teacher-panel-aigrade button.bg-indigo-600,
#teacher-panel-aigrade button[onclick="aiExamRunOcr()"],
#teacher-panel-aigrade button[onclick="aiExamRunGrading()"] {
  background-color: #D96D3F !important;
  color: #fff !important;
  border-radius: var(--radius-pill) !important;
  font-weight: 800;
}

/* 內層內容塊直角（膠囊輸入與小控件除外） */
#view-student .rounded-xl,
#view-teacher .rounded-xl,
#view-admin .rounded-xl,
#view-student .bg-white.rounded-lg,
#view-teacher .bg-white.rounded-lg,
#view-admin .bg-white.rounded-lg,
#error-mark-modal > div,
#admin-account-modal > div {
  border-radius: 0 !important;
}
#view-student input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="number"]),
#view-teacher input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="number"]),
#view-admin input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="number"]),
#view-student select, #view-teacher select, #view-admin select,
#view-login input.field, #login-form input, .register-form input.field {
  border-radius: var(--radius-pill) !important;
}
#view-student input[type="number"],
#view-teacher input[type="number"],
#view-admin input[type="number"] {
  border-radius: 8px !important;
}
#view-student textarea, #view-teacher textarea, #view-admin textarea,
#error-mark-modal textarea, #admin-account-modal textarea {
  border-radius: 18px !important;
}

/* 卷頭遮罩圖例色塊（取代方塊符號） */
.legend-swatch {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.3em;
  vertical-align: -0.1em;
  border: 1.5px solid #000;
  background: #000;
}
.legend-swatch-ink { background: #000; }

/* 圖例色塊必須跟卷面標註同一套色 */
.legend-chip {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  vertical-align: middle;
  flex-shrink: 0;
}
.legend-chip-fact {
  background: #F8E4D8;
  border: 1.5px solid var(--coral);
}

/* 註冊錯誤提示 */
.auth-error:not(.hidden) {
  margin: 0;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  background: #F8E4D8;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.auth-success-box {
  border: 2px solid var(--ink);
  background: #FFF6C9;
  padding: 14px 16px;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.65;
}
.auth-success-box strong { font-weight: 800; }
.class-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 6px;
}
.class-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.auth-panel[hidden] { display: none !important; }


/* ---------- 匯入教材 / 待確認清單 ---------- */
.import-app-root { display: flex; flex-direction: column; gap: 16px; }
.import-thumb {
  display: block;
  max-width: 240px;
  max-height: 160px;
  width: auto;
  height: auto;
  border: 2px solid var(--ink, #000);
  background: #fff;
  object-fit: contain;
}
.import-advanced-details {
  margin-top: 0;
}
.import-advanced-summary {
  list-style: none;
  cursor: pointer;
  background: #FFFFFF;
  border: 2px solid var(--ink, #000);
  border-radius: 16px;
  padding: 16px 20px;
  color: #000;
}
.import-advanced-summary::-webkit-details-marker { display: none; }
.import-advanced-summary::marker { content: ""; }
.import-advanced-summary::before {
  content: "展開 ";
  font-size: 12px;
  font-weight: 800;
  color: #D96D3F;
  margin-right: 6px;
}
details.import-advanced-details[open] > .import-advanced-summary::before {
  content: "收起 ";
}
.import-intro-card h3,
#import-pending-panel h3,
#import-bank-panel h3 {
  color: #000;
}


/* ---------- App-like mobile shell (bottom nav, safe area, 44px targets) ---------- */
#js-error-banner {
  top: env(safe-area-inset-top, 0px);
}
#ai-exam-zoom-modal > button[aria-label="關閉"] {
  top: calc(1rem + env(safe-area-inset-top, 0px));
}

#bottom-nav {
  display: none;
}

#ai-exam-ocr-pane.is-image-collapsed #ai-exam-ocr-left-img {
  display: none;
}

#ai-exam-ocr-pane.is-image-collapsed {
  grid-template-columns: 1fr;
}

#ai-exam-camera-btn {
  min-height: 44px;
}

#toast-banner {
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 768px) {
  .btn,
  .btn-compact,
  #login-submit-btn,
  .ai-exam-upload-actions button,
  #view-student button:not(.chrome-link):not(.bottom-nav-item),
  #view-teacher button:not(.chrome-link):not(.bottom-nav-item):not(.ai-exam-thumb-btn),
  #view-admin button:not(.chrome-link):not(.bottom-nav-item) {
    min-height: 44px;
  }

  #view-login input.field,
  #login-form input,
  .register-form input.field,
  #view-student input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="number"]),
  #view-teacher input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="number"]),
  #view-admin input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="number"]),
  #view-student select,
  #view-teacher select,
  #view-admin select {
    min-height: 44px;
    height: 44px;
  }

  body.is-app.has-bottom-nav #tabs,
  body.is-app.has-bottom-nav #admin-tabs {
    display: none !important;
  }

  body.is-app.has-bottom-nav #bottom-nav:not([hidden]) {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--white);
    border-top: 2px solid var(--ink);
    padding: 4px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    color: var(--ink);
  }

  body.is-app.has-bottom-nav .canvas {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }

  body.is-app.has-bottom-nav #toast-banner {
    bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }

  .bottom-nav-item {
    flex: 1 0 auto;
    min-width: 3.25rem;
    min-height: 44px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 6px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.2;
  }

  .bottom-nav-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .bottom-nav-item .icon {
    width: 22px;
    height: 22px;
  }
  .bottom-nav-badge {
    position: absolute;
    top: -4px;
    right: -9px;
    min-width: 1rem;
    height: 1rem;
    padding: 0 4px;
    border-radius: 999px;
    background: #D96D3F;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    line-height: 1rem;
    text-align: center;
  }

  .bottom-nav-item.is-active {
    color: var(--ink);
  }

  .bottom-nav-item.is-active .bottom-nav-label {
    color: var(--coral);
  }

  /* AI 改卷核對頁：手機改為上圖下字（桌面 lg 並排不變） */
  #ai-exam-ocr-pane {
    grid-template-columns: 1fr;
  }
}

@media print {
  #bottom-nav {
    display: none !important;
  }
}


/* ---------- Individual student analysis drawer ---------- */
#student-analysis-select {
  min-height: 44px;
}
.sa-class-weak { color: #D96D3F; }
.sa-name-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
  margin: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: #000;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.sa-name-btn:hover, .sa-name-btn:focus-visible {
  color: #D96D3F;
  outline: 2px solid #000;
  outline-offset: 2px;
}
.sa-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.sa-open-btn,
.sa-back-btn,
.sa-assign-btn,
.sa-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid #000;
  background: #E7CD3A;
  color: #000;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}
.sa-open-btn:hover,
.sa-back-btn:hover,
.sa-assign-btn:hover,
.sa-close-btn:hover {
  background: #fff;
}
.sa-open-btn:focus-visible,
.sa-back-btn:focus-visible,
.sa-assign-btn:focus-visible,
.sa-close-btn:focus-visible,
#student-analysis-select:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

#student-analysis-drawer.hidden,
#student-analysis-drawer[hidden] {
  display: none !important;
}
.sa-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
}
body.sa-drawer-open {
  overflow: hidden;
}
.sa-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.sa-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  height: 100%;
  background: #fff;
  color: #1F1F1F;
  border-left: 2px solid #000;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sa-panel-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 16px 8px;
  border-bottom: 2px solid #000;
  background: #E7CD3A;
}
.sa-panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  color: #000;
  line-height: 1.35;
  padding-top: 8px;
}
.sa-close-btn {
  width: 44px;
  padding: 0;
  background: #fff;
}
.sa-panel-disclaimer {
  margin: 0;
  padding: 10px 16px;
  font-size: 12px;
  line-height: 1.6;
  color: #1F1F1F;
  background: #fff;
  border-bottom: 1px solid #DDD;
}
.sa-panel-body {
  flex: 1;
  overflow: auto;
  padding: 16px 16px 28px;
  -webkit-overflow-scrolling: touch;
}
.sa-mod {
  margin: 0 0 20px;
  padding: 0 0 16px;
  border-bottom: 1px solid #E5E5E5;
}
.sa-mod:last-child { border-bottom: 0; margin-bottom: 0; }
.sa-mod h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 900;
  color: #000;
}
.sa-mod h4 {
  margin: 10px 0 6px;
  font-size: 13px;
  font-weight: 800;
  color: #000;
}
.sa-disclaimer,
.sa-source-note,
.sa-demo-line,
.sa-demo-note {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.6;
  color: #1F1F1F;
}
.sa-demo-note { display: inline; margin-left: 6px; color: #555; }
.sa-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin: 10px 0;
}
.sa-overview-grid .sa-k {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #555;
}
.sa-overview-grid .sa-v {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: #000;
}
.sa-source-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.sa-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid #000;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
}
.sa-badge .icon { width: 14px; height: 14px; }
.sa-badge-official { background: #E7CD3A; color: #000; }
.sa-badge-practice { background: #FFF6C9; color: #000; }
.sa-badge-demo { background: #F3F3F3; color: #000; }
.sa-empty {
  margin: 8px 0 0;
  padding: 12px;
  border: 1px dashed #BBB;
  background: #FAFAFA;
  font-size: 13px;
  line-height: 1.6;
}
.sa-rec-list,
.sa-error-list,
.sa-trend-list,
.sa-follow-list,
.sa-typo-box ul {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}
.sa-rec-list li,
.sa-error-list li,
.sa-trend-list li,
.sa-follow-list li,
.sa-typo-box li {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #DDD;
  background: #FAFAFA;
  font-size: 13px;
  line-height: 1.6;
}
.sa-error-tag { font-weight: 800; margin: 6px 0 4px; color: #000; }
.sa-excerpt {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-left: 3px solid #D96D3F;
  background: #fff;
  font-size: 12px;
  color: #1F1F1F;
}
.sa-dims { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.sa-dim { padding: 10px 0 0; }
.sa-dim-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.sa-dim-label { font-size: 13px; font-weight: 800; color: #000; }
.sa-follow-tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #D96D3F;
  color: #D96D3F;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.sa-dim.is-weak .sa-bar-student { background: #D96D3F; }
.sa-dim.is-weak .sa-bar-v { color: #D96D3F; }
.sa-bar-row {
  display: grid;
  grid-template-columns: 88px 1fr 48px;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}
.sa-bar-k { font-size: 11px; font-weight: 700; color: #555; }
.sa-bar-track {
  height: 10px;
  background: #EEE;
  border: 1px solid #DDD;
  border-radius: 999px;
  overflow: hidden;
}
.sa-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  width: 0;
}
.sa-bar-student { background: #000; }
.sa-bar-class { background: #9A9A9A; }
.sa-bar-v {
  font-family: Oswald, "Noto Sans TC", sans-serif;
  font-weight: 600;
  font-size: 13px;
  text-align: right;
  color: #000;
}
.sa-ratio { margin: 6px 0 0; font-size: 12px; font-weight: 700; }
.sa-practice-box {
  margin-top: 14px;
  padding: 12px;
  border: 2px solid #000;
  background: #fff;
}
.sa-practice-item + .sa-practice-item { margin-top: 10px; }
.sa-typo-box {
  margin-top: 8px;
  padding: 10px 12px;
  border: 2px solid #000;
  background: #FFFBEA;
}
.sa-assign-btn { margin-top: 8px; width: 100%; background: #E7CD3A; }

@media (max-width: 768px) {
  .sa-panel {
    width: 100%;
    left: 0;
    right: 0;
    border-left: 0;
  }
  .sa-panel-head {
    grid-template-columns: 1fr auto;
  }
  .sa-panel-head h2 {
    grid-column: 1 / -1;
    order: 3;
    padding-top: 0;
  }
  .sa-bar-row { grid-template-columns: 72px 1fr 40px; }
  .sa-overview-grid { grid-template-columns: 1fr; }
}

@media (min-width: 769px) {
  .sa-back-btn {
    /* keep visible on desktop so teachers can return the same way */
  }
}


/* Import confirm: unusable until 出處／授權 filled */
button[data-import-action="confirm-one"]:disabled,
button[data-import-action="confirm-selected"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}


/* PWA install (login only; hidden when already standalone) */
.pwa-install {
  margin-top: 1rem;
}
.pwa-install-btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 1.5px solid #000;
  border-radius: 0.7rem;
  background: #fff;
  color: #000;
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
}
.pwa-install-btn:hover {
  background: #FFF6C9;
}
body:not(.view-login) .pwa-install {
  display: none;
}

/* 指令詞多選快捷與附加條件 */
.cw-hint { font-size: 11px; color: #475569; margin: 0; }
.cw-row-label { font-size: 11px; font-weight: 700; color: #1F1F1F; margin: 0 0 4px; }
.cw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cw-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.85rem;
  padding: 0.15rem 0.65rem;
  border: 1px solid #000;
  background: #fff;
  color: #1F1F1F;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  border-radius: 999px;
}
.cw-chip:hover { background: #F8E4D8; }
.cw-chip.is-on { background: #E7CD3A; }
.cw-suggest {
  font-size: 11px;
  font-weight: 700;
  color: #1F1F1F;
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
.cw-other { display: flex; gap: 8px; align-items: center; }
.cw-other[hidden] { display: none !important; }



/* ---------- 教材庫圖庫 ---------- */
.ilib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.ilib-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ilib-thumb,
.ilib-print {
  display: block;
  max-width: 100%;
  max-height: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 2px solid var(--ink, #000);
  background: #fff;
}
.ilib-figure {
  margin: 0.6rem 0;
}
.ilib-figure figcaption {
  font-size: 11px;
  color: #475569;
  margin-top: 4px;
}
.ilib-picker {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ilib-picker[hidden] {
  display: none !important;
}
.ilib-picker-panel {
  background: #fff;
  max-width: 920px;
  width: 100%;
  max-height: 86vh;
  overflow: auto;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
}
