:root {
  color-scheme: light;
  --background: #f8f7e9;
  --ink: #255e62;
  --teal: #287b7d;
  --muted: #607879;
  --line: #dce1d6;
  --white: #fff;
  --mint: #dcefe5;
  --green: #3f7331;
  --green-light: #f0f5e7;
  --amber: #785617;
  --amber-light: #faf0d9;
  --blue: #2a6897;
  --blue-light: #e6f1f9;
  --red: #a84c3e;
  --red-light: #fbede7;
  --radius: 16px;
  font-family: "PingFang HK", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; cursor: pointer; color: inherit; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .52; }
button, a, summary, [tabindex] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--teal); outline-offset: 4px; }
button:not(:disabled):hover { filter: brightness(.97); }
button:not(:disabled):active { transform: translateY(1px); }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
svg.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.svg-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.page { width: min(1600px, 100%); min-height: 100dvh; margin: auto; padding: 0 28px; display: flex; flex-direction: column; }
.page-header { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.quiet-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: transparent; padding: 8px 14px; font-size: 14px; font-weight: 600; }
.page-header .quiet-button { border-color: var(--line); background: #fdfcf6; }
.quiet-button .icon { width: 18px; height: 18px; }
.help-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: #fdfcf6; font: 700 24px Georgia, serif; }
.workspace { display: grid; grid-template-columns: minmax(360px, .92fr) minmax(0, 1.5fr); align-items: stretch; gap: 24px; padding-bottom: 24px; flex: 1; min-height: 0; }
.training { display: flex; flex-direction: column; gap: 20px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: #fdfcf6; min-width: 0; min-height: 0; }
.picture-column { min-width: 0; min-height: 0; flex: 1; display: flex; flex-direction: column; }
h1 { font-size: clamp(32px, 3.5vw, 48px); font-weight: 700; letter-spacing: .025em; line-height: 1.4; }
.training-counter { padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 24px; background: var(--ink); color: var(--white); border-radius: 10px; font-size: 15px; font-weight: 600; }
.training-counter > span { white-space: nowrap; }
.training-counter strong { font-size: 23px; font-variant-numeric: tabular-nums; margin-left: 4px; }
.completed-counter { font-size: 13px; font-weight: 500; color: #e0eee5; padding-left: 20px; border-left: 1px solid #ffffff38; }
.completed-counter strong { font-size: 19px; color: var(--white); }
.image-stage { position: relative; display: flex; align-items: center; justify-content: center; height: 360px; min-height: 140px; flex: 1; margin: 0 0 12px; }
.image-stage img { display: block; width: 100%; height: 100%; object-fit: contain; }
.image-status { position: absolute; font-size: 15px; text-align: center; padding: 16px; background: #fdfcf6; }
.retry-image { position: absolute; bottom: 12px; background: var(--white); }
.word-box { min-height: 64px; padding: 10px 12px; background: var(--white); border: 1px solid #e8ece3; border-top: 5px solid #ecefe6; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: clamp(23px, 2vw, 30px); line-height: 1.5; font-weight: 700; overflow-wrap: anywhere; text-align: center; flex-shrink: 0; }
.answer-column { display: flex; flex-direction: column; gap: 14px; min-width: 0; flex-shrink: 0; }
.answer-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#answer-count { color: var(--muted); font-size: 11px; white-space: nowrap; }
.eyebrow { font-size: 12px; letter-spacing: .08em; font-weight: 600; color: var(--muted); }
.current-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 13px; }
.queue-badge { padding: 3px 10px; border-radius: 6px; background: #e1e9df; font-size: 12px; font-weight: 700; }
.queue-badge[data-queue="fast"] { color: var(--blue); background: var(--blue-light); }
#current-wrong { color: var(--red); font-size: 12px; }
.answer-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.answer-button { min-height: 132px; width: 100%; min-width: 0; padding: 14px 10px; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 26px 36px 14px; align-content: center; align-items: center; justify-items: center; gap: 4px; text-align: center; border: 1px solid; border-radius: 12px; transition: background-color .15s, opacity .15s; }
.answer-button.correct { background: var(--green-light); border-color: #b9cfa9; color: var(--green); }
.answer-button.tips { background: var(--amber-light); border-color: #ddcd9d; color: var(--amber); }
.answer-button.wrong { background: var(--blue-light); border-color: #b5d0df; color: var(--blue); }
.answer-label { font-size: 18px; font-weight: 700; line-height: 1.4; white-space: nowrap; grid-row: 1; grid-column: 1; }
.answer-note { font-size: 10px; line-height: 14px; grid-row: 3; grid-column: 1; }
.score-change { font-size: 27px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; grid-row: 2; grid-column: 1; }
.score-change span { font-size: 11px; font-weight: 500; margin-left: 3px; }
.queue-section { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; }
.selection-bar { background: #eeefe2; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; flex-shrink: 0; }
.cycle { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.cycle span { padding: 6px 10px; border-radius: 6px; font-size: 12px; color: var(--muted); font-weight: 600; border: 1px solid transparent; }
.cycle span.active { background: var(--ink); color: var(--white); }
.cycle i { font-size: 12px; font-style: normal; color: var(--muted); }
.selection-bar p { width: 100%; font-size: 12px; line-height: 1.6; border-top: 1px solid #d8dece; padding-top: 10px; }
.last-change { min-height: 44px; display: flex; align-items: center; gap: 10px; font-size: 12px; line-height: 1.7; padding: 10px 14px; border: 1px solid #ddd9bd; background: #fbf5e3; border-radius: 10px; flex-shrink: 0; }
.change-dot { width: 6px; height: 6px; background: var(--teal); border-radius: 50%; flex-shrink: 0; }
.last-change.flash .change-dot { animation: change-pulse .4s ease-out; }
@keyframes change-pulse { 50% { box-shadow: 0 0 0 5px var(--mint); } }
.queues { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; flex: 1; min-height: 0; }
.queue-panel { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fdfcf6; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.queue-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.main-panel .queue-panel-header { background: #edf1e7; }
.fast-panel .queue-panel-header { background: #eaf1f1; }
.queue-panel h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.queue-name { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.queue-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.fast-panel .queue-dot { background: var(--blue); }
.queue-count { min-width: 30px; padding: 2px 8px; text-align: center; background: var(--white); border-radius: 6px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.queue-column-labels, .queue-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 42px; align-items: center; column-gap: 8px; padding: 0 12px; }
.fast-columns, .queue-row.fast-row { grid-template-columns: 28px minmax(0, 1fr) 42px 38px; }
.queue-column-labels { font-size: 10px; color: var(--muted); height: 32px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.queue-column-labels span:nth-child(n+3) { text-align: right; }
.queue-scroll { height: 480px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #bdc9bc transparent; flex: 1; }
.queue-list { list-style: none; padding: 0; margin: 0; }
.queue-row { min-height: 46px; padding-top: 9px; padding-bottom: 9px; border-bottom: 1px solid #e9ece2; font-size: 12px; line-height: 1.6; }
.queue-row.is-current { background: var(--mint); box-shadow: inset 3px 0 var(--teal); }
.queue-row.is-changed:not(.is-current) { background: #fff4d5; box-shadow: inset 3px 0 #c89435; }
.row-position { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }
.row-label { min-width: 0; overflow-wrap: anywhere; }
.current-label { display: inline-block; font-size: 9px; font-weight: 700; background: var(--ink); color: var(--white); padding: 0 4px; margin-right: 6px; border-radius: 3px; vertical-align: 1px; }
.row-score { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.row-wrong { justify-self: end; font-size: 11px; font-variant-numeric: tabular-nums; }
.row-wrong.has-errors { color: var(--red); background: var(--red-light); padding: 1px 6px; border-radius: 4px; font-weight: 700; }
.empty-queue { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; text-align: center; font-size: 13px; line-height: 2; color: var(--muted); }
.empty-queue small { font-size: 11px; }
.completed-panel { border: 1px solid var(--line); border-radius: 10px; background: #fdfcf6; flex-shrink: 0; }
.completed-panel summary { list-style: none; min-height: 54px; padding: 14px 20px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 600; }
.completed-panel summary::-webkit-details-marker { display: none; }
.completed-tick { margin-right: 8px; color: var(--green); }
#completed-list-count { display: inline-block; margin-left: 8px; min-width: 24px; text-align: center; font-variant-numeric: tabular-nums; }
.details-hint { font-weight: 400; font-size: 11px; color: var(--muted); }
.details-hint::after { content: " ＋"; }
details[open] .details-hint::after { content: " −"; }
.completed-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 120px; overflow-y: auto; padding: 0 20px; }
.completed-list:not(:empty) { padding-bottom: 20px; }
.completed-word { display: inline-block; background: var(--green-light); border: 1px solid #d0ddc4; border-radius: 6px; padding: 6px 10px; font-size: 12px; color: var(--green); overflow-wrap: anywhere; }
.completed-empty { padding: 0 20px 20px; font-size: 12px; color: var(--muted); }
.primary-button { min-height: 46px; border: 1px solid var(--teal); border-radius: 10px; background: var(--teal); color: var(--white); padding: 10px 24px; font-size: 14px; font-weight: 600; }
.completion { min-width: 0; min-height: 490px; padding: 40px 16px; text-align: center; border: 1px solid var(--line); background: #fdfcf6; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.completion-check { width: 80px; height: 80px; border-radius: 50%; background: var(--mint); margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; }
.completion-check .icon { width: 46px; height: 46px; stroke-width: 2.5; }
.completion h1 { margin: 8px 0; }
.completion > p { color: var(--muted); font-size: 16px; }
.completion-stats { display: flex; justify-content: center; gap: 48px; margin: 24px 0; font-size: 12px; color: var(--muted); }
.completion-stats > span { display: flex; flex-direction: column; gap: 4px; }
.completion-stats strong { font-size: 32px; color: var(--ink); font-variant-numeric: tabular-nums; }
dialog { color: var(--ink); background: var(--background); border: 1px solid var(--line); border-radius: 20px; padding: 0; box-shadow: 0 16px 64px #183c3d30; }
dialog::backdrop { background: #183c3d70; }
.help-dialog { width: min(600px, calc(100% - 32px)); max-height: calc(100dvh - 48px); background: var(--white); }
.help-dialog[open] { display: flex; flex-direction: column; }
.dialog-header { display: flex; gap: 16px; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.dialog-header h2 { font-size: 22px; }
.close-button { width: 44px; height: 44px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 28px; }
.dialog-content { overflow-y: auto; padding: 18px 24px; font-size: 13px; line-height: 1.7; }
.dialog-content h3 { font-size: 15px; margin: 18px 0 8px; }
.dialog-content h3:first-child { margin-top: 0; }
.dialog-content table { border-collapse: collapse; width: 100%; font-size: 13px; text-align: left; }
.dialog-content th, .dialog-content td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.dialog-content tbody th { width: 40%; font-weight: 500; }
.help-note { margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.help-note strong { color: var(--ink); }
.help-cycle { background: #f3f6f0; border-radius: 8px; padding: 10px 14px; letter-spacing: .025em; }
.help-routing { margin: 0; }
.help-routing > div { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.help-routing dt { font-weight: 700; }
.help-routing dd { margin: 0; }
.restart-dialog { width: min(440px, calc(100% - 32px)); padding: 28px; }
.restart-dialog h2 { font-size: 24px; }
.restart-dialog p { font-size: 14px; line-height: 1.9; margin: 12px 0 24px; color: var(--muted); }
.restart-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px; }
.noscript { padding: 24px; color: var(--red); }
@media (min-width: 1100px) {
  .image-stage img { width: 86%; height: 86%; }
}
@media (min-width: 1100px) and (max-width: 1240px) {
  .answer-button { padding: 14px 8px; }
  .score-change { font-size: 24px; }
  .answer-label { font-size: 16px; }
}
@media (min-width: 1100px) and (min-height: 660px) {
  .page { height: 100dvh; }
  .workspace { grid-template-rows: minmax(0, 1fr); }
  .image-stage { height: auto; }
  .queue-scroll { height: auto; }
}
@media (max-width: 1099px) {
  .page { padding: 0 24px; }
  .workspace { grid-template-columns: 1fr; gap: 20px; }
  .training { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 24px; }
  .image-stage { flex: none; height: 260px; }
  .answer-buttons { grid-template-columns: 1fr; }
  .answer-button { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; min-height: 78px; padding: 12px 16px; gap: 4px 16px; justify-items: start; text-align: left; }
  .answer-label { grid-column: 1; grid-row: 1 / 3; font-size: 20px; }
  .tips .answer-label { grid-row: 1; }
  .answer-note { grid-column: 1; grid-row: 2; font-size: 11px; }
  .score-change { grid-column: 2; grid-row: 1 / 3; font-size: 26px; }
  .queue-scroll { height: 300px; flex: none; }
  .completion { min-height: 400px; }
}
@media (max-width: 620px) {
  .page { padding: 0 16px; }
  .page-header { min-height: 76px; gap: 8px; }
  .header-actions { gap: 6px; }
  .page-header .quiet-button { padding: 8px; width: 40px; min-height: 40px; }
  .page-header .quiet-button span { display: none; }
  .help-button { width: 40px; height: 40px; }
  .training-counter { font-size: 12px; padding: 8px 10px; gap: 12px; }
  .training-counter strong { font-size: 19px; margin-left: 2px; }
  .completed-counter { font-size: 11px; padding-left: 12px; }
  .completed-counter strong { font-size: 17px; }
  .counter-unit { display: none; }
  .training { display: flex; padding: 16px; gap: 16px; }
  .picture-column, .answer-column { width: 100%; }
  h1 { font-size: 34px; }
  .image-stage { height: 260px; }
  .word-box { min-height: 58px; font-size: 24px; }
  .answer-meta { gap: 8px; }
  .current-meta { gap: 8px; font-size: 12px; }
  #current-wrong { font-size: 10px; }
  #answer-count { font-size: 10px; }
  .answer-buttons { gap: 8px; }
  .answer-button { min-height: 72px; padding: 10px 14px; column-gap: 12px; }
  .answer-label { font-size: 20px; }
  .score-change { font-size: 25px; }
  .selection-bar { padding: 12px; gap: 12px; }
  .cycle { gap: 8px; }
  .cycle span { padding: 5px 8px; }
  .queues { grid-template-columns: 1fr; }
  .queue-scroll { height: 240px; }
  .dialog-header { padding: 20px 16px 16px; }
  .dialog-header h2 { font-size: 21px; }
  .dialog-content { padding: 16px; }
  .help-dialog { max-height: calc(100dvh - 24px); }
  .completion { min-height: 470px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
