﻿:root {
  --teal: #3dbfb8;
  --teal-dark: #2aa09a;
  --teal-light: #e8f7f6;
  --teal-bg: #d0f0ee;
  --gold: #FEC750;
  --gold-dark: #e5b030;
  --red: #e74c3c;
  --text: #2d3748;
  --text-light: #718096;
  --border: #b2dfdb;
  --bg: #e8f5f4;
  --card: #ffffff;
  --shadow: 0 2px 16px rgba(61,191,184,0.10);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Sans TC', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Header ── */
.header {
  background: #15ABAA;
  background-position: center; background-size: cover;
  display: flex; align-items: center; justify-content: center;
  height: 56px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  border-bottom: 1px solid rgba(255,255,255,0.15);
  color: white;
}
.header-inner {
  width: 100%; max-width: 1400px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 0 8px; min-height: 56px;
}
.header-logo { display: flex; align-items: center; flex: 1; min-width: 0; }
.header-logo a { display: flex; align-items: center; }
.logo-img { height: 28px; width: auto; max-width: calc(100vw - 7rem); display: block; }
.header-right { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.btn-header-action {
  background: white; color: var(--teal-dark);
  border: none; border-radius: 8px; padding: 7px 16px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: background 0.2s, color 0.2s; white-space: nowrap;
}
.btn-header-action:hover { background: var(--gold); color: #333; }
.btn-header-action.active { background: var(--gold); color: #333; }
.header-icon-btn {
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  transition: background 0.2s; padding: 0; color: white;
}
.header-icon-btn:hover { background: rgba(15,144,146,0.7); }
.header-icon-btn img { width: 24px; height: 24px; filter: brightness(0) invert(1); display: block; }

/* 9-dot grid icon */
.dots-grid {
  display: grid; grid-template-columns: repeat(3, 5px); gap: 4px;
}
.dots-grid span {
  width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}

/* portal menu (產品選單) */
.portal-menu-wrap { position: relative; }
.portal-menu-dropdown {
  display: none; position: fixed; right: 0; top: 56px; z-index: 200;
  width: min(360px, 100vw); overflow: hidden;
  border-top-left-radius: 16px; border-bottom-left-radius: 16px;
  background: white; color: #334155;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}
.portal-menu-dropdown.open { display: block; }
.portal-menu-scroll {
  max-height: calc(90vh - 4rem); overflow-y: auto;
  padding: 16px 12px;
}
.portal-menu-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px 8px;
}
.portal-app-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 8px 4px; border-radius: 16px;
  text-decoration: none; color: #334155; text-align: center;
  transition: background 0.2s;
}
.portal-app-item:hover { background: #f8fafc; }
.portal-app-icon {
  width: 60px; height: 60px; border-radius: 50%; overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  border: 1px solid #f1f5f9;
  transition: transform 0.2s;
}
.portal-app-item:hover .portal-app-icon { transform: scale(1.05); }
.portal-app-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portal-app-name {
  font-size: 15px; line-height: 1.25;
  color: #334155; transition: color 0.2s;
}
.portal-app-item:hover .portal-app-name { color: var(--teal-dark); }

/* login button */
.header-login-btn {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  border-radius: 12px; padding: 8px 6px;
  color: white; transition: background 0.2s;
  font-family: inherit;
}
.header-login-btn:hover { background: rgba(15,144,146,0.7); }
.header-login-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.login-label {
  display: none; font-size: 16px; font-weight: 600;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chevron-down-icon {
  display: none; width: 18px; height: 18px; flex-shrink: 0;
  transition: transform 0.2s;
}
.chevron-down-icon.visible { display: none; }

/* user dropdown */
.user-wrap { position: relative; }
.user-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 12px);
  background: white; border-radius: 16px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
  min-width: 200px; padding: 8px; z-index: 200;
  color: #334155;
}
.user-dropdown.open { display: block; }
.user-dropdown .logout-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  background: none; border: none; border-radius: 12px;
  font-size: 14px; font-weight: 500; color: #475569;
  cursor: pointer; font-family: inherit; transition: background 0.2s, color 0.2s;
}
.user-dropdown .logout-btn:hover { background: #fef2f2; color: #dc2626; }
.user-dropdown .logout-btn svg { flex-shrink: 0; }

/* ── Header responsive (sm: 640px) ── */
@media (min-width: 640px) {
  .header { height: 64px; }
  .header-inner { min-height: 64px; gap: 16px; padding: 0 24px; }
  .logo-img { height: 40px; max-width: none; }
  .header-right { gap: 12px; }
  .header-icon-btn { width: 48px; height: 48px; }
  .header-login-btn { gap: 8px; padding: 8px 12px; }
  .header-login-btn svg { width: 26px; height: 26px; }
  .login-label { display: block; }
  .chevron-down-icon.visible { display: block; }
  .portal-menu-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: min(400px, calc(100vw - 1.5rem));
    border-radius: 8px;
  }
  .portal-menu-scroll { padding: 12px 16px 12px 16px; }
  .portal-menu-grid { gap: 12px 16px; }
  .portal-app-item { gap: 4px; padding: 12px 8px; }
  .portal-app-icon { width: 80px; height: 80px; }
  .portal-app-name { font-size: 18px; }
}

/* ── Hero / Banner ── */
.hero { width: 100%; background: #e8f5f4; display: flex; justify-content: center; align-items: center; padding: 22px 20px 0; }
.hero-banner { display: block; max-height: 145px; width: auto; max-width: 680px; object-fit: contain; }
.hero-toggle-wrap { background: #e8f5f4; display: flex; justify-content: center; padding: 16px 20px 22px; }
.hero-toggle-wrap > .toggle-bar { width: calc(62% - 64px); max-width: 1136px; min-width: 536px; }
.toggle-bar { background: #ffffff; border-radius: 40px; display: flex; padding: 4px; gap: 0; border: 1.5px solid #e0e0e0; }
.toggle-btn {
  flex: 1; padding: 10px 0; border-radius: 32px; border: none; font-size: 20px; font-weight: 700;
  cursor: pointer; transition: all 0.25s; color: #999;
  background: transparent; font-family: inherit; text-align: center;
}
.toggle-btn.active { background: var(--gold); color: #333; box-shadow: 0 2px 10px rgba(245,200,66,0.35); }

/* ── Main ── */
.main { width: 62%; max-width: 1200px; min-width: 600px; margin: 0 auto; padding: 28px 32px 60px; box-sizing: border-box; }

/* ── Card ── */
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 28px 32px; margin-bottom: 24px; }
.redispatch-banner {
  padding: 16px 18px;
  background: linear-gradient(135deg, #f2fffd 0%, #ebfbfa 100%);
  border: 1px solid rgba(61,191,184,0.28);
  box-shadow: 0 2px 10px rgba(61,191,184,0.08);
}
.redispatch-banner-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 900;
  color: var(--teal-dark);
  margin-bottom: 6px;
}
.redispatch-banner-title iconify-icon {
  font-size: 18px;
}
.redispatch-banner-desc {
  font-size: 13px;
  line-height: 1.8;
  color: #5f7382;
}

/* ── Form ── */
.field-label { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.field-input {
  width: 100%; border: 2px solid #cccccc; border-radius: 10px;
  padding: 13px 16px; font-size: 14px; font-family: inherit; outline: none;
  color: var(--text-light); transition: border-color 0.2s; background: white;
}
.field-input:focus { border-color: var(--teal); color: var(--text); }
.field-row { display: flex; align-items: center; gap: 12px; }
.field-row .field-input { flex: 1; }
.btn-select-class {
  background: var(--teal); color: white; border: none; border-radius: 10px;
  padding: 13px 22px; font-size: 16px; font-weight: 700; cursor: pointer;
  white-space: nowrap; transition: background 0.2s; font-family: inherit;
}
.btn-select-class:hover { background: var(--teal-dark); }
.section-title { font-size: 18px; font-weight: 700; margin: 20px 0 10px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.btn-view-img {
  background: white; border: 2px solid var(--teal); border-radius: 20px;
  padding: 5px 16px; font-size: 13px; color: var(--teal); cursor: pointer;
  font-weight: 600; transition: background 0.2s, color 0.2s; font-family: inherit;
}
.btn-view-img:hover { background: var(--teal); color: white; }

/* ── Upload zone ── */
.upload-zone {
  border: 2.5px dashed var(--teal); border-radius: 16px; background: var(--teal-light);
  min-height: 190px; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px; cursor: pointer; position: relative; transition: background 0.2s;
}
.upload-zone:hover { background: var(--teal-bg); }
.upload-zone.is-dragover {
  background: #dff3f1;
  border-color: #20a29b;
  box-shadow: inset 0 0 0 2px rgba(32, 162, 155, 0.18);
}
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(61,191,184,0.15); border: none; border-radius: 50%;
  width: 38px; height: 38px; font-size: 20px; color: var(--teal-dark);
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s;
}
.nav-arrow:hover { background: rgba(61,191,184,0.35); }
.nav-left { left: 10px; } .nav-right { right: 10px; }
.upload-zone-text { text-align: center; color: var(--text-light); font-size: 16px; line-height: 1.8; }
.upload-zone-text strong { font-size: 18px; color: var(--text); }
.upload-zone input[type=file] { display: none; }

/* ── 多圖預覽縮圖列 ── */
.upload-thumb-scroll {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 12px 6px; box-sizing: border-box;
  scrollbar-width: thin; scrollbar-color: var(--teal) transparent;
}
.upload-thumb-scroll::-webkit-scrollbar { height: 4px; }
.upload-thumb-scroll::-webkit-scrollbar-thumb { background: var(--teal); border-radius: 2px; }
.upload-thumb-row {
  display: flex; gap: 10px; align-items: flex-start;
  min-width: max-content;
}
.upload-thumb-item {
  flex-shrink: 0; width: 140px; height: 100px; border-radius: 8px;
  overflow: hidden; border: 2px solid #dde8e7;
  background: #f0faf9; cursor: zoom-in;
  transition: border-color 0.15s;
}
.upload-thumb-item:hover { border-color: var(--teal); }
.upload-thumb-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 新增圖片按鈕（縮圖列尾端） */
.upload-thumb-add {
  flex-shrink: 0; width: 100px; height: 100px; border-radius: 8px;
  border: 2px dashed var(--teal); background: #f0faf9;
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  color: var(--teal); font-size: 12px; font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.upload-thumb-add:hover { background: #e0f5f3; border-color: #00796b; color: #00796b; }
.upload-thumb-add .thumb-add-icon { font-size: 28px; line-height: 1; }
.upload-thumb-add.is-disabled {
  cursor: not-allowed;
  background: #f3f6f6;
  border-color: #cfd9d8;
  color: #9aa7a6;
}
.upload-thumb-add.is-disabled:hover {
  background: #f3f6f6;
  border-color: #cfd9d8;
  color: #9aa7a6;
}
.upload-thumb-meta {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 4px 12px 10px; box-sizing: border-box;
  font-size: 12px; color: var(--text-light); gap: 8px;
}
.upload-capacity-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(61,191,184,0.12);
  color: #1a8f89;
  font-weight: 700;
}
.upload-capacity-badge.is-warning {
  background: rgba(237, 88, 88, 0.12);
  color: #d84a4a;
}

/* ── AI派題 layout ── */
.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.numbered-step { font-size: 18px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-btn {
  border: 2px solid var(--teal); border-radius: 10px; padding: 9px 20px;
  font-size: 16px; font-weight: 600; cursor: pointer; background: white;
  color: var(--teal); transition: all 0.2s; font-family: inherit;
}
.radio-btn.active, .radio-btn:hover { background: var(--teal); color: white; }
.check-group { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.check-btn {
  border: 2px solid var(--teal); border-radius: 10px; padding: 9px 20px;
  font-size: 16px; font-weight: 600; cursor: pointer; background: var(--teal);
  color: white; transition: all 0.2s; font-family: inherit;
}
.check-btn.inactive { background: white; color: var(--teal); }

/* ── Main action buttons ── */
.btn-generate, .btn-send {
  width: 100%; background: var(--gold); color: #333; border: none; border-radius: 12px;
  padding: 16px; font-size: 18px; font-weight: 900; cursor: pointer;
  transition: background 0.2s, transform 0.1s; font-family: inherit;
}
.btn-generate { margin: 18px 0; letter-spacing: 1px; }
.btn-send { margin-top: 4px; letter-spacing: 2px; }
.btn-generate:hover, .btn-send:hover { background: var(--gold-dark); transform: translateY(-1px); }

/* ── Two-panel questions ── */
.two-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; min-height: 280px; }
.panel { border-radius: 14px; padding: 16px; min-height: 260px; display: flex; flex-direction: column; gap: 10px; }
.panel-left { background: var(--teal-light); border: 2px solid var(--border); }
.panel-right { background: #fff9e8; border: 2px dashed var(--gold); }
.panel-label { font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--text-light); }
.panel-right .panel-label { color: #856404; }
.q-item {
  background: white; border-radius: 10px; padding: 12px 14px; font-size: 13px;
  line-height: 1.6; color: var(--text); cursor: pointer; display: flex; align-items: flex-start; gap: 8px;
  transition: box-shadow 0.2s, transform 0.15s; border: 1px solid #e2e8f0;
}
.q-item:hover { box-shadow: 0 4px 16px rgba(61,191,184,0.18); transform: translateY(-1px); }
.q-item-text {
  flex: 1;
  line-height: 1.9;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.q-item-text mjx-container {
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}
.q-item-text mjx-container[jax="CHTML"] {
  font-size: 1em !important;
}
.q-arrow {
  flex-shrink: 0; width: 24px; height: 24px; background: var(--teal); color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; margin-top: 2px;
}
.panel-right .q-item .q-arrow { background: var(--gold); color: #333; }
.panel-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-light); font-size: 13px; text-align: center; line-height: 1.8; }
.btn-dispatch-wrap { text-align: center; margin: 12px 0 4px; }
.btn-dispatch-questions {
  background: var(--gold); color: #333; border: none; border-radius: 10px;
  padding: 11px 36px; font-size: 18px; font-weight: 700; cursor: pointer;
  transition: background 0.2s; font-family: inherit;
}
.btn-dispatch-questions:hover { background: var(--gold-dark); }

/* ── Draggable list ── */
.q-list { display: flex; flex-direction: column; gap: 10px; }
.q-list-item {
  background: white; border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 12px; cursor: grab;
  transition: box-shadow 0.2s; font-size: 14px; line-height: 1.6;
}
.q-list-item:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); }
.q-list-item.dragging { opacity: 0.55; box-shadow: 0 10px 28px rgba(0,0,0,0.12); }
.q-list-item.drag-over { border-color: var(--teal); background: #f0faf9; }
.drag-handle { font-size: 18px; color: #aaa; flex-shrink: 0; margin-top: 2px; user-select: none; cursor: grab; }

/* ── Table ── */
.table-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 180px; border: 2px solid #cccccc; border-radius: 10px; padding: 10px 14px; font-size: 14px; font-family: inherit; outline: none; transition: border-color 0.2s; }
.search-input:focus { border-color: var(--teal); }
.select-time { border: 2px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 14px; font-family: inherit; outline: none; background: white; cursor: pointer; }
.btn-export { background: var(--teal); color: white; border: none; border-radius: 10px; padding: 10px 20px; font-size: 14px; font-weight: 700; cursor: pointer; transition: background 0.2s; white-space: nowrap; font-family: inherit; }
.btn-export:hover { background: var(--teal-dark); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 12px 14px; font-size: 14px; font-weight: 700; border-bottom: 2px solid var(--teal-bg); vertical-align: middle; }
.data-table td { padding: 13px 14px; font-size: 14px; border-bottom: 1px solid #f0f4f4; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.2s ease; }
.data-table tbody tr:hover { background: var(--teal-light); }
.data-table tbody tr:hover td { background: transparent; }
.badge { display: inline-block; border-radius: 6px; padding: 2px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-ai { background: #e8f7f6; color: var(--teal-dark); }
.badge-book { background: #fff3cd; color: #856404; }
.action-icons { display: flex; gap: 8px; align-items: center; }
.icon-btn .tooltip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.75); color: white; padding: 3px 8px; border-radius: 6px; font-size: 11px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.icon-btn:hover .tooltip { opacity: 1; }

/* ── Detail ── */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.detail-top-btns { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn-back { background: white; border: 2px solid var(--teal); color: var(--teal); border-radius: 10px; padding: 8px 18px; font-size: 16px; font-weight: 700; cursor: pointer; transition: background 0.2s, color 0.2s; font-family: inherit; }
.btn-back:hover { background: var(--teal); color: white; }
.answer-count-badge { background: var(--teal); color: white; border-radius: 10px; padding: 8px 18px; font-size: 16px; font-weight: 700; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.chart-box { background: var(--teal-light); border-radius: 14px; padding: 16px; }
.chart-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; text-align: center; }
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut { width: 100px; height: 100px; flex-shrink: 0; }
.donut svg { width: 100%; height: 100%; }
.donut-legend { display: flex; flex-direction: column; gap: 5px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 90px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.bar { width: 100%; border-radius: 4px 4px 0 0; background: var(--teal); }
.bar-label { font-size: 10px; color: var(--text-light); }
.score-red { color: var(--red); font-weight: 700; }

/* ── Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 999; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: 20px; padding: 28px 32px 24px; max-width: 560px; width: 92%; box-shadow: 0 20px 60px rgba(0,0,0,0.18); animation: modalIn 0.25s ease; }
@keyframes modalIn { from { transform: scale(0.92) translateY(16px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.modal-close { display: block; background: none; border: none; font-size: 20px; cursor: pointer; color: #999; margin-left: auto; margin-bottom: 10px; line-height: 1; }
.modal-content { display: flex; gap: 20px; align-items: stretch; }
.qr-box { width: 130px; height: 130px; background: #f0f0f0; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 26px; font-weight: 900; color: #999; letter-spacing: 2px; position: relative; }
.qr-logo-overlay { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:26px; height:26px; background:#fff; border-radius:4px; padding:2px; box-sizing:border-box; object-fit:contain; pointer-events:none; }
.modal-info { flex: 1; }
.modal-info-box { background: var(--teal-light); border-radius: 12px; padding: 14px 16px; line-height: 2; font-size: 16px; }
.modal-info-box a { color: var(--teal-dark); word-break: break-all; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.modal-btn { flex: 1; border: 2px solid var(--teal); background: white; color: var(--teal); border-radius: 10px; padding: 11px 10px; font-size: 16px; font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.modal-btn:hover { background: var(--teal-light); }
.modal-btn.primary { background: var(--teal); color: white; }
.modal-btn.primary:hover { background: var(--teal-dark); }
.modal-title-row { display:flex; align-items:flex-start; gap:12px; margin-bottom:16px; }
.modal-title { font-size:24px; font-weight:900; color:var(--text); }
.modal-subtitle { font-size:13px; color:var(--text-light); margin-top:4px; line-height:1.6; }

.book-image-editor-modal { max-width: 860px; }
.book-image-editor-list {
  display: grid;
  gap: 14px;
  max-height: min(62vh, 720px);
  overflow-y: auto;
  padding-right: 4px;
}
.book-image-editor-item {
  display: grid;
  grid-template-columns: 28px 120px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid #d9ece9;
  border-radius: 16px;
  background: #f9fffe;
  cursor: grab;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.book-image-editor-item:hover {
  box-shadow: 0 6px 20px rgba(61, 191, 184, 0.10);
}
.book-image-editor-item.dragging {
  opacity: 0.55;
  box-shadow: 0 10px 28px rgba(0,0,0,0.12);
}
.book-image-editor-item.drag-over {
  border-color: var(--teal);
  background: #f0faf9;
}
.book-image-editor-handle {
  font-size: 18px;
  color: #98a8ad;
  user-select: none;
  cursor: grab;
  justify-self: center;
}
.book-image-editor-thumb {
  width: 120px;
  height: 84px;
  border-radius: 12px;
  overflow: hidden;
  background: #edf7f6;
  border: 1px solid #d7ebe8;
}
.book-image-editor-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.book-image-editor-meta {
  min-width: 0;
  display: grid;
  gap: 6px;
}
.book-image-editor-order {
  font-size: 16px;
  font-weight: 900;
  color: var(--teal-dark);
}
.book-image-editor-name {
  font-size: 13px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-image-editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.book-image-editor-btn {
  min-width: 76px;
  border: 1px solid #bfe7e3;
  background: #fff;
  color: var(--teal-dark);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}
.book-image-editor-btn:hover { background: var(--teal-light); }
.book-image-editor-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  background: #f6fbfa;
}
.book-image-editor-btn.danger {
  border-color: #ffd1d9;
  color: #cf3f64;
}
.book-image-editor-btn.danger:hover {
  background: #fff4f6;
}

/* ── Class Selection Field ── */
.class-select-field-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.class-select-field-row input { flex: 1; cursor: pointer; }
.btn-select-class { background: var(--teal); color: white; border: none; border-radius: 15px; padding: 10px 25px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; white-space: nowrap; transition: background 0.2s; }
.btn-select-class:hover { background: var(--teal-dark); }

.selected-class-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; min-height: 0; }
.class-tag-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 25px; background: var(--teal-light); border: 1.5px solid #c3e4e0; font-size: 14px; font-weight: 600; color: var(--teal-dark); }
.class-tag-pill .tag-remove { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text-light); padding: 0 0 0 2px; line-height: 1; transition: color 0.2s; }
.class-tag-pill .tag-remove:hover { color: #cf3f64; }

/* ── Class Selector Modal (z-index 2000) ── */
.class-modal-overlay { position: fixed; inset: 0; background: rgba(16,24,40,0.55); z-index: 2000; display: none; align-items: center; justify-content: center; backdrop-filter: blur(5px); padding: 24px; }
.class-modal-overlay.open { display: flex; }
.class-modal-content { background: white; border-radius: 30px; padding: 36px 40px 28px; max-width: 600px; width: 100%; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 20px 70px rgba(0,0,0,0.18); }
.class-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-shrink: 0; }
.class-modal-title { font-size: 24px; font-weight: 700; color: var(--text); margin: 0; }
.class-modal-close { background: none; border: none; font-size: 22px; color: var(--text-light); cursor: pointer; padding: 4px 8px; border-radius: 8px; transition: background 0.15s; }
.class-modal-close:hover { background: #f0f5f4; }
.new-class-btn { border: 2px solid var(--teal); background: white; color: var(--teal); padding: 8px 20px; border-radius: 15px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.2s; }
.new-class-btn:hover { background: var(--teal); color: white; }

.class-select-all-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #e4eeed; cursor: pointer; flex-shrink: 0; margin-bottom: 4px; }
.class-checkbox { width: 18px; height: 18px; accent-color: var(--teal); cursor: pointer; }

.class-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px 0; min-height: 0; }
.class-item { border: 2px solid #e4eeed; border-radius: 15px; padding: 16px 20px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.class-item:hover { border-color: var(--teal); background: var(--teal-light); }
.class-badge { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.class-badge.speedy { background: #e0f7ef; color: #1a9960; }
.class-badge.google { background: #fde8e8; color: #d74557; }
.class-name { flex: 1; font-weight: 600; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-count { color: var(--text-light); font-size: 14px; white-space: nowrap; flex-shrink: 0; }
.class-loading { padding: 24px; text-align: center; color: var(--text-light); font-size: 14px; }
.class-loading.class-error { color: #E74C3C; }

.class-modal-footer { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 16px 0 0; border-top: 1px solid #e4eeed; margin-top: 8px; }
.class-selected-count { font-size: 15px; color: var(--text-light); }
.class-selected-count strong { color: var(--teal); font-size: 18px; }
.class-confirm-btn { background: var(--teal); color: white; border: none; padding: 10px 28px; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background 0.2s; }
.class-confirm-btn:hover { background: var(--teal-dark); }

/* ── Create Class Sub-Modal (z-index 3000) ── */
.create-class-overlay { position: fixed; inset: 0; background: rgba(16,24,40,0.55); z-index: 3000; display: none; align-items: center; justify-content: center; backdrop-filter: blur(5px); padding: 24px; }
.create-class-overlay.open { display: flex; }
.create-class-content { background: white; border-radius: 30px; padding: 36px 40px 28px; max-width: 600px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 70px rgba(0,0,0,0.18); }
.create-class-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.create-class-title { font-size: 24px; font-weight: 700; color: var(--text); margin: 0; }
.class-type-tabs { display: flex; gap: 12px; margin-bottom: 24px; }
.class-type-tab { flex: 1; padding: 14px 20px; border: 2px solid #e4eeed; border-radius: 15px; background: white; cursor: pointer; font-weight: 600; font-size: 15px; text-align: center; font-family: inherit; transition: all 0.2s; color: var(--text); }
.class-type-tab:hover { border-color: var(--teal); }
.class-type-tab.active { border-color: var(--teal); background: var(--teal-light); color: var(--teal); }
.create-class-form { margin-bottom: 8px; }
.create-class-form .field-input { margin-bottom: 16px; }

.google-upload-area { margin-top: 4px; padding: 16px; border: 1.5px dashed #ccc; border-radius: 12px; background: #f9fafb; margin-bottom: 16px; }
.upload-roster-btn { padding: 8px 18px; border: 1.5px solid var(--teal); border-radius: 8px; background: white; color: var(--teal); font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.2s; }
.upload-roster-btn:hover { background: var(--teal); color: white; }
.roster-upload-status { font-size: 13px; color: var(--text-light); }
.download-template-link { font-size: 13px; color: var(--teal); text-decoration: underline; cursor: pointer; }

.create-class-error { color: #E74C3C; font-size: 13px; min-height: 0; }
.create-class-footer { display: flex; gap: 12px; justify-content: flex-end; padding-top: 16px; border-top: 2px solid #e4eeed; margin-top: 16px; }
.create-class-footer .btn-cancel { display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 24px; border: 2px solid #e2e8f0; border-radius: 12px; background: white; font-size: 15px; font-weight: 600; font-family: inherit; color: var(--text); cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.create-class-footer .btn-cancel:hover { border-color: var(--teal); background: var(--teal-light); }

/* ── Roster Review Popup (z-index 10001) ── */
.roster-review-overlay { position: fixed; inset: 0; background: rgba(16,24,40,0.5); z-index: 10001; display: none; align-items: center; justify-content: center; padding: 24px; }
.roster-review-overlay.open { display: flex; }
.roster-review-panel { background: white; border-radius: 16px; padding: 28px 24px; max-width: 720px; width: 100%; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 20px 70px rgba(0,0,0,0.18); }
.roster-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.roster-table th { padding: 10px 12px; border-bottom: 2px solid var(--teal); background: var(--teal-light); text-align: left; font-weight: 700; font-size: 13px; position: sticky; top: 0; }
.roster-table td { padding: 8px 12px; border-bottom: 1px solid #e4eeed; }
.roster-row-dupe { background: #fef3e2; }
.roster-row-dupe input { border: 1.5px solid #dc2626; border-radius: 6px; padding: 4px 8px; font-size: 13px; width: 100%; box-sizing: border-box; }
.roster-input-normal { border: 1px solid #e4eeed; border-radius: 6px; padding: 4px 8px; font-size: 13px; width: 100%; box-sizing: border-box; background: transparent; }
.roster-input-normal:disabled { background: transparent; border-color: transparent; }
.btn-roster-delete { background: none; border: none; color: #cf3f64; cursor: pointer; font-size: 18px; padding: 2px 6px; border-radius: 6px; transition: background 0.15s; }
.btn-roster-delete:hover { background: #fff4f6; }

/* ── Toast ── */
.toast { position: fixed; bottom: 28px; right: 28px; background: var(--teal-dark); color: white; padding: 12px 22px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: 0 4px 20px rgba(0,0,0,0.2); z-index: 9999; display: none; }

/* ── Full page loading ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(232, 245, 244, 0.82);
  backdrop-filter: blur(2px);
  z-index: 10010;
}
.loading-overlay.open { display: flex; }
.loading-card {
  width: min(92vw, 360px);
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(61,191,184,0.22);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(27, 85, 95, 0.18);
  padding: 24px 22px;
  text-align: center;
}
.loading-spinner {
  font-size: 44px;
  color: var(--teal-dark);
  display: inline-flex;
  margin-bottom: 12px;
}
.loading-title {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 8px;
}
.loading-desc {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-light);
}

/* ── Footer ── */
.site-footer {
  margin-top: auto; flex-shrink: 0; width: 100%;
  background: #009594; padding: 16px;
  text-align: center; font-size: 14px; color: rgba(255,255,255,0.9);
}
.site-footer .footer-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.site-footer .footer-links {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: center; gap: 8px 16px;
}
.site-footer a { color: white; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer .footer-brand { font-weight: 600; text-decoration: underline; margin-right: 4px; }
.site-footer .footer-sep { display: none; color: rgba(255,255,255,0.7); }
.site-footer .footer-ai { margin-top: 4px; font-size: 14px; color: white; }
@media (min-width: 640px) {
  .site-footer { font-size: 16px; }
  .site-footer .footer-sep { display: inline; }
}

/* ── Page visibility ── */
.page { display: none; background: #e8f5f4; }
.page.active { display: flex; flex-direction: column; min-height: calc(100vh - 56px); }

.answer-canvas-box {
  flex: 1; max-width: 960px; height: 100%;
  border-radius: 20px;
  padding: 10px; display: flex; align-items: stretch;
}
.answer-canvas {
  flex: 1; background: #e8f7f6; border-radius: 14px;
  cursor: crosshair; display: block; width: 100%; height: 100%;
  touch-action: none;
}
.answer-nav {
  background: none; border: none; font-size: 36px; font-weight: 900;
  color: var(--teal-dark); cursor: pointer; padding: 0 8px;
  transition: color 0.2s; flex-shrink: 0;
}
.answer-nav:hover { color: var(--teal); }

/* Page dots */
.page-dot {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border);
  background: white; color: var(--text); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.page-dot.active { background: var(--teal); color: white; border-color: var(--teal); }

/* Toolbar */
.toolbar {
  height: 68px; background: white; border-top: 1px solid #eee;
  display: flex; align-items: center; padding: 0 12px; gap: 4px;
  position: sticky; bottom: 0; z-index: 50;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.tool-rec {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rec-dot {
  width: 18px; height: 18px; border-radius: 50%; background: #e74c3c;
  display: block;
}
.tool-rec.recording .rec-dot { animation: recPulse 0.8s infinite alternate; }
@keyframes recPulse { from { opacity: 1; } to { opacity: 0.3; } }

.tool-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 8px; border: none; border-radius: 10px;
  background: transparent; cursor: pointer; transition: background 0.15s; color: var(--text-light);
  font-family: inherit; flex-shrink: 0; min-width: 48px;
}
.tool-btn:hover { background: var(--teal-light); color: var(--teal-dark); }
.tool-btn.active { background: var(--teal); color: white; }
.tool-label { font-size: 10px; font-weight: 600; }

.toolbar-submit {
  margin-left: auto; background: var(--teal); color: white; border: none;
  border-radius: 10px; padding: 10px 24px; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: background 0.2s; font-family: inherit; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.toolbar-submit:hover { background: var(--teal-dark); }

/* Review toolbar right side */
.toolbar-review-right {
  margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.review-student-btn {
  display: flex; align-items: center; gap: 4px;
  border: 2px solid var(--border); border-radius: 10px;
  padding: 0 12px; height: 38px; box-sizing: border-box;
  background: white; cursor: pointer;
  font-size: 16px; font-weight: 700; font-family: inherit;
  transition: border-color 0.2s; white-space: nowrap;
}
.review-student-btn:hover { border-color: var(--teal); }
.student-menu {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 0;
  background: white; border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  min-width: 120px; overflow: hidden; z-index: 200;
}
.student-menu.open { display: block; }
.student-menu-item {
  padding: 10px 16px; font-size: 14px; cursor: pointer; transition: background 0.15s;
}
.student-menu-item:hover { background: var(--teal-light); }
.score-input {
  width: 68px; border: 2px solid #ccc; border-radius: 10px;
  padding: 0 10px; height: 38px; box-sizing: border-box;
  font-size: 16px; font-weight: 700; font-family: inherit;
  text-align: center; outline: none; transition: border-color 0.2s;
}
.score-input:focus { border-color: var(--teal); }
.review-btn {
  border-radius: 10px; padding: 0 16px; height: 38px; box-sizing: border-box;
  font-size: 16px; font-weight: 700; display: inline-flex; align-items: center;
  cursor: pointer; border: 2px solid transparent; font-family: inherit;
  transition: background 0.2s, color 0.2s, border-color 0.2s; white-space: nowrap;
}
.review-btn.outline { background: white; border: 2px solid var(--teal); color: var(--teal); }
.review-btn.outline:hover { background: var(--teal-light); }
.review-btn.teal { background: var(--teal); color: white; border: 2px solid var(--teal); }
.review-btn.teal:hover { background: var(--teal-dark); }
.review-btn.gold { background: white; color: #ED0041; border: 2px solid #ED0041; }
.review-btn.gold:hover { background: #fff0f4; }

/* ── Student question card ── */
.student-q-card {
  background: white; border-radius: 14px; padding: 24px 28px;
  width: 100%; max-width: 860px; margin: 0 auto;
  box-shadow: 0 2px 16px rgba(61,191,184,.10);
  display: flex; flex-direction: column; gap: 16px;
}
.student-q-num  { font-size: 12px; font-weight: 700; color: var(--teal-dark); }
.student-q-text { font-size: 15px; font-weight: 600; line-height: 2.0; color: var(--text); white-space: pre-line; }
.student-q-canvas { width: 100%; height: 180px; background: #eefaf9; border-radius: 10px; cursor: crosshair; display: block; touch-action: none; }



/* Student answer page: content-center is column, answer-wrap fills remaining */
#page-student-answer .page-content-center { gap: 0; }
#page-student-answer .answer-canvas-box {
  flex: 1; max-width: 860px; width: 100%;
  border-radius: 20px;
  padding: 10px; display: flex; align-items: stretch;
}
#page-student-answer .answer-wrap { padding: 0 12px; }

/* Teacher review: canvas fills space */
#page-teacher-review .page-content-center { justify-content: stretch; }
#page-teacher-review .answer-wrap { padding: 12px; }


/* ── QR box ── */
.qr-box {
  width: 130px; height: 130px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: white; border-radius: 12px; padding: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}
.qr-box img:not(.qr-logo-overlay), .qr-box canvas { width: 120px !important; height: 120px !important; }


/* ══════════════════════════════════════════════
   RWD — 響應式設計
   斷點：
     ≤ 1024px  → 平板
     ≤ 768px   → 大手機 / 小平板
     ≤ 480px   → 手機
   ══════════════════════════════════════════════ */

/* ── 平板（≤ 1024px）── */
@media (max-width: 1024px) {
  .main {
    width: 90%;
    min-width: 0;
  }
  .hero-toggle-wrap > .toggle-bar {
    width: calc(90% - 64px);
    min-width: 0;
    max-width: 1136px;
  }

  .hero-banner {
    max-width: 100%;
  }

  /* AI派題雙欄 → 維持雙欄但縮小間距 */
  .ai-grid {
    gap: 16px;
  }

  /* 試卷詳情圖表雙欄 → 維持但允許換行 */
  .charts-row {
    gap: 12px;
  }

  /* 工具列 - 允許捲動 */
  .toolbar {
    overflow-x: auto;
    gap: 2px;
    padding: 0 8px;
  }
  .tool-btn {
    min-width: 42px;
    padding: 5px 6px;
  }
}

/* ── 手機 / 小平板（≤ 768px）── */
@media (max-width: 768px) {
  /* ─ 通用容器 ─ */
  .main,
  .hero-toggle-wrap > .toggle-bar {
    width: 100%;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .main {
    padding: 16px 12px 90px; /* 底部加空間避免內容被固定 toggle bar 遮擋 */
  }

  /* ─ Header ─ */
  .header {
    padding: 0 12px;
    gap: 8px;
  }
  .logo-img {
    height: 28px;
  }
  .btn-header-action {
    padding: 6px 10px;
    font-size: 13px;
  }
  .header-right {
    gap: 6px;
  }

  /* ─ Hero / Toggle ─ */
  .hero {
    padding: 14px 12px 0;
  }
  .hero-banner {
    max-height: 90px;
  }
  /* 手機：toggle bar 固定於螢幕底部 */
  .hero-toggle-wrap {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 99;
    background: #e8f5f4;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.10);
    padding: 10px 16px 16px;
  }
  .hero-toggle-wrap > .toggle-bar {
    width: 100%;
  }
  .toggle-btn {
    font-size: 14px;
    padding: 9px 0;
  }

  /* ─ Card ─ */
  .card {
    padding: 18px 14px;
    border-radius: 12px;
  }

  /* ─ AI Grid：雙欄 → 單欄 ─ */
  .ai-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  /* ─ 雙面板：並排 → 上下堆疊 ─ */
  .two-panel {
    grid-template-columns: 1fr;
    gap: 12px;
    min-height: auto;
  }
  .panel {
    min-height: 180px;
  }

  /* ─ 上傳區縮小 ─ */
  .upload-zone {
    min-height: 140px;
  }
  .book-image-editor-item {
    grid-template-columns: 1fr;
  }
  .book-image-editor-handle {
    justify-self: flex-start;
  }
  .book-image-editor-thumb {
    width: 100%;
    height: 180px;
  }
  .book-image-editor-actions {
    justify-content: flex-start;
  }

  /* ─ 按鈕 ─ */
  .btn-generate,
  .btn-send {
    font-size: 18px;
    padding: 14px;
  }
  .btn-dispatch-questions {
    padding: 10px 24px;
    font-size: 18px;
  }

  /* ─ 表格：水平捲動 ─ */
  .data-table th,
  .data-table td {
    padding: 10px 10px;
    font-size: 13px;
  }

  /* 全局 data-table 水平捲動（欄位隱藏由各頁自行控制）*/
  .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* ─ 搜尋列 ─ */
  .table-toolbar {
    gap: 8px;
  }
  .search-input {
    min-width: 120px;
  }

  /* ─ 詳情頁 ─ */
  .detail-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .detail-top-btns {
    width: 100%;
    justify-content: space-between;
  }

  /* ─ 圖表：並排 → 單欄 ─ */
  .charts-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .donut-wrap {
    justify-content: center;
  }

  /* ─ Class Modal RWD ─ */
  .class-modal-content { padding: 24px 16px 20px; width: 96%; border-radius: 20px; }
  .create-class-content { padding: 24px 16px 20px; width: 96%; border-radius: 20px; }
  .roster-review-panel { padding: 20px 14px; width: 98%; }
  .class-item { padding: 12px 14px; gap: 8px; }
  .class-type-tabs { gap: 8px; }
  .class-type-tab { padding: 10px 14px; font-size: 14px; }
  .class-modal-title, .create-class-title { font-size: 20px; }
  .btn-select-class { padding: 8px 16px; font-size: 13px; }

  /* ─ Modal ─ */
  .modal {
    padding: 20px 16px 18px;
    border-radius: 16px;
    width: 96%;
  }
  .modal-content {
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }
  .modal-actions {
    gap: 8px;
  }
  .modal-btn {
    font-size: 16px;
    padding: 10px 8px;
  }

  /* ─ QR Modal info ─ */
  .modal-info-box {
    font-size: 14px;
    line-height: 1.8;
  }

  /* ─ 工具列 ─ */
  .toolbar {
    height: auto;
    min-height: 56px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 8px;
    gap: 2px;
  }
  .tool-btn {
    min-width: 40px;
    padding: 4px 5px;
    font-size: 11px;
  }
  .tool-label {
    font-size: 9px;
  }
  .toolbar-submit {
    padding: 8px 14px;
    font-size: 16px;
    white-space: nowrap;
    margin-left: 6px;
  }

  /* ─ 批改右側工具列 ─ */
  .toolbar-review-right {
    gap: 5px;
  }
  .review-btn {
    padding: 7px 10px;
    font-size: 12px;
  }
  .score-input {
    width: 54px;
    padding: 7px 6px;
    font-size: 13px;
  }
  .review-student-btn {
    padding: 7px 8px;
    font-size: 13px;
  }

  /* ─ Toast ─ */
  .toast {
    bottom: 80px;
    right: 12px;
    left: 12px;
    text-align: center;
  }

  /* ─ 試卷列表：功能圖示欄縮小 ─ */
  .action-icons {
    gap: 4px;
  }
}

/* ── 手機（≤ 480px）── */
@media (max-width: 480px) {
  /* ─ Header：隱藏次要圖示按鈕 ─ */
  .header-icon-btn:not(.user-wrap .header-icon-btn) {
    display: none;
  }
  .logo-img {
    height: 24px;
  }
  .btn-header-action {
    padding: 6px 8px;
    font-size: 12px;
  }

  /* ─ Card ─ */
  .card {
    padding: 14px 12px;
    border-radius: 10px;
  }

  /* ─ 表格：更精簡 ─ */
  .data-table th,
  .data-table td {
    padding: 8px 8px;
    font-size: 12px;
  }

  /* 手機小螢幕：表格水平捲動，不隱藏欄位（由各頁自行控制）*/

  /* ─ 按鈕列全寬 ─ */
  .detail-top-btns {
    flex-direction: column;
    gap: 8px;
  }
  .btn-back,
  .answer-count-badge {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
  }

  /* ─ 圖表甜甜圈：直式排列 ─ */
  .donut-wrap {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .donut-legend {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 12px;
  }

  /* ─ 上傳區 ─ */
  .upload-zone {
    min-height: 120px;
  }
  .upload-zone-text {
    font-size: 12px;
  }

  /* ─ 選項按鈕群組 ─ */
  .check-group,
  .radio-group {
    gap: 8px;
  }
  .check-btn,
  .radio-btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* ─ 工具列（批改頁）：部分按鈕換行 ─ */
  .toolbar-review-right {
    flex-wrap: wrap;
    max-width: 220px;
  }

  /* ─ Modal ─ */
  .modal-actions {
    flex-direction: column;
  }
  .modal-btn {
    width: 100%;
  }

  /* ─ 頁碼圓點縮小 ─ */
  .page-dot {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  /* ─ 學生題目卡片 ─ */
  .student-q-card {
    padding: 18px 14px;
    border-radius: 10px;
  }
  .student-q-text {
    font-size: 14px;
    line-height: 1.8;
  }
  .student-option-btn {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* ── 桌機：字級放大 ── */
@media (min-width: 769px) {
  .field-label       { font-size: 16px; }
  .field-input       { font-size: 15px; }
  .toggle-btn        { font-size: 16px; }
  .btn-header-action { font-size: 15px; }
  .student-q-num     { font-size: 14px; }
  .student-q-text    { font-size: 17px; }
  .page-dot          { font-size: 15px; width: 38px; height: 38px; }
}


