:root {
  --bg: #fbfaf7; --fg: #1f2328; --muted: #5d6670; --line: #d9dde2;
  --ok: #1a7f37; --ng: #b42318; --accent: #2457c5; --card: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c; --fg: #e8eaed; --muted: #a3acb6; --line: #343a42;
    --ok: #4ac26b; --ng: #ff7b72; --accent: #7aa2ff; --card: #1d2126;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 18px/1.6 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
}
main { max-width: 32rem; margin: 0 auto; padding: 16px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 1.5rem; margin: 8px 0 16px; }
section { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
p { margin: 0 0 8px; }
.big { font-size: 1.25rem; font-weight: 600; text-wrap: balance; }
.ok { color: var(--ok); }
.ng { color: var(--ng); }
.note { color: var(--muted); font-size: 0.9rem; }
.mono, code { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; overflow-wrap: anywhere; }
.en { display: none; color: var(--muted); font-size: 0.95rem; }
body.show-en .en { display: block; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 0; }
dt { color: var(--muted); font-size: 0.9rem; }
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
button {
  font: inherit; min-height: 44px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer;
}
button.primary { width: 100%; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }
#emu-accounts { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#emu-accounts .note { width: 100%; margin: 0; }

/* Header actions */
.header-actions { display: flex; gap: 8px; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
h3 { font-size: 0.95rem; margin: 12px 0 4px; }
#state-learner, #state-admin { display: block; }

/* Admin dashboard */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: center; }
.week-label { font-weight: 600; margin: 0; }
.week-nav .note { margin: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; text-align: center; min-width: 0; }
.stat-value { font-size: 1.1rem; font-weight: 600; overflow-wrap: anywhere; }
.stat-label { font-size: 0.75rem; color: var(--muted); }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; }
.day { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.day-n { font-size: 0.75rem; color: var(--muted); min-height: 1.2em; }
.bar { width: 100%; height: 72px; display: flex; align-items: flex-end; background: var(--bg); border-radius: 6px; overflow: hidden; }
.fill { width: 100%; background: color-mix(in srgb, var(--accent) 35%, transparent); display: flex; align-items: flex-end; }
.fill-right { width: 100%; background: var(--accent); }
.day-label { font-size: 0.75rem; color: var(--muted); }
.legend { margin-top: 4px; font-size: 0.8rem; }
table.subjects { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.9rem; }
.subjects th, .subjects td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.subjects th { color: var(--muted); font-weight: 500; }
.subjects td:not(:first-child), .subjects th:not(:first-child) { text-align: right; }
ul.missed, ul.calendar { margin: 0; padding-left: 20px; overflow-wrap: anywhere; }
.waiting { color: var(--ng); font-weight: 600; margin-top: 8px; }
.cal-date { font-weight: 600; }
.cal-when { color: var(--muted); }

/* Sections (D38): current learning and review, scored apart */
.block { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.block:first-of-type { border-top: 0; margin-top: 8px; padding-top: 0; }
.block.review { background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: 10px; padding: 10px; border-top: 0; }
.block-title { display: block; font-size: 1rem; font-weight: 600; margin: 0 0 4px; }
.block-head { font-weight: 600; margin: 0 0 4px; }
.small-head { font-size: 0.85rem; font-weight: 600; margin: 8px 0 2px; }
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
rt { font-size: 0.55em; }
#learner-week-wrap .week-nav { border: 0; padding: 0 0 12px; margin: 0; background: none; }
