:root {
  --ink: #1F2430;
  --muted: #5B6170;
  --line: #B9BEC9;
  --faint: #E9ECF1;
  --bg: #F6F7F9;
  --card: #FFFFFF;
  --brand: #2B3A55;
  --good: #23784A;
  --warn: #A3303F;
  --c: #2B3A55;
  --radius: 12px;
  --head: "Century Gothic", "Avenir Next", "Futura", "Segoe UI", system-ui, sans-serif;
  --body: "Calibri", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  font-size: 18px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); line-height: 1.5; }
h1, h2, h3, h4 { font-family: var(--head); line-height: 1.25; margin: 1.4em 0 .5em; }
h1 { font-size: 1.7rem; margin-top: .6em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
a { color: var(--brand); }
img { max-width: 100%; height: auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }
.glyph { font-family: "Segoe UI Symbol", "Segoe UI Emoji", "Noto Emoji", "Apple Color Emoji", sans-serif; }
main { max-width: 860px; margin: 0 auto; padding: 1rem 1rem 5rem; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--brand); color: #fff; display: flex; flex-wrap: wrap;
  align-items: center; gap: .3rem 1rem; padding: .45rem 1rem; }
.topbar .brand { color: #fff; font-family: var(--head); font-weight: 700; text-decoration: none; margin-right: auto; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem; }
.topbar nav a { color: #fff; text-decoration: none; padding: .35rem .7rem; border-radius: 999px; font-size: .95rem; }
.topbar nav a.on { background: rgba(255, 255, 255, .18); font-weight: 700; }

/* ---------------------------------------------------------------- basics */
.card { background: var(--card); border-radius: var(--radius); padding: 1.2rem 1.4rem; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.card.error { border-left: 6px solid var(--warn); }
.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 999px; padding: .6rem 1.3rem;
  font: 700 1rem var(--head); text-decoration: none; cursor: pointer; }
.btn.big { font-size: 1.15rem; padding: .8rem 1.8rem; }
.btn.ghost { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
.btn.danger { color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.row.between { justify-content: space-between; }
.field { display: block; margin: .8rem 0; }
.field > span { display: block; font-weight: 700; margin-bottom: .25rem; }
.field.inline { display: flex; align-items: center; gap: .6rem; }
.field.inline > span { margin: 0; }
input, textarea, select { font: inherit; color: inherit; }
input:not([type=radio]):not([type=checkbox]), textarea, select { width: 100%; padding: .55rem .7rem; border: 2px solid var(--line);
  border-radius: 8px; background: #fff; }
input[type=number] { width: 7rem; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
input:disabled, textarea:disabled { background: #FAFAFB; color: var(--ink); -webkit-text-fill-color: var(--ink); opacity: 1; }
input[type=radio], input[type=checkbox] { width: 1.2rem; height: 1.2rem; accent-color: var(--c); margin: 0 .45rem 0 0; vertical-align: -.2rem; }
fieldset { border: 0; padding: 0; margin: .8rem 0; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
legend { font-weight: 700; padding: 0; margin-bottom: .3rem; width: 100%; }
.login { max-width: 420px; margin: 3rem auto; }
.error-text { color: var(--warn); font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1.2rem;
  border-radius: 10px; max-width: 90vw; z-index: 30; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.tip { position: absolute; z-index: 40; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: .45rem .65rem; font-size: .85rem; line-height: 1.35; box-shadow: 0 4px 14px rgba(0, 0, 0, .15); pointer-events: none; max-width: 260px; }

/* ---------------------------------------------------------------- lesson cards */
.eyebrow { font-family: var(--head); font-weight: 700; color: var(--muted); margin: .4rem 0; text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; }
.hero { display: grid; gap: .9rem; justify-items: start; }
.lcard { display: grid; gap: .15rem; text-decoration: none; color: var(--ink); background: var(--card); border-radius: var(--radius);
  padding: .8rem .9rem; border-top: 6px solid var(--c); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); min-width: 0; }
.lcard:hover { box-shadow: 0 3px 10px rgba(0, 0, 0, .12); }
.lcard.big { width: 100%; padding: 1.2rem 1.4rem; }
.lcard.big .lc-title { font-size: 1.5rem; }
.lc-day { font-size: .8rem; color: var(--muted); font-weight: 700; }
.lc-title { font-family: var(--head); font-weight: 700; font-size: 1rem; line-height: 1.25; }
.lc-sub { font-size: .85rem; color: var(--muted); }
.badge { justify-self: start; margin-top: .35rem; font-size: .78rem; font-weight: 700; border-radius: 999px; padding: .1rem .6rem;
  background: var(--faint); color: var(--muted); }
.badge.draft { background: #FFF4D6; color: #7A5A00; }
.badge.waiting { background: #E4ECF8; color: #24508A; }
.badge.marked { background: #DDF1E5; color: #1C603B; }
.lcard.marked { opacity: .92; }
.week-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.term-row { display: grid; grid-template-columns: 4.5rem repeat(5, minmax(0, 1fr)); gap: .5rem; margin-bottom: .5rem; align-items: stretch; }
.term-w { font-family: var(--head); font-weight: 700; font-size: .85rem; align-self: center; color: var(--muted); }
.term .lcard { padding: .5rem .55rem; }
.term .lc-title { font-size: .82rem; }
.term .lc-sub, .term .lc-day { display: none; }
.term .badge { font-size: .7rem; }
@media (max-width: 700px) {
  .term-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .term-w { grid-column: 1 / -1; }
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; margin: 1.2rem 0; }
.stat { background: var(--card); border-radius: var(--radius); padding: .9rem 1rem; display: grid; gap: .1rem; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.stat .num { font-family: var(--head); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat .lab { color: var(--muted); font-size: .85rem; }

/* ---------------------------------------------------------------- lesson page */
.lhead { background: var(--c); color: #fff; border-radius: var(--radius); padding: 1rem 1.3rem 1.1rem; }
.lhead h1 { margin: .2rem 0 .3rem; font-size: 1.6rem; }
.lh-top { margin: 0; font-size: .85rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; opacity: .92; }
.lh-sub { margin: 0; opacity: .92; }
.lh-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.chip { background: rgba(255, 255, 255, .2); border-radius: 999px; padding: .15rem .7rem; font-size: .85rem; font-weight: 700; }
.chip.warn { background: #FFE2E2; color: var(--warn); }
.chip.parent { background: #fff; color: var(--c); }
.note { margin: .8rem 0; background: #FFF8E6; border-left: 5px solid #D9A400; padding: .6rem .9rem; border-radius: 8px; font-size: .92rem; }
.psum { margin: .8rem 0; background: var(--card); border-left: 5px solid var(--c); padding: .5rem .9rem; border-radius: 8px; font-size: .9rem; }
.psum p { margin: .3rem 0; }
.blocks { margin-top: .4rem; }
.sec { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; background: color-mix(in srgb, var(--c) 12%, white);
  color: var(--c); padding: .45rem .8rem; border-radius: 8px; margin: 1.6rem 0 .8rem; font-size: 1.05rem; }
.sec-min { font-family: var(--body); font-weight: 400; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.p { margin: .6rem 0; }
.p.body_s { font-size: .92rem; }
.blank { display: inline-block; width: 9rem !important; padding: .15rem .4rem !important; margin: .1rem .2rem; border-width: 0 0 2px !important;
  border-radius: 0 !important; background: color-mix(in srgb, var(--c) 6%, white) !important; }
.passage { background: var(--card); border: 2px solid color-mix(in srgb, var(--c) 45%, white); border-radius: var(--radius);
  padding: 1rem 1.3rem; font-size: 1.08rem; line-height: 1.65; margin: .8rem 0; }
.passage h4 { margin: 0 0 .5rem; color: var(--c); font-size: 1.2rem; }
.passage p { margin: .55rem 0; }
.passage .source { font-size: .85rem; color: var(--muted); }
.info { background: color-mix(in srgb, var(--c) 7%, white); border: 1px solid color-mix(in srgb, var(--c) 40%, white);
  border-radius: var(--radius); padding: .8rem 1.1rem; margin: .8rem 0; }
.info h4 { margin: 0 0 .3rem; }
.info p { margin: 0; }
.table-wrap { overflow-x: auto; margin: .8rem 0; }
table.data { border-collapse: collapse; background: #fff; font-size: .95rem; min-width: 50%; }
table.data th, table.data td { border: 1px solid var(--line); padding: .35rem .6rem; text-align: center; vertical-align: middle; }
table.data th { background: var(--c); color: #fff; font-weight: 700; }
table.data tr:nth-child(odd) td { background: #F7F8FA; }
table.data input.cell { min-width: 5rem; padding: .25rem .4rem; }
table.log td { text-align: left; }
.fig { margin: .7rem 0; }
.fig img { display: block; }
@media (max-width: 600px) {
  .fig { overflow-x: auto; }
  .fig img { max-width: none; width: min(var(--w), 560px); }
}
textarea.work { margin: .5rem 0; border-style: dashed; }

.q { background: var(--card); border-radius: var(--radius); padding: .9rem 1.1rem 1rem; margin: .8rem 0; box-shadow: 0 1px 3px rgba(0, 0, 0, .07); }
.q-head { display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: start; }
.q-n { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--c); color: #fff;
  font: 700 .95rem var(--head); }
.q-text { padding-top: .1rem; }
.q-pts { font-size: .8rem; color: var(--muted); white-space: nowrap; padding-top: .3rem; }
.q textarea.answer { margin-top: .6rem; }
.q .paper { display: inline-block; margin-top: .35rem; font-size: .85rem; color: var(--muted); }
.opts { display: grid; gap: .4rem; margin: .7rem 0 0; }
.opt { display: flex; align-items: center; gap: .3rem; border: 2px solid var(--faint); border-radius: 10px; padding: .5rem .7rem; cursor: pointer; }
.opt:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, white); }
.opt b { margin-right: .4rem; }
ol.opts.plain { padding-left: 2.2rem; }
ol.tf { list-style: lower-alpha; padding-left: 1.6rem; margin: .7rem 0 0; display: grid; gap: .5rem; }
ol.tf li { padding: .2rem 0; }
ol.tf li > span:first-child { display: block; }
.tf-btns { display: flex; gap: .5rem; margin-top: .25rem; }
.tf-btns label { border: 2px solid var(--faint); border-radius: 999px; padding: .2rem .8rem; cursor: pointer; }
.tf-btns label:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, white); font-weight: 700; }
.drill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .5rem .9rem; margin-top: .7rem; }
.drill-item { display: grid; grid-template-columns: 1fr 5.5rem; align-items: center; gap: .4rem; padding: .3rem .4rem; border-radius: 8px; }
.drill-item .expr { font-size: 1.05rem; }
.drill-item input { text-align: center; padding: .35rem .3rem !important; }
.drill-item .dmark { grid-column: 1 / -1; font-size: .78rem; font-weight: 700; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.drill-item .dmark:empty { display: none; }
.drill-item.right { background: #E7F5EC; }
.drill-item.right .dmark { color: var(--good); }
.drill-item.wrong { background: #FBEAEA; }
.drill-item.wrong .dmark { color: var(--warn); }
.mark:empty { display: none; }
.mark { margin-top: .6rem; }
.got, .wait { display: inline-block; font-size: .85rem; font-weight: 700; border-radius: 999px; padding: .1rem .7rem; }
.got.full { background: #DDF1E5; color: #1C603B; }
.got.part { background: #FFF4D6; color: #7A5A00; }
.got.none { background: #FBEAEA; color: var(--warn); }
.wait { background: var(--faint); color: var(--muted); }

.refl { background: var(--card); border-radius: var(--radius); padding: .9rem 1.1rem; margin: 1.6rem 0 1rem; border: 2px dashed var(--line); }
.refl h3 { margin: 0; }
.feel { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0; }
.feel label { border: 2px solid var(--faint); border-radius: 999px; padding: .25rem .9rem; cursor: pointer; }
.feel label:has(input:checked) { border-color: var(--c); font-weight: 700; }
.lesson-foot { margin: 1.4rem 0; display: grid; gap: .4rem; justify-items: start; }
.total { font-size: 1.2rem; }

/* ---------------------------------------------------------------- parent */
.pbox { background: #FFFBEF; border: 1px solid #E8D9A8; border-radius: 10px; padding: .6rem .8rem; }
.pbox p { margin: .25rem 0; }
.keytext { font-size: .95rem; }
.stepper { display: inline-flex; gap: .25rem; vertical-align: middle; }
.stepper button { min-width: 2.3rem; height: 2.3rem; border-radius: 8px; border: 2px solid var(--line); background: #fff; font: 700 1rem var(--head); cursor: pointer; }
.stepper button.on { background: var(--c); border-color: var(--c); color: #fff; }
.dmark .stepper button { min-width: 1.9rem; height: 1.9rem; font-size: .85rem; }
.dmark .key { color: var(--ink); font-weight: 400; }
.auto, .tag { font-size: .78rem; color: var(--muted); background: var(--faint); border-radius: 999px; padding: .05rem .5rem; }
.scorebox { width: 100%; }
.scorebox h3 { margin-top: 0; }
.plist { display: grid; gap: .5rem; }
.prow { display: grid; grid-template-columns: 7rem 1fr auto; gap: .8rem; align-items: center; background: var(--card); border-left: 6px solid var(--c);
  border-radius: 10px; padding: .6rem .9rem; text-decoration: none; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .07); }
.prow .pr-l { font-weight: 700; font-size: .85rem; color: var(--muted); }
.prow .pr-t { font-family: var(--head); font-weight: 700; }
.prow .pr-s { font-size: .85rem; color: var(--muted); text-align: right; }
@media (max-width: 600px) { .prow { grid-template-columns: 1fr; gap: .1rem; } .prow .pr-s { text-align: left; } }
select { max-width: 32rem; }

/* ---------------------------------------------------------------- progress charts */
.chart-wrap { background: var(--card); border-radius: var(--radius); padding: .6rem; box-shadow: 0 1px 3px rgba(0, 0, 0, .07); }
.chart { width: 100%; height: auto; display: block; font-family: var(--body); }
.chart .grid { stroke: var(--faint); stroke-width: 1; }
.chart .axis { stroke: var(--ink); stroke-width: 1; }
.chart .target { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .tick { fill: var(--muted); font-size: 12px; }
.chart .bar { fill: var(--brand); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit:focus { fill: rgba(43, 58, 85, .06); outline: none; }
.tableview { margin: .6rem 0 1rem; font-size: .9rem; }
.tableview summary { cursor: pointer; color: var(--brand); }
.seg { display: inline-flex; flex-wrap: wrap; gap: .3rem; background: var(--faint); padding: .25rem; border-radius: 999px; margin-bottom: .6rem; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: .35rem .9rem; font: 700 .85rem var(--body); color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.msg { background: var(--card); border-radius: var(--radius); padding: .6rem 1rem .8rem; margin: .7rem 0; border-left: 6px solid var(--c); }
.msg h3 { margin: .3rem 0 .4rem; }
.msrow { display: grid; grid-template-columns: 1fr 9rem 9.5rem; gap: .8rem; align-items: center; padding: .4rem 0; border-top: 1px solid var(--faint); font-size: .9rem; }
.ms-code { font-weight: 700; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.ms-bar { outline: none; }
.track { position: relative; display: block; height: 10px; background: var(--faint); border-radius: 5px; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c); border-radius: 5px; }
.tick70 { position: absolute; left: 70%; top: -3px; bottom: -3px; width: 2px; background: var(--muted); }
.ms-st { font-size: .85rem; }
@media (max-width: 640px) { .msrow { grid-template-columns: 1fr; gap: .3rem; } }
.day { background: var(--card); border-radius: var(--radius); padding: .4rem 1rem .6rem; margin: .6rem 0; }
.day h3 { margin: .4rem 0; }
.day ul { margin: 0; padding-left: 1.1rem; }
.day .t { color: var(--muted); font-variant-numeric: tabular-nums; }

@media print {
  .topbar, .lesson-foot, .lh-chips { display: none; }
  body { background: #fff; }
}
