@charset "UTF-8";

:root {
  color-scheme: light;
  --bg: #f3f1eb;
  --paper: #fffcf5;
  --ink: #343c34;
  --muted: #656d61;
  --line: #d6d9cd;
  --accent: #9e5131;
  --accent-soft: #f3e6d7;
  --sage: #697e5e;
  --sage-soft: #e9eee1;
  --highlight: #f9e8b8;
  --shadow: 0 12px 34px rgb(48 61 38 / 5%);
  --japanese-sans: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  --times: "Times New Roman", Times, "Noto Serif", serif;
  --serif: var(--japanese-sans);
  --ui-sans: "Segoe UI", "Noto Sans JP", "Noto Sans", Arial, sans-serif;
  --sans: var(--ui-sans);
  --overlay: 15 23 15;
  --reading-size: 20px;
  --reading-weight: 550;
}

[lang="ja"] { --serif: var(--japanese-sans); --sans: var(--japanese-sans); --reading-weight: 500; }
[lang="en"], [lang="vi"] { --serif: var(--times); --sans: var(--ui-sans); --reading-weight: 550; }

:root[data-size="small"] { --reading-size: 17px; }
:root[data-size="large"] { --reading-size: 24px; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0f;
  --paper: #191919;
  --ink: #f2f2f2;
  --muted: #b5b5b5;
  --line: #454545;
  --accent: #e0e0e0;
  --accent-soft: #303030;
  --sage: #c4c4c4;
  --sage-soft: #252525;
  --highlight: #343434;
  --shadow: 0 15px 40px rgb(0 0 0 / 28%);
  --overlay: 0 0 0;
}

:root[data-theme="pixel"] {
  --bg: #fff2c7;
  --paper: #fffdf3;
  --ink: #352952;
  --muted: #695275;
  --line: #c39eab;
  --accent: #a73870;
  --accent-soft: #ffe1ee;
  --sage: #386b53;
  --sage-soft: #dcf1c5;
  --highlight: #ffe16f;
  --shadow: 5px 5px 0 #d6b2c0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 120px; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: var(--sans); line-height: 1.6; }
button, input, textarea, select { font: inherit; color: inherit; }
button, select, summary, input[type="radio"] { cursor: pointer; }
a { color: var(--accent); text-underline-offset: .2em; }
button { border: 0; }
button:disabled { cursor: wait; opacity: .62; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.38; }
h1 { font-size: clamp(34px, 4vw, 54px); letter-spacing: -.035em; }
h2 { font-size: clamp(28px, 3vw, 36px); }
h3 { font-size: 26px; }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 4px;
}
.long-text { font-family: var(--serif); font-size: var(--reading-size); font-weight: var(--reading-weight); line-height: 1.95; overflow-wrap: anywhere; }
.long-text p { margin-bottom: 1.25em; }
.muted, .small { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.icon { display: inline-flex; width: 21px; height: 21px; flex: 0 0 auto; align-items: center; justify-content: center; vertical-align: middle; }
.icon svg { width: 100%; height: 100%; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); font-weight: 650; font-size: 20px; text-decoration: none; line-height: 1.3; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .1em; }
.brand-symbol { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); background: var(--sage-soft); border-radius: 11px; color: var(--sage); }
.brand-symbol .icon { width: 24px; height: 24px; }
.button, .text-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; background: transparent; color: var(--ink); text-decoration: none; }
.button { min-height: 45px; padding: 10px 17px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-weight: 650; text-align: center; }
.button:hover { background: var(--sage-soft); }
.button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.button.primary:hover { filter: brightness(1.12); }
.button.accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 8px; flex: 0 0 auto; }
.icon-button:hover { background: var(--sage-soft); }
.text-button { color: var(--accent); padding: 8px 0; font-size: 12px; }
.button-row { display: flex; gap: 11px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.preferences-controls { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.preference { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--muted); }
.preference select { max-width: 180px; min-height: 34px; padding: 5px 22px 5px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--paper); font-size: 12px; }
.source-note { padding: 22px 25px; border: 1px solid var(--line); border-left: 4px solid var(--sage); border-radius: 9px; background: var(--paper); font-size: 13px; line-height: 1.8; }
.source-note p { margin-bottom: 10px; }
.source-note p:not(.source-label):not(.source-links) { font-family: var(--serif); font-size: var(--reading-size); font-weight: var(--reading-weight); line-height: 1.85; }
.source-note p:last-child { margin: 0; }
.source-note .source-label { color: var(--sage); font-size: 11px; font-weight: 700; letter-spacing: .07em; }
.source-note .source-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.source-video { width: 100%; max-width: 480px; aspect-ratio: 16 / 9; margin: 14px 0 18px; overflow: hidden; border-radius: 8px; background: #171717; }
.source-video iframe { display: block; width: 100%; height: 100%; border: 0; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 30px; padding: 6px 11px; font-size: 11px; background: var(--paper); }
.ai-status { color: var(--muted); font-size: 11px; display: inline-flex; align-items: center; gap: 7px; }
.status-dot { width: 7px; height: 7px; background: var(--muted); border-radius: 50%; }
.ai-status.ready .status-dot { background: var(--sage); }
.dialog { width: min(760px, calc(100% - 28px)); max-height: 88vh; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgb(var(--overlay) / 65%); backdrop-filter: blur(4px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 20px 25px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 24px; margin: 0; }
.dialog-body { padding: 25px; }
.selected-quote { border-left: 3px solid var(--accent); padding: 13px 17px; margin: 0 0 20px; background: var(--accent-soft); max-height: 170px; overflow: auto; white-space: pre-wrap; }
.ai-modes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.ai-modes button { padding: 9px 13px; border: 1px solid var(--line); border-radius: 6px; background: transparent; font-size: 12px; }
.ai-modes button.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.ai-result { white-space: pre-wrap; margin-top: 23px; padding-top: 20px; border-top: 1px solid var(--line); }
.ai-result:empty { display: none; }
.ai-result.error { color: var(--accent); }
.selection-button { position: fixed; z-index: 80; max-width: calc(100vw - 24px); padding: 10px 15px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--paper); box-shadow: var(--shadow); font-size: 12px; font-weight: 650; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 150; max-width: min(650px, 90vw); padding: 12px 19px; border: 1px solid var(--line); border-radius: 8px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow); font-size: 12px; text-align: center; }
.toast:empty { display: none; }
.skip-link { position: fixed; top: -100px; left: 20px; z-index: 200; padding: 10px 20px; background: var(--paper); }
.skip-link:focus { top: 10px; }
.page-footer { margin-top: 45px; padding-top: 22px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 15px; font-size: 12px; color: var(--muted); }
.page-footer p { margin: 0; }
.reader-topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px; padding: 19px max(24px, calc((100vw - 1320px) / 2)); border-bottom: 1px solid var(--line); background: var(--paper); }
.reader-workspace { max-width: 1320px; margin: 0 auto; padding: 50px 32px; }
.reader-hero { max-width: 950px; margin-bottom: 30px; }
.reader-hero h1 { margin-bottom: 22px; }
.reader-nav { display: flex; flex-wrap: wrap; gap: 8px; padding: 23px 0; margin: 15px 0 20px; }
.reader-nav a { font-size: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; background: var(--paper); }
.reader-chapter { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: 30px; margin-bottom: 25px; scroll-margin-top: 30px; }
.reader-chapter h2 { margin-bottom: 12px; }
.reader-columns { display: grid; grid-template-columns: 1fr; gap: 24px; }
.reader-columns.compare { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.reader-language { font-size: 11px; color: var(--sage); font-weight: 750; text-transform: uppercase; letter-spacing: .07em; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-top: 15px; }
.reader-segment { position: relative; padding-top: 18px; }
.reader-segment p { margin-bottom: 12px; }
.time-label { font-family: var(--sans); font-size: 11px; font-weight: 650; color: var(--muted); }
.segment-note { font-size: calc(var(--reading-size) * .85); color: var(--muted); background: var(--sage-soft); border-radius: 6px; padding: 11px 14px; font-family: var(--serif); font-weight: var(--reading-weight); }
.lecture-evidence { margin: 24px 0; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--sage-soft); }
.lecture-evidence figcaption { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; font-family: var(--serif); font-size: var(--reading-size); font-weight: 600; line-height: 1.7; }
.lecture-command { margin: 14px 0; padding: 12px 15px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); font-family: "Cascadia Code", Consolas, monospace; font-size: var(--reading-size); font-weight: 550; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.lecture-command code { font: inherit; white-space: inherit; }
.lecture-command:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.lecture-table-scroll { max-width: 100%; overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.lecture-table-scroll:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.lecture-table { width: 100%; min-width: 540px; border-collapse: collapse; text-align: left; font-family: var(--serif); font-size: var(--reading-size); font-weight: var(--reading-weight); line-height: 1.75; }
.lecture-table th, .lecture-table td { padding: 12px 15px; vertical-align: top; overflow-wrap: anywhere; }
.lecture-table th { font-weight: 600; }
.lecture-table th[scope="row"] { width: 34%; }
.lecture-table th[scope="col"] { background: var(--sage-soft); border-bottom: 1px solid var(--line); }
.lecture-table tbody tr + tr th, .lecture-table tbody tr + tr td { border-top: 1px solid var(--line); }
.lecture-table code { font-family: "Cascadia Code", Consolas, monospace; font-size: .92em; font-weight: 550; white-space: pre-wrap; }
.lecture-matrix { min-width: 1000px; table-layout: fixed; }
.lecture-matrix th[scope="row"], .lecture-matrix thead th:first-child { width: 14%; }
.lecture-evidence p:last-child { margin-bottom: 0; }
.back-top { position: fixed; right: 20px; bottom: 20px; background: var(--paper); box-shadow: var(--shadow); }
.pixel-only { display: none; }
:root[data-theme="pixel"] body { background-image: radial-gradient(#dab582 1px, transparent 1px); background-size: 12px 12px; }
:root[data-theme="pixel"] .pixel-only { display: block; }
:root[data-theme="pixel"] .calm-only { display: none; }
:root[data-theme="pixel"] .button, :root[data-theme="pixel"] .brand-symbol, :root[data-theme="pixel"] .reader-chapter, :root[data-theme="pixel"] .source-note, :root[data-theme="pixel"] .dialog { border-radius: 2px; box-shadow: 4px 4px 0 var(--line); }
:root[data-theme="pixel"] .button:hover { transform: translate(-1px, -1px); }
@media (max-width: 760px) {
  .reader-workspace { padding: 30px 17px; }
  .reader-topbar { padding: 16px 18px; }
  .reader-columns.compare { grid-template-columns: 1fr; }
  .reader-chapter { padding: 22px 19px; }
  .reader-hero .button-row .button { flex: 1 1 160px; }
  .dialog-body, .dialog-head { padding: 19px; }
  .preference select { max-width: 145px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
@media print { .preferences-controls, .button-row, .reader-nav, .back-top, .selection-button, .toast { display: none !important; } body { background: white; color: black; } .reader-chapter { box-shadow: none; break-inside: auto; } }
/* Selectable workflow diagrams in all three themes. */
.learning-diagram { margin: 24px 0; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--sage-soft); }
.learning-diagram figcaption { font-weight: 700; margin-bottom: 18px; }
.diagram-steps { display: grid; grid-template-columns: repeat(var(--step-count), minmax(0, 1fr)); gap: 26px; list-style: none; padding: 0; margin: 0; }
.diagram-steps li { position: relative; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); overflow-wrap: anywhere; }
.diagram-index { display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 9px; background: var(--sage); color: var(--paper); border-radius: 50%; font-family: var(--sans); font-weight: 750; }
.diagram-steps strong { display: block; }
.diagram-steps p { margin: 9px 0 0; font-size: .9em; line-height: 1.7; }
.diagram-steps li:not(:last-child)::after { content: '→'; position: absolute; right: -24px; top: 22px; color: var(--ink); font-family: var(--sans); }
.source-details { margin: 14px 0; }
.source-details summary { cursor: pointer; font-weight: 650; margin-bottom: 10px; }
:root[data-theme="pixel"] .learning-diagram, :root[data-theme="pixel"] .diagram-steps li { border-radius: 2px; box-shadow: 3px 3px 0 var(--line); }
:root[data-theme="pixel"] .diagram-index { border-radius: 2px; }
@media (max-width: 1050px) {
  .diagram-steps { grid-template-columns: 1fr; }
  .diagram-steps li:not(:last-child)::after { content: '↓'; right: auto; left: 22px; top: auto; bottom: -25px; }
}
@media print { .source-video { display: none; } .learning-diagram { break-inside: avoid; } }
.input-guide, .quick-reference, .reference-details { margin: 22px 0; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--sage-soft); }
.input-guide summary, .reference-details summary, .exercise-answer summary { font-weight: 650; }
.input-guide dt { font-weight: 650; margin-top: 14px; }
.input-guide dd { margin: 5px 0 0; }
.input-guide p { margin-top: 16px; }
.quick-reference h3 { font-size: var(--reading-size); }
.quick-reference ul, .exercise-answer ul { padding-left: 1.4em; }
.exercise-answer { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.example-answer { white-space: pre-line; margin-top: 16px; }
.lesson-article code { font-family: "Cascadia Code", Consolas, monospace; font-size: .9em; background: var(--sage-soft); padding: .1em .25em; border-radius: 3px; overflow-wrap: anywhere; }
.lesson-article > p[id], .lecture-evidence[id] { scroll-margin-top: 120px; }
.lesson-article > p[id]:focus, .lecture-evidence[id]:focus { outline: 2px solid var(--accent); outline-offset: 5px; }
:root[data-theme="pixel"] .input-guide, :root[data-theme="pixel"] .quick-reference, :root[data-theme="pixel"] .reference-details { border-radius: 2px; }
