@import url('https://fonts.googleapis.com/css2?family=BIZ+UDPGothic:wght@400;700&family=Klee+One:wght@600&family=Shippori+Mincho+B1:wght@600;800&family=IBM+Plex+Mono:wght@500&display=swap');

/* Tokens: a graph-paper notebook in cool grey, indigo ink, and vermilion reserved for corrections. */
:root {
  --paper: #eef1f4;
  --sheet: #fafbfc;
  --grid: #dbe1e8;
  --ink: #1f2a44;
  --ink-2: #56607a;
  --line: #c7cfda;
  --shu: #d2452b;
  --shu-soft: #f8e3dd;
  --ok: #2f7d5b;
  --focus: #3d5fd9;
  --display: 'Shippori Mincho B1', 'Yu Mincho', serif;
  --body: 'BIZ UDPGothic', 'Yu Gothic UI', 'Hiragino Sans', sans-serif;
  --pen: 'Klee One', 'Yu Kyokasho', cursive;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12161d; --sheet: #191e27; --grid: #222a36; --ink: #e3e8f1; --ink-2: #9aa5ba;
    --line: #34404f; --shu: #ff7c5e; --shu-soft: #3a211c; --ok: #6cc59a; --focus: #8ea6ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12161d; --sheet: #191e27; --grid: #222a36; --ink: #e3e8f1; --ink-2: #9aa5ba;
  --line: #34404f; --shu: #ff7c5e; --shu-soft: #3a211c; --ok: #6cc59a; --focus: #8ea6ff; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font: 400 16px/1.75 var(--body);
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; background-position: -1px -1px;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px 96px; }

/* Masthead */
.mast { display: flex; align-items: center; gap: 12px; padding: 18px 0 14px; }
.mark { font: 800 22px/1 var(--display); letter-spacing: .02em; text-decoration: none; display: flex; align-items: baseline; gap: 2px; }
.mark i { font-style: normal; color: var(--shu); font-family: var(--pen); font-weight: 600; font-size: 20px; }
.mast .spacer { flex: 1; }
.streak { display: flex; gap: 3px; align-items: center; }
.streak span { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--line); background: var(--sheet); }
.streak span.on { background: var(--shu); border-color: var(--shu); }
.streak span.today { outline: 1px solid var(--ink-2); outline-offset: 1px; }
.navlink { font-size: 14px; text-decoration: none; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--sheet); white-space: nowrap; }

/* Sheets */
.sheet { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin: 14px 0; }
.eyebrow { font: 500 12px/1.4 var(--mono); color: var(--ink-2); letter-spacing: .04em; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.35; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 16px; font-family: var(--body); font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
p { margin: .4em 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 18px; border-radius: var(--r);
  border: 1px solid var(--ink); background: var(--ink); color: var(--sheet); font-weight: 700; cursor: pointer; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.shu { background: var(--shu); border-color: var(--shu); color: #fff; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.textbtn { background: none; border: 0; padding: 6px 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; font-size: 14px; }

/* Notebook list */
.entry { display: grid; grid-template-columns: 58px 1fr; gap: 14px; text-decoration: none; padding: 16px 0; border-top: 1px dashed var(--line); }
.entry:first-child { border-top: 0; }
.entry .date { font: 500 13px/1.3 var(--mono); color: var(--ink-2); text-align: right; padding-top: 3px; }
.entry .date b { display: block; font-size: 18px; color: var(--ink); }
.entry .title { font-weight: 700; }
.entry .sum { color: var(--ink-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chip { display: inline-block; font-size: 12px; line-height: 1; padding: 5px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); background: var(--sheet); }
.chip.go { border-color: var(--ink); color: var(--ink); font-weight: 700; }
.chip.wait { border-style: dashed; }
.chip.err { border-color: var(--shu); color: var(--shu); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* Pipeline (real session progress) */
.pipe { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 14px 0 4px; }
.pipe div { position: relative; padding-top: 16px; font-size: 13px; color: var(--ink-2); }
.pipe div::before { content: ''; position: absolute; top: 5px; left: 0; right: 0; height: 2px; background: var(--line); }
.pipe div::after { content: ''; position: absolute; top: 0; left: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--sheet); border: 2px solid var(--line); }
.pipe div.done { color: var(--ink); }
.pipe div.done::before, .pipe div.done::after { background: var(--ink); border-color: var(--ink); }
.pipe div.now { color: var(--ink); font-weight: 700; }
.pipe div.now::after { border-color: var(--ink); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ink) 15%, transparent); } }

/* Scenes */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-top: 18px; }
.tab { flex: none; border: 1px solid var(--line); background: var(--sheet); border-radius: var(--r) var(--r) 0 0; padding: 8px 14px; cursor: pointer; font-size: 14px; border-bottom-color: transparent; }
.tab[aria-selected="true"] { border-color: var(--ink); font-weight: 700; }
.tab small { font-family: var(--mono); color: var(--ink-2); margin-right: 6px; }
.scene { border-top-left-radius: 0; margin-top: -1px; }
.quote { margin: 14px 0; padding: 4px 0 4px 14px; border-left: 3px solid var(--ink); font-size: 17px; }
.quote p { margin: 0 0 6px; }
.quote p::before { content: '「'; } .quote p::after { content: '」'; }
.why { font-size: 14px; color: var(--ink-2); }

/* Red-pen annotations: the signature. Handwritten, vermilion, beside the words they correct. */
.pen { font-family: var(--pen); font-weight: 600; color: var(--shu); line-height: 1.6; }
.note { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 10px 0; padding-left: 12px; border-left: 2px solid var(--shu); }
.note .tag { font-family: var(--pen); color: var(--shu); font-weight: 600; white-space: nowrap; }
.note q { font-size: 14px; color: var(--ink-2); quotes: '「' '」'; }
.note .pen { grid-column: 1 / -1; }
.mark-line { display: flex; gap: 8px; margin-top: 6px; }
.mark-line .glyph { font-family: var(--pen); color: var(--shu); font-weight: 600; width: 1.2em; flex: none; text-align: center; }
.mark-line.good .glyph { color: var(--ok); }
.mark-line.good .pen { color: var(--ok); }

.recommend { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--ink); border-radius: var(--r); margin: 16px 0; }
.recommend .name { font: 800 20px/1.3 var(--display); }
.lens { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 0; border-top: 1px dashed var(--line); }
.lens b { font-size: 14px; }
.lens p { grid-column: 1; margin: 0; font-size: 14px; color: var(--ink-2); }
.lens .btn { grid-row: 1 / span 2; grid-column: 2; }
details.transcript summary { cursor: pointer; color: var(--ink-2); font-size: 14px; }
.line { display: grid; grid-template-columns: 52px 1fr; gap: 10px; font-size: 14px; padding: 4px 0; }
.line .t { font: 500 12px/1.9 var(--mono); color: var(--ink-2); }
.line .who { font-size: 11px; color: var(--ink-2); margin-right: 6px; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }

/* Practice frames */
.qs { margin: 10px 0 0; padding-left: 1.2em; color: var(--ink-2); font-size: 14px; }
.frame { margin-top: 18px; }
.cells { display: grid; gap: 12px; }
@media (min-width: 640px) { .cells.cols3 { grid-template-columns: repeat(3, 1fr); } .cells.cols2 { grid-template-columns: repeat(2, 1fr); } }
.cell { border: 1.5px solid var(--ink); border-radius: var(--r); padding: 12px; background: var(--sheet); min-width: 0; }
.cell > label, .cell > .label { display: block; font: 800 15px/1.3 var(--display); }
.cell .hint { font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.field { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 6px 2px; resize: vertical; min-height: 38px; }
textarea.field { min-height: 64px; line-height: 1.6; }
.field:focus { outline: none; border-bottom-color: var(--focus); box-shadow: 0 1px 0 var(--focus); }
.listrow { display: flex; gap: 6px; align-items: flex-start; }
.listrow::before { content: '・'; padding-top: 7px; color: var(--ink-2); }
.listrow .x { border: 0; background: none; color: var(--ink-2); cursor: pointer; padding: 8px 4px; }
.add { border: 1px dashed var(--line); background: none; border-radius: var(--r); padding: 6px 10px; margin-top: 8px; cursor: pointer; color: var(--ink-2); font-size: 14px; }
.ro { white-space: pre-wrap; padding: 4px 2px; min-height: 1.6em; }
.ro.empty { color: var(--ink-2); }

/* Tree: connector lines drawn from borders */
.tree-root { border: 1.5px solid var(--ink); border-radius: var(--r); padding: 10px 12px; background: var(--sheet); }
.branches { margin-left: 18px; padding-left: 18px; border-left: 1.5px solid var(--ink); }
.branch { position: relative; margin-top: 12px; }
.branch::before { content: ''; position: absolute; left: -18px; top: 24px; width: 18px; border-top: 1.5px solid var(--ink); }
.branch:last-child::after { content: ''; position: absolute; left: -20px; top: 25px; bottom: -2px; width: 4px; background: var(--paper); }
.children { margin-left: 16px; padding-left: 14px; border-left: 1px dashed var(--ink-2); }
.child { position: relative; }
.child::before { content: ''; position: absolute; left: -14px; top: 20px; width: 12px; border-top: 1px dashed var(--ink-2); }

/* Matrix */
.matrix { display: grid; grid-template-columns: 22px 1fr 1fr; grid-template-rows: 1fr 1fr 22px; gap: 4px; margin-top: 8px; }
.matrix .axis-y { grid-row: 1 / 3; writing-mode: vertical-rl; text-align: center; font-size: 12px; color: var(--ink-2); }
.matrix .axis-x { grid-column: 2 / 4; text-align: center; font-size: 12px; color: var(--ink-2); }
.quad { border: 1.5px solid var(--ink); border-radius: var(--r); min-height: 110px; padding: 8px; background: var(--sheet); display: flex; flex-direction: column; gap: 4px; }
.quad .qlabel { font-size: 11px; color: var(--ink-2); font-family: var(--mono); }
.quad.best { border-width: 2.5px; }
.quad .item { font-size: 14px; border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; background: var(--paper); }
.placer { display: grid; gap: 8px; margin-top: 14px; }
.placer .prow { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 8px 0; border-top: 1px dashed var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: var(--sheet); padding: 6px 10px; cursor: pointer; font-size: 13px; border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--sheet); font-weight: 700; }

/* Classify */
.sentence { padding: 10px 0; border-top: 1px dashed var(--line); }
.sentence p { margin: 0 0 6px; }

/* Feedback */
.overall { font-size: 18px; margin: 6px 0 10px; }
.compare { display: grid; gap: 14px; }
@media (min-width: 720px) { .compare.on { grid-template-columns: 1fr 1fr; } }
.model { border-style: dashed; }
.habit { display: inline-block; font-family: var(--pen); font-weight: 600; color: var(--shu); border: 1.5px solid var(--shu); border-radius: 50% 46% 52% 44%; padding: 4px 14px; transform: rotate(-2deg); }
.toast { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 520px; margin: 0 auto; background: var(--ink); color: var(--sheet); padding: 12px 16px; border-radius: var(--r); font-size: 14px; }
.empty-state { text-align: center; padding: 36px 12px; }
.empty-state h2 { margin-bottom: 8px; }
.loading { color: var(--ink-2); padding: 40px 0; text-align: center; }
.review-sec { padding: 14px 0; border-top: 1px dashed var(--line); }
.review-sec:first-of-type { border-top: 0; }
ul.plain { list-style: none; padding: 0; margin: 6px 0; }
ul.plain li { padding: 4px 0; }
.daynav { display: flex; align-items: center; gap: 8px; }
.daynav .d { font: 500 15px/1 var(--mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Mode switch: worked example vs. writing it yourself */
.seg.modes { display: flex; margin: 16px 0 12px; }
.seg.modes button { flex: 1; padding: 10px; font-size: 15px; }
/* Example explanations: same hand as the red pen, but in ink — a teacher's board note, not a correction. */
.mark-line.explain .glyph, .mark-line.explain .pen { color: var(--ink); }
.mark-line.explain .pen { opacity: .85; }
.explain-lead { font-family: var(--pen); font-weight: 600; font-size: 17px; margin: 4px 0 12px; }
.frame.example .cell, .frame.example .tree-root, .frame.example .quad { border-style: dashed; }
.tips { margin-top: 16px; }
/* Two kinds of advice side by side */
.advice { display: grid; gap: 12px; margin-top: 18px; }
@media (min-width: 640px) { .advice { grid-template-columns: 1fr 1fr; } }
.advice-col { border: 1px solid var(--line); border-top: 3px solid var(--ink); border-radius: var(--r); padding: 12px 14px; background: var(--sheet); }
.advice-col + .advice-col { border-top-color: var(--shu); }
.advice-col li { padding: 6px 0; border-top: 1px dashed var(--line); font-size: 15px; }
.advice-col li:first-child { border-top: 0; }

.listrow .btn { flex: none; white-space: nowrap; }
.listrow .field { flex: 1; min-width: 0; }
@media (max-width: 480px) {
  .streak span:nth-child(-n+7) { display: none; }
  .mast { gap: 8px; }
  .matrix { grid-template-columns: 18px 1fr 1fr; }
  .quad { padding: 6px; min-height: 96px; }
  .quad .pen { font-size: 13px; }
  .sheet { padding: 16px; }
}

.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .big { font-size: 18px; }
