:root {
  color-scheme: light;
  --paper: #fffefa;
  --white: #fff;
  --surround: #e9edf2;
  --masthead: #182d49;
  --brass: #c9a677;
  --ink: #202b3b;
  --muted: #515e70;
  --faint: #d8dde4;
  --rule: #939eae;
  --navy: #203e62;
  --wash: #edf2f8;
  --ochre: #86472c;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif CJK JP", serif;
  --gutter: clamp(18px, 6vw, 36px);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--surround);
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p, fieldset, legend { margin: 0; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button, input, select, a, summary { -webkit-tap-highlight-color: transparent; }
button, summary { cursor: pointer; }
a { color: inherit; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }
h1:focus { outline: none; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.frame { max-width: 690px; margin-inline: auto; padding-inline: var(--gutter); }
.masthead { background: var(--masthead); border-bottom: 2px solid var(--brass); }
.masthead-inner {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: env(safe-area-inset-top);
}
main.frame {
  min-height: calc(100vh - 116px);
  background: var(--paper);
}
.masthead :focus-visible { outline-color: var(--brass); }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .04em;
  text-decoration: none;
}
.brand-icon { flex: 0 0 32px; object-fit: contain; }
.audience { color: #d7e0ed; font-size: 12px; }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--paper); }
.steps a {
  display: grid;
  place-items: center;
  position: relative;
  min-height: 45px;
  border-bottom: 1px solid var(--faint);
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.steps a[aria-current] { color: var(--navy); font-weight: 700; background: var(--wash); }
.steps a[aria-current]::after { content: ""; position: absolute; bottom: -1px; inset-inline: 16%; height: 3px; background: currentColor; }
.screen { padding-block: 30px max(36px, env(safe-area-inset-bottom)); }
h1, h2, .round-name { font-family: var(--serif); font-weight: 600; }
h1 { font-size: clamp(27px, 7.2vw, 36px); line-height: 1.45; letter-spacing: .025em; }
h2 { font-size: 20px; line-height: 1.55; letter-spacing: .02em; }
.intro { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 3px double var(--rule); }
.sheet-subject { color: var(--navy); font-size: 12px; font-weight: 600; letter-spacing: .07em; }
.intro > p:last-child { color: var(--muted); margin-top: 7px; font-size: 14px; line-height: 1.7; }
.panel { min-width: 0; margin: 0; padding: 0; border: 0; background: transparent; }
.guide, .revision-note { padding: 16px; background: var(--wash); border-left: 3px solid var(--navy); }
.guide { margin-block: 18px; }
.guide p, .guide li, .backup-dialog p, .backup-dialog li, .revision-note p, .revision-note li, .notice p, .notice li {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.75;
}
.guide ol, .backup-dialog ul, .notice ul, .revision-note ul { padding-inline-start: 1.45em; margin-block: 6px 0; }
.guide-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.guide-actions .button { flex: 1 1 148px; padding-inline: 10px; }
.notice { padding: 15px 16px; background: #faf0e8; border-left: 2px solid var(--ochre); overflow-wrap: anywhere; }
.revision-note { margin-block: 16px; }
.revision-note li span, .revision-note li strong { display: block; }
.input-callout { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 46px; margin-bottom: 18px; color: var(--navy); font-size: 14px; text-decoration: none; }
.input-callout strong { text-decoration: underline; text-underline-offset: 4px; }
.callout-chevron { font-family: Georgia, serif; font-size: 24px; }
.fields { padding-block: 20px; border-top: 1px solid var(--rule); }
.fields > h2 { color: var(--navy); }
.field-label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
input, select {
  display: block;
  width: 100%;
  min-width: 0;
  height: 45px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--white);
  color: var(--ink);
  padding: 6px 9px;
  font-variant-numeric: tabular-nums;
}
input::placeholder { color: var(--muted); opacity: 1; font-size: 13px; }
input:focus, select:focus { border-color: var(--navy); }
.field-hint { margin: 4px 0 10px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.score-group, .step2-fields { border: 0; padding: 0; min-width: 0; }
.score-group { margin-block: 14px; }
.score-group legend { padding: 0; margin-bottom: 4px; font-size: 14px; font-weight: 650; }
.score-grid, .mistake-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.score-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.score-grid label, .mistake label { min-width: 0; font-size: 12px; color: var(--muted); }
.score-grid input, .mistake label input { margin-top: 4px; padding-inline: 6px; }
.mistake { padding: 9px 11px 12px; margin: 12px 0; border: 1px solid var(--faint); min-width: 0; }
.mistake legend { padding-inline: 4px; font-size: 13px; font-weight: 600; }
.mistake-top { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; margin-bottom: 8px; }
.remove-row { min-height: 44px; padding: 0 9px; border: 0; background: none; color: var(--navy); font-size: 13px; text-decoration: underline; }
.daimon { background: #f3f5f8; }
.shomon { background: var(--paper); }
.check-label { display: flex; align-items: center; gap: 9px; min-height: 44px; margin-top: 6px; font-size: 14px; }
.check-label input { width: 19px; height: 19px; flex: 0 0 19px; margin: 0; accent-color: var(--navy); }
.step2-fields, .optional-scores { border-top: 1px solid var(--faint); padding-top: 7px; }
.actions { display: grid; gap: 8px; margin-top: 18px; }
.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  width: 100%;
  border-radius: 3px;
  padding: 10px 28px;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.primary { background: var(--navy); color: var(--white); border: 1px solid var(--navy); }
.primary:hover { background: #162f50; }
.secondary { background: var(--paper); color: var(--navy); border: 1px solid #939eae; }
.secondary:hover { background: var(--wash); }
.arrow { position: absolute; right: 15px; font-size: 18px; }
.text-link { display: flex; justify-content: center; align-items: center; min-height: 44px; color: var(--navy); font-size: 14px; text-underline-offset: 4px; }
.preview-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 10px;
  row-gap: 3px;
  padding-bottom: 12px;
  border-bottom: 3px double var(--rule);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.round-name { color: var(--ink); font-size: 14px; }
.example-badge { margin-left: auto; font-size: 11px; white-space: nowrap; }
.result-hero { padding-block: 24px; }
.score-reading { margin: 0 0 16px; }
.gain { display: flex; align-items: baseline; gap: 2px; color: var(--ochre); font: 500 clamp(64px, 18vw, 84px)/1.08 Georgia, "Times New Roman", serif; letter-spacing: -.045em; font-variant-numeric: lining-nums; }
.gain span { font-family: var(--serif); font-size: .40em; letter-spacing: -.1em; }
.gain small { font-family: var(--serif); font-size: 21px; margin-left: 4px; letter-spacing: 0; }
.pickup-numbers, .child-pickup { color: var(--muted); font-size: 14px; line-height: 1.8; font-variant-numeric: tabular-nums; }
.pickup-numbers { margin-top: 4px; }
.pickup-numbers > span, .child-pickup > span { display: inline-block; }
.pickup-numbers strong, .child-pickup strong { color: var(--ink); font-size: 16px; font-weight: 600; }
.score-arrow { margin-inline: 3px; color: var(--muted); }
.jump-to-week {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  min-height: 52px;
  padding: 13px 16px;
  gap: 4px 12px;
  border: 0;
  border-left: 3px solid var(--navy);
  background: var(--wash);
  color: var(--navy);
  text-align: left;
}
.jump-to-week:hover { background: #e0e9f5; }
.jump-label { font-size: 13px; font-weight: 650; align-self: center; }
.jump-to-week strong { grid-column: 1; font-family: var(--serif); font-size: 20px; line-height: 1.5; overflow-wrap: anywhere; }
.jump-arrow { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 21px; }
.summary-panel { padding: 20px 0; border-top: 1px solid var(--faint); }
.karte-section.greeting { padding: 0 0 19px; border-top: 0; }
.karte-section.greeting p:first-child { color: var(--ink); margin-bottom: 5px; }
.karte-section.mismatch { margin: 2px 0 18px; padding: 14px; border-top: 0; }
.karte-section .karte-line, .data-details p, .summary-panel > p { color: #38465a; font-size: 14px; line-height: 1.85; overflow-wrap: anywhere; }
.karte-section h2 + .karte-line, .summary-panel h2 + p { margin-top: 6px; }
.karte-line + .karte-line { margin-top: 4px; }
.greeting .karte-line + .karte-line { margin-top: 0; }
.karte-section.this_week { border-top: 2px solid var(--navy); }
.this_week h2 { color: var(--navy); scroll-margin-top: 18px; }
.week-lines { margin: 10px 0 0; padding-inline-start: 1.2em; }
.week-lines li::marker { color: var(--navy); }
.data-details { font-size: 14px; }
.karte-section .data-details { margin-top: 8px; }
.data-details summary, .optional-scores summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--navy);
  font-weight: 600;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
.data-details summary::after, .optional-scores summary::after {
  content: "";
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  margin: 0 4px 4px auto;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
details[open] > summary::after { transform: rotate(225deg); margin-bottom: -4px; }
.delta { border-block: 1px solid var(--faint); }
.delta[open] { padding-bottom: 12px; }
.basis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
.basis-grid > div { border-left: 1px solid var(--rule); padding-left: 10px; }
.basis-grid dt { color: var(--muted); font-size: 12px; }
.basis-grid dd { margin: 2px 0 0; font-size: 20px; font-weight: 600; }
.review-row { border-top: 1px solid var(--faint); }
.review-row summary { padding: 4px 8px; }
.review-row summary::after { margin-left: 0; }
.review-row strong { font-weight: 600; }
.question-count { margin-left: auto; white-space: nowrap; font-size: 13px; }
.problem-list { list-style: none; margin: 0; padding: 0 8px 8px; }
.problem-list li { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 10px; padding-block: 2px; font-size: 13px; overflow-wrap: anywhere; }
.problem-list li span, .review-row .empty-problems { color: var(--muted); }
.review-row .empty-problems { padding: 0 8px 8px; font-size: 13px; }
.trend { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.trend th, .trend td { padding: 6px 3px; border-bottom: 1px solid var(--faint); text-align: right; }
.trend th:first-child { text-align: left; }
.trend thead th { color: var(--muted); font-size: 12px; }

.child-sheet { padding-top: 24px; }
.child-hero h1 { margin: 2px 0 8px; font-size: clamp(29px, 8.5vw, 42px); }
.child-hero h1 span { color: var(--navy); font: 500 1.3em/1 Georgia, serif; margin-inline: .05em; }
.child-work > p { color: #38465a; font-size: 15px; line-height: 1.75; }
.child-checks { margin-top: 16px; border-top: 2px solid var(--navy); background: var(--wash); }
.child-checks label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 57px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--faint);
  cursor: pointer;
  overflow-wrap: anywhere;
}
.child-checks input { opacity: 0; position: absolute; inset: 0; height: 100%; margin: 0; cursor: pointer; }
.child-checks strong { font-size: 19px; font-weight: 600; }
.check-box { flex: 0 0 22px; height: 22px; display: grid; place-items: center; border: 1.5px solid var(--navy); border-radius: 2px; }
.child-checks input:checked + .check-box { background: var(--navy); color: var(--white); }
.child-checks input:checked + .check-box::after { content: "✓"; font-size: 16px; }
.child-checks input:checked ~ strong { color: var(--muted); text-decoration: line-through; }
.child-checks input:focus-visible + .check-box { outline: 2px solid var(--navy); outline-offset: 4px; }
.teacher-question { margin-top: 24px; }
.teacher-question h2, .child-score h2 { font: 600 13px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif; color: var(--navy); }
.teacher-question .karte-line { margin-top: 5px; font-family: var(--serif); font-size: 18px; line-height: 1.75; overflow-wrap: anywhere; }
.child-score { padding: 13px 0; margin-top: 22px; border-top: 1px solid var(--rule); }
.child-score p { font-size: 14px; line-height: 1.7; }
.child-note { display: flex; flex-wrap: wrap; gap: 0 14px; align-items: baseline; padding-block: 11px; border-block: 1px solid var(--faint); color: var(--ink); font-size: 14px; }
.child-note span { color: var(--muted); font-size: 12px; }
.history-list { display: grid; margin: 0; padding: 0; list-style: none; }
.history-item { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-block: 16px; border-top: 1px solid var(--rule); }
.history-item h2 { grid-column: 1 / -1; color: var(--navy); }
.history-item .button { padding-inline: 8px; }
.history-item .remove-history { grid-column: 1 / -1; justify-self: end; }
.backup-status, .backup-errors { color: #853f28; }
.backup-dialog {
  width: min(440px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  padding: 18px;
  margin: auto;
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: auto;
  color: var(--ink);
  background: var(--paper);
}
.backup-dialog::backdrop { background: #182d497d; }
.backup-dialog .data-details, #backup-conflicts { margin-top: 12px; }
.backup-dialog .data-details .button, #backup-cancel { margin-top: 9px; }
.backup-dialog li { overflow-wrap: anywhere; }
#backup-file-summary:empty { display: none; }
@media (max-width: 355px) {
  :root { --gutter: 16px; }
  .preview-line { column-gap: 7px; }
  .score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mistake { padding-inline: 8px; }
}
@media print {
  :root { color-scheme: light; background: white; --paper: white; --ink: black; --navy: #222; --faint: #bbb; --rule: #888; }
  body.child-view :is(.masthead, .steps, .child-actions) { display: none; }
  body.child-view main { max-width: none; min-height: 0; padding: 0; }
  #child { padding-block: 0; }
  #child-content { max-width: 155mm; margin: 8mm auto 0; break-inside: avoid; }
  .child-sheet { padding-top: 8mm; }
  .child-hero h1 { font-size: 30pt; }
  .child-checks label { min-height: 15mm; }
  .teacher-question { margin-block: 8mm; }
  .check-box { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
