:root {
  --page-bg: #0d1117;
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #2ea44f;
  --accent-dim: rgba(46, 164, 79, 0.15);
  --brand-color: #c9d1d9;
  --primary-text: #7ee787;
  --panel-shadow: none;
  --danger: #f85149;
  --danger-dim: rgba(248, 81, 73, 0.18);
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.theme-design-1 {
  --page-bg: #0d1117;
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #2ea44f;
  --accent-dim: rgba(46, 164, 79, 0.15);
  --brand-color: #c9d1d9;
  --primary-text: #7ee787;
  --panel-shadow: none;
  --danger: #f85149;
  --danger-dim: rgba(248, 81, 73, 0.18);
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

.theme-design-2 {
  --page-bg: linear-gradient(180deg, #eef6ff 0%, #fffaf0 100%);
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #cbd5e1;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-dim: rgba(37, 99, 235, 0.12);
  --brand-color: #1d4ed8;
  --primary-text: #1d4ed8;
  --panel-shadow: 0 10px 30px rgba(37, 99, 235, 0.08);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.12);
  --radius: 14px;
  --font: "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

.theme-design-3 {
  --page-bg: radial-gradient(circle at 12% 12%, #fef08a 0 12%, transparent 13%),
    radial-gradient(circle at 88% 8%, #67e8f9 0 10%, transparent 11%),
    linear-gradient(135deg, #fdf2f8 0%, #fef3c7 45%, #ecfeff 100%);
  --bg: #fff7ed;
  --surface: #ffffff;
  --border: #f9a8d4;
  --text: #4a1835;
  --muted: #a21caf;
  --accent: #db2777;
  --accent-dim: rgba(219, 39, 119, 0.18);
  --brand-color: #c026d3;
  --primary-text: #be185d;
  --panel-shadow: 0 16px 0 rgba(219, 39, 119, 0.15);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.14);
  --radius: 28px;
  --font: "Comic Sans MS", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", cursive, sans-serif;
}

.theme-design-4 {
  --page-bg: linear-gradient(180deg, #f0fdf4 0%, #ecfeff 100%);
  --bg: #f7fee7;
  --surface: #ffffff;
  --border: #bbf7d0;
  --text: #14342b;
  --muted: #4d7c5a;
  --accent: #16a34a;
  --accent-dim: rgba(22, 163, 74, 0.13);
  --brand-color: #15803d;
  --primary-text: #15803d;
  --panel-shadow: 0 12px 30px rgba(22, 163, 74, 0.11);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.12);
  --radius: 16px;
  --font: "Trebuchet MS", "Yu Gothic UI", "Meiryo", sans-serif;
}

.theme-design-5 {
  --page-bg: radial-gradient(circle at top, #155e75 0%, #082f49 42%, #020617 100%);
  --bg: #082f49;
  --surface: rgba(12, 74, 110, 0.88);
  --border: #38bdf8;
  --text: #e0f2fe;
  --muted: #bae6fd;
  --accent: #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.18);
  --brand-color: #cffafe;
  --primary-text: #cffafe;
  --panel-shadow: 0 16px 38px rgba(8, 47, 73, 0.35);
  --danger: #fb7185;
  --danger-dim: rgba(251, 113, 133, 0.16);
  --radius: 18px;
  --font: "Segoe UI", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
}

.theme-design-6 {
  --page-bg: linear-gradient(135deg, #3b2416 0%, #8a3f16 48%, #f59e0b 100%);
  --bg: #fff7ed;
  --surface: #fffbeb;
  --border: #b45309;
  --text: #3b2416;
  --muted: #92400e;
  --accent: #d97706;
  --accent-dim: rgba(217, 119, 6, 0.2);
  --brand-color: #92400e;
  --primary-text: #92400e;
  --panel-shadow: 0 18px 36px rgba(69, 26, 3, 0.22);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.13);
  --radius: 10px;
  --font: Georgia, "Yu Mincho", "Hiragino Mincho ProN", "Yu Gothic UI", serif;
}

.theme-design-7 {
  --page-bg: radial-gradient(circle at top, #581c87 0%, #1e1b4b 45%, #020617 100%);
  --bg: #111827;
  --surface: rgba(30, 27, 75, 0.92);
  --border: #a78bfa;
  --text: #ede9fe;
  --muted: #c4b5fd;
  --accent: #a855f7;
  --accent-dim: rgba(168, 85, 247, 0.2);
  --brand-color: #f5d0fe;
  --primary-text: #f5d0fe;
  --panel-shadow: 0 0 34px rgba(168, 85, 247, 0.22);
  --danger: #e11d48;
  --danger-dim: rgba(225, 29, 72, 0.12);
  --radius: 20px;
  --font: "Century Gothic", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
}

.theme-design-8 {
  --page-bg: #f4f4f5;
  --bg: #ffffff;
  --surface: #fafafa;
  --border: #a1a1aa;
  --text: #18181b;
  --muted: #52525b;
  --accent: #27272a;
  --accent-dim: rgba(39, 39, 42, 0.1);
  --brand-color: #18181b;
  --primary-text: #18181b;
  --panel-shadow: 0 8px 24px rgba(24, 24, 27, 0.08);
  --danger: #b91c1c;
  --danger-dim: rgba(185, 28, 28, 0.1);
  --radius: 8px;
  --font: Arial, "Helvetica Neue", "Yu Gothic UI", "Meiryo", sans-serif;
}

.theme-design-9 {
  --page-bg: #111827;
  --bg: #1f2937;
  --surface: #111827;
  --border: #facc15;
  --text: #fef3c7;
  --muted: #fde68a;
  --accent: #facc15;
  --accent-dim: rgba(250, 204, 21, 0.17);
  --brand-color: #facc15;
  --primary-text: #facc15;
  --panel-shadow: 0 0 0 3px rgba(250, 204, 21, 0.16);
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.16);
  --radius: 4px;
  --font: "Courier New", "MS Gothic", "Yu Gothic UI", monospace;
}

.theme-design-10 {
  --page-bg: linear-gradient(180deg, #fff7f2 0%, #fde7e7 52%, #f8efe7 100%);
  --bg: #fffaf7;
  --surface: rgba(255, 253, 249, 0.96);
  --border: #e8b4b8;
  --text: #4b2e2a;
  --muted: #8c5f5a;
  --accent: #c45a64;
  --accent-dim: rgba(196, 90, 100, 0.14);
  --brand-color: #8f3f46;
  --primary-text: #8f3f46;
  --panel-shadow: 0 12px 30px rgba(143, 63, 70, 0.1);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.12);
  --radius: 18px;
  --font: "Yu Mincho", "Hiragino Mincho ProN", "Yu Gothic UI", serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
}

#setupPanel[hidden],
#mainArea[hidden],
#homeworkPanel[hidden],
#testPanel[hidden],
#adminPanel[hidden],
#homeworkCard[hidden],
#homeworkCommentaryWrap[hidden],
#homeworkNext[hidden],
#homeworkComplete[hidden],
#testFormWrap[hidden],
#testUnitLine[hidden],
#testIntro[hidden],
#testProgressWrap[hidden],
#testResult[hidden],
#testTimeNotice[hidden],
#unitSelectPanel[hidden],
#btnAdmin[hidden],
#testBackConfirm[hidden] {
  display: none !important;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 48px;
}

.app--wide {
  max-width: 960px;
}

.header {
  margin-bottom: 24px;
}

.theme-design-2 .header,
.theme-design-3 .header,
.theme-design-4 .header,
.theme-design-5 .header,
.theme-design-6 .header,
.theme-design-7 .header,
.theme-design-8 .header,
.theme-design-9 .header,
.theme-design-10 .header {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--panel-shadow);
}

.brand {
  display: flex;
  align-items: center;
}

.brand-name {
  margin: 0;
  color: var(--brand-color);
}

.tagline {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  margin-bottom: 18px;
}

.theme-design-2 .panel,
.theme-design-3 .panel,
.theme-design-4 .panel,
.theme-design-5 .panel,
.theme-design-6 .panel,
.theme-design-7 .panel,
.theme-design-8 .panel,
.theme-design-9 .panel,
.theme-design-10 .panel {
  box-shadow: var(--panel-shadow);
}

.panel-title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.setup-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-block .select,
.field-block--unit .unit-select-trigger {
  width: 100%;
}

.setup-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.file-label {
  cursor: pointer;
}

.file-name {
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-all;
}

.inline-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.select {
  flex: 1;
  min-width: 200px;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.select optgroup {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.85rem;
}

.select option {
  font-weight: normal;
  color: var(--text);
  background: var(--bg);
}

/* 単元: ネイティブ select の上向きポップアップを避け、常に下に展開するカスタム一覧 */
.unit-select-combo {
  position: relative;
  width: 100%;
}

.unit-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

.unit-select-trigger {
  display: block;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.unit-select-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.unit-select-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 50;
  margin-top: 4px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.unit-select-group {
  margin-bottom: 8px;
}

.unit-select-group:last-child {
  margin-bottom: 0;
}

.unit-select-group-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 8px 4px;
}

.unit-select-option {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  text-align: left;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.unit-select-option:hover {
  background: rgba(128, 128, 128, 0.12);
}

.unit-title-display {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}

.mode-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--primary-text);
}

.btn-primary:hover {
  background: rgba(46, 164, 79, 0.28);
}

.theme-design-2 .btn-primary:hover,
.theme-design-3 .btn-primary:hover,
.theme-design-4 .btn-primary:hover,
.theme-design-5 .btn-primary:hover,
.theme-design-6 .btn-primary:hover,
.theme-design-7 .btn-primary:hover,
.theme-design-8 .btn-primary:hover,
.theme-design-9 .btn-primary:hover,
.theme-design-10 .btn-primary:hover {
  background: var(--accent-dim);
  filter: brightness(0.98);
}

.btn-secondary {
  background: var(--bg);
}

.btn-secondary:hover {
  border-color: var(--muted);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  min-height: 40px;
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-badge {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* 進捗（クイズモード・チャレンジモード共通） */
.study-progress {
  margin: 0 0 18px;
  padding: 14px 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(46, 164, 79, 0.06), transparent);
}

.test-panel .study-progress {
  background: linear-gradient(180deg, rgba(88, 166, 255, 0.08), transparent);
}

/* チャレンジモード：回答進捗をスクロール時も見えるよう画面上部に追尾 */
.test-progress-sticky-wrap {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 0 -18px 18px;
  padding: 12px 18px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.test-progress-sticky-wrap .study-progress {
  margin-bottom: 0;
}

.test-timer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.35);
}

.test-timer-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.test-timer-clock {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #79c0ff;
  letter-spacing: 0.04em;
}

.test-timer-sec {
  font-size: 0.75rem;
  color: var(--muted);
}

.test-timer-row--urgent {
  background: rgba(248, 81, 73, 0.12);
  border-color: rgba(248, 81, 73, 0.45);
  animation: timerPulse 1s ease infinite alternate;
}

.test-timer-row--urgent .test-timer-clock {
  color: #ff7b72;
}

@keyframes timerPulse {
  from {
    box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.2);
  }
  to {
    box-shadow: 0 0 12px rgba(248, 81, 73, 0.25);
  }
}

.test-time-notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.5;
  text-align: left;
  color: #ffa198;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.35);
}

.progress-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.progress-emoji {
  font-size: 1.35rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(46, 164, 79, 0.35));
}

.test-panel .progress-emoji {
  filter: drop-shadow(0 0 8px rgba(88, 166, 255, 0.4));
}

.progress-label {
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: 0.02em;
}

.progress-label strong {
  color: #7ee787;
  font-size: 1.12em;
}

.test-panel .progress-label strong {
  color: #79c0ff;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #3fb950);
  box-shadow: 0 0 12px rgba(46, 164, 79, 0.45);
  transition: width 0.45s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.progress-fill--test {
  background: linear-gradient(90deg, #58a6ff, #a371f7);
  box-shadow: 0 0 12px rgba(88, 166, 255, 0.4);
}

.progress-scores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
  background: rgba(46, 164, 79, 0.18);
  border: 1px solid rgba(46, 164, 79, 0.45);
  color: var(--text);
}

.progress-pill--test {
  background: rgba(88, 166, 255, 0.12);
  border-color: rgba(88, 166, 255, 0.35);
}

.progress-pill strong {
  color: #7ee787;
  font-size: 1.1em;
}

.progress-pill--test strong {
  color: #79c0ff;
}

.pill-icon {
  font-size: 1rem;
}

.progress-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.progress-hint strong {
  color: var(--text);
}

.question-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.q-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  background: var(--bg);
}

.q-block.done {
  border-color: rgba(46, 164, 79, 0.45);
}

.q-num {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.q-text {
  margin: 0 0 14px;
  font-size: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.q-text pre,
.test-card .question-text pre,
.test-all-questions .question-text pre,
.test-result-detail .question-text pre,
.commentary pre {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.9em;
  line-height: 1.45;
  white-space: pre;
  word-break: normal;
}

.q-text pre code,
.test-card .question-text pre code,
.test-all-questions .question-text pre code,
.test-result-detail .question-text pre code,
.commentary pre code {
  font-family: inherit;
  font-size: inherit;
}

.q-text code,
.test-card .question-text code,
.test-all-questions .question-text code,
.test-result-detail .question-text code,
.commentary code {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
}

.q-text pre code,
.test-card .question-text pre code,
.test-all-questions .question-text pre code,
.test-result-detail .question-text pre code,
.commentary pre code {
  padding: 0;
  border: none;
  background: transparent;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opt-btn {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  text-align: left;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}

.opt-btn-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.opt-btn-label {
  flex: 1;
  text-align: left;
  word-break: break-word;
}

.opt-mark {
  flex-shrink: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  animation: markPop 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

.opt-mark--ok {
  color: #3fb950;
  text-shadow: 0 0 14px rgba(63, 185, 80, 0.65);
}

.opt-mark--ng {
  color: #f85149;
  text-shadow: 0 0 12px rgba(248, 81, 73, 0.55);
}

@keyframes markPop {
  0% {
    transform: scale(0.2) rotate(-12deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.12) rotate(3deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.opt-btn:hover:not(:disabled) {
  border-color: var(--muted);
}

.opt-btn:disabled {
  cursor: default;
}

.opt-btn.flash-correct {
  animation: flashCorrect 0.55s ease forwards;
}

.opt-btn.flash-wrong {
  animation: flashWrong 0.55s ease forwards;
}

@keyframes flashCorrect {
  0% {
    border-color: var(--border);
    background: var(--surface);
  }
  35% {
    border-color: var(--accent);
    background: rgba(46, 164, 79, 0.35);
    box-shadow: 0 0 0 2px rgba(46, 164, 79, 0.35);
  }
  100% {
    border-color: var(--accent);
    background: rgba(46, 164, 79, 0.2);
  }
}

@keyframes flashWrong {
  0% {
    border-color: var(--border);
    background: var(--surface);
  }
  35% {
    border-color: var(--danger);
    background: var(--danger-dim);
    box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.35);
  }
  100% {
    border-color: rgba(248, 81, 73, 0.6);
    background: rgba(248, 81, 73, 0.12);
  }
}

.answer-feedback {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: feedbackIn 0.4s ease forwards;
}

.answer-feedback-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.answer-feedback--ok {
  background: rgba(46, 164, 79, 0.2);
  border: 2px solid rgba(46, 164, 79, 0.65);
  color: #7ee787;
  box-shadow: 0 0 20px rgba(46, 164, 79, 0.25);
}

.answer-feedback--ok .answer-feedback-mark {
  background: rgba(46, 164, 79, 0.45);
  color: #fff;
}

.answer-feedback--ng {
  background: rgba(248, 81, 73, 0.12);
  border: 2px solid rgba(248, 81, 73, 0.45);
  color: #ffa198;
  box-shadow: 0 0 16px rgba(248, 81, 73, 0.15);
}

.answer-feedback--ng .answer-feedback-mark {
  background: rgba(248, 81, 73, 0.4);
  color: #fff;
}

@keyframes feedbackIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.commentary {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  background: rgba(46, 164, 79, 0.08);
  font-size: 0.9rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.commentary-label {
  display: block;
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 4px;
  font-weight: 600;
}

.homework-next-btn {
  margin-top: 14px;
  width: 100%;
}

.admin-panel .study-progress {
  background: linear-gradient(180deg, rgba(210, 153, 34, 0.16), transparent);
}

.progress-fill--admin {
  background: linear-gradient(90deg, #d29922, #f2cc60);
  box-shadow: 0 0 12px rgba(242, 204, 96, 0.28);
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 16px;
}

.admin-nav-btn {
  min-width: 138px;
}

.admin-question-picker {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.admin-select {
  width: 100%;
}

.admin-card .question-text {
  margin: 0 0 18px;
  font-size: 1.05rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-meta,
.admin-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-meta {
  margin: 0 0 14px;
}

.admin-meta-pill,
.admin-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.86rem;
  line-height: 1.3;
}

.admin-status-pill--ok {
  color: #7ee787;
  border-color: rgba(63, 185, 80, 0.45);
  background: rgba(46, 164, 79, 0.12);
}

.admin-status-pill--ng {
  color: #ffa198;
  border-color: rgba(248, 81, 73, 0.45);
  background: rgba(248, 81, 73, 0.12);
}

.admin-options .opt-btn:disabled {
  opacity: 1;
}

.admin-options .opt-btn.admin-answer {
  border-color: #3fb950;
  background: rgba(46, 164, 79, 0.12);
  box-shadow: 0 0 0 1px rgba(63, 185, 80, 0.25);
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(1, 4, 9, 0.72);
}

.confirm-dialog {
  width: 100%;
  max-width: 420px;
  margin: 0;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.confirm-message {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

#homeworkCommentaryWrap {
  margin-top: 4px;
}

.homework-result-line {
  margin: 10px 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.homework-result-line strong {
  color: #7ee787;
  font-size: 1.12em;
}

.completion-title {
  display: block;
  font-size: 1.25rem;
  color: #7ee787;
  margin-bottom: 6px;
  text-shadow: 0 0 14px rgba(126, 231, 135, 0.35);
}

.completion-sub {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
}

.completion-banner {
  margin-top: 20px;
  padding: 20px 18px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  text-align: center;
}
.completion-banner--perfect {
  border-color: rgba(126, 231, 135, 0.55);
  background: linear-gradient(180deg, rgba(46, 164, 79, 0.28), rgba(46, 164, 79, 0.08));
  box-shadow: 0 0 28px rgba(46, 164, 79, 0.2);
  animation: completionGlow 1.6s ease infinite alternate;
}

@keyframes completionGlow {
  from {
    box-shadow: 0 0 20px rgba(46, 164, 79, 0.15);
  }
  to {
    box-shadow: 0 0 32px rgba(126, 231, 135, 0.28);
  }
}

.test-card .question-text {
  margin: 0 0 18px;
  font-size: 1.05rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.test-unit-line {
  margin: 0 0 10px;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  line-height: 1.45;
}

.test-result-unit {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.test-intro {
  margin: 0 0 12px;
  font-size: 0.95rem;
  line-height: 1.55;
}

.test-pending-hint {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.test-all-questions {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 20px;
}

.test-q-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  background: var(--bg);
}

.test-q-head {
  margin-bottom: 8px;
}

.test-q-num {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #79c0ff;
}

.test-all-questions .question-text {
  margin: 0 0 14px;
  font-size: 1.02rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.opt-btn--test.selected {
  border-color: #58a6ff;
  background: rgba(88, 166, 255, 0.12);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.25);
}

.test-submit-btn {
  width: 100%;
  min-height: 52px;
  font-size: 1.05rem;
  font-weight: 700;
}

.test-result {
  margin-top: 0;
  padding-top: 8px;
  border-top: none;
  text-align: center;
}

.test-result-summary {
  margin-bottom: 20px;
}

.score-line {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 10px;
}

.score-line strong {
  color: #79c0ff;
}

.pass-line {
  font-size: 1.05rem;
  margin: 0 0 8px;
  min-height: 2rem;
}

.pass-line--pass .pass-badge--ok {
  animation: passPop 0.55s ease;
}

.pass-badge {
  display: inline-block;
  font-weight: 800;
  font-size: 1.35rem;
  margin-right: 8px;
}

.pass-badge--ok {
  color: #7ee787;
  text-shadow: 0 0 14px rgba(126, 231, 135, 0.45);
}

.pass-badge--ng {
  color: #ffa198;
}

.pass-note {
  font-size: 0.88rem;
  color: var(--muted);
}

.test-result-detail {
  text-align: left;
  margin-bottom: 20px;
  max-height: 720px;
  overflow-y: auto;
  padding: 4px 4px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.test-review-block {
  padding: 14px 14px 16px;
  border-bottom: 1px solid var(--border);
}

.test-review-block:last-child {
  border-bottom: none;
}

.test-review-block--ok {
  border-left: 4px solid var(--accent);
}

.test-review-block--ng {
  border-left: 4px solid var(--danger);
}

.test-review-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 10px;
}

.test-review-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.test-review-mark {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
}

.test-review-block--ok .test-review-mark {
  color: #3fb950;
}

.test-review-block--ng .test-review-mark {
  color: #f85149;
}

.test-review-label {
  font-weight: 700;
  font-size: 1rem;
}

.test-review-block--ok .test-review-label {
  color: #7ee787;
}

.test-review-block--ng .test-review-label {
  color: #ffa198;
}

.test-result-detail .question-text {
  font-size: 0.98rem;
  margin-bottom: 10px;
}

.test-result-detail .commentary {
  margin-top: 8px;
}

.test-result--perfect .score-line strong {
  color: #7ee787;
}

.test-result--perfect {
  padding-top: 8px;
}

@keyframes passPop {
  0% {
    transform: scale(0.88);
  }
  60% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

.footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 0.75rem;
}

.footer code {
  font-family: var(--mono);
  font-size: 0.72rem;
}

@media (min-width: 600px) {
  .app {
    padding: 28px;
    padding-bottom: 48px;
  }

  .options.cols-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
}

@media (max-width: 599px) {
  .admin-nav-btn,
  .admin-question-picker,
  .confirm-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .confirm-actions {
    flex-direction: column;
  }

  .q-text pre,
  .admin-card .question-text pre,
  .test-card .question-text pre,
  .test-all-questions .question-text pre,
  .test-result-detail .question-text pre,
  .commentary pre {
    overflow-x: hidden;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}
