:root {
  color-scheme: light;
  --ink: #17343a;
  --muted: #6e8587;
  --paper: #ffffff;
  --canvas: #f3f6f2;
  --line: #e0e9e3;
  --teal: #167a70;
  --teal-dark: #105f58;
  --teal-pale: #e5f3ee;
  --coral: #dc805d;
  --coral-pale: #fff0e9;
  --gold: #d4a24d;
  --shadow: 0 20px 55px rgba(28, 61, 60, 0.08);
  font-family: 'Yu Gothic UI', 'Yu Gothic', Meiryo, 'Segoe UI', sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  background: var(--canvas);
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(ellipse at 10% -15%, rgba(217, 234, 224, .72), transparent 42rem),
    var(--canvas);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell { min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 40px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  background: var(--teal);
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  box-shadow: 0 7px 18px rgba(22, 122, 112, .18);
}
.brand-title { display: block; font-size: 15px; font-weight: 700; letter-spacing: .03em; }
.brand-subtitle { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; letter-spacing: .12em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.language-control { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.language-control select {
  min-width: 132px;
  padding: 9px 32px 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
}
.mode-chip, .soft-chip, .status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.mode-chip { color: var(--teal-dark); background: var(--teal-pale); }
.mode-chip::before { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); content: ''; }
.soft-chip { color: #8c6730; background: #f8f0df; }
.status-chip { color: #8a9b96; background: #f0f3ef; }
.status-chip.done { color: var(--teal-dark); background: var(--teal-pale); }

.main-wrap { max-width: 1440px; margin: 0 auto; padding: 14px 40px 72px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 16px 0 26px; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(27px, 3vw, 39px); line-height: 1.25; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 21px; letter-spacing: -.02em; }
h3 { margin-bottom: 6px; font-size: 16px; }
.lede { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 700;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .icon-button:focus-visible, .week-tab:focus-visible, .reading-row:focus-visible { outline: 3px solid rgba(22, 122, 112, .25); outline-offset: 2px; }
.button-primary { color: #fff; background: var(--teal); box-shadow: 0 8px 17px rgba(22, 122, 112, .16); }
.button-primary:hover { background: var(--teal-dark); }
.button-quiet { border-color: var(--line); color: var(--ink); background: #fff; }
.button-soft { color: var(--teal-dark); background: var(--teal-pale); }
.button-small { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.button:disabled { cursor: not-allowed; opacity: .42; transform: none; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card {
  position: relative;
  min-height: 118px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 8px 24px rgba(24, 59, 57, .035);
}
.stat-card::after { position: absolute; right: -15px; bottom: -34px; width: 95px; height: 95px; border-radius: 50%; background: var(--teal-pale); opacity: .75; content: ''; }
.stat-card:nth-child(2)::after { background: #f8eadb; }
.stat-card:nth-child(3)::after { background: #e8edf6; }
.stat-card:nth-child(4)::after { background: #f8f0df; }
.stat-label { position: relative; z-index: 1; color: var(--muted); font-size: 12px; }
.stat-value { position: relative; z-index: 1; display: block; margin-top: 11px; font-size: 31px; font-weight: 700; letter-spacing: -.05em; }
.stat-note { position: relative; z-index: 1; margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; }

.tabs { display: flex; gap: 6px; width: fit-content; padding: 5px; border: 1px solid var(--line); border-radius: 13px; background: #eaf0eb; }
.tab-button { border: 0; border-radius: 9px; padding: 10px 16px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; }
.tab-button[aria-selected="true"] { color: var(--ink); background: #fff; box-shadow: 0 2px 8px rgba(24, 59, 57, .08); }
.teacher-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 26px 0 16px; }
.teacher-toolbar .lede { font-size: 13px; }
.toolbar-actions { display: flex; gap: 9px; }
.panel { border: 1px solid var(--line); border-radius: 19px; background: rgba(255,255,255,.94); box-shadow: 0 8px 24px rgba(24, 59, 57, .035); }
.week-admin-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.week-admin-card { padding: 19px 20px; }
.week-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.week-card-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.week-access-chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 7px 11px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.week-access-chip.released { color: var(--teal-dark); background: var(--teal-pale); }
.week-title-line { display: flex; align-items: center; gap: 10px; }
.week-index { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 11px; color: var(--teal-dark); background: var(--teal-pale); font-size: 12px; font-weight: 700; }
.week-theme { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.reading-admin-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #edf1ed; }
.reading-admin-row:first-of-type { border-top: 0; }
.reading-admin-title { margin: 0; font-size: 13px; font-weight: 600; }
.reading-admin-meta { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.student-links-panel { margin-top: 24px; padding: 21px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-title-row .lede { font-size: 12px; }
.student-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.student-link-row { display: grid; grid-template-columns: minmax(160px, .8fr) minmax(150px, 1fr) auto; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid #edf1ed; border-radius: 12px; background: #fbfcfa; }
.student-name { overflow: hidden; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.student-country { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 500; }
.student-url { overflow: hidden; color: #78908e; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.progress-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.progress-table th, .progress-table td { padding: 10px 9px; border-bottom: 1px solid #edf1ed; text-align: center; font-size: 11px; }
.progress-table th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #f7faf7; font-weight: 700; }
.progress-table th:first-child, .progress-table td:first-child { position: sticky; left: 0; z-index: 2; min-width: 188px; text-align: left; background: #fff; }
.progress-table th:first-child { z-index: 3; background: #f7faf7; }
.progress-table tr:last-child td { border-bottom: 0; }
.progress-student-name { font-size: 12px; font-weight: 700; }
.progress-country { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.progress-cell { display: inline-flex; min-width: 46px; justify-content: center; border-radius: 8px; padding: 6px 7px; color: #788b87; background: #f3f5f2; font-weight: 700; }
.progress-cell.complete { color: var(--teal-dark); background: var(--teal-pale); }
.progress-cell.partial { color: #946f35; background: #fbf3e2; }
.local-note { display: flex; align-items: flex-start; gap: 10px; margin-top: 18px; padding: 13px 15px; border: 1px solid #f0dfbd; border-radius: 13px; color: #796337; background: #fff9eb; font-size: 12px; line-height: 1.65; }
.local-note strong { color: #654d24; }

.student-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 16px 0 24px; }
.student-hero-copy { max-width: 780px; }
.student-progress-card { min-width: 215px; padding: 17px 20px; border: 1px solid #d8e8df; border-radius: 16px; background: rgba(255,255,255,.8); }
.progress-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.progress-number { color: var(--ink); font-size: 22px; font-weight: 700; letter-spacing: -.04em; }
.progress-track { height: 7px; margin-top: 11px; overflow: hidden; border-radius: 999px; background: #e7eeea; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--teal); transition: width .25s ease; }
.week-tabs { display: flex; gap: 8px; margin: 0 0 18px; overflow-x: auto; padding: 1px 0 5px; scrollbar-width: thin; }
.week-tab { flex: 0 0 auto; min-width: 102px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.8); color: var(--muted); text-align: left; }
.week-tab[aria-current="true"] { border-color: #b8dacf; color: var(--teal-dark); background: #e6f3ee; box-shadow: inset 0 0 0 1px #d5ebe3; }
.week-tab:disabled { cursor: not-allowed; opacity: .5; background: #f0f2ef; }
.week-tab-label { display: block; font-size: 12px; font-weight: 700; }
.week-tab-meta { display: block; margin-top: 4px; font-size: 10px; }
.week-intro { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 13px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.75); }
.week-intro-title { margin: 0; font-size: 14px; font-weight: 700; }
.week-intro-sub { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.reader-layout { display: grid; grid-template-columns: 250px minmax(0,1fr); gap: 16px; align-items: start; }
.reading-list { padding: 9px; }
.reading-list-label { margin: 9px 10px 8px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.reading-row { display: grid; grid-template-columns: 31px 1fr auto; align-items: center; gap: 9px; width: 100%; padding: 10px 8px; border: 0; border-radius: 11px; background: transparent; color: var(--ink); text-align: left; }
.reading-row:hover { background: #f6f9f6; }
.reading-row[aria-current="true"] { background: var(--teal-pale); color: var(--teal-dark); }
.reading-row-number { display: grid; width: 29px; height: 29px; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--muted); font-size: 11px; font-weight: 700; }
.reading-row[aria-current="true"] .reading-row-number { border-color: #bfdfd3; color: var(--teal-dark); }
.reading-row-title { overflow: hidden; font-size: 11px; font-weight: 600; line-height: 1.4; text-overflow: ellipsis; }
.reading-check { color: var(--teal); font-size: 14px; font-weight: 700; }
.reading-page { min-width: 0; padding: clamp(24px, 4vw, 48px); }
.reading-page-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.reading-kicker { margin: 0 0 8px; color: var(--teal); font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.reading-page h2 { margin: 0; font-size: clamp(21px, 2.5vw, 29px); line-height: 1.4; }
.reading-page-body { min-height: 330px; padding: 24px 0 25px; color: #304b4e; font-family: 'Yu Gothic UI', 'Yu Gothic', Meiryo, sans-serif; font-size: clamp(18px, 1.8vw, 22px); font-weight: 400; line-height: 2.12; letter-spacing: .018em; white-space: pre-wrap; overflow-wrap: anywhere; }
.reading-page-body ruby { ruby-position: over; }
.reading-page-body rt { color: var(--muted); font-size: .48em; letter-spacing: 0; }
.ruby-toggle { display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; color: var(--muted); font-size: 12px; cursor: pointer; }
.ruby-toggle input { width: 17px; height: 17px; accent-color: var(--teal); }
.reading-support { display: grid; gap: 13px; margin: 0 0 22px; }
.reading-audio-card, .reading-translation, .reading-vocabulary { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfa; }
.support-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reading-support h3 { margin: 0; color: var(--ink); font-size: 14px; }
.reading-voice-player { display: block; width: 100%; margin-top: 12px; }
.support-status { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.translation-content { margin-top: 10px; color: #304b4e; font-size: 14px; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.translation-content p { margin: 0; }
.vocabulary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.vocabulary-card { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.vocabulary-term-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.vocabulary-term-row strong { color: var(--ink); font-size: 17px; }
.vocabulary-reading { color: var(--muted); font-size: 11px; }
.vocabulary-level { margin-left: auto; padding: 2px 6px; border-radius: 99px; color: var(--teal-dark); background: var(--teal-pale); font-size: 9px; font-weight: 800; }
.vocabulary-meaning, .vocabulary-example { margin: 9px 0 0; color: #40595a; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.vocabulary-meaning > span, .vocabulary-example > span { color: var(--muted); font-size: 10px; font-weight: 700; }
.vocabulary-example { padding-top: 8px; border-top: 1px solid #edf1ed; }
.recording-panel { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #f8fbf8; }
.recording-panel .student-audio { width: 100%; }
.recording-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.recording-timer { min-width: 64px; color: var(--coral); font-size: 20px; font-variant-numeric: tabular-nums; font-weight: 700; }
.recording-hint, .recording-note, .recording-error { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.recording-note { color: #8c6730; }
.recording-error { color: #a94731; font-weight: 700; }
.reading-row:disabled { cursor: not-allowed; opacity: .55; }
.reading-page-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding-top: 18px; border-top: 1px solid var(--line); }
.reading-page-nav { display: flex; gap: 8px; }
.reading-done-button { min-width: 168px; }
.reading-done-button.is-done { color: var(--teal-dark); background: var(--teal-pale); box-shadow: none; }
.student-signoff { display: flex; justify-content: space-between; gap: 16px; margin-top: 14px; color: var(--muted); font-size: 10px; }

.empty-state { padding: 46px 24px; text-align: center; }
.empty-state p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.edit-dialog { width: min(760px, calc(100vw - 28px)); max-height: min(90vh, 900px); padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); color: var(--ink); box-shadow: 0 25px 100px rgba(20, 53, 51, .28); }
.edit-dialog::backdrop { background: rgba(20, 45, 43, .32); backdrop-filter: blur(3px); }
.edit-dialog form { padding: 25px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.icon-button { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--muted); font-size: 23px; line-height: 1; }
.field-label { display: block; margin: 15px 0 7px; color: #496467; font-size: 12px; font-weight: 700; }
.text-input, .text-area { display: block; width: 100%; border: 1px solid #d9e4dd; border-radius: 11px; background: #fbfcfa; color: var(--ink); outline: 0; }
.text-input { padding: 11px 13px; }
.text-area { min-height: 300px; padding: 13px; resize: vertical; font-family: 'Yu Gothic UI', 'Yu Gothic', Meiryo, sans-serif; font-size: 14px; line-height: 1.9; }
.text-input:focus, .text-area:focus { border-color: #85bdb1; box-shadow: 0 0 0 3px rgba(22, 122, 112, .1); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 19px; }
.toast { position: fixed; right: 24px; bottom: 22px; z-index: 20; padding: 12px 16px; border-radius: 12px; color: #fff; background: #173f42; box-shadow: 0 10px 30px rgba(16, 54, 54, .24); font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .topbar, .main-wrap { padding-right: 24px; padding-left: 24px; }
  .week-admin-list { grid-template-columns: 1fr; }
  .student-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar { padding-top: 16px; padding-bottom: 14px; }
  .topbar, .main-wrap { padding-right: 16px; padding-left: 16px; }
  .topbar-actions { gap: 8px; }
  .language-control select { min-width: 116px; }
  .brand-subtitle { display: none; }
  .main-wrap { padding-top: 10px; }
  .page-heading, .student-hero { align-items: flex-start; flex-direction: column; }
  .page-heading { margin-top: 10px; }
  .student-progress-card { width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
  .stat-card { min-height: 100px; padding: 14px; }
  .stat-value { font-size: 27px; }
  .teacher-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .button { flex: 1; }
  .student-link-row { grid-template-columns: minmax(0,1fr) auto; }
  .student-url { grid-column: 1 / 2; grid-row: 2; }
  .student-link-row .button { grid-column: 2; grid-row: 1 / 3; }
  .reader-layout { grid-template-columns: 1fr; }
  .reading-list { display: flex; gap: 5px; overflow-x: auto; padding: 8px; }
  .reading-list-label { display: none; }
  .reading-row { flex: 0 0 200px; grid-template-columns: 29px 1fr auto; }
  .reading-page { padding: 22px 18px; }
  .reading-page-body { min-height: 250px; padding-top: 20px; font-size: 18px; }
  .vocabulary-grid { grid-template-columns: 1fr; }
  .reading-audio-card, .reading-translation, .reading-vocabulary { padding: 13px; }
  .reading-page-footer { align-items: stretch; flex-direction: column; }
  .reading-page-nav { justify-content: space-between; }
  .reading-page-nav .button { flex: 1; }
  .reading-done-button { width: 100%; }
  .student-signoff { flex-direction: column; gap: 5px; }
  .tabs { width: 100%; }
  .tab-button { flex: 1; }
  .section-title-row { align-items: flex-start; flex-direction: column; }
  .section-title-row > .button { width: 100%; }
}

@media (max-width: 420px) {
  .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
  .brand-title { font-size: 13px; }
  .language-control { font-size: 10px; }
  .language-control select { min-width: 104px; padding-right: 25px; font-size: 12px; }
  .mode-chip { display: none; }
  .page-heading h1 { font-size: 28px; }
  .week-tab { min-width: 90px; }
  .week-intro { align-items: flex-start; flex-direction: column; }
}
