@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700;900&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── 北歐色系 ── */
  --nord0:  #2E3440;  /* 深夜藍（最深）*/
  --nord1:  #3B4252;  /* 深石板 */
  --nord2:  #434C5E;  /* 石板 */
  --nord3:  #4C566A;  /* 淺石板 */
  --nord4:  #D8DEE9;  /* 霧灰（最淺深色）*/
  --nord5:  #E5E9F0;  /* 煙白 */
  --nord6:  #ECEFF4;  /* 雪白 */
  --nord7:  #8FBCBB;  /* 北極青綠 */
  --nord8:  #88C0D0;  /* 冰川藍 */
  --nord9:  #81A1C1;  /* 霧藍 */
  --nord10: #5E81AC;  /* 深霧藍 */
  --nord11: #BF616A;  /* 北極紅 */
  --nord12: #D08770;  /* 砂岩橙 */
  --nord13: #EBCB8B;  /* 琥珀黃 */
  --nord14: #A3BE8C;  /* 苔原綠 */
  --nord15: #B48EAD;  /* 薰衣紫 */

  /* ── 語義 token ── */
  --bg:        #F0F3F8;
  --surface:   #FFFFFF;
  --surface-2: #F7F9FC;
  --border:    #DDE3EC;
  --border-2:  #C8D0DD;

  --text-primary:   var(--nord0);
  --text-secondary: var(--nord3);
  --text-muted:     #7B8794;

  --primary:        var(--nord10);
  --primary-light:  #EDF2F8;
  --primary-hover:  #4D6D97;

  --success:        #6B9E7A;
  --success-light:  #EEF6F1;
  --success-border: #B3D4BC;

  --danger:         #BF616A;
  --danger-light:   #FAF0F1;
  --danger-border:  #E8B4B8;

  --optional:       var(--nord15);
  --optional-light: #F5F0F7;
  --optional-border: #D8C5E0;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(46,52,64,.06), 0 1px 2px rgba(46,52,64,.04);
  --shadow:    0 4px 16px rgba(46,52,64,.08), 0 1px 4px rgba(46,52,64,.04);
  --shadow-lg: 0 8px 32px rgba(46,52,64,.1), 0 2px 8px rgba(46,52,64,.05);
  --shadow-xl: 0 20px 60px rgba(46,52,64,.16), 0 4px 16px rgba(46,52,64,.08);
}

body {
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Microsoft JhengHei', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ── Navbar ── */
.navbar {
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar h1 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--nord0);
  letter-spacing: -0.01em;
}

.navbar a {
  color: var(--nord9);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  transition: background .15s;
}
.navbar a:hover { background: var(--primary-light); }

/* ── 容器 ── */
.container { max-width: 820px; margin: 32px auto; padding: 0 20px; }
.container-wide { max-width: 1120px; margin: 32px auto; padding: 0 20px; }

/* ── 卡片 ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

/* ── 按鈕 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all .16s;
  text-decoration: none;
  letter-spacing: .01em;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 4px rgba(94,129,172,.3);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 3px 12px rgba(94,129,172,.35); }

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 1px 4px rgba(107,158,122,.25);
}
.btn-success:hover { filter: brightness(1.08); }

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border: 1.5px solid var(--danger-border);
}
.btn-danger:hover { background: var(--danger-light); }

.btn-outline {
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}
.btn-ghost:hover { background: var(--nord6); color: var(--text-primary); }

.btn-sm { padding: 6px 13px; font-size: .8rem; border-radius: 7px; }
.btn-lg { padding: 13px 30px; font-size: .97rem; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ── 表單 ── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  margin-bottom: 7px;
  font-size: .8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.required { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .93rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  transition: all .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--nord9);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(129,161,193,.18);
}
.form-control::placeholder { color: var(--text-muted); }

/* ── 學生 Hero ── */
.hero {
  background: var(--nord0);
  padding: 60px 20px;
  text-align: center;
  color: white;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 50%, rgba(136,192,208,.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 60%, rgba(94,129,172,.1) 0%, transparent 60%);
}
.hero-content { position: relative; }
.hero h1 {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -.04em;
  margin-bottom: 8px;
  color: var(--nord6);
}
.hero p { font-size: 1rem; color: var(--nord4); margin-bottom: 36px; }

.name-input-wrap {
  display: flex;
  gap: 10px;
  max-width: 400px;
  margin: 0 auto;
}
.name-input-wrap input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid rgba(216,222,233,.2);
  border-radius: 9px;
  font-size: .95rem;
  background: rgba(255,255,255,.08);
  color: white;
  outline: none;
  transition: all .2s;
  font-family: inherit;
}
.name-input-wrap input::placeholder { color: rgba(216,222,233,.45); }
.name-input-wrap input:focus {
  border-color: var(--nord8);
  background: rgba(255,255,255,.13);
  box-shadow: 0 0 0 3px rgba(136,192,208,.15);
}
.name-input-wrap .start-btn {
  padding: 12px 22px;
  border-radius: 9px;
  background: var(--nord8);
  color: var(--nord0);
  font-weight: 800;
  font-size: .9rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all .18s;
  white-space: nowrap;
}
.name-input-wrap .start-btn:hover { background: var(--nord7); transform: translateY(-1px); }

/* ── 題目卡片 ── */
.question-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  transition: box-shadow .2s, border-color .2s;
}
.question-card:hover { box-shadow: var(--shadow); border-color: var(--border-2); }

/* 選填題卡片 */
.question-card.optional {
  border-color: var(--optional-border);
  background: var(--surface);
}
.question-card.optional:hover { border-color: var(--optional); }

.question-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.q-badge {
  background: var(--primary);
  color: white;
  font-size: .75rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.optional-badge {
  background: var(--optional-light);
  color: var(--optional);
  border: 1px solid var(--optional-border);
  font-size: .73rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.question-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.5;
}

.zoomable { cursor: zoom-in; }

.question-image {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 9px;
  margin-bottom: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* ── 選項 ── */
.options { display: flex; flex-direction: column; gap: 9px; }

.option-label {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  transition: all .16s;
  font-size: .92rem;
  color: var(--text-secondary);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.option-label:hover {
  border-color: var(--nord9);
  background: var(--primary-light);
  color: var(--primary);
  transform: translateX(3px);
}
.option-label input[type="radio"] { display: none; }

.option-label.selected {
  border-color: var(--nord10);
  background: var(--primary-light);
  color: var(--nord0);
  font-weight: 700;
  transform: translateX(3px);
}
.option-label.correct {
  border-color: var(--success);
  background: var(--success-light);
  color: var(--success);
  font-weight: 700;
}
.option-label.wrong {
  border-color: var(--danger);
  background: var(--danger-light);
  color: var(--danger);
  font-weight: 700;
}

.opt-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--nord5);
  border: 1.5px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .82rem;
  flex-shrink: 0;
  transition: all .16s;
  color: var(--text-secondary);
}
.option-label.selected .opt-circle { background: var(--primary); border-color: var(--primary); color: white; }
.option-label.correct .opt-circle { background: var(--success); border-color: var(--success); color: white; }
.option-label.wrong .opt-circle { background: var(--danger); border-color: var(--danger); color: white; }

/* ── 填充題輸入 ── */
.fill-input-wrap { margin-top: 4px; }
.fill-input {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  outline: none;
  transition: all .15s;
}
.fill-input:focus {
  border-color: var(--nord9);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(129,161,193,.18);
}
.fill-input::placeholder { color: var(--text-muted); }

/* ── 進度 ── */
.quiz-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  padding: 13px 18px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.quiz-progress-bar { flex: 1; height: 5px; background: var(--nord5); border-radius: 3px; overflow: hidden; }
.quiz-progress-fill {
  height: 100%;
  background: var(--nord8);
  border-radius: 3px;
  transition: width .4s cubic-bezier(.4,0,.2,1);
}
.quiz-progress-text { font-size: .83rem; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }

/* ── 提交區 ── */
.submit-bar {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
  text-align: center;
  margin-bottom: 36px;
  box-shadow: var(--shadow-sm);
}
.submit-bar p { color: var(--text-muted); font-size: .83rem; margin-top: 9px; }

/* ── 成績頁 ── */
.result-hero {
  background: var(--nord1);
  border-radius: var(--radius-lg);
  padding: 40px 28px;
  text-align: center;
  color: var(--nord6);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.result-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% -10%, rgba(136,192,208,.12) 0%, transparent 55%);
}
.result-hero.fail { background: var(--nord2); }
.result-hero-content { position: relative; }

.score-ring { width: 140px; height: 140px; margin: 0 auto 18px; position: relative; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .score-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-num { font-size: 2.4rem; font-weight: 900; line-height: 1; color: var(--nord6); }
.score-unit { font-size: .82rem; color: var(--nord4); }

.result-name { font-size: 1.4rem; font-weight: 900; margin-bottom: 5px; }
.result-summary { color: var(--nord4); font-size: .9rem; }

.result-item {
  display: flex; gap: 13px;
  padding: 15px 17px; border-radius: var(--radius-sm); margin-bottom: 9px;
  align-items: flex-start;
}
.result-item.correct { background: var(--success-light); border: 1.5px solid var(--success-border); }
.result-item.wrong { background: var(--danger-light); border: 1.5px solid var(--danger-border); }
.result-item.optional-result { opacity: .85; }
.result-icon { font-size: 1.2rem; margin-top: 1px; flex-shrink: 0; }
.result-item h4 { font-size: .92rem; font-weight: 700; margin-bottom: 3px; }
.result-item p { font-size: .84rem; color: var(--text-secondary); }

/* ── 後台 ── */
.admin-sidebar {
  width: 230px;
  background: var(--nord0);
  min-height: calc(100vh - 60px);
  padding: 16px 0;
  flex-shrink: 0;
}
.sidebar-section {
  padding: 10px 18px 4px;
  font-size: .7rem; font-weight: 800;
  color: var(--nord3);
  text-transform: uppercase; letter-spacing: .09em;
}
.admin-sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; margin: 2px 8px;
  color: var(--nord4); text-decoration: none;
  font-size: .88rem; font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all .15s;
}
.admin-sidebar a:hover { background: rgba(216,222,233,.08); color: var(--nord6); }
.admin-sidebar a.active {
  background: rgba(136,192,208,.12);
  color: var(--nord8);
  border: 1px solid rgba(136,192,208,.15);
}
.sidebar-icon { font-size: .95rem; width: 20px; text-align: center; }

.admin-layout { display: flex; min-height: calc(100vh - 60px); }
.admin-content { flex: 1; padding: 28px; overflow: auto; background: var(--bg); }

/* ── 頁面標題 ── */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.page-header h2 { font-size: 1.3rem; font-weight: 900; color: var(--text-primary); letter-spacing: -.02em; }

/* ── 表格 ── */
.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: var(--surface-2);
  padding: 12px 16px; text-align: left;
  font-weight: 800; color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; white-space: nowrap;
}
tbody td {
  padding: 12px 16px; border-bottom: 1px solid var(--nord5);
  vertical-align: middle; color: var(--text-secondary);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ── 登入頁 ── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--nord0);
  padding: 20px;
}
.login-card {
  background: rgba(59,66,82,.6);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(216,222,233,.1);
  border-radius: 20px;
  padding: 44px 38px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-xl);
  text-align: center;
}
.login-logo {
  width: 66px; height: 66px;
  background: var(--nord10);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 22px;
  box-shadow: 0 6px 24px rgba(94,129,172,.35);
}
.login-card h2 { font-size: 1.5rem; font-weight: 900; color: var(--nord6); margin-bottom: 5px; letter-spacing: -.03em; }
.login-card p { color: var(--nord4); font-size: .87rem; margin-bottom: 28px; }

.login-field { margin-bottom: 12px; text-align: left; }
.login-field input {
  width: 100%; padding: 12px 15px;
  background: rgba(46,52,64,.5);
  border: 1.5px solid rgba(216,222,233,.12);
  border-radius: 9px;
  color: var(--nord6); font-size: .93rem; font-family: inherit; outline: none;
  transition: all .2s;
}
.login-field input:focus {
  border-color: var(--nord8);
  background: rgba(46,52,64,.7);
  box-shadow: 0 0 0 3px rgba(136,192,208,.12);
}
.login-field input::placeholder { color: rgba(216,222,233,.3); }
.login-submit {
  width: 100%; padding: 13px;
  background: var(--nord10); color: white;
  border: none; border-radius: 9px;
  font-size: .95rem; font-weight: 800; cursor: pointer; margin-top: 6px;
  box-shadow: 0 3px 16px rgba(94,129,172,.35);
  transition: all .18s; font-family: inherit;
}
.login-submit:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 5px 22px rgba(94,129,172,.4); }
.login-back { margin-top: 18px; }
.login-back a { color: rgba(216,222,233,.35); font-size: .83rem; text-decoration: none; }
.login-back a:hover { color: rgba(216,222,233,.65); }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(46,52,64,.55);
  backdrop-filter: blur(3px);
  z-index: 300; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 18px; padding: 0;
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn .2s cubic-bezier(.34,1.4,.64,1);
}
@keyframes modalIn {
  from { opacity:0; transform: scale(.93) translateY(10px); }
  to   { opacity:1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 26px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
  border-radius: 18px 18px 0 0;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 900; color: var(--text-primary); }
.modal-body { padding: 22px 26px 26px; }
.modal-close {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--nord5); border: none; cursor: pointer;
  font-size: 1rem; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .15s;
}
.modal-close:hover { background: var(--border); color: var(--text-primary); }

/* ── 圖片上傳 ── */
.upload-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-sm);
  padding: 26px; text-align: center;
  cursor: pointer; transition: all .2s;
  background: var(--surface-2); position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--nord9); background: var(--primary-light);
}
.upload-zone.has-image { border-style: solid; border-color: var(--success); background: var(--success-light); padding: 12px; }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-icon { font-size: 1.8rem; margin-bottom: 6px; }
.upload-text { font-size: .88rem; color: var(--text-secondary); font-weight: 600; }
.upload-hint { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }
.upload-preview { max-width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; display: none; }

/* ── 選項格 ── */
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option-field { display: flex; align-items: center; gap: 8px; }
.opt-letter {
  width: 32px; height: 32px; border-radius: 7px;
  background: var(--primary); color: white;
  font-weight: 900; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── 正確答案選擇 ── */
.answer-choices { display: flex; gap: 8px; }

.answer-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: 9px;
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--text-muted);
  background: var(--surface-2);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.answer-btn:hover {
  border-color: var(--success);
  background: var(--success-light);
  color: var(--success);
}
.answer-btn.selected {
  border-color: var(--success);
  background: var(--success-light);
  color: var(--success);
  box-shadow: 0 0 0 3px rgba(107,158,122,.18);
}

/* ── 題型切換按鈕 ── */
.type-btn {
  flex: 1; padding: 9px 14px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--surface-2);
  font-size: .88rem; font-weight: 700; color: var(--text-muted);
  cursor: pointer; text-align: center; transition: all .15s;
}
.type-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.type-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* ── 切換輸入模式按鈕 ── */
.toggle-input-btn {
  margin-left: auto; font-size: .73rem; font-weight: 700;
  color: var(--primary); background: var(--primary-light);
  border: 1px solid #BFD0E8; border-radius: 6px;
  padding: 2px 9px; cursor: pointer; transition: all .14s;
  text-transform: none; letter-spacing: 0;
}
.toggle-input-btn:hover { background: #dbeafe; }

/* ── 選填開關 ── */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  background: var(--optional-light);
  border: 1.5px solid var(--optional-border);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}
.toggle-row-label { font-size: .88rem; font-weight: 700; color: var(--optional); }
.toggle-row-sub { font-size: .78rem; color: var(--text-muted); margin-top: 1px; }

.toggle {
  position: relative; width: 44px; height: 24px;
  background: var(--border-2); border-radius: 12px;
  cursor: pointer; transition: background .2s; flex-shrink: 0;
}
.toggle.on { background: var(--optional); }
.toggle::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: white; border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform .2s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.toggle.on::after { transform: translateX(20px); }

/* ── 提示訊息 ── */
.alert {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px; border-radius: 9px; margin-bottom: 15px;
  font-size: .86rem; font-weight: 600;
}
.alert-success { background: var(--success-light); border: 1.5px solid var(--success-border); color: var(--success); }
.alert-error { background: var(--danger-light); border: 1.5px solid var(--danger-border); color: var(--danger); }

.paste-hint {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 13px; background: #FEF9EC;
  border: 1.5px solid #F0DCB0; border-radius: 8px;
  font-size: .8rem; color: #7A5C2A; font-weight: 600; margin-bottom: 10px;
}
kbd {
  background: white; padding: 1px 6px;
  border-radius: 4px; border: 1px solid #D4AC6E;
  font-family: monospace; font-size: .8rem;
}

/* ── 徽章 ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 20px;
  font-size: .75rem; font-weight: 700; letter-spacing: .02em;
}
.badge-success { background: var(--success-light); color: var(--success); border: 1px solid var(--success-border); }
.badge-danger  { background: var(--danger-light);  color: var(--danger);  border: 1px solid var(--danger-border); }
.badge-blue    { background: var(--primary-light);  color: var(--primary); border: 1px solid #BFD0E8; }
.badge-optional{ background: var(--optional-light); color: var(--optional); border: 1px solid var(--optional-border); }
.badge-answer {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--success); color: white;
  font-size: .95rem; font-weight: 900;
  display: inline-flex; align-items: center; justify-content: center;
}
.badge-answer-optional {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--optional); color: white;
  font-size: .95rem; font-weight: 900;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ── 空狀態 ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: .95rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 5px; }
.empty-state p { font-size: .84rem; }

/* ── 統計卡片 ── */
.stat-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: .73rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 900; color: var(--text-primary); letter-spacing: -.04em; }
.stat-card .stat-sub { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* ── 進度條 ── */
.progress-wrap { display: flex; align-items: center; gap: 9px; }
.progress-bar { height: 5px; background: var(--nord5); border-radius: 3px; overflow: hidden; flex: 1; max-width: 90px; }
.progress-fill { height: 100%; background: var(--nord8); border-radius: 3px; }

/* ── 作答導覽 ── */
.quiz-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px; gap: 12px;
  padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.quiz-nav .btn { min-width: 100px; }

.auto-next-label {
  display: flex; align-items: center; gap: 8px;
  font-size: .83rem; color: var(--text-secondary); font-weight: 600;
  cursor: pointer; user-select: none;
}
.auto-next-label input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; border: 2px solid var(--border-2);
  border-radius: 5px; background: var(--surface-2); cursor: pointer;
  position: relative; transition: all .15s; flex-shrink: 0;
}
.auto-next-label input[type="checkbox"]:checked {
  background: var(--nord8); border-color: var(--nord8);
}
.auto-next-label input[type="checkbox"]:checked::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 900; color: white;
}

.quiz-submit-area {
  text-align: center; margin-top: 18px;
}
.quiz-submit-area p {
  font-size: .78rem; color: var(--text-muted); margin-top: 8px;
}

/* ── 題目總覽面板 ── */
.overview-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(46,52,64,.55); backdrop-filter: blur(3px);
  z-index: 300;
}
.overview-panel {
  display: none; position: fixed; top: 0; right: 0; bottom: 0;
  width: min(340px, 85vw);
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 301; box-shadow: var(--shadow-xl);
  overflow-y: auto; padding: 22px;
  animation: slideInRight .2s ease-out;
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.overview-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.overview-header h3 {
  margin: 0; font-size: 1rem; font-weight: 800; color: var(--text-primary);
}
.overview-close {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--nord5); border: none; cursor: pointer;
  font-size: .95rem; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .15s;
}
.overview-close:hover { background: var(--border); color: var(--text-primary); }

.overview-progress {
  font-size: .82rem; color: var(--text-muted); font-weight: 600;
  margin-bottom: 14px; padding: 8px 12px;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.overview-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
}
.overview-btn {
  aspect-ratio: 1; border-radius: 8px;
  font-weight: 700; font-size: .82rem;
  cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent;
  transition: all .15s; background: var(--surface-2);
  color: var(--text-muted);
}
.overview-btn:hover { border-color: var(--nord8); transform: scale(1.06); }
.overview-btn.answered { background: var(--success-light); color: var(--success); border-color: var(--success-border); }
.overview-btn.current  { background: var(--primary-light); color: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 2px rgba(94,129,172,.2); }
.overview-btn .opt-tag {
  position: absolute; top: 1px; right: 3px;
  font-size: .5rem; font-weight: 700; color: var(--optional);
}

.overview-submit {
  margin-top: 20px;
}

.navbar-overview-btn {
  background: var(--surface-2); border: 1.5px solid var(--border);
  color: var(--text-secondary); font-size: .82rem; font-weight: 700;
  padding: 6px 14px; border-radius: 8px; cursor: pointer;
  transition: all .15s; display: flex; align-items: center; gap: 5px;
}
.navbar-overview-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ── 響應式 ── */
@media (max-width: 768px) {
  .admin-sidebar { display: none; }
  .options-grid { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.65rem; }
  .name-input-wrap { flex-direction: column; }
  .admin-content { padding: 18px 14px; }
}

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