/* 任何元素身上只要有別的 display: 規則（例如 .row { display: flex }），
   就會蓋掉瀏覽器內建的 [hidden] 規則，讓標了 hidden 的元素照樣露出來。 */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  max-width: 40rem;
  margin: 3rem auto;
  padding: 0 1rem;
  line-height: 1.6;
}

textarea { width: 100%; font-size: 1.1rem; padding: 0.5rem; }

.row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.75rem 0; }

button { padding: 0.5rem 1rem; font-size: 1rem; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.recording { background: #c0392b; color: white; }
/* 固定寬度，切 1x／0.75x 時整排按鈕才不會跟著跳位 */
button.speed { min-width: 6.5rem; }

.status { min-height: 1.5rem; color: #555; }
.status.error { color: #c0392b; font-weight: bold; }

.overall { font-size: 4rem; font-weight: bold; line-height: 1; }

.colored { font-size: 1.5rem; }
.colored .green { color: #1e8449; }
.colored .yellow { color: #b7950b; }
.colored .red { color: #c0392b; }
.colored .omitted { text-decoration: line-through; }
.colored .inserted { color: #999; font-style: italic; }

.weakest {
  font-size: 1.1rem;
  color: #c0392b;
  margin: 0.25rem 0 0.75rem;
}
.weakest .sound { font-weight: bold; font-size: 1.3rem; }

.colored span { cursor: pointer; border-bottom: 1px dotted transparent; }
.colored span:hover { border-bottom-color: currentColor; }
.colored span.omitted, .colored span.inserted { cursor: default; }
.colored span.selected { background: #f0f0f0; border-radius: 3px; }

.phonemes {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fafafa;
  border-left: 3px solid #ddd;
}
.phonemes h3 { margin: 0 0 0.5rem; font-size: 1rem; font-weight: normal; color: #555; }
.phonemes table { border-collapse: collapse; font-size: 1.05rem; }
.phonemes td { padding: 0.15rem 0.9rem 0.15rem 0; }
.phonemes .sound { font-size: 1.25rem; }
.phonemes .low { color: #c0392b; font-weight: bold; }
.phonemes .heard { color: #777; }

/* 三區版面：左欄固定寬、主畫面捲動、練習面板釘在右下 */
body { max-width: none; margin: 0; padding: 0; }

.layout {
  display: grid;
  grid-template-columns: 18rem 1fr;
  grid-template-rows: 1fr auto;
  height: 100vh;
}

#sidebar {
  grid-row: 1 / 3;
  border-right: 1px solid #e0e0e0;
  padding: 1rem;
  overflow-y: auto;
}
#sidebar h1 { font-size: 1.3rem; margin: 0 0 1rem; }

.entry {
  width: 100%;
  text-align: left;
  margin-bottom: 1rem;
}
.entry.active { background: #eef3fa; font-weight: bold; }

.field { display: block; font-size: 0.85rem; color: #666; margin-bottom: 0.5rem; }
.field select { width: 100%; padding: 0.3rem; font-size: 0.95rem; }

#article-list { list-style: none; padding: 0; margin: 1rem 0 0; }
#article-list li {
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.4;
}
#article-list li:hover { background: #f5f5f5; }
#article-list .date { color: #888; font-size: 0.85rem; margin-right: 0.4rem; }
#article-list .count { display: block; color: #888; font-size: 0.8rem; }

.hint { white-space: pre-line; color: #888; font-size: 0.85rem; }

#article { padding: 1.5rem 2rem; overflow-y: auto; }
#article h2 { margin: 0 0 0.25rem; }
.meta { color: #888; margin: 0 0 1.5rem; }

#sentence-list { list-style: none; padding: 0; margin: 0; max-width: 42rem; }
li.sentence {
  padding: 0.35rem 0.5rem 0.35rem 1.5rem;
  cursor: pointer;
  border-radius: 4px;
  position: relative;
  font-size: 1.1rem;
}
li.sentence::before {
  content: "○";
  position: absolute;
  left: 0.25rem;
  color: #ccc;
}
li.sentence.green::before  { content: "●"; color: #1e8449; }
li.sentence.yellow::before { content: "●"; color: #b7950b; }
li.sentence.red::before    { content: "●"; color: #c0392b; }
li.sentence.current { background: #eef3fa; }
li.sentence.current::before { content: "◉"; color: #2c6fb5; }
li.sentence:hover { background: #f5f5f5; }
/* 文章標題也是一句練習，只是排版上要看得出它是標題。 */
li.sentence.title { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
/* 單字小標：標示接下來這幾句在練哪個字，本身不可點。 */
li.term {
  margin: 0.9rem 0 0.2rem;
  padding-left: 1.5rem;
  color: #2c6fb5;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}
li.divider {
  margin: 1.25rem 0 0.5rem;
  color: #888;
  font-size: 0.85rem;
  border-top: 1px solid #e0e0e0;
  padding-top: 0.5rem;
}

#practice {
  grid-column: 2;
  border-top: 1px solid #e0e0e0;
  padding: 1rem 2rem;
  background: #fbfbfb;
}
.current { font-size: 1.25rem; margin: 0 0 0.5rem; min-height: 1.6rem; }
.nav { align-items: center; }
.progress { color: #666; font-size: 0.9rem; }

#quiz {
  max-width: 42rem;
  margin: 2rem 0 1rem;
  border-top: 1px solid #e0e0e0;
  padding-top: 1rem;
}
#quiz h3 { margin: 0 0 1rem; font-size: 0.85rem; color: #888; font-weight: 600; }
.quiz-question { margin-bottom: 1.5rem; }
.quiz-prompt { margin: 0 0 0.5rem; font-size: 1.05rem; }
.quiz-options { list-style: none; padding: 0; margin: 0; }
.quiz-options li.option {
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
}
.quiz-options li.option:hover { background: #f5f5f5; }
.quiz-options li.chosen { background: #eef3fa; border-color: #2c6fb5; }
/* 對完答案就不能再選，游標也別再假裝可以點。 */
.quiz-options li.correct,
.quiz-options li.wrong { cursor: default; }
.quiz-options li.correct { background: #e8f5ec; border-color: #1e8449; }
.quiz-options li.wrong { background: #fdecea; border-color: #c0392b; }
.quiz-options li.correct::after { content: " ✓"; color: #1e8449; }
.quiz-options li.wrong::after { content: " ✗"; color: #c0392b; }
.quiz-footer { display: flex; align-items: center; gap: 0.75rem; }
.quiz-score { color: #555; }
.meta a { color: #2c6fb5; text-decoration: none; }
.meta a:hover { text-decoration: underline; }

/* 本課單字：點了才給中文。虛線底線是「這裡可以點」的提示，不搶視線。 */
.term-mark {
  border-bottom: 1px dashed #2c6fb5;
  cursor: pointer;
}
.term-mark:hover { background: #eef3fa; }
.gloss {
  margin-left: 0.25rem;
  color: #2c6fb5;
  font-size: 0.9em;
}

/* 登入頁：畫面正中一張小表單。 */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login { width: 20rem; }
.login h1 { font-size: 1.5rem; margin: 0 0 1.5rem; }
.login input { width: 100%; padding: 0.4rem; font-size: 1rem; box-sizing: border-box; }
.login button { width: 100%; margin-top: 0.5rem; }

/* 左欄標題下的使用者列 */
.user-bar { font-size: 0.85rem; color: #666; margin: -0.5rem 0 1rem; }
.user-bar a, button.link { color: #2c6fb5; text-decoration: none; }
button.link { background: none; border: none; padding: 0; font-size: inherit; cursor: pointer; }
.user-bar a:hover, button.link:hover { text-decoration: underline; }

/* 帳號設定 */
#settings-panel { max-width: 26rem; }
.settings-block { margin-bottom: 2rem; }
.settings-block h3 { font-size: 1rem; margin: 0 0 0.5rem; }
.settings-block input { width: 100%; padding: 0.4rem; font-size: 1rem; box-sizing: border-box; }

/* 沒金鑰時的常駐提示 */
.banner {
  background: #fff8e1;
  border: 1px solid #f0d58c;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}
.banner a { color: #2c6fb5; }

/* 左欄練習狀態：沒碰過的數字淡掉，練完的變綠加勾 */
#article-list li.untouched .count { color: #bbb; }
#article-list li.partial .count { color: #555; }
#article-list li.done .count { color: #1e8449; font-weight: 600; }

/* 每句的練習歷史 */
.history { margin-top: 0.75rem; font-size: 0.9rem; color: #555; }
.history.error { color: #c0392b; }
.history h3 { margin: 0 0 0.25rem; font-size: 0.85rem; color: #888; font-weight: 600; }
.history ul { list-style: none; padding: 0; margin: 0; max-height: 8rem; overflow-y: auto; }
.history li { display: flex; gap: 0.75rem; align-items: center; }
.history .when { color: #888; min-width: 6.5rem; }
.history .score { font-weight: 600; min-width: 2rem; }
.history .score.green { color: #1e8449; }
.history .score.yellow { color: #b7950b; }
.history .score.red { color: #c0392b; }
.history .empty { color: #999; }
