/* 全レッスン・参照資料で共通のスタイル（Tufte 風：余白多め、装飾少なめ） */

:root {
  --bg: #fffff8;
  --ink: #1b1b18;
  --muted: #6b6a60;
  --rule: #dcd9c6;
  --soft: #f4f1e4;
  --accent: #8b1e24;
  --ok: #2f6b3b;
  --ok-bg: #e8f1e6;
  --ng: #9b2226;
  --ng-bg: #f7e6e4;
  --serif-ja: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --serif-en: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}

/* 暗い配色。claude.ai で開いたときは、claude.ai 側の「ライト／ダーク」の切り替え（data-theme）を優先する */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1916;
    --ink: #ecebe4;
    --muted: #a09e92;
    --rule: #3a3832;
    --soft: #24231f;
    --accent: #e58a8d;
    --ok: #93d09c;
    --ok-bg: #1f3122;
    --ng: #f0a0a0;
    --ng-bg: #3a2222;
  }
}

:root[data-theme="dark"] {
  --bg: #1a1916;
  --ink: #ecebe4;
  --muted: #a09e92;
  --rule: #3a3832;
  --soft: #24231f;
  --accent: #e58a8d;
  --ok: #93d09c;
  --ok-bg: #1f3122;
  --ng: #f0a0a0;
  --ng-bg: #3a2222;
}

html { font-size: 17px; }

/* hidden 属性は、display を指定したクラス（.row など）より常に優先する */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif-ja);
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 38rem;
  margin: 0 auto;
  padding: 3.5rem 1rem 6rem;
}

/* 広い画面では本文を左に寄せて、右の余白に注を置く */
@media (min-width: 1000px) {
  main { margin-left: max(2rem, calc(50vw - 28rem)); }
}

/* ---------- 見出し ---------- */

.kicker {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0;
}

h1 {
  font-weight: normal;
  font-size: 2rem;
  line-height: 1.4;
  margin: 0.3rem 0 0.4rem;
}

.subtitle {
  font-style: italic;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.meta {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.4rem;
  margin-bottom: 2.2rem;
}

h2 {
  font-weight: normal;
  font-size: 1.35rem;
  margin: 3rem 0 0.6rem;
}

h2 .label {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

h3 {
  font-weight: normal;
  font-size: 1.05rem;
  margin: 1.8rem 0 0.3rem;
}

p { margin: 0 0 1rem; }

a { color: var(--accent); text-underline-offset: 0.18em; }

/* ---------- 余白の注（サイドノート） ---------- */

.note {
  display: block;
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--muted);
  border-left: 2px solid var(--rule);
  padding-left: 0.8rem;
  margin: 0.4rem 0 1.2rem;
}

@media (min-width: 1000px) {
  .note {
    float: right;
    clear: right;
    width: 15rem;
    margin: 0.3rem -17.5rem 1rem 0;
    border-left: none;
    padding-left: 0;
  }
}

/* ---------- 英語フレーズ ---------- */

.phrase {
  font-family: var(--serif-en);
  font-size: 1.15em;
  letter-spacing: 0.005em;
}

.phrase u {
  text-decoration: none;
  border-bottom: 2px solid var(--ng);
}

/* 音が変わる所の印：点線の下線と、変化の番号（data-n）を右上につける */
.chg { border-bottom: 2px dotted var(--accent); }
.chg[data-n]::after {
  content: attr(data-n);
  font-family: var(--sans);
  font-size: 0.55em;
  color: var(--accent);
  vertical-align: super;
  margin-left: 0.1em;
}

.big-phrase {
  font-family: var(--serif-en);
  font-size: 1.4rem;
  line-height: 1.5;
  margin: 0.2rem 0 0.4rem;
}

/* ---------- 表 ---------- */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0 1.6rem;
  font-size: 0.95rem;
}

th {
  font-family: var(--sans);
  font-weight: normal;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--ink);
  padding: 0.3rem 0.5rem;
}

td {
  border-bottom: 1px solid var(--rule);
  padding: 0.6rem 0.5rem;
  vertical-align: top;
}

td.num {
  font-family: var(--sans);
  color: var(--muted);
  width: 1.5rem;
}

/* ---------- ボタン類 ---------- */

button {
  font-family: var(--sans);
  cursor: pointer;
}

.say {
  font-size: 0.72rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.1rem 0.7rem;
  margin: 0.15rem 0.3rem 0.15rem 0;
  white-space: nowrap;
}

.say:hover { border-color: var(--accent); color: var(--accent); }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.5rem 0;
}

.primary {
  font-size: 0.82rem;
  color: var(--bg);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 0.35rem 0.9rem;
}

.secondary {
  font-size: 0.82rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.35rem 0.9rem;
}

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

button:disabled { cursor: default; opacity: 0.6; }

/* 再生ボタンの横に出す短い知らせ（「途中で切れた」など） */
.play-note {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--muted);
}

/* ---------- 声の選択欄 ---------- */

.voice-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  margin: -1.2rem 0 2.2rem;
}

.voice-picker select {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.15rem 0.3rem;
  margin-left: 0.3rem;
  max-width: 16rem;
}

.voice-picker .picker-hint { flex-basis: 100%; }

/* ---------- 練習カード ---------- */

.exercise {
  border-top: 1px solid var(--rule);
  padding: 1.2rem 0 0.8rem;
}

.exercise .q { margin-bottom: 0.4rem; }

.exercise .qnum {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--muted);
  margin-right: 0.4rem;
}

.step {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.2rem 0;
}

.recall input,
.dictation input {
  flex: 1 1 16rem;
  font-family: var(--serif-en);
  font-size: 1.1rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink);
  padding: 0.3rem 0.1rem;
  min-width: 0;
}

.recall input:focus,
.dictation input:focus { outline: none; border-bottom-color: var(--accent); }

.idk { margin: 0 0 0.6rem; }

/* 区切る練習（chunker.js） */
.chunk-line { line-height: 2.4; margin: 0.4rem 0; }

.chunk-line .w {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 0.05em 0.15em;
  margin: 0;
  cursor: pointer;
}

.chunk-line .w:hover:not(:disabled) { background: var(--soft); }
.chunk-line .w:disabled { opacity: 1; cursor: default; }
.chunk-line .w.cut::after { content: " /"; color: var(--accent); font-weight: bold; }
.chunk-line .w.extra::after { color: var(--ng); }

.slash { font-weight: bold; }
.slash.hit { color: var(--ok); }
.slash.miss { color: var(--ng); }

/* 根拠さがし（evidence.js） */
.evidence .passage p { line-height: 1.9; }

.evidence .sent {
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 0.1em 0.2em;
  margin: 0;
  cursor: pointer;
}

.evidence .sent:hover:not(:disabled) { background: var(--soft); }
.evidence .sent:disabled { opacity: 1; cursor: default; }
.evidence .sent.picked { background: var(--soft); box-shadow: inset 0 -2px 0 var(--accent); }
.evidence .sent.is-answer { background: var(--ok-bg); box-shadow: inset 0 -2px 0 var(--ok); }
.evidence .sent.is-wrong { background: var(--ng-bg); box-shadow: inset 0 -2px 0 var(--ng); }

/* ペース読み（paced-reader.js） */
.pace-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 5.5rem;
  background: var(--soft);
  border-radius: 6px;
  padding: 1rem;
  margin: 0.6rem 0 0.2rem;
  text-align: center;
}

.pace-text { font-family: var(--serif-en); font-size: 1.5rem; line-height: 1.4; }
.pace-text:not(:empty) { min-height: 1.4em; }

.speed.chosen { border-color: var(--ink); background: var(--soft); }

/* 長文の本文（英文のメールや案内） */
.passage {
  font-family: var(--serif-en);
  font-size: 1.02rem;
  line-height: 1.75;
  background: var(--soft);
  border-radius: 6px;
  padding: 1.1rem 1.3rem;
  margin: 0.8rem 0;
}

.passage p { margin: 0 0 0.8rem; }
.passage p:last-child { margin-bottom: 0; }
.passage .mail-head { font-family: var(--sans); font-size: 0.8rem; color: var(--muted); }

.choices { margin: 0.6rem 0; }

.choices button {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--serif-en);
  font-size: 1.05rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.55rem 0.9rem;
  margin: 0.4rem 0;
}

.choices button:hover:not(:disabled) { border-color: var(--ink); }
.choices button.correct { background: var(--ok-bg); border-color: var(--ok); opacity: 1; }
.choices button.wrong { background: var(--ng-bg); border-color: var(--ng); opacity: 1; }

.fb {
  font-size: 0.95rem;
  margin: 0.6rem 0;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
}

.fb.ok { background: var(--ok-bg); }
.fb.ng { background: var(--ng-bg); }
.fb strong { font-family: var(--sans); font-size: 0.85rem; }
.fb.ok strong { color: var(--ok); }
.fb.ng strong { color: var(--ng); }
.fb p { margin: 0.3rem 0 0; }

.explain { font-size: 0.95rem; }

/* ---------- 囲み ---------- */

.box {
  background: var(--soft);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  margin: 1.2rem 0;
}

.box p:last-child { margin-bottom: 0; }

.summary-line {
  display: block;
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.7;
  background: var(--soft);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin: 0.6rem 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 日課：単語（srs.js） ---------- */

.srs {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.2rem 1.4rem 1.4rem;
  margin: 1.4rem 0;
}

.srs-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.6rem;
  margin-bottom: 1.2rem;
}

.srs-word {
  font-family: var(--serif-en);
  font-size: 2rem;
  line-height: 1.3;
  margin: 0.4rem 0 0.2rem;
}

.srs-word .phrase { font-size: inherit; }

.srs-pos, .srs-box {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
}

.srs-back { border-top: 1px dashed var(--rule); margin-top: 1rem; padding-top: 0.8rem; }
.srs-ja { font-size: 1.1rem; margin: 0 0 0.8rem; }
.srs-ex { margin: 0 0 0.2rem; }
.srs-exja { font-size: 0.9rem; color: var(--muted); margin: 0 0 0.6rem; }
.srs-rate { margin-top: 0.8rem; }
.srs-done table { margin-top: 1rem; }

/* ---------- 日課：多読の記録（reading-log.js） ---------- */

.reading-log { margin: 1.4rem 0; }

.reading-log .log-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.reading-log label {
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  gap: 0.2rem;
}

.reading-log input {
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  padding: 0.3rem 0.2rem;
}

.reading-log input:focus { outline: none; border-bottom-color: var(--accent); }
.reading-log input.title { min-width: 12rem; flex: 1; }
.reading-log input.words { width: 6rem; }

/* 語数を数える欄：毎回使うので畳まず、先頭で目立たせる */
.reading-log .counter {
  background: var(--soft);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  margin: 0 0 1.1rem;
}

.reading-log .counter-head {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

.reading-log .counter textarea { margin-top: 0; background: var(--bg); }

.reading-log .count {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.55rem 0 0;
}

.reading-log .count.has { color: var(--ok); font-weight: 600; }
.reading-log .count .n { font-size: 1.4rem; letter-spacing: 0.01em; }

.reading-log textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--serif-en);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--soft);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.6rem;
  margin-top: 0.3rem;
}

.reading-log textarea:focus { outline: none; border-color: var(--accent); }

.bar {
  height: 10px;
  background: var(--soft);
  border: 1px solid var(--rule);
  border-radius: 5px;
  overflow: hidden;
  margin: 0.4rem 0;
}

.bar span { display: block; height: 100%; background: var(--accent); }

.log-list { font-family: var(--sans); font-size: 0.8rem; }
.log-list td.num { color: var(--muted); }

/* ---------- 折りたたみ ---------- */

details { margin: 0.8rem 0; }

summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
}

summary:hover { color: var(--accent); }

/* ---------- 記録の書き出し（store.js） ---------- */

.data-backup { margin: 1.2rem 0; }

.backup-hint {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.3rem 0 0;
}

footer {
  border-top: 1px solid var(--rule);
  margin-top: 3.5rem;
  padding-top: 1.2rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
}

footer ol { padding-left: 1.2rem; }

/* ── 指で操作する端末（スマホ・タブレット）だけ、押せる範囲を広げる ──
   画面の広さやなく「ポインタが粗いか＝指か」で判定するので、マウスの PC は見た目が一切変わらへん。
   マウスは1pxを狙えるが指の接地面は8mmほどあって、Android は48px、Apple は44pxを最小の目安にしてる。
   いちばん効くのは .say（読み上げ）で、もとは高さ24px しかない。シャドーイングでは
   「0.85倍で流す」と「1.0倍で流す」が隣り合うので、指やと押し間違える。 */
@media (pointer: coarse) {
  .say {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
    margin: 0.2rem 0.4rem 0.2rem 0;
  }

  .primary,
  .secondary {
    min-height: 48px;
    font-size: 0.95rem;
    padding: 0.5rem 1.2rem;
  }

  .choices button {
    min-height: 48px;
    padding: 0.8rem 0.9rem;
  }

  /* 入力欄と選択欄は、文字が16px未満やと触った瞬間にブラウザが勝手に画面を拡大する。
     書き取りのたびに拡大されたら邪魔なので、指の端末では16pxを下回らせへん */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-height: 44px;
    font-size: max(16px, 1rem);
  }

  /* 声の選択欄は .voice-picker select の指定（0.75rem）のほうが強いので、名指しで上書きする */
  .voice-picker select {
    font-size: max(16px, 1rem);
    padding: 0.3rem 0.5rem;
  }
}

/* ---------- 印刷 ---------- */

@media print {
  :root { --bg: #fff; --ink: #000; --muted: #444; --rule: #bbb; --soft: #f3f3f3; }
  body { font-size: 11pt; }
  main { padding: 0; margin: 0; max-width: none; }
  .say, .no-print, .row button, .voice-picker { display: none !important; }
  .note { float: none; width: auto; margin: 0.3rem 0 0.8rem; border-left: 2px solid var(--rule); padding-left: 0.6rem; }
  a { color: #000; }
  table, tr { page-break-inside: avoid; }
}

/* ---------- 時間を測る問題セット（timed-set.js） ---------- */

.timer-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin: 1rem 0;
  padding: 0.7rem 0.9rem;
  background: var(--soft);
  border-radius: 6px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.timer-bar .clock {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.timer-bar .clock strong { font-size: 1.05rem; }
.timer-bar .timer-over { color: var(--ng); }
.timer-result { margin: 1rem 0; }
