:root {
  --bg: #faf9f7;
  --panel: #ffffff;
  --border: #ddd6cc;
  --text: #2b2620;
  --muted: #756f63;
  --accent: #6b5b3f;
  --ok: #3a6b4c;
  --warn: #9c6b1f;
  --err: #a13a3a;
  font-family: -apple-system, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }

#app { max-width: 720px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem 1.4rem; margin-bottom: 1rem; }

h1 { font-size: 1.2rem; }
h2 { font-size: 1.05rem; margin-top: 0; }

.muted { color: var(--muted); font-size: .9rem; }

textarea, input[type=text] {
  width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid var(--border);
  border-radius: 8px; background: #fffdf9; resize: vertical; margin-bottom: .6rem;
}
textarea { min-height: 5rem; }

button {
  font: inherit; padding: .55rem 1.1rem; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); }
button.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* RECALL_EVALUATION's "追問" vs "下一步/查看訂正" — kept visually separate
   (border + spacing) so the two buttons don't sit close enough to mis-tap
   into the wrong one on mobile (real student feedback, 2026-08-23). */
.ask-block { border: 1px solid var(--border); border-radius: 8px; padding: .8rem .9rem; margin: .8rem 0; background: var(--bg); }
.continue-block { margin-top: 1rem; }

/* "查看之前的內容" history panel (2026-08-23). */
.history-item { padding: .7rem 0; border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: none; }

.progress-list { list-style: none; padding: 0; margin: .6rem 0; font-size: .9rem; }
.progress-list li { padding: .15rem 0; color: var(--muted); }
.progress-list li.done::before { content: "✓ "; color: var(--ok); }
.progress-list li.current { color: var(--text); font-weight: 600; }
.progress-list li.current::before { content: "→ "; }

.feedback-block { margin: .5rem 0; }
.feedback-block .label { font-weight: 600; font-size: .85rem; margin-bottom: .2rem; }
.feedback-block.correct .label { color: var(--ok); }
.feedback-block.imprecise .label { color: var(--warn); }
.feedback-block.error .label { color: var(--err); }
.feedback-block ul { margin: .2rem 0; padding-left: 1.2rem; }

.question-text { white-space: pre-wrap; font-size: 1.02rem; line-height: 1.7; }
.teaching-text { white-space: pre-wrap; line-height: 1.8; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; border: 1px solid var(--border); color: var(--muted); }

.hint-log { border-left: 3px solid var(--warn); padding-left: .7rem; margin: .6rem 0; font-size: .9rem; }

#error-banner { display: none; background: #fbeaea; border: 1px solid var(--err); color: var(--err); padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }

.login-box { max-width: 360px; margin: 4rem auto; }

table.chapter-list { width: 100%; border-collapse: collapse; }
table.chapter-list td { padding: .5rem .3rem; border-bottom: 1px solid var(--border); }
table.chapter-list tr { cursor: pointer; }
table.chapter-list tr:hover { background: #f3efe6; }

/* photo answer widget — deliberately plain, no camera effects/badges */
.mode-tabs { display: flex; gap: .4rem; margin-bottom: .7rem; }
.mode-tabs button { flex: 1; background: transparent; color: var(--muted); border-color: var(--border); }
.mode-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.photo-input-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.photo-input-row label.upload-btn {
  font: inherit; padding: .55rem 1.1rem; border-radius: 8px; border: 1px dashed var(--border);
  background: #fffdf9; color: var(--text); cursor: pointer; display: inline-block;
}
.photo-input-row input[type=file] { display: none; }

.photo-pages { display: flex; gap: .6rem; flex-wrap: wrap; margin: .6rem 0; }
.photo-page { position: relative; width: 96px; }
.photo-page img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.photo-page .page-num { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: .7rem; padding: 0 .35rem; border-radius: 999px; }
.photo-page .remove-btn {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 999px;
  background: var(--err); color: #fff; border: none; font-size: .8rem; line-height: 1; padding: 0; cursor: pointer;
}

.uncertain-block { border-left: 3px solid var(--warn); padding-left: .7rem; margin: .6rem 0; font-size: .9rem; }
.transcription-block { background: #f6f4ee; border-radius: 8px; padding: .6rem .8rem; margin: .5rem 0; font-size: .9rem; white-space: pre-wrap; }

.system-diagram { width: 100%; margin: .8rem 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.math-diagram-svg { display: block; width: 100%; height: auto; max-height: 62vh; color: var(--text); }
.diagram-grid { stroke: #e8e4dc; stroke-width: 1; }
.diagram-axis { stroke: #4a4640; stroke-width: 1.8; }
.diagram-line, .diagram-polygon { stroke: #4a4640; stroke-width: 2; fill: none; }
.diagram-function { stroke: #315f86; stroke-width: 2.5; fill: none; }
.diagram-highlight { stroke: #8a5b18; stroke-width: 4; }
.diagram-projection, .diagram-asymptote { stroke: #777; stroke-width: 1.5; stroke-dasharray: 6 5; }
.diagram-region { stroke: #6b5b3f; stroke-width: 1.5; fill: #eee8dc; }
.diagram-point, .diagram-endpoint, .diagram-feature { stroke: #2b2620; stroke-width: 2; color: #2b2620; }
.diagram-mark { stroke: #8a4e20; stroke-width: 2.2; fill: none; }
.diagram-tick { stroke: #4a4640; stroke-width: 1.4; }
.diagram-label, .diagram-axis-label, .diagram-function-label, .diagram-note { fill: #2b2620; font: 14px -apple-system, "Noto Sans TC", sans-serif; }
.diagram-note { fill: var(--muted); font-size: 12px; }
.diagram-arrow { fill: #4a4640; }
.diagram-caption { padding: 0 .7rem .4rem; margin: 0; text-align: right; }
@media (max-width: 420px) {
  #app { padding-left: .65rem; padding-right: .65rem; }
  .card { padding: 1rem .85rem; }
  .diagram-label, .diagram-axis-label, .diagram-function-label { font-size: 15px; }
}
