:root {
  --background: #f6f7f3;
  --surface: #ffffff;
  --text: #19332d;
  --accent: #234e45;
  --muted: #56635e;
  --border: #d5ddd7;
  --navigation-height: 4.5rem;
  font-family: system-ui, sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.page {
  max-width: 48rem;
  margin-inline: auto;
  padding: 2rem 1rem calc(var(--navigation-height) + env(safe-area-inset-bottom) + 2rem);
}
h1 { font-size: clamp(1.5rem, 6vw, 2.25rem); line-height: 1.25; }
.bottom-navigation {
  position: fixed;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: var(--navigation-height);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.bottom-navigation > * {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--navigation-height);
  padding: 0.5rem 0.25rem;
  font-size: 0.875rem;
  text-decoration: none;
}
.bottom-navigation [aria-current="page"] { font-weight: 700; border-top: 3px solid var(--accent); }
.bottom-navigation [aria-disabled="true"] { color: var(--muted); }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0.5rem 0;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--button-background);
  border-radius: 0.7rem;
  background: var(--button-background);
  color: #ffffff;
  font: inherit;
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
  max-width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.flash { padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: 0.5rem; background: var(--surface); }
.avatar-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin: 1rem 0; padding: 0; border: 0; }
.option-list { display: grid; gap: 0.5rem; margin: 1rem 0; padding: 0; border: 0; }
.option-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}
.avatar-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}
.user-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.field { display: grid; gap: 0.25rem; margin: 0.75rem 0; }
.field-check { display: flex; align-items: center; gap: 0.5rem; }
.field input:not([type="checkbox"]), .field textarea, .field select {
  min-height: 44px;
  padding: 0.5rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}
.field select { width: 100%; min-width: 0; }
.list { padding-left: 1.25rem; }
.paragraph-muted { color: var(--muted); }
.list > li { margin: 0.5rem 0; }
.skip-link { position: fixed; top: -5rem; left: 1rem; padding: 1rem; background: var(--surface); }
.skip-link:focus { top: 1rem; }
.subject-cards { display: grid; gap: 1rem; }
.subject-card { padding: 1rem; border: 1px solid var(--border); border-radius: 0.75rem; background: var(--surface); min-width: 0; }
.subject-card h3 { margin-top: 0; }
.subject-card progress { width: 100%; accent-color: var(--accent); }
.chart { position: relative; height: 18rem; min-width: 0; margin-block: 1rem; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.table-scroll th, .table-scroll td { padding: 0.5rem; text-align: left; }
details > summary { min-height: 44px; padding-block: 0.75rem; cursor: pointer; }
.ranking-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ranking-tabs [aria-current="page"] { box-shadow: inset 0 0 0 2px #ffffff; }
.ranking-list { padding-left: 1.5rem; }
.ranking-list li { padding: 0.5rem; overflow-wrap: anywhere; }
.ranking-list strong { margin-left: 1rem; }
.site-footer { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; }
.tooltip { display: inline-flex; vertical-align: middle; }
.tooltip-button { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0.5rem; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--accent); font: inherit; cursor: pointer; }
.tooltip-panel { position: fixed; z-index: 20; width: 18rem; max-width: calc(100vw - 2rem); max-height: calc(100dvh - 2rem); overflow: auto; padding: 0.75rem; border: 1px solid var(--border); border-radius: 0.5rem; background: var(--surface); color: var(--text); font-size: 0.9375rem; font-weight: normal; line-height: 1.5; box-shadow: 0 0.25rem 1rem #19332d26; }
.page-updated, #terms-contact { overflow-wrap: anywhere; }
.analytics-widget { padding-block: 1rem; border-bottom: 1px solid var(--border); }

/* Shared appearance tokens: every screen, form and tooltip uses the same theme. */
:root {
  color-scheme: light;
  --background: #f3f5fc;
  --surface: #ffffff;
  --surface-raised: #eef1fb;
  --text: #202b45;
  --muted: #5c6780;
  --accent: #234e45;
  --accent-soft: #e6f2ec;
  --button-background: #234e45;
  --on-accent: #ffffff;
  --success: #167354;
  --success-soft: #e7f5ee;
  --warning: #174236;
  --warning-soft: #e3eee8;
  --danger: #b9384b;
  --danger-soft: #fff0f2;
  --border: #d8deed;
  --shadow: 0 5px 22px #26345b0a;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #111827;
  --surface: #1b2538;
  --surface-raised: #263249;
  --text: #edf0fa;
  --muted: #b2bed4;
  --accent: #a0d8bd;
  --accent-soft: #233f37;
  --button-background: #285e4e;
  --on-accent: #142b23;
  --success: #79d7ae;
  --success-soft: #1b3b36;
  --warning: #76b49a;
  --warning-soft: #1c352b;
  --danger: #ffa4b1;
  --danger-soft: #3c2835;
  --border: #39465e;
  --shadow: 0 5px 22px #00000019;
}
body { color: var(--text); background: var(--background); line-height: 1.55; }
.page { max-width: 64rem; padding-top: 1.5rem; }
h1 { letter-spacing: -0.035em; margin: 0 0 1.25rem; }
h2 { font-size: 1.25rem; letter-spacing: -0.02em; margin-top: 1.5rem; }
h3 { font-size: 1.0625rem; }
p { overflow-wrap: anywhere; }
a { text-underline-offset: 0.2em; }
button, input, select, textarea { color: var(--text); accent-color: var(--accent); }
.field input:not([type="checkbox"]), .field textarea, .field select { background: var(--surface); color: var(--text); width: 100%; min-width: 0; border-color: var(--border); border-radius: 0.65rem; padding: 0.65rem 0.8rem; }
.field label, legend, .settings dt { font-weight: 650; }
.field-check { align-items: flex-start; margin-block: 0.75rem; }
.field-check input { flex: 0 0 auto; margin-top: 0.4rem; }
.flash { border-left: 4px solid var(--success); background: var(--success-soft); }
.flash-alert { border-left-color: var(--danger); background: var(--danger-soft); }
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0; }
.header-inner { max-width: 64rem; margin-inline: auto; padding: 0.9rem 1rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.65rem 1rem; align-items: center; width: 100%; }
.brand { display: flex; align-items: center; gap: 0.65rem; font-size: 0.95rem; font-weight: 750; color: var(--text); text-decoration: none; line-height: 1.2; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: 0 0 auto; border-radius: 0.75rem; background: var(--accent); color: var(--on-accent); font-size: 1.5rem; font-weight: 800; }
.theme-picker { display: grid; gap: 0.15rem; }
.theme-picker label { font-size: 0.7rem; font-weight: 650; color: var(--muted); }
.theme-picker select { font: inherit; font-size: 0.8rem; min-height: 44px; width: 9.5rem; max-width: 100%; border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.3rem 0.45rem; background: var(--surface); }
.header-user { grid-column: 1 / -1; display: flex; gap: 0.5rem; align-items: center; min-width: 0; }
.profile-chip { display: flex; gap: 0.5rem; align-items: center; min-width: 0; font-size: 0.85rem; color: var(--muted); }
.bottom-navigation { z-index: 10; box-shadow: 0 -4px 20px #11182708; }
.bottom-navigation > a { flex-direction: column; gap: 0.1rem; color: var(--muted); font-weight: 550; }
.bottom-navigation [aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.navigation-icon { font-size: 1.3rem; line-height: 1.1; }
.site-footer { color: var(--muted); font-size: 0.875rem; }
.site-footer a { color: var(--muted); }
.landing-lead { font-size: 1.5rem; font-weight: 650; line-height: 1.35; color: var(--accent); max-width: 30rem; }
.settings-grid, .subject-cards { display: grid; gap: 1rem; }
.settings-panel, .subject-card, .activity-panel, .continue-panel, .analytics-widget, .catalog-list > li {
  padding: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; box-shadow: var(--shadow); min-width: 0;
}
.settings-panel > h2:first-child, .analytics-widget > h2:first-child { margin-top: 0; }
.settings { margin: 0; }
.settings dt { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.8rem; }
.settings dd { margin: 0.2rem 0 1rem; overflow-wrap: anywhere; }
.settings-panel + .settings-panel { margin-top: 0; }
.learning-panel { border-top: 4px solid var(--warning); }
.communication-panel { border-top: 4px solid var(--accent); }
.danger-panel { border-color: var(--danger); background: var(--danger-soft); }
.danger-panel h2 { color: var(--danger); }
.account-panel .button_to { display: inline-block; margin-right: 0.5rem; }
.activity-panel { display: flex; flex-wrap: wrap; gap: 0.35rem 1.5rem; align-items: baseline; margin-bottom: 1rem; }
.activity-panel h2 { width: 100%; margin: 0; font-size: 0.85rem; color: var(--muted); }
.activity-panel p { margin: 0; }
.activity-panel [data-streak] { font-weight: 750; color: var(--success); }
.continue-panel { background: var(--accent-soft); border-color: var(--accent); margin-block: 1rem 1.75rem; }
.continue-panel h2 { font-size: 1.6rem; margin: 0.25rem 0; }
.eyebrow { color: var(--accent); font-size: 0.8rem; font-weight: 750; margin: 0; }
.subject-card { border-top: 4px solid var(--accent); }
.subject-card:nth-child(3n+2) { border-top-color: var(--success); }
.subject-card:nth-child(3n) { border-top-color: var(--warning); }
.subject-card p { margin: 0.6rem 0; }
.subject-card progress { display: block; height: 0.65rem; border: 0; border-radius: 1rem; background: var(--surface-raised); overflow: hidden; }
.subject-card progress::-webkit-progress-bar { background: var(--surface-raised); }
.subject-card progress::-webkit-progress-value { background: var(--success); border-radius: 1rem; }
.subject-card progress::-moz-progress-bar { background: var(--success); border-radius: 1rem; }
.catalog-list { padding: 0; list-style: none; display: grid; gap: 1rem; }
.catalog-list > li { display: flex; flex-direction: column; gap: 0.4rem; margin: 0; border-left: 4px solid var(--accent); }
.catalog-list > li > a:first-child { font-size: 1.1rem; font-weight: 700; }
.catalog-list > li > span { color: var(--muted); font-size: 0.85rem; }
.achievement-list { padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; list-style: none; }
.achievement-list li { padding: 0.6rem 0.8rem; border: 1px solid var(--border); background: var(--warning-soft); border-radius: 0.75rem; }
.achievement-list time { display: block; color: var(--muted); font-size: 0.75rem; }
.bell-link { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; font-size: 1.3rem; text-decoration: none; }
.bell-badge { position: absolute; top: 0; right: 0; min-width: 1.25rem; height: 1.25rem; padding: 0 0.3rem; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 0.75rem; line-height: 1.25rem; text-align: center; }
.notice-list { list-style: none; padding: 0; display: grid; gap: 0.75rem; }
.notice { padding: 0.75rem; border: 1px solid var(--border); border-radius: 0.75rem; background: var(--surface); }
.notice-unread { border-color: var(--accent); }
.notice-new { font-size: 0.75rem; color: var(--accent); font-weight: 750; }
.achievement-list li > span { font-size: 1.4em; }
.achievement-icons .tooltip-button { width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 1.4rem; }
.option-list label:has(input:checked), .avatar-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.table-scroll { border: 1px solid var(--border); border-radius: 0.7rem; }
.table-scroll table { border-collapse: collapse; width: 100%; }
.table-scroll th { background: var(--surface-raised); }
.table-scroll td, .table-scroll th { border-bottom: 1px solid var(--border); }
.analytics-widget { margin-block: 1rem; }
.section-heading, .action-with-hint { display: flex; gap: 0.35rem; align-items: center; }
.section-heading > h1, .section-heading > h2, .section-heading > h3 { min-width: 0; }
.section-heading > .tooltip, .action-with-hint > .tooltip { flex: 0 0 auto; }
.action-with-hint > form { min-width: 0; }
.tooltip { margin-inline: 0.3rem; align-items: center; line-height: 1; }
.tooltip-button { position: relative; min-width: 24px; min-height: 24px; width: 24px; height: 24px; padding: 0; font-size: 0.75rem; font-weight: 750; background: var(--accent-soft); color: var(--accent); border-color: var(--border); }
.tooltip-button::after { content: ""; position: absolute; inset: -10px; }
.tooltip-panel { background: var(--surface); border-color: var(--accent); line-height: 1.55; box-shadow: 0 8px 32px #00000026; }
.skip-link { z-index: 40; }
@media (min-width: 48rem) {
  .settings-grid, .subject-cards, .catalog-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .learning-panel, .danger-panel, .account-panel { grid-column: 1 / -1; }
  .header-inner { grid-template-columns: minmax(0, 1fr) auto auto; }
  .header-user { grid-column: 2; grid-row: 1; }
  .theme-picker { grid-column: 3; grid-row: 1; }
  .page { padding-top: 2rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .button { transition: background-color 120ms ease, border-color 120ms ease; }
}

.report-with-hint { align-items: flex-start; }
.report-with-hint > .report { min-width: 0; flex: 1; }
.report-with-hint > .tooltip { margin-top: 0.85rem; }

.paragraph-status { display: inline-flex; align-items: center; gap: 0.35rem; max-width: 100%; padding: 0.2rem 0.55rem; border-radius: 0.5rem; font-size: 0.875rem; vertical-align: middle; color: var(--muted); background: var(--surface-raised); }
.paragraph-status-icon { flex: 0 0 auto; font-size: 1.15rem; font-weight: 750; line-height: 1; }
.paragraph-status-mastered { color: var(--success); background: var(--success-soft); }
.paragraph-status-read { color: var(--accent); background: var(--accent-soft); }

/* Long navigation labels must reflow when text is enlarged to 200%. */
.bottom-navigation > * { min-width: 0; overflow-wrap: anywhere; text-align: center; }
h1, h2, h3, .brand { overflow-wrap: anywhere; }
