/*
  維尼功課台 v3 — staff home page, built for older eyes and hands.

  Layout: one calm reading column (≤ 40 Chinese characters wide) on a soft
  "eye-care green" ground (護眼綠), a big bottom tab bar that never moves,
  and homework grouped per class by the day it must be handed in.
  Accessibility target: WCAG 2.2 AAA — text ≥ 7:1, controls ≥ 3:1,
  targets ≥ 44px (we use ≥ 60px), four colour themes the user can choose,
  motion only when wanted and never longer than a few seconds.
*/

/* ── Themes (every colour is a token; contrast is checked by a script) ── */
:root,
html[data-look="sage"] {
  color-scheme: light;
  --ground: #e3ede2;        /* 護眼綠 page ground */
  --card: #f8fbf7;
  --card-2: #ecf3ea;
  --ink: #12241a;
  --ink-2: #2d4234;
  --line: #496052;
  --primary: #1b4a7a;       /* calm blue: "you can press this" */
  --on-primary: #ffffff;
  --primary-soft: #dce8f5;
  --urgent: #8a1b2a;  --urgent-bg: #fbe3e3;
  --soon: #663b00;    --soon-bg: #fbeacb;
  --later: #2d4234;   --later-bg: #dde8de;
  --done: #175530;    --done-bg: #d8efdd;  --done-solid: #1b5e37;  --on-done: #ffffff;
  --new: #0d4d63;     --new-bg: #d9eef4;   --on-new: #ffffff;
  --warn: #5e3700;    --warn-bg: #fdebc6;
  --coach: #f0b429;   --coach-line: #7a5200;  --coach-bg: #fff3c9;
  --focus: #1b4a7a;   --halo: #ffffff;
  --brand: #8a1231;
  --scrim: rgba(10, 22, 15, 0.64);
  --shadow: none;
}
html[data-look="paper"] {
  color-scheme: light;
  --ground: #f1ebdd;  --card: #fffcf5;  --card-2: #f7f0e1;
  --ink: #221b10;     --ink-2: #463b2b;  --line: #685840;
  --primary: #28467a; --on-primary: #ffffff; --primary-soft: #e1e8f4;
  --urgent: #8a1b2a;  --urgent-bg: #fae3e0;
  --soon: #633a00;    --soon-bg: #f9e7c6;
  --later: #463b2b;   --later-bg: #ebe2d0;
  --done: #175530;    --done-bg: #dcefdc;  --done-solid: #1b5e37;  --on-done: #ffffff;
  --new: #0d4d63;     --new-bg: #dcecef;   --on-new: #ffffff;
  --warn: #5e3700;    --warn-bg: #fbe6bf;
  --coach: #f0b429;   --coach-line: #7a5200;  --coach-bg: #fff1c2;
  --focus: #28467a;   --halo: #ffffff;
  --brand: #8a1231;
  --scrim: rgba(28, 22, 12, 0.64);
  --shadow: none;
}
html[data-look="contrast"] {
  color-scheme: light;
  --ground: #ffffff;  --card: #ffffff;  --card-2: #f0f0f0;
  --ink: #000000;     --ink-2: #1a1a1a;  --line: #000000;
  --primary: #002d6b; --on-primary: #ffffff; --primary-soft: #e3ecfa;
  --urgent: #7a0010;  --urgent-bg: #ffe5e8;
  --soon: #4f2c00;    --soon-bg: #ffecc7;
  --later: #000000;   --later-bg: #ececec;
  --done: #003d1c;    --done-bg: #dcf5e3;  --done-solid: #0a4a26;  --on-done: #ffffff;
  --new: #00384a;     --new-bg: #ddf1f7;   --on-new: #ffffff;
  --warn: #4a2800;    --warn-bg: #ffe9bd;
  --coach: #ffb800;   --coach-line: #000000;  --coach-bg: #fff1b8;
  --focus: #000000;   --halo: #ffd400;
  --brand: #6e0d27;
  --scrim: rgba(0, 0, 0, 0.72);
  --shadow: none;
}
html[data-look="night"] {
  color-scheme: dark;
  --ground: #0f1714;  --card: #18221e;  --card-2: #1f2b26;
  --ink: #eef3ef;     --ink-2: #c9d5cd;  --line: #8da396;
  --primary: #a9cbff; --on-primary: #0a1a30; --primary-soft: #1c2c42;
  --urgent: #ffc2c2;  --urgent-bg: #3a1a1f;
  --soon: #ffd98f;    --soon-bg: #372a12;
  --later: #d3ddd6;   --later-bg: #243029;
  --done: #aee8bf;    --done-bg: #16301f;  --done-solid: #aee8bf;  --on-done: #0b2414;
  --new: #a8e3f3;     --new-bg: #13303a;   --on-new: #06242e;
  --warn: #ffd98f;    --warn-bg: #372a12;
  --coach: #ffd24d;   --coach-line: #ffd24d;  --coach-bg: #3a3212;
  --focus: #ffd24d;   --halo: #0f1714;
  --brand: #ffb3c4;
  --scrim: rgba(0, 0, 0, 0.72);
  --shadow: none;
}

/* ── Type scale: one size setting drives everything ─────────────────── */
:root { --fs: 22px; --ts-head: 1.22em; --ts-body: 1em; --ts-sm: 0.85em;
  --tap: max(56px, 2.8em); --radius: 18px; --tabbar: 5.6rem;
  --font: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Heiti TC", sans-serif; }
html[data-face="md"] { --fs: 18px; }
html[data-face="lg"] { --fs: 22px; }
html[data-face="xl"] { --fs: 26px; }
html[data-face="xxl"] { --fs: 31px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--ground);
  scroll-padding-top: 5.5rem;
  scroll-padding-bottom: calc(var(--tabbar) + 2rem);
}
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.8;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body.has-tabs { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px)); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; touch-action: manipulation; text-align: inherit; }
.btn, .chip, .seen, .stu-tick, .tab, .tile, .seg-btn {
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
a { color: var(--primary); text-underline-offset: 0.22em; }
[hidden] { display: none !important; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; box-shadow: 0 0 0 8px var(--halo); border-radius: 12px; }
.ic { width: 1.35em; height: 1.35em; flex: none; stroke: currentColor; fill: none; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.vh:focus { position: fixed; left: 12px; top: 12px; z-index: 60; width: auto; height: auto; clip: auto; padding: 12px 18px; border-radius: 12px; background: var(--primary); color: var(--on-primary); font-weight: 800; text-decoration: none; }

.shell {
  max-width: 48rem;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 14px 36px;
}

/* ── Brand bar ──────────────────────────────────────────────────────── */
.brandbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 1.05em; font-weight: 900; color: var(--brand); letter-spacing: -0.01em; margin-bottom: 14px; }
.brand-id { display: flex; align-items: center; gap: 10px; }
.brandbar svg, .brandbar .brand-logo { width: 36px; height: 36px; flex: none; border-radius: 8px; display: block; }
.brandbar .btn { font-size: var(--fs); }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45em;
  min-height: var(--tap);
  padding: 0.35em 1.05em;
  border-radius: var(--radius);
  border: 3px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-weight: 800;
  line-height: 1.3;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-danger { background: var(--urgent-bg); border-color: var(--urgent); color: var(--urgent); }
.btn-wide { width: 100%; min-height: max(62px, 3.1em); }
.btn-quiet { border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 0.25em; min-height: var(--tap); padding-inline: 0.4em; color: var(--primary); }
.btn:disabled, button:disabled { opacity: 0.58; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 14px; }

/* ── Page heading for sub-pages ─────────────────────────────────────── */
.page-head { display: grid; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 1.45em; line-height: 1.35; text-wrap: balance; }
.lead { color: var(--ink-2); font-weight: 700; max-width: 34em; }
.back { justify-self: start; }

/* ── Greeting + progress (home) ─────────────────────────────────────── */
.hello {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 22px;
  padding: 14px 18px;
  margin-bottom: 14px;
}
.hello-text { min-width: 0; display: grid; gap: 2px; }
.greet { font-weight: 800; color: var(--brand); font-size: var(--ts-body); line-height: 1.4; }
.hello h1 { font-size: 1.35em; line-height: 1.35; text-wrap: balance; }
.hello h1 b { color: var(--primary); font-variant-numeric: tabular-nums; }
.fresh { color: var(--ink-2); font-weight: 700; font-size: var(--ts-sm); }
.autosave-note {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--done); font-weight: 800; font-size: var(--ts-sm);
  margin-top: 2px;
}
.calm-note {
  background: var(--done-bg); color: var(--done);
  border: 3px solid var(--done-solid); border-radius: var(--radius);
  padding: 12px 16px; font-weight: 800; margin-bottom: 14px;
}
.action-feedback-wrap:empty { margin: 0; }
.action-feedback {
  background: var(--done-bg); color: var(--done);
  border: 2px solid var(--done-solid); border-radius: 12px;
  padding: 10px 14px; font-weight: 800; font-size: var(--ts-sm);
}
.action-feedback.warn {
  background: var(--warn-bg); color: var(--warn); border-color: var(--warn);
}
.btn.btn-done {
  background: var(--done-bg); border-color: var(--done-solid); color: var(--done);
}
.done-section { margin-top: 22px; padding-top: 14px; border-top: 2px dashed var(--line); }
.done-heading {
  font-size: var(--ts-body); font-weight: 900; color: var(--done);
  margin: 0 0 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.date-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.date-pills .btn[aria-pressed="true"] {
  background: var(--primary); border-color: var(--primary); color: var(--on-primary);
}
.home-refresh-box {
  background: var(--primary-soft); color: var(--ink);
  border: 3px solid var(--primary); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px; display: grid; gap: 8px; font-weight: 800;
}
.home-refresh-box.done {
  background: var(--done-bg); color: var(--done); border-color: var(--done-solid);
}
.home-refresh-box.warn {
  background: var(--warn-bg); color: var(--warn); border-color: var(--warn);
}
.foot-account {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding-top: 10px; border-top: 2px dashed var(--line);
}
.foot-account .btn { min-height: var(--tap); }
.print-frame { position: fixed; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none; }
.print-options { display: grid; gap: 12px; }
.print-opt {
  display: grid; gap: 2px; text-align: left; justify-items: start;
  width: 100%; padding: 12px 16px;
}
.print-opt small { font-weight: 700; font-size: var(--ts-sm); color: var(--ink-2); }
.print-opt.btn-primary small { color: var(--on-primary); }
.ring { position: relative; flex: none; width: 5.8em; height: 5.8em; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: var(--card-2); }
.ring .fill { stroke: var(--done-solid); stroke-linecap: round; transition: stroke-dashoffset 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.ring span { position: relative; font-weight: 900; font-size: var(--ts-head); line-height: 1; text-align: center; font-variant-numeric: tabular-nums; }
.ring small { display: block; font-size: max(14px, 0.72em); font-weight: 800; color: var(--ink-2); margin-top: 3px; }
.hello.all-done { background: var(--done-bg); border-color: var(--done-solid); }
.hello.all-done .star { width: 4.2em; height: 4.2em; fill: var(--coach); stroke: var(--coach-line); stroke-width: 1.2; flex: none; }
html:not([data-motion="off"]) .hello.all-done .star { animation: star-in 0.9s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes star-in { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Persistent Message Dock (WCAG 2.2.3 No Timing) ─────────────────── */
.msg-dock {
  background: var(--primary-soft); color: var(--ink);
  border: 3px solid var(--primary); border-radius: var(--radius);
  padding: 16px; margin-bottom: 18px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
}
.msg-dock.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.msg-dock.done { background: var(--done-bg); color: var(--done); border-color: var(--done-solid); }
.msg-dock.bad { background: var(--urgent-bg); color: var(--urgent); border-color: var(--urgent); }
.msg-text { font-weight: 800; flex: 1 1 14rem; }
.msg-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ── Class focus pager & filters ────────────────────────────────────── */
.focus-card, .mine {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 20px;
  display: grid; gap: 14px;
}
.pager-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
}
.pager-title { text-align: center; min-width: 0; }
.pager-title-row { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; }
.pager-title h2 { font-size: var(--ts-head); line-height: 1.25; }
.pager-sub { color: var(--ink-2); font-size: var(--ts-sm); font-weight: 800; margin-top: 2px; }
.mine-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mine-top h2 { font-size: var(--ts-head); }
.chips { display: flex; flex-wrap: wrap; gap: 12px; }
.chip, .cls-btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: var(--tap);
  padding: 0.3em 0.95em;
  border-radius: 14px;
  border: 3px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  font-weight: 800;
}
.chip::before { content: ""; width: 0.85em; height: 0.85em; border-radius: 4px; background: var(--tint, var(--line)); border: 2px solid var(--ink); flex: none; }
.chip.chip-all::before { display: none; }
.chip .n { font-size: var(--ts-sm); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chip.done { background: var(--done-bg); border-color: var(--done-solid); }
.chip.done .n { color: var(--done); }
.chip[aria-current="true"], .cls-btn[aria-current="true"] {
  background: var(--primary); color: var(--on-primary); border-color: var(--primary);
}
.chip[aria-current="true"]::before { border-color: var(--on-primary); }
.chip[aria-current="true"] .n { color: var(--on-primary); }
.filter-row {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding-top: 12px; border-top: 2px solid var(--line);
}
.stu-filter-row {
  display: grid; gap: 10px;
  padding-top: 12px; border-top: 2px solid var(--line);
}
.stu-filter-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
}
.chip.chip-stu::before { display: none; }
.action-row {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding-top: 12px; border-top: 2px solid var(--line);
}
.seg-toggle {
  display: inline-flex; flex-wrap: nowrap;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-2);
}
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap);
  padding: 0.35em 0.95em;
  font-weight: 900;
  line-height: 1.3;
  color: var(--ink);
  background: transparent;
  text-align: center;
}
.seg-btn + .seg-btn { border-left: 2px solid var(--line); }
.seg-btn[aria-pressed="true"],
.seg-btn[aria-checked="true"] {
  background: var(--primary);
  color: var(--on-primary);
}
.hint { color: var(--ink-2); font-weight: 700; font-size: var(--ts-sm); }

/* ── Notices ────────────────────────────────────────────────────────── */
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--warn-bg); color: var(--warn);
  border: 3px solid var(--warn); border-radius: var(--radius);
  padding: 14px 16px; font-weight: 800; margin-bottom: 16px;
}
.notice > div { display: grid; gap: 12px; }

/* ── Class sections ─────────────────────────────────────────────────── */
.cls { margin-bottom: 30px; }
.cls-h {
  position: sticky; top: 6px; z-index: 5;
  display: grid; gap: 6px;
  background: color-mix(in srgb, var(--card) 74%, transparent);
  backdrop-filter: blur(16px) saturate(1.35);
  -webkit-backdrop-filter: blur(16px) saturate(1.35);
  border: 2px solid color-mix(in srgb, var(--line) 55%, transparent);
  border-left: 10px solid var(--tint, var(--primary));
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--ink) 10%, transparent);
}
:root[data-look="contrast"] .cls-h {
  background: var(--card);
  border: 3px solid var(--line);
  border-left: 12px solid var(--tint, var(--primary));
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}
.cls-h-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.cls-h h2 { font-size: var(--ts-head); line-height: 1.3; }
.cls-h p { font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cls-h.done p { color: var(--done); }
.meter { height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--card-2) 85%, transparent); overflow: hidden; border: 2px solid color-mix(in srgb, var(--line) 70%, transparent); }
.meter > span { display: block; height: 100%; width: var(--pct, 0%); background: var(--done-solid); border-radius: 999px; transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
.cls-note { background: var(--warn-bg); color: var(--warn); border: 3px solid var(--warn); border-radius: 14px; padding: 12px 16px; font-weight: 800; margin-bottom: 14px; }
.cls-cheer { display: flex; align-items: center; gap: 10px; background: var(--done-bg); color: var(--done); border: 3px solid var(--done-solid); border-radius: 14px; padding: 12px 16px; font-weight: 800; margin-bottom: 14px; }
.empty { background: var(--card); border: 3px solid var(--line); border-radius: var(--radius); padding: 20px; font-weight: 700; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-size: var(--ts-body); margin-bottom: 6px; }

/* Due-date band: shape + words + colour work together. */
.due {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  margin: 22px 0 12px;
  padding: 10px 16px;
  border-radius: 14px;
  border: 2px solid currentColor;
  font-size: var(--ts-body); font-weight: 900;
  color: var(--later); background: var(--later-bg);
}
.due span { font-weight: 800; font-size: var(--ts-sm); }
.due.d1 { color: var(--urgent); background: var(--urgent-bg); }
.due.d2 { color: var(--soon); background: var(--soon-bg); }

/* ── Homework 2-card responsive grid & card ────────────────────────── */
.hw-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.hw-grid > .hw { margin-bottom: 0; }
.stu-manage-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.hw {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
  display: grid; gap: 14px;
  border: 3px solid var(--line);
  transition: background-color 0.18s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.hw.band-d1 { border: 4px double var(--urgent); box-shadow: inset 8px 0 0 var(--urgent); }
.hw.band-d2 { border: 3px dashed var(--soon); box-shadow: inset 8px 0 0 var(--soon); }
.hw.band-d3 { border: 3px solid var(--line); box-shadow: inset 8px 0 0 var(--later); }
.hw.done { background: var(--done-bg); border: 3px solid var(--done-solid); box-shadow: none; }
.hw.done h3, .hw.done h4 { text-decoration: line-through; }
.hw-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.hw-badges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.due-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 10px;
  font-weight: 900; font-size: var(--ts-sm);
  border: 2px solid currentColor;
  color: var(--later); background: var(--later-bg);
}
.due-pill.d1 { color: var(--urgent); background: var(--urgent-bg); }
.due-pill.d2 { color: var(--soon); background: var(--soon-bg); }
.subj {
  display: inline-flex; align-items: center;
  padding: 4px 14px 4px 10px;
  border-radius: 10px;
  border: 2px solid var(--line);
  border-left: 8px solid var(--tint, var(--line));
  background: var(--card-2);
  color: var(--ink);
  font-weight: 900;
  font-size: var(--ts-sm);
}
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: var(--ts-sm); color: var(--on-new); background: var(--new); }
.hw h3, .hw h4 { font-size: var(--ts-head); line-height: 1.45; }
.kw-row { display: flex; flex-wrap: wrap; gap: 10px; }
.kw-tag {
  padding: 4px 12px; border-radius: 8px;
  background: var(--warn-bg); color: var(--warn);
  border: 2px solid var(--warn); font-weight: 900; font-size: var(--ts-sm);
}
.hw-body {
  overflow-wrap: anywhere;
  background: var(--card-2);
  border-radius: 12px;
  padding: 12px 14px;
}
.hw-body .none { color: var(--ink-2); }
.kw { font-weight: 900; color: inherit; background: none; text-decoration: underline; text-decoration-thickness: 3px; text-decoration-color: var(--coach-line); text-underline-offset: 0.2em; }
.hw-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.eclass { font-weight: 800; display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 4px 6px; }
.eclass .ic { width: 1.1em; height: 1.1em; }
.eclass-icon-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--card-2);
  color: var(--primary);
  text-decoration: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.eclass-icon-btn .ic { width: 1.2em; height: 1.2em; }

/* The one primary action on each card: a big "seen" switch with a drawn tick. */
.seen {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  min-height: max(62px, 3.2em);
  padding: 0.4em 1.05em 0.4em 0.85em;
  border-radius: 16px;
  border: 3px solid var(--primary);
  background: var(--primary-soft);
  color: var(--ink);
  font-weight: 900;
  line-height: 1.3;
}
.seen .box {
  flex: none; position: relative;
  width: 1.7em; height: 1.7em;
  border: 3px solid var(--primary);
  border-radius: 8px;
  background: var(--card);
  display: grid; place-items: center;
}
.seen .box svg { width: 1.2em; height: 1.2em; stroke: var(--on-done); fill: none; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; }
.seen small { display: block; font-weight: 800; font-size: var(--ts-sm); color: var(--ink-2); }
.seen.on { background: var(--card); border-color: var(--done-solid); color: var(--done); }
.seen.on .box { background: var(--done-solid); border-color: var(--done-solid); }
.seen.on .box svg { stroke-dashoffset: 0; }
.seen.pop .box svg { transition: stroke-dashoffset 0.35s cubic-bezier(0.22, 1, 0.36, 1) 0.05s; }
.seen.pop .box { animation: box-pop 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
.burst { position: absolute; left: 1.6em; top: 50%; width: 0; height: 0; pointer-events: none; }
.burst i { position: absolute; width: 9px; height: 9px; margin: -4.5px; border-radius: 50%; background: var(--coach); animation: burst 0.7s ease-out forwards; }
@keyframes box-pop { 0% { transform: scale(1); } 45% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes burst { from { transform: rotate(var(--a)) translateX(0); opacity: 1; } to { transform: rotate(var(--a)) translateX(2.4em); opacity: 0; } }

/* Per-student tick board inside each homework card */
.stu-board {
  border-top: 2px dashed var(--line);
  padding-top: 12px;
  display: grid;
  gap: 10px;
}
.stu-board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stu-summary {
  font-weight: 900;
  color: var(--ink-2);
  font-size: var(--ts-sm);
  font-variant-numeric: tabular-nums;
}
.stu-summary.done { color: var(--done); }
.btn-stu-all {
  min-height: 44px;
  padding: 0.25em 0.85em;
  font-size: var(--ts-sm);
  border-radius: 12px;
}
.stu-ticks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.stu-tick {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0.3em 0.9em 0.3em 0.65em;
  border-radius: 14px;
  border: 3px solid var(--primary);
  background: var(--primary-soft);
  color: var(--ink);
  font-weight: 900;
  line-height: 1.25;
}
.stu-tick .box {
  width: 1.35em;
  height: 1.35em;
  border: 3px solid var(--primary);
  border-radius: 7px;
  background: var(--card);
  display: grid;
  place-items: center;
  flex: none;
}
.stu-tick .box svg {
  width: 1em;
  height: 1em;
  stroke: var(--on-done);
  fill: none;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.stu-tick.on {
  background: var(--card);
  border-color: var(--done-solid);
  color: var(--done);
}
.stu-tick.on .box {
  background: var(--done-solid);
  border-color: var(--done-solid);
}
.stu-tick.on .box svg { opacity: 1; }
.stu-setup-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  font-size: var(--ts-sm);
  font-weight: 800;
  color: var(--ink-2);
}

/* Student management cards (#students) */
.stu-cls-card {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  display: grid;
  gap: 14px;
}
.stu-cls-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.stu-cls-head h2 { font-size: var(--ts-head); line-height: 1.3; }
.cov-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: var(--ts-sm);
  font-weight: 900;
}
.cov-pill.ok {
  background: var(--done-bg);
  color: var(--done);
  border: 2px solid var(--done-solid);
}
.cov-pill.missing {
  background: var(--warn-bg);
  color: var(--warn);
  border: 2px solid var(--warn);
}
.stu-item-list { display: grid; gap: 10px; }
.stu-item-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--card-2);
  border: 2px solid var(--line);
}
.stu-item-info { min-width: 0; display: grid; gap: 2px; }
.stu-item-info strong { font-size: var(--ts-body); color: var(--ink); }
.stu-item-info small { font-size: var(--ts-sm); font-weight: 700; color: var(--ink-2); }
.stu-item-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stu-item-actions .btn { min-height: 46px; padding: 0.25em 0.85em; font-size: var(--ts-sm); }

/* ── Choice tiles (class picker, look settings) ─────────────────────── */
.section-h { font-size: var(--ts-head); margin: 24px 0 10px; display: flex; align-items: center; gap: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.4em, 1fr)); gap: 12px; }
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 3.6em;
  padding: 0.4em 0.5em 0.35em;
  border-radius: var(--radius);
  border: 3px solid var(--line);
  border-top: 10px solid var(--tint, var(--line));
  background: var(--card);
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
}
.tile small { font-size: var(--ts-sm); font-weight: 800; color: var(--ink-2); display: inline-flex; align-items: center; gap: 4px; }
.tile.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tile.on small { color: var(--on-primary); }
.tile .ic { width: 1em; height: 1em; }
.tiles.wide { grid-template-columns: repeat(auto-fill, minmax(8.5em, 1fr)); }
.swatch { width: 100%; border-radius: 10px; padding: 6px 8px; margin-bottom: 4px; font-weight: 900; border: 2px solid var(--line); }
.look-actions { align-items: center; margin-top: 20px; }
.look-actions .btn-primary { flex: 1 1 12em; min-height: max(62px, 3.1em); }
.stickybar {
  position: sticky; bottom: 0; z-index: 6;
  display: grid; gap: 8px;
  margin: 26px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--ground);
  border-top: 3px solid var(--line);
}
.stickybar p { font-weight: 800; text-align: center; }
body.has-tabs .stickybar { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px)); }

/* ── Help & on-demand quick guide ──────────────────────────────────── */
.help-box {
  background: var(--card);
  border: 4px solid var(--primary);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 20px;
  display: grid; gap: 14px;
}
.help-box h2 { font-size: var(--ts-head); }
.help-steps { list-style: decimal inside; display: grid; gap: 10px; font-weight: 700; }
.steps { display: grid; gap: 14px; list-style: none; counter-reset: s; }
.steps > li { background: var(--card); border: 3px solid var(--line); border-radius: var(--radius); padding: 16px 16px 16px 3.2em; position: relative; font-weight: 700; display: grid; gap: 10px; }
.steps > li::before { counter-increment: s; content: counter(s); position: absolute; left: 14px; top: 16px; width: 1.6em; height: 1.6em; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-weight: 900; }
.demo { pointer-events: none; }
.faq { display: grid; gap: 12px; margin-top: 22px; }
.faq details { background: var(--card); border: 3px solid var(--line); border-radius: var(--radius); }
.faq summary { cursor: pointer; font-weight: 900; padding: 14px 16px; min-height: var(--tap); display: flex; align-items: center; gap: 10px; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "＋"; color: var(--primary); font-weight: 900; }
.faq details[open] summary::before { content: "－"; }
.faq details p { padding: 0 16px 16px; font-weight: 700; color: var(--ink-2); }

/* ── Past days ──────────────────────────────────────────────────────── */
.days { display: grid; gap: 14px; list-style: none; }
.day {
  display: flex; align-items: center; gap: 16px; width: 100%;
  min-height: max(62px, var(--tap));
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 3px solid var(--line);
  text-align: left;
}
.day .date { flex: none; width: 3.2em; text-align: center; line-height: 1.1; }
.day .date b { display: block; font-size: var(--ts-head); color: var(--primary); font-variant-numeric: tabular-nums; }
.day .date small { font-size: var(--ts-sm); font-weight: 800; color: var(--ink-2); }
.day .what { display: grid; min-width: 0; font-weight: 800; }
.day .what > span { color: var(--ink-2); font-size: var(--ts-sm); }
.nw { display: inline-block; margin-right: 0.8em; }
.day .ic { margin-left: auto; color: var(--primary); }

/* ── Bottom tab bar ─────────────────────────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--card);
  border-top: 3px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar ul { list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); max-width: 48rem; margin: 0 auto; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; min-height: var(--tabbar);
  padding: 6px 2px 8px;
  font-size: clamp(15px, 0.82em, 20px);
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink-2);
  text-align: center;
  position: relative;
}
.tab .ic { width: 1.7em; height: 1.7em; }
.tab[aria-current="page"] { color: var(--primary); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -3px; left: 18%; right: 18%; height: 5px; border-radius: 0 0 6px 6px; background: var(--primary); }
.tab[aria-current="page"] .ic { background: var(--primary-soft); border-radius: 12px; padding: 3px; }

/* ── Fallback toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 12px);
  width: min(calc(100vw - 32px), 34rem);
  background: var(--ink); color: var(--card);
  border: 3px solid var(--card);
  border-radius: 18px; padding: 14px 18px; font-weight: 900;
  display: flex; align-items: center; gap: 10px;
}
body:not(.has-tabs) .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }

/* ── Failed-class chip badge, keyword overview banner, manual notes ─── */
.chip.has-err { border-color: var(--warn); }
.err-mark {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 0.35em; border-radius: 6px;
  background: var(--warn-bg); color: var(--warn);
  border: 2px solid var(--warn); font-size: var(--ts-sm); line-height: 1.3;
}
.kw-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--warn-bg); color: var(--warn);
  border: 3px solid var(--warn); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 18px; font-weight: 800;
}
.tag-manual {
  background: var(--coach-bg); color: var(--ink);
  border: 2px solid var(--coach-line);
}
.manual-author { font-weight: 800; font-size: var(--ts-sm); color: var(--ink-2); }
.inline-confirm {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 14px;
  background: var(--urgent-bg); color: var(--urgent);
  border: 2px solid var(--urgent); font-weight: 800;
}

/* ── Inline note form & print options panel ─────────────────────────── */
.note-form, .pdf-panel, .print-panel {
  background: var(--card);
  border: 4px solid var(--primary);
  border-radius: 22px;
  padding: 20px;
  margin-bottom: 20px;
  display: grid; gap: 16px;
}
.note-form h3, .pdf-panel h3, .print-panel h3 { font-size: var(--ts-head); line-height: 1.35; }
.note-form form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11em, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 800; color: var(--ink); }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.4em 0.75em;
  border-radius: 14px;
  border: 3px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.5;
}
.field textarea { min-height: 5.5em; resize: vertical; }
.pdf-group { display: grid; gap: 8px; }
.pdf-group-label { font-weight: 800; color: var(--ink); }
.btn.opt-btn[aria-pressed="true"] {
  background: var(--primary); border-color: var(--primary); color: var(--on-primary);
}
.check-line {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap);
  padding: 10px 14px;
  border-radius: 14px;
  border: 3px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}
.check-line input[type="checkbox"] {
  width: 1.45em; height: 1.45em; flex: none;
  accent-color: var(--primary); cursor: pointer;
}

/* ── User bar & section pills (VPS mode) ────────────────────────────── */
.user-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px;
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px; font-size: var(--ts-sm); font-weight: 800; color: var(--ink);
}
.user-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.user-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.user-bar .btn { min-height: var(--tap); padding: 0.25em 0.9em; font-size: var(--ts-body); }
.user-pw-box {
  background: var(--card); border: 3px solid var(--primary); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; display: grid; gap: 12px;
}
.user-pw-box h2 { font-size: var(--ts-head); }
.sec-pill {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
  border: 2px solid var(--primary);
  font-size: var(--ts-sm); font-weight: 800; line-height: 1.4;
}

/* ── Footer & LAN QR Code ───────────────────────────────────────────── */
.foot { margin-top: 28px; padding-top: 16px; border-top: 2px solid var(--line); color: var(--ink-2); font-weight: 700; font-size: var(--ts-sm); display: grid; gap: 12px; }
.admin { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.admin .btn { min-height: var(--tap); }
.qr-box {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  margin-top: 4px;
}
.qr-box summary {
  cursor: pointer; font-weight: 900; color: var(--ink);
  padding: 12px 16px; min-height: var(--tap);
  display: flex; align-items: center; gap: 10px; list-style: none;
}
.qr-box summary::-webkit-details-marker { display: none; }
.qr-box summary::before { content: "＋"; color: var(--primary); font-weight: 900; }
.qr-box[open] summary::before { content: "－"; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12em, 1fr)); gap: 16px; padding: 0 16px 16px; }
.qr-item {
  display: grid; justify-items: center; gap: 8px;
  padding: 14px; border-radius: 14px;
  background: var(--card-2);
  text-align: center;
}
.qr-img {
  width: 180px; height: 180px; max-width: 100%;
  border-radius: 10px; background: var(--card);
  padding: 6px;
}
.qr-url { font-weight: 800; color: var(--ink); word-break: break-all; }

/* ── Loading ────────────────────────────────────────────────────────── */
.loading { display: grid; justify-items: center; gap: 14px; padding: 48px 0; font-weight: 800; color: var(--ink-2); }
.spinner { width: 3em; height: 3em; border-radius: 50%; border: 6px solid var(--card-2); border-top-color: var(--primary); }
html:not([data-motion="off"]) .spinner { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Motion: screens slide in gently; everything stops if asked ─────── */
html:not([data-motion="off"]) main.enter { animation: enter 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.desk-only { display: none !important; }
@media (hover: hover) and (min-width: 760px) {
  .desk-only { display: inline-flex !important; }
  .btn:hover, .tile:hover, .chip:hover, .cls-btn:hover, .day:hover { border-color: var(--primary); }
  .eclass-icon-btn:hover { border-color: var(--primary); background: var(--primary-soft); }
  .seen:hover, .stu-tick:hover { border-color: var(--done-solid); }
  .tab:hover { color: var(--primary); }
}

@media print {
  .tabbar, .bubble, .spot, .update-bar, .toast, .msg-dock, .help-box, .seen, .stu-board, .stu-setup-hint, .stu-filter-row, .eclass, .eclass-icon-btn, .foot, .mine, .focus-card, .notice, .note-form, .pdf-panel, .print-panel, .home-refresh-box, .user-bar, .user-pw-box, .action-feedback, .foot-account, .kw-banner, .qr-box, .btn-del-note, .inline-confirm { display: none !important; }
  body.has-tabs { padding-bottom: 0; }
  .cls-h { position: static; background: var(--card); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
  .hw { break-inside: avoid; border: 2px solid #000; }
}

@media (forced-colors: active) {
  .hw, .hw-body, .card, .mine, .focus-card, .hello, .empty, .cls-h, .meter, .chip, .cls-btn, .tile, .btn, .seg-toggle, .day, .bubble, .toast, .msg-dock, .help-box, .note-form, .pdf-panel, .print-panel, .home-refresh-box, .calm-note, .action-feedback, .kw-banner, .qr-box, .qr-item, .inline-confirm, .check-line, .field input, .field select, .field textarea, .user-bar, .user-pw-box, .sec-pill, .stu-tick, .stu-cls-card, .stu-item-row, .cov-pill, .eclass-icon-btn {
    border: 2px solid CanvasText;
  }
  .meter > span, .seen.on .box, .stu-tick.on .box, .tile.on, .chip[aria-current="true"], .cls-btn[aria-current="true"], .btn.opt-btn[aria-pressed="true"], .date-pills .btn[aria-pressed="true"], .seg-btn[aria-pressed="true"], .seg-btn[aria-checked="true"] {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
  .chip::before { background: CanvasText; forced-color-adjust: none; }
}

@media (max-width: 600px) {
  .pager-row { grid-template-columns: 1fr; }
  .seg-toggle { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
}

/* Very narrow screens (or 200% zoom on a phone): stack instead of squeezing. */
@media (max-width: 320px) {
  .steps > li { padding: 3.2em 14px 14px; }
  .steps > li::before { left: 14px; top: 12px; }
  .day { flex-wrap: wrap; gap: 8px 12px; }
  .hello { flex-wrap: wrap; }
  .shell { padding-inline: 12px; }
  .stickybar { margin-inline: -12px; padding-inline: 12px; }
  .tab { font-size: clamp(14px, 0.8em, 17px); }
}
