/* Listening Practice — docs/ui-guidelines.md 準拠(デジタル庁デザインシステムのトークンを簡約適用) */
* { box-sizing: border-box; }
:root {
  /* カラー(基調はティール#2F99A1。文字・ボタンにはコントラスト4.5:1を満たす明度調整版を使う) */
  --primary: #227177;        /* ボタン・リンク・アクティブ(白文字5.7:1) */
  --primary-strong: #156168; /* hover / active */
  --primary-accent: #2F99A1; /* 非テキスト装飾(プログレスバー・罫線アクセント) */
  --primary-soft: #E1F3F4;
  --text: #1A1A1A;           /* Solid-Gray-900 */
  --text-sub: #666666;       /* Solid-Gray-600 */
  --text-disabled: #949494;  /* Solid-Gray-420 */
  --line: #E6E6E6;           /* Solid-Gray-100 */
  --bg: #F2F2F2;             /* Solid-Gray-50 */
  --surface: #FFFFFF;
  --error: #EC0000;          /* Red-800 */
  --error-strong: #CE0000;   /* Red-900 */
  --error-soft: #FDEEEE;
  --success: #259D63;        /* Green-600 */
  --success-strong: #17714A; /* 小さめ文字用(4.5:1) */
  --success-soft: #E9F6EF;
  --warning: #B78F00;        /* Yellow-700 */
  --focus-ring: #7FCCD3;     /* フォーカス外輪(淡ティール)。濃ティールの上でも3.1:1で見える */
  /* スペーシング(8pxグリッド: 4/8/16/24/40のみ) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 40px;
  /* 角丸 */
  --r-control: 8px;
  --r-card: 12px;
}

[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", -apple-system, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
.container { max-width: 720px; margin: 0 auto; padding: var(--sp-3) var(--sp-3) 96px; }

/* フォーカス(ティールの二重輪郭)。内側=濃ティール(白地に5.7:1)、
   外側=淡ティール(ティールのボタン上でも3.1:1)で、どの背景でも輪郭が残る */
:focus-visible {
  outline: 2px solid var(--primary);
  box-shadow: 0 0 0 5px var(--focus-ring);
  border-radius: var(--r-control);
}

/* ---- 見出し・テキスト ---- */
header.app { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); min-height: 44px; }
header.app.stack { display: block; }
header.app h1 { font-size: 20px; margin: 0; line-height: 1.5; }
header.app.stack .sub { display: block; }
header.app .page-title {
  font-size: 16px; font-weight: 700; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sub { color: var(--text-sub); font-size: 14px; }
.caption { color: var(--text-sub); font-size: 12px; }
.error-text { color: var(--error); font-size: 14px; white-space: pre-wrap; }
.error-text:empty { display: none; }
.error-text.ok { color: var(--success-strong); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--sp-3); margin-bottom: var(--sp-4); }
.card > :last-child { margin-bottom: 0; }
.card h2 { font-size: 16px; margin: 0 0 var(--sp-3); line-height: 1.5; }
.card h2 .sub { font-weight: 400; margin-left: var(--sp-1); }
.mini-head { font-size: 14px; font-weight: 700; margin: var(--sp-4) 0 var(--sp-2); }
.mini-head .sub { font-weight: 400; margin-left: var(--sp-1); }

.icon { width: 1em; height: 1em; flex: none; }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }

/* ---- ボタン ----
   solid(=.primary 最重要・1画面1つ) / outline(既定) / text(.text 取消・退出、.danger 破壊的) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 48px; padding: 0 var(--sp-3);
  border: 1px solid var(--primary); border-radius: var(--r-control);
  background: var(--surface); color: var(--primary);
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.btn:active { background: var(--primary-soft); }
@media (hover: hover) { .btn:hover { background: var(--primary-soft); } }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-strong); }
@media (hover: hover) { .btn.primary:hover { background: var(--primary-strong); } }
.btn.text { border-color: transparent; background: transparent; color: var(--primary); text-decoration: underline; font-weight: 400; }
.btn.text:active { background: var(--primary-soft); }
.btn.danger { color: var(--error); }
.btn.danger:active { background: var(--error-soft); }
@media (hover: hover) {
  .btn.text:hover { background: var(--primary-soft); }
  .btn.danger:hover { background: var(--error-soft); }
}
.btn.large { min-height: 56px; font-size: 16px; }
.btn.small { min-height: 36px; padding: 0 var(--sp-2); font-size: 14px; border-width: 1px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled { background: var(--line); border-color: var(--line); color: var(--text-disabled); cursor: default; }
.btn.text:disabled { background: transparent; border-color: transparent; }

/* アイコンのみのボタン(3点メニューなど)。タップ領域44pxを確保 */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; margin: -8px 0;
  border: none; border-radius: var(--r-control); background: transparent;
  color: var(--text-sub); cursor: pointer; font: inherit;
}
.icon-btn:active { background: var(--bg); }
@media (hover: hover) { .icon-btn:hover { background: var(--bg); } }
.icon-btn .icon { width: 20px; height: 20px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  font: inherit; color: inherit; border: 1px solid var(--text-disabled); border-radius: var(--r-control);
  padding: 10px 12px; background: var(--surface); max-width: 100%; min-height: 44px;
}
/* 入力中の枠もティールにそろえる(:focus-visibleの二重輪郭と重ねて使う) */
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
/* チェック・ラジオの選択色もブラウザ既定の青ではなくティールに */
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 20px; height: 20px; }
textarea { min-height: 48px; }
label.field { display: block; font-size: 14px; color: var(--text-sub); }
label.field > input, label.field > select { margin-top: var(--sp-1); display: block; width: 100%; }

/* ---- 難易度の星(自動推定・5段階) ---- */
.stars { display: inline-flex; gap: 2px; color: var(--primary); vertical-align: -1px; }
.stars .icon { width: 12px; height: 12px; }
.stars .icon.off { color: var(--line); }

/* ---- バッジ ---- */
.status-badge {
  display: inline-block; font-size: 12px; padding: 2px var(--sp-2); border-radius: 999px;
  background: var(--bg); color: var(--text-sub); white-space: nowrap;
}
.status-badge.ready { background: var(--success-soft); color: var(--success-strong); }
.status-badge.processing { background: var(--primary-soft); color: var(--primary); }
.status-badge.error { background: var(--error-soft); color: var(--error-strong); }

/* ---- 使い方ステップ ---- */
.howto { display: flex; flex-direction: column; gap: var(--sp-3); margin: var(--sp-4) 0; text-align: left; }
.howto .step { display: flex; gap: var(--sp-2); align-items: flex-start; }
.howto .n {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.howto b { display: block; font-size: 16px; }
.howto .sub { display: block; margin-top: 2px; }

/* ---- ホーム: つづきから ---- */
.resume-card {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--primary-soft); border: 1px solid var(--primary-accent); border-radius: var(--r-card);
  padding: var(--sp-3); margin-bottom: var(--sp-4); text-decoration: none; color: inherit;
}
.resume-card .info { flex: 1; min-width: 0; }
.resume-card .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume-card .go { color: var(--primary); font-weight: 700; white-space: nowrap; }

/* ---- ホーム: 教材 ---- */
.mat-card { border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--sp-3); }
.mat-card + .mat-card, .mat-group + .mat-card, .mat-card + .mat-group { margin-top: var(--sp-3); }
.mat-card .mat-head { display: flex; align-items: flex-start; gap: var(--sp-2); }
.mat-card .mat-title { flex: 1; min-width: 0; font-weight: 700; }
.mat-card .mat-meta { color: var(--text-sub); font-size: 14px; margin: var(--sp-1) 0 var(--sp-3); }
.mat-card .error-text { margin: 0 0 var(--sp-2); }
.mat-card .mat-actions { display: flex; gap: var(--sp-2); align-items: center; }
.mat-card .mat-actions .btn.primary { flex: 1; }
.mat-group { border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.mat-group + .mat-group { margin-top: var(--sp-3); }
.mat-group summary {
  cursor: pointer; padding: var(--sp-3); display: flex; align-items: center; gap: var(--sp-2);
  flex-wrap: wrap; background: var(--surface); min-height: 44px;
}
.mat-group summary b { flex: 1 1 100%; min-width: 0; }
.mat-group summary .icon-btn { margin-left: auto; }
.mat-group[open] summary { border-bottom: 1px solid var(--line); }
.mat-group-body { padding: var(--sp-3); }
.mat-group-body .mat-card + .mat-card { margin-top: var(--sp-3); }
.mat-group-actions { padding-top: var(--sp-3); display: flex; justify-content: flex-end; }

/* ---- ホーム: 記録 ---- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.stat { border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--sp-2) var(--sp-3); }
.stat-label { font-size: 12px; color: var(--text-sub); }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.5; }
.stat-value small { font-size: 12px; font-weight: 400; color: var(--text-sub); }

.chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; min-height: 36px; padding: 0 var(--sp-3);
  background: var(--surface); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--sp-1); font: inherit; font-size: 14px;
}
.chip:active { background: var(--primary-soft); }
@media (hover: hover) { .chip:hover { background: var(--primary-soft); } }
.chip b { color: var(--error-strong); font-size: 12px; }
.chip-hint { margin-top: var(--sp-2); }

.recent-row {
  display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; font-size: 14px;
}
.recent-row:last-child { border-bottom: none; }
.recent-row:active { background: var(--bg); }
@media (hover: hover) { .recent-row:hover { background: var(--bg); } }
.recent-row .when { color: var(--text-sub); font-size: 12px; white-space: nowrap; flex: none; }
.recent-row .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row .icon { color: var(--text-disabled); }
.recent-row.disabled { color: var(--text-sub); }

/* カード下部の「すべて見る」型リンク行 */
.list-link {
  display: flex; align-items: center; gap: var(--sp-2); min-height: 48px;
  margin-top: var(--sp-2); padding-top: var(--sp-1); border-top: 1px solid var(--line);
  text-decoration: none; color: var(--primary); font-size: 14px; font-weight: 700;
}
.list-link .icon { margin-left: auto; color: var(--text-disabled); }
.list-link:active { background: var(--bg); }
@media (hover: hover) { .list-link:hover { background: var(--bg); } }

/* カード全体がリンクのナビカード(マイ辞書など) */
a.card.nav-card {
  display: flex; align-items: center; gap: var(--sp-3);
  text-decoration: none; color: inherit; cursor: pointer;
}
a.card.nav-card .info { flex: 1; min-width: 0; }
a.card.nav-card .info b { display: block; font-size: 16px; }
a.card.nav-card .info .sub { display: block; margin-top: 2px; }
a.card.nav-card .icon { color: var(--text-disabled); }
a.card.nav-card:active { background: var(--bg); }
@media (hover: hover) { a.card.nav-card:hover { background: var(--bg); } }

/* ---- マイ辞書 ---- */
.word-row {
  width: 100%; padding: var(--sp-2) 0; border: none; border-bottom: 1px solid var(--line);
  background: transparent; font: inherit; text-align: left; cursor: pointer; display: block;
}
.word-row:last-child { border-bottom: none; }
.word-row:active { background: var(--bg); }
@media (hover: hover) { .word-row:hover { background: var(--bg); } }
.word-row .w-head { display: flex; align-items: baseline; gap: var(--sp-2); }
.word-row .w-word { font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 16px; }
.word-row .w-ipa { color: var(--primary); font-size: 14px; }
.word-row .w-when { margin-left: auto; color: var(--text-sub); font-size: 12px; white-space: nowrap; }
.word-row .w-mean {
  color: var(--text-sub); font-size: 14px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---- 学習の記録(全履歴) ---- */
.date-head { font-size: 14px; font-weight: 700; margin: var(--sp-4) 0 var(--sp-1); }
.date-head:first-child { margin-top: 0; }

/* ---- 学習カレンダー(ヒートマップ) ----
   セル寸法・2pxギャップはデータ可視化用の例外(docs/ui-guidelines.md参照) */
.hm-scroll { overflow-x: auto; }
.hm-grid { display: flex; gap: 2px; width: max-content; }
.hm-col { display: flex; flex-direction: column; gap: 2px; }
.hm-mlabel { height: 16px; font-size: 12px; line-height: 16px; color: var(--text-sub); white-space: nowrap; overflow: visible; width: 12px; }
.hm-dlabel { height: 12px; width: 14px; font-size: 12px; line-height: 12px; color: var(--text-sub); }
.hm-cell {
  width: 12px; height: 12px; border-radius: 2px; border: none; padding: 0;
  background: var(--line); cursor: pointer; flex: none;
}
.hm-cell.l1 { background: #C9E8EB; }
.hm-cell.l2 { background: #8FD0D6; }
.hm-cell.l3 { background: var(--primary-accent); }
.hm-cell.l4 { background: var(--primary); }
.hm-cell.future { background: transparent; cursor: default; }
.hm-legend { display: flex; align-items: center; gap: 2px; justify-content: flex-end; margin-top: var(--sp-1); font-size: 12px; color: var(--text-sub); }
.hm-legend span:first-child { margin-right: var(--sp-1); }
.hm-legend span:last-child { margin-left: var(--sp-1); }
.hm-legend .hm-cell { cursor: default; }
.hm-detail { min-height: 18px; }

/* ---- マイ辞書: 今日の復習 ---- */
.quiz-row .w-mean { color: var(--text-disabled); }
.quiz-row.open .w-mean { color: var(--text-sub); }

/* ---- ホーム: 教材追加 ---- */
.upload-grid { display: flex; flex-direction: column; gap: var(--sp-3); }
.file-label {
  display: flex; align-items: center; justify-content: center; min-height: 56px;
  border: 1px dashed var(--text-disabled); border-radius: var(--r-control);
  color: var(--text-sub); cursor: pointer; font-size: 14px; padding: var(--sp-2) var(--sp-3);
  text-align: center;
}
.file-label.picked { border: 1px solid var(--primary); color: var(--primary); background: var(--primary-soft); }
.file-label input { display: none; }
details.adv summary { cursor: pointer; color: var(--text-sub); font-size: 14px; min-height: 44px; display: flex; align-items: center; }
details.adv .adv-body { padding: var(--sp-1) 0 var(--sp-2); }

/* ---- 書き取り ---- */
.dictation { text-align: center; }
.dict-topbar { display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; }
.dict-topbar .title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px; color: var(--text-sub);
}
.dict-topbar .spacer { width: 64px; flex: none; }
.progress-track { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin: var(--sp-3) 0 var(--sp-4); }
.progress-track i { display: block; height: 100%; background: var(--primary-accent); border-radius: 999px; transition: width .25s; }
.dict-pos { font-size: 32px; font-weight: 700; line-height: 1.5; }
.dict-pos .of { color: var(--text-sub); font-weight: 400; font-size: 20px; }
.dict-pos .unit { font-size: 16px; font-weight: 400; color: var(--text-sub); }
.play-state { height: 24px; margin: var(--sp-1) 0; color: var(--primary); font-size: 14px; }
.play-state.playing::after { content: "再生中"; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.count { font-size: 14px; color: var(--text-sub); margin-bottom: var(--sp-4); }
.count b { color: var(--text); font-size: 20px; }
.count .over { color: var(--warning); }

.dict-controls { display: flex; flex-direction: column; gap: var(--sp-2); margin: 0 auto var(--sp-4); max-width: 400px; }
.dict-controls .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.speed-row { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.speed-control { display: inline-flex; gap: var(--sp-2); }
.speed-btn {
  border: 1px solid var(--text-disabled); background: var(--surface); border-radius: 999px;
  min-height: 40px; padding: 0 var(--sp-3); font: inherit; font-size: 14px; cursor: pointer; color: var(--text-sub);
}
.speed-btn.active { background: var(--text); color: #fff; border-color: var(--text); }
.hint { color: var(--text-sub); font-size: 12px; margin-top: var(--sp-4); }
.key-hint { display: none; }
@media (hover: hover) and (pointer: fine) { .key-hint { display: block; } }

.overlay-center {
  position: fixed; inset: 0; background: var(--surface); display: flex; flex-direction: column;
  align-items: center; justify-content: center; z-index: 50; text-align: center;
  padding: var(--sp-4); overflow-y: auto;
}
.overlay-center .panel { max-width: 400px; width: 100%; }
.overlay-center h2 { font-size: 20px; margin: 0 0 var(--sp-2); }

/* ---- 答え合わせ: モード切替 ---- */
.mode-bar-wrap {
  position: sticky; top: 0; z-index: 30; background: var(--bg);
  margin: 0 calc(-1 * var(--sp-3)); padding: var(--sp-2) var(--sp-3);
}
.mode-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.mode-btn {
  border: 1px solid var(--text-disabled); border-radius: var(--r-control); background: var(--surface);
  cursor: pointer; min-height: 56px; padding: var(--sp-1);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: inherit; color: var(--text);
}
.mode-btn .step-n { font-size: 12px; color: var(--text-sub); line-height: 1.5; }
.mode-btn .lab { font-size: 16px; font-weight: 700; line-height: 1.5; }
.mode-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.mode-btn.active .step-n { color: #fff; opacity: .8; }
.mode-hint {
  margin-top: var(--sp-2); font-size: 14px; line-height: 1.5;
  background: var(--primary-soft); color: var(--text); border-radius: var(--r-control);
  padding: var(--sp-2) var(--sp-3);
}

.review-tools { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.partial-note { margin: 0 0 var(--sp-3); }

/* ---- 答え合わせ: トランスクリプト ---- */
.transcript { font-size: 17px; line-height: 2; font-family: Georgia, "Times New Roman", serif; }
.transcript .seg { border-radius: var(--r-control); padding: 2px; }
.transcript .w { border-radius: 4px; padding: 1px; }
.transcript.mode-listen .seg { cursor: pointer; }
@media (hover: hover) { .transcript.mode-listen .seg:hover { background: var(--primary-soft); } }
.transcript .seg.playing { background: var(--primary-soft); box-shadow: 0 0 0 2px var(--primary-soft); }
.transcript.mode-mark .w, .transcript.mode-dict .w { cursor: pointer; }
@media (hover: hover) {
  .transcript.mode-mark .w:hover { background: var(--error-soft); }
  .transcript.mode-dict .w:hover { background: var(--primary-soft); }
}
.transcript .w.miss { background: var(--error-soft); border-bottom: 2px solid var(--error); }
.transcript.mode-mark ::selection { background: #F5C6C6; }

/* ---- 答え合わせ: 結果 ---- */
.score-band { display: flex; align-items: center; gap: var(--sp-3); }
.score-main { font-size: 40px; font-weight: 700; color: var(--success); line-height: 1.2; }
.score-main small { font-size: 16px; font-weight: 400; }
.score-band .detail { font-size: 14px; color: var(--text-sub); }

table.summary { width: 100%; border-collapse: collapse; font-size: 14px; }
table.summary th, table.summary td { padding: var(--sp-2); border-bottom: 1px solid var(--line); text-align: right; }
table.summary th { color: var(--text-sub); font-size: 12px; font-weight: 600; }
table.summary .over { color: var(--error-strong); font-weight: 700; }
details.plain summary { cursor: pointer; color: var(--text-sub); font-size: 14px; min-height: 44px; display: flex; align-items: center; }
details.plain .sub { margin: var(--sp-1) 0 var(--sp-2); display: block; }

/* ---- データ表(先生用の一覧。横スクロールで包む) ---- */
.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th, table.data-table td {
  padding: var(--sp-2); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
table.data-table th { color: var(--text-sub); font-size: 12px; font-weight: 600; white-space: nowrap; }
table.data-table td.nowrap { white-space: nowrap; }
table.data-table td.right { text-align: right; }
table.data-table .miss { color: var(--error-strong); font-weight: 700; }

/* ---- 教材編集 ---- */
.editor-head { display: flex; flex-direction: column; gap: var(--sp-3); }
.seg-row { display: grid; grid-template-columns: 30px 1fr; gap: var(--sp-2); padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.seg-row .num { color: var(--text-sub); font-size: 14px; padding-top: var(--sp-2); }
.seg-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.seg-head input[type=number] { width: 96px; min-height: 36px; padding: var(--sp-1) var(--sp-2); }
.seg-dur { font-size: 12px; color: var(--text-sub); }
.seg-dur.warn { color: var(--warning); font-weight: 700; }
.seg-row textarea { width: 100%; margin-top: var(--sp-2); resize: vertical; }
.seg-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); flex-wrap: wrap; }
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
  padding: var(--sp-2) var(--sp-3) calc(var(--sp-2) + env(safe-area-inset-bottom));
  display: flex; gap: var(--sp-2); align-items: center; justify-content: center; z-index: 40;
}

/* ---- 辞書ボトムシート ---- */
.sheet-overlay { position: fixed; inset: 0; background: rgba(26, 26, 26, .4); z-index: 190; }
.dict-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  background: var(--surface); border-radius: var(--r-card) var(--r-card) 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, .2);
  padding: var(--sp-2) var(--sp-3) calc(var(--sp-3) + env(safe-area-inset-bottom));
  max-height: 55vh; overflow-y: auto; animation: sheet-up .18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40%); opacity: .4; } }
.dict-sheet .grip { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 0 auto var(--sp-2); }
.dict-sheet .head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.dict-sheet .word { font-size: 22px; font-weight: 700; font-family: Georgia, "Times New Roman", serif; }
.dict-sheet .ipa { color: var(--primary); font-size: 14px; }
.dict-sheet .listen-word { margin-left: auto; }
.dict-sheet .mean { margin-top: var(--sp-2); font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.dict-sheet .none { color: var(--text-sub); margin-top: var(--sp-2); font-size: 14px; }
.dict-sheet .sheet-actions {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: var(--sp-3); padding-top: var(--sp-2); border-top: 1px solid var(--line);
}

/* ---- アクションシート(教材メニューなど) ---- */
.action-sheet .sheet-title {
  font-size: 14px; color: var(--text-sub); padding: var(--sp-1) 0 var(--sp-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.action-sheet .sheet-item {
  display: flex; align-items: center; width: 100%; min-height: 48px;
  padding: 0 var(--sp-2); border: none; border-top: 1px solid var(--line);
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
  border-radius: 0;
}
.action-sheet .sheet-item:active { background: var(--bg); }
@media (hover: hover) { .action-sheet .sheet-item:hover { background: var(--bg); } }
.action-sheet .sheet-item.danger { color: var(--error); }
.action-sheet .sheet-item.cancel { color: var(--text-sub); }

/* ---- 辞書ホバーツールチップ(PCのみ) ---- */
#dict-tip {
  position: fixed; z-index: 210; background: var(--text); color: #fff;
  border-radius: var(--r-control); padding: var(--sp-2) var(--sp-3); font-size: 14px; line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25); pointer-events: none;
}
#dict-tip .ipa { color: #7FCCD3; margin-left: var(--sp-1); }
#dict-tip .mean { margin-top: var(--sp-1); color: #E6E6E6; }

/* ---- モーダル ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26, 26, 26, .4); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: var(--sp-3);
}
.modal { background: var(--surface); border-radius: var(--r-card); padding: var(--sp-4); max-width: 400px; width: 100%; }
.modal p { margin: 0 0 var(--sp-3); }
.modal .prompt-input { width: 100%; margin-bottom: var(--sp-3); }
.modal .options { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.modal .options label { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: var(--sp-2); }
.modal-buttons { display: flex; gap: var(--sp-2); justify-content: flex-end; }
.modal-buttons .btn { min-width: 96px; }

/* ---- フッター(ログイン状態・ログアウト) ---- */
.app-footer {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding-top: var(--sp-3); border-top: 1px solid var(--line);
}

/* ---- ログイン(PIN入力) ---- */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: var(--sp-3);
}
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: var(--sp-5) var(--sp-4); width: 100%; max-width: 400px; text-align: center;
}
.login-card h1 { font-size: 20px; margin: 0; }
.login-card .login-role { font-size: 16px; margin: var(--sp-4) 0 var(--sp-3); }
.login-card label.field { text-align: left; }
.pin-input {
  width: 100%; text-align: center; font-size: 32px; letter-spacing: 16px;
  padding-left: 16px; /* letter-spacingの右ズレ補正 */
  min-height: 56px;
}
.login-alt { color: var(--primary); }

/* ---- 先生用ホーム: ひと目で先生の画面だとわかるようにする ---- */
.teacher-bar {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  background: var(--primary); color: #fff; border-radius: var(--r-card);
  padding: var(--sp-1) var(--sp-3); margin-bottom: var(--sp-3); font-size: 14px;
}
.teacher-bar .tag {
  flex: none; background: var(--surface); color: var(--primary);
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px var(--sp-2);
}
.teacher-bar .what { flex: 1; min-width: 0; }
.teacher-bar a {
  display: inline-flex; align-items: center; gap: var(--sp-1); min-height: 44px;
  color: #fff; font-weight: 700; white-space: nowrap;
}

/* ---- 生徒ロール: 教材の管理UIだけ隠す(API側でも403で防いでいる)。
       教材の追加は既定で生徒にもひらいている(先生が /settings.html で切替) ---- */
body.role-student .icon-btn[data-act="menu"],
body.role-student button[data-act="retry"],
body.role-student details.adv { display: none; }

/* ---- 表示のカスタマイズ(先生のみ) ---- */
label.check { display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; cursor: pointer; }
.ms-row { padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.ms-row:first-child { padding-top: 0; }
.ms-row:last-child { border-bottom: none; }
.ms-head { display: flex; align-items: flex-end; gap: var(--sp-2); }
.ms-head .ms-days { width: 112px; flex: none; }
.ms-head .btn { margin-left: auto; }

/* ---- PC ---- */
@media (min-width: 640px) {
  .container { padding: var(--sp-4) var(--sp-3) 96px; }
  .mode-bar-wrap { margin: 0 calc(-1 * var(--sp-3)); }
  .mat-card .mat-actions .btn.primary { flex: 0 0 auto; min-width: 200px; }
  .upload-grid { flex-direction: row; align-items: stretch; }
  .upload-grid .file-label { flex: 1; }
  .upload-grid label.field { flex: 1; }
  .dict-sheet { left: 50%; right: auto; transform: translateX(-50%); width: 480px; border-radius: var(--r-card); bottom: var(--sp-4); }
}
