/* ---------- design tokens: 「机の上の学習ノート」 ---------- */
:root {
  --paper: #f6f3ec; --paper-2: #fffdf8; --ink: #23262b; --ink-2: #4b4f56; --muted: #7a7f86; --line: #e2dcd0; --line-2: #cfc7b8;
  --indigo: #2a4d7a; --indigo-ink: #ffffff; --indigo-soft: #e7eef8;
  --ok: #3e7f57; --ok-soft: #e6f2ea; --ng: #b9452f; --ng-soft: #f7e6e1; --warn: #a8731c; --warn-soft: #f8efdb;
  --hl: #f3e9c9;                 /* marker highlight */
  --fs: 16px; --radius: 6px;
  --serif: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", "Georgia", serif;
  --sans: "Segoe UI", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", Meiryo, system-ui, sans-serif;
  --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", Menlo, monospace;
}
[data-theme="dark"] {
  --paper: #15181d; --paper-2: #1c2026; --ink: #e9e5dc; --ink-2: #c9c4ba; --muted: #8f949c; --line: #2a2f37; --line-2: #3a404a;
  --indigo: #8db3e2; --indigo-ink: #0f1a2a; --indigo-soft: #1f2b3d;
  --ok: #7fc48c; --ok-soft: #1f3226; --ng: #e6836b; --ng-soft: #3a2420; --warn: #e0b25b; --warn-soft: #3a3020;
  --hl: #3b3520;
}
* { box-sizing: border-box; }
html { font-size: var(--fs); }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.75; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
a { color: var(--indigo); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .01em; }
h2 { font-size: 1.35rem; margin: 0 0 .4rem; }
h3 { font-size: 1.02rem; margin: 1.2rem 0 .4rem; }
.serif { font-family: var(--serif); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 18px 28px 10px; max-width: 900px; margin: 0 auto; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.brand .mark { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; color: var(--indigo); border: 2px solid var(--indigo); border-radius: 50%; width: 1.9em; height: 1.9em; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.brand .name { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.brand .sub { font-size: .8rem; color: var(--muted); }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav button { background: transparent; border: 0; padding: 6px 10px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.nav button.active { color: var(--ink); border-bottom-color: var(--indigo); font-weight: 600; }
.nav button:hover { color: var(--ink); }
main { max-width: 900px; margin: 0 auto; padding: 10px 28px 80px; }
.foot { max-width: 900px; margin: 0 auto; padding: 0 28px 40px; color: var(--muted); font-size: .78rem; line-height: 1.6; }

/* ---------- primitives ---------- */
.sec { padding: 22px 0; border-top: 1px solid var(--line); }
.sec:first-child { border-top: 0; }
.sec-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.sec-title h2 { margin: 0; }
.sec-title .hint { color: var(--muted); font-size: .85rem; }
.paper { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; }
.btn { background: var(--indigo); color: var(--indigo-ink); border: 0; border-radius: var(--radius); padding: 10px 18px; cursor: pointer; font-weight: 600; letter-spacing: .02em; }
.btn:hover { filter: brightness(1.08); }
.btn.big { padding: 14px 26px; font-size: 1.05rem; }
.btn.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line-2); font-weight: 500; }
.btn.quiet:hover { background: var(--paper-2); }
.btn.soft { background: var(--indigo-soft); color: var(--indigo); }
.btn.small { padding: 5px 11px; font-size: .85rem; }
.btn.danger { color: var(--ng); border-color: var(--ng); }
.btn:disabled { opacity: .45; cursor: default; filter: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tag { display: inline-block; border: 1px solid var(--line-2); border-radius: 999px; padding: 0 9px; font-size: .76rem; color: var(--ink-2); line-height: 1.6; }
.tag.fill { background: var(--indigo-soft); color: var(--indigo); border-color: transparent; }
.kbd { border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: .78rem; background: var(--paper-2); font-family: var(--mono); }
label.check { display: inline-flex; gap: 6px; align-items: center; padding: 4px 11px; border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer; user-select: none; font-size: .9rem; }
label.check.on { background: var(--indigo); color: var(--indigo-ink); border-color: var(--indigo); }
select, input[type=text], input[type=number], input[type=search], input[type=date], textarea { font: inherit; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--paper-2); color: var(--ink); }
input[type=search], input[type=text], textarea { width: 100%; }
input[type=range] { width: 200px; vertical-align: middle; }
.notice { border-left: 3px solid var(--warn); padding: 8px 14px; background: var(--warn-soft); border-radius: 0 var(--radius) var(--radius) 0; font-size: .9rem; margin: 10px 0; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > div { height: 100%; background: var(--indigo); }
.bar.ok > div { background: var(--ok); }
details summary { cursor: pointer; }

/* ---------- home ---------- */
.greet { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }
.hero { padding: 26px 0 22px; }
.hero h1 { font-size: 2rem; margin: 0 0 6px; line-height: 1.35; }
.hero h1 .n { color: var(--indigo); }
.hero .lead { color: var(--ink-2); margin: 0 0 16px; }
.pulse { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.pulse .p { border-top: 2px solid var(--line-2); padding-top: 8px; }
.pulse .p .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.pulse .p .v .u { font-size: .85rem; font-weight: 500; color: var(--muted); margin-left: 2px; }
.pulse .p .k { color: var(--muted); font-size: .8rem; }
.map { display: grid; gap: 10px; }
.map .f { display: grid; grid-template-columns: 9.5em 1fr 3.5em; gap: 12px; align-items: center; }
.map .f.sub { grid-template-columns: 9.5em 1fr 3.5em; font-size: .86rem; color: var(--ink-2); }
.map .f.sub .fn { padding-left: 1.2em; }
.map .pct { text-align: right; font-variant-numeric: tabular-nums; }
.links { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.links a { text-decoration: none; border-bottom: 1px dotted var(--line-2); color: var(--ink); }
.links a:hover { color: var(--indigo); border-bottom-style: solid; }
.ring { width: 64px; height: 64px; }

/* ---------- question ---------- */
.qbar { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.progress { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 18px; }
.progress > div { height: 100%; background: var(--indigo); transition: width .25s; }
.qhead { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.qmeta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .82rem; margin-bottom: 12px; }
.qtext { font-size: 1.04rem; white-space: pre-wrap; word-break: break-word; margin: 6px 0 16px; line-height: 1.85; }
.qtext pre { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto; font-size: .9rem; white-space: pre; font-family: var(--mono); line-height: 1.5; }
.qtext table { border-collapse: collapse; margin: 6px 0; font-size: .92rem; }
.qtext td, .qtext th { border: 1px solid var(--line-2); padding: 3px 10px; white-space: pre-wrap; }
.qimg { max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; display: block; margin: 8px 0 16px; }
.choices { display: grid; gap: 6px; }
.choice { display: flex; gap: 14px; align-items: flex-start; text-align: left; background: transparent; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; cursor: pointer; white-space: pre-wrap; line-height: 1.7; }
.choice:hover { border-color: var(--indigo); background: var(--paper-2); }
.choice .k { flex: 0 0 auto; width: 1.7em; height: 1.7em; border-radius: 50%; border: 1px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--indigo); font-size: .9rem; margin-top: .15em; }
.choice.selected { border-color: var(--indigo); background: var(--indigo-soft); }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.correct .k { background: var(--ok); color: #fff; border-color: var(--ok); }
.choice.wrong { border-color: var(--ng); background: var(--ng-soft); }
.choice.wrong .k { background: var(--ng); color: #fff; border-color: var(--ng); }
.choice:disabled { cursor: default; }
.verdict { margin: 14px 0 6px; font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.verdict.ok { color: var(--ok); } .verdict.ng { color: var(--ng); }
.grade { margin-top: 10px; padding: 12px 0 4px; border-top: 1px dashed var(--line-2); }
.grade .row { margin: 6px 0; }
.grade-btn { display: inline-flex; flex-direction: column; align-items: center; min-width: 108px; }
.grade-btn .ivl { font-size: .74rem; font-weight: 400; opacity: .85; }
.memo { font-size: .8rem; color: var(--muted); }
.expl { margin-top: 18px; border-left: 3px solid var(--indigo); padding: 4px 0 4px 16px; }
.expl summary { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; list-style: none; }
.expl summary::-webkit-details-marker { display: none; }
.expl summary::before { content: "▸ "; color: var(--indigo); }
.expl[open] summary::before { content: "▾ "; }
.expl .lead { font-weight: 600; margin: 8px 0; background: linear-gradient(transparent 55%, var(--hl) 55%); display: inline; }
.expl h4 { font-size: .9rem; margin: 14px 0 4px; color: var(--muted); font-weight: 600; letter-spacing: .05em; }
.opts { display: grid; gap: 4px; }
.opt { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.opt .k { flex: 0 0 1.6em; font-weight: 700; }
.opt.ok .k { color: var(--ok); } .opt.ng .k { color: var(--ng); }
.expl ul { margin: 4px 0; padding-left: 1.3em; }
.expl .rel a { margin-right: 10px; }

/* ---------- lists & sheet ---------- */
.list .item { padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .item:hover { background: var(--paper-2); }
.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 5px; }
.sheet button { border: 1px solid var(--line); background: transparent; border-radius: 4px; padding: 5px 0; cursor: pointer; font-size: .8rem; line-height: 1.3; }
.sheet button.done { background: var(--indigo-soft); color: var(--indigo); }
.sheet button.cur { outline: 2px solid var(--indigo); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-family: var(--mono); }
.timer.low { color: var(--ng); }
table.stats { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.stats th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
table.stats td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.stats td.num { text-align: right; font-variant-numeric: tabular-nums; }
.forecast { display: flex; gap: 4px; align-items: flex-end; height: 110px; padding: 6px 0 0; }
.fc { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.fcbar { width: 70%; background: var(--indigo); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.fcl { font-size: .62rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.fcn { font-size: .74rem; }
.gains { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 14px 0; }
.gains .g { border-left: 3px solid var(--indigo); padding-left: 12px; }
.gains .g .v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.gains .g .k { color: var(--muted); font-size: .82rem; }

/* ---------- 午後 ---------- */
.pmlist .item { display: grid; grid-template-columns: 3.2em 1fr auto; gap: 10px; align-items: baseline; }
.pmlist .qn { font-family: var(--serif); font-weight: 700; }
.pmpage { max-width: 100%; display: block; border: 1px solid var(--line); background: #fff; margin: 0 0 10px; }
.pmtools { position: sticky; top: 0; background: var(--paper); padding: 8px 0; z-index: 5; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.rate { display: flex; gap: 8px; flex-wrap: wrap; }
.rate button { flex: 1; min-width: 120px; }

@media (max-width: 640px) {
  .top { padding: 14px 16px 8px; } main { padding: 8px 16px 70px; } .foot { padding: 0 16px 30px; }
  .hero h1 { font-size: 1.55rem; } .map .f, .map .f.sub { grid-template-columns: 7em 1fr 3.2em; }
}
.sec h2, .sec .sec-title { scroll-margin-top: 64px; }

/* Structured learning course */
.eyebrow { color:var(--indigo); font-size:.77rem; letter-spacing:.06em; font-weight:700; }
.course-head { padding:24px 0 18px; }
.course-head h1 { font-size:clamp(1.7rem,4vw,2.45rem); line-height:1.4; margin:.4em 0; }
.course-head .lead { max-width:40rem; }
.course-home { border-bottom:1px solid var(--line); }
.course-start { margin-top:26px; padding:26px; background:var(--indigo-soft); border-radius:12px; }
.course-start h2 { margin-top:12px; }
.course-chapters { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.course-chapter { background:var(--paper-2); border:1px solid var(--line); border-radius:10px; padding:20px; }
.course-chapter h3 { margin:.4em 0; font-size:1.2rem; }
.course-chapter p { margin:.6em 0; font-size:.92rem; }
.course-lessons { padding-left:20px; }
.course-lessons li { margin:8px 0; }
.course-lessons button { display:flex; width:100%; justify-content:space-between; gap:10px; text-align:left; border:0; padding:6px 0; background:none; color:var(--indigo); cursor:pointer; }
.course-lessons small { flex-shrink:0; color:var(--muted); font-size:.7rem; align-self:center; }
.course-breadcrumb { display:flex; gap:12px; flex-wrap:wrap; align-items:center; color:var(--muted); font-size:.8rem; margin-top:20px; }
.course-prereqs { display:flex; flex-wrap:wrap; gap:8px; font-size:.86rem; }
.text-btn { background:none; border:0; color:var(--indigo); text-decoration:underline; padding:4px 0; cursor:pointer; }
.course-steps { display:flex; gap:4px; padding:6px; border:1px solid var(--line); border-radius:8px; overflow-x:auto; }
.course-steps button { white-space:nowrap; flex:1; padding:9px 12px; border:0; border-radius:5px; background:none; color:var(--muted); cursor:pointer; font-size:.85rem; }
.course-steps button.active { background:var(--indigo); color:var(--indigo-ink); }
.course-body { background:var(--paper-2); padding:26px; margin:20px 0; border:1px solid var(--line); border-radius:10px; }
.course-body h2 { font-family:var(--sans); font-size:1.1rem; }
.course-body p { line-height:1.9; }
.concept { display:flex; gap:16px; margin-bottom:28px; }
.concept-number { flex:0 0 30px; height:30px; line-height:30px; text-align:center; color:var(--indigo); background:var(--indigo-soft); border-radius:50%; font-size:.82rem; }
.concept p { margin:8px 0 0; }
.course-table { overflow:auto; margin:22px 0; }
.course-table table { border-collapse:collapse; width:100%; font-size:.94rem; }
.course-table th,.course-table td { border:1px solid var(--line-2); padding:10px 14px; text-align:left; white-space:nowrap; }
.course-table th { background:var(--indigo-soft); }
.worked-steps { padding-left:24px; margin:24px 0; }
.worked-steps li { padding:8px 0 8px 8px; }
.course-answer { padding:16px; background:var(--ok-soft); color:var(--ink); border-left:3px solid var(--ok); margin:18px 0; }
.course-body textarea { margin:10px 0 0; resize:vertical; }
.course-body details { margin:20px 0; }
.course-choices { display:grid; gap:10px; margin:22px 0; }
.course-choices button { display:flex; gap:14px; align-items:baseline; text-align:left; padding:15px 18px; border:1px solid var(--line-2); border-radius:8px; background:var(--paper); cursor:pointer; }
.course-choices button span { color:var(--muted); }
.course-choices button:hover:not(:disabled) { border-color:var(--indigo); background:var(--indigo-soft); }
.course-choices .correct { border-color:var(--ok); background:var(--ok-soft); }
.course-choices .wrong { border-color:var(--ng); background:var(--ng-soft); }
.course-choices button:disabled { cursor:default; opacity:1; }
.course-feedback { margin:18px 0; padding:18px; background:var(--indigo-soft); border-radius:8px; }
.course-feedback h3 { margin:0; }
.course-reason { display:flex; flex-wrap:wrap; gap:8px; border:1px solid var(--line); padding:14px; margin:20px 0; }
.course-bottom { padding:4px 0 24px; }
.course-progress { display:flex; flex-wrap:wrap; gap:12px 24px; margin:20px 0; font-size:.85rem; color:var(--muted); }
.course-progress b { color:var(--ink); margin-left:6px; }
button:focus-visible { outline:3px solid var(--indigo); outline-offset:3px; }
@media(max-width:640px) {
 .course-chapters { grid-template-columns:1fr; }
 .course-body { padding:18px 15px; }
 .course-start { padding:20px; }
 .course-steps button { padding:9px 10px; }
 .concept { gap:10px; }
 .course-lessons button { flex-wrap:wrap; }
}
