/* Resident Reading: design tokens first, then base, components, site, reader, owner console. */
:root {
  --bg: #F3F6F5;
  --surface: #FFFFFF;
  --ink: #14262B;
  --muted: #4A5E63;
  --line: #D4DDDB;
  --line-strong: #7D918E;
  --teal: #0F4C55;
  --teal-dark: #0A3840;
  --teal-tint: #E4EFF0;
  --signal: #C42F2F;
  --focus: #1A7482;
  --ok: #175F3C;   --ok-bg: #DFF1E6;
  --warn: #7A4E00; --warn-bg: #FAEBC8;
  --bad: #9A2020;  --bad-bg: #FBE3E0;
  --info: #3A4968; --info-bg: #E8EBF3;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 10px;
  --r-lg: 14px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body:has(dialog[open]) { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { width: min(72rem, 100% - 2.5rem); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.015em; line-height: 1.12; }
h2 { font-size: clamp(1.75rem, 3.2vw, 2.4rem); }
h3 { font-size: 1.3rem; }
.muted-p { color: var(--muted); }
.fine { color: var(--muted); font-size: 0.875rem; }
.empty { color: var(--muted); padding: 1.25rem 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.75rem; padding: 0.55rem 1.1rem;
  border: 1px solid transparent; border-radius: var(--r);
  font-weight: 600; font-size: 0.95rem; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-lg { min-height: 3.25rem; padding: 0.7rem 1.5rem; font-size: 1.02rem; }
.btn-sm { min-height: 2.25rem; padding: 0.35rem 0.8rem; font-size: 0.875rem; }
.btn-block { display: flex; width: 100%; margin-top: 0.75rem; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--teal-dark); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--teal-tint); border-color: var(--teal); }
.btn-danger { background: #A32424; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #861C1C; }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover:not(:disabled) { color: var(--bad); background: var(--bad-bg); }
.btn-ghost-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.45); }
.btn-ghost-light:hover { background: rgba(255, 255, 255, 0.12); }
.link { background: none; border: 0; padding: 0; color: var(--teal); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.icon { flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 0; border-radius: var(--r); background: transparent; cursor: pointer; }
.icon-btn:hover { background: rgba(127, 145, 142, 0.18); }

/* ---------- status chips ---------- */
.chip { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; line-height: 1.5; white-space: nowrap; background: #E6EAE9; color: var(--muted); }
.chip.is-active { background: var(--ok-bg); color: var(--ok); }
.chip.is-pending { background: var(--warn-bg); color: var(--warn); }
.chip.is-revoked { background: var(--bad-bg); color: var(--bad); }
.chip.is-new { background: #E6EAE9; color: var(--muted); }
.chip.is-sample { background: var(--info-bg); color: var(--info); }
.chip.is-free { background: var(--teal-tint); color: var(--teal); }

/* ---------- forms ---------- */
.field { margin: 0 0 1rem; }
.field label { display: block; margin-bottom: 0.3rem; font-weight: 600; font-size: 0.9rem; }
.field small { display: block; margin-top: 0.3rem; color: var(--muted); font-size: 0.82rem; }
.opt { color: var(--muted); font-weight: 400; }
input, select, textarea {
  width: 100%; padding: 0.65rem 0.8rem; font: inherit; font-size: 1rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--r);
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: 3px solid rgba(26, 116, 130, 0.3); outline-offset: 0; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; padding: 0; accent-color: var(--teal); flex: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.check { display: flex; align-items: center; gap: 0.6rem; margin: 0.4rem 0; cursor: pointer; }
.form-error { margin: 0 0 0.75rem; color: var(--bad); font-weight: 600; font-size: 0.92rem; }
.notice { margin: 0 0 1rem; padding: 0.7rem 0.9rem; border-left: 3px solid var(--teal); border-radius: 0 var(--r) var(--r) 0; background: var(--teal-tint); font-size: 0.92rem; }
.notice-warn { border-left-color: #B7791F; background: var(--warn-bg); color: #4F3300; }
.search input { background: #fff; }
.help { margin: 0 0 1rem; padding: 0.6rem 0.9rem; border: 1px solid var(--line); border-radius: var(--r); font-size: 0.9rem; }
.help summary { cursor: pointer; font-weight: 600; }
.help ul { margin-top: 0.5rem; display: grid; gap: 0.3rem; }
.help code { padding: 0.05rem 0.35rem; background: var(--teal-tint); border-radius: 4px; font: 0.85em var(--mono); }
.swap { margin-top: 1rem; text-align: center; color: var(--muted); font-size: 0.92rem; }

/* ---------- dialogs and toasts ---------- */
dialog { padding: 0; border: 0; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgba(8, 28, 32, 0.6); }
dialog.dlg { width: min(30rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); border-radius: var(--r-lg); box-shadow: 0 24px 60px -12px rgba(8, 28, 32, 0.5); overflow: auto; }
dialog.dlg-sm { width: min(26rem, calc(100vw - 2rem)); }
dialog.dlg-wide { width: min(46rem, calc(100vw - 2rem)); }
.dlg-body { position: relative; padding: 1.75rem; }
.dlg-body h2 { font-size: 1.65rem; margin-bottom: 0.6rem; padding-right: 2rem; }
.dlg-body > p { margin-bottom: 1rem; }
.dlg-x { position: absolute; top: 0.9rem; right: 0.9rem; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.dlg-x:hover { background: var(--teal-tint); color: var(--ink); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; flex-wrap: wrap; }
.account-line { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.75rem; color: var(--muted); }
#toasts { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 2147483647; display: grid; gap: 0.5rem; width: min(26rem, calc(100vw - 2rem)); pointer-events: none; }
.toast { padding: 0.75rem 1rem; border-radius: var(--r); background: var(--ink); color: #fff; font-size: 0.92rem; box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.45); transition: opacity 0.4s; }
.toast-error { background: #8E1F1F; }
.toast.out { opacity: 0; }

/* ---------- site header ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4.25rem; }
.bar .btn, .brand span { white-space: nowrap; }
.brand { display: inline-flex; align-items: center; gap: 0.65rem; text-decoration: none; font-family: var(--serif); font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; }
.logo rect { fill: var(--teal); }
.logo path { stroke: #fff; }
.primary-nav { display: flex; gap: 1.75rem; font-weight: 500; font-size: 0.95rem; }
.primary-nav a { text-decoration: none; color: var(--muted); padding: 0.4rem 0; }
.primary-nav a:hover { color: var(--teal); }
.bar-actions { display: flex; align-items: center; gap: 0.6rem; }
.member-pill { display: inline-flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0.8rem 0.3rem 0.35rem; border: 1px solid var(--line-strong); border-radius: 99px; background: #fff; cursor: pointer; }
.member-pill:hover { border-color: var(--teal); }
.avatar { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--teal); color: #fff; font-weight: 600; font-size: 0.9rem; }
.pill-name { font-weight: 600; font-size: 0.92rem; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; background-color: #fff;
  background-image:
    linear-gradient(rgba(196, 47, 47, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(196, 47, 47, 0.16) 1px, transparent 1px),
    linear-gradient(rgba(196, 47, 47, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(196, 47, 47, 0.07) 1px, transparent 1px);
  background-size: 60px 60px, 60px 60px, 12px 12px, 12px 12px;
  border-bottom: 1px solid var(--line);
  padding: clamp(2.5rem, 7vw, 5rem) 0 clamp(8rem, 14vw, 10.5rem);
}
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: clamp(2rem, 6vw, 5rem); align-items: center; }
.hero h1 { font-size: clamp(2.5rem, 6vw, 4.2rem); line-height: 1.04; letter-spacing: -0.025em; max-width: 15ch; text-wrap: balance; }
.lead { margin-top: 1.25rem; max-width: 34rem; font-size: 1.15rem; line-height: 1.65; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }
.hero .fine { margin-top: 1rem; }
.specimen { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: 0 22px 44px -22px rgba(10, 56, 64, 0.45); }
.specimen-bar { display: flex; justify-content: space-between; gap: 1rem; padding: 0.55rem 1rem; background: var(--teal-dark); color: #CFE3E5; font-size: 0.8rem; }
.specimen-page { position: relative; padding: 1.5rem 1.5rem 2.6rem; }
.specimen-page h2 { font-size: 1.55rem; }
.specimen-page h3 { margin: 0.9rem 0 0.4rem; font-family: var(--sans); font-size: 0.95rem; font-weight: 600; letter-spacing: 0; color: var(--teal); }
.specimen-page ul { display: grid; gap: 0.35rem; padding-left: 1.1rem; list-style: disc; font-family: var(--serif); font-size: 1.02rem; line-height: 1.45; }
.specimen-callout { margin-top: 1rem; padding: 0.7rem 0.9rem; border-left: 3px solid var(--teal); background: var(--teal-tint); font-family: var(--serif); font-size: 0.98rem; line-height: 1.45; }
.specimen-wm { position: absolute; right: 1rem; bottom: 0.7rem; font-size: 0.72rem; color: rgba(20, 38, 43, 0.35); font-style: italic; }
.ecg { position: absolute; left: 0; bottom: 0; width: 100%; height: clamp(110px, 16vw, 150px); pointer-events: none; }
.ecg path { fill: none; stroke: var(--signal); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
@media (prefers-reduced-motion: no-preference) {
  .ecg:not(.still) path { animation: trace 3.2s cubic-bezier(0.45, 0.05, 0.3, 1) 0.2s both; }
  @keyframes trace { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
}

/* ---------- sections ---------- */
.section { padding: clamp(3rem, 7vw, 5.5rem) 0; }
.band { background: var(--surface); border-block: 1px solid var(--line); }
.section-intro { max-width: 40rem; margin-bottom: 2rem; }
.section-intro p { margin-top: 0.6rem; color: var(--muted); font-size: 1.05rem; }

/* library: a table of contents */
.library-grid { display: grid; grid-template-columns: 19rem minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3.5rem); align-items: start; }
.contents { position: sticky; top: 5.5rem; }
.contents-row { display: flex; align-items: baseline; gap: 0.5rem; width: 100%; padding: 0.5rem 0.65rem; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; color: var(--muted); font-size: 0.95rem; }
.contents-row:hover { background: var(--teal-tint); color: var(--ink); }
.contents-row.is-active { background: var(--teal); color: #fff; font-weight: 600; }
.c-lead { flex: 1; min-width: 0.5rem; border-bottom: 1px dotted currentColor; opacity: 0.45; transform: translateY(-0.25em); }
.c-count { font-variant-numeric: tabular-nums; font-weight: 600; }
.notes-panel { min-width: 0; }
.search { display: block; margin-bottom: 1.5rem; }
.notes-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-bottom: 0.6rem; border-bottom: 2px solid var(--ink); font-size: 1.6rem; }
.notes-count { font: 500 0.9rem var(--sans); color: var(--muted); letter-spacing: 0; }
.note-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 1.25rem; width: 100%; padding: 1rem 0.25rem; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.note-row:hover { background: rgba(228, 239, 240, 0.7); }
.note-main { display: grid; gap: 0.15rem; }
.note-main strong { font-family: var(--serif); font-size: 1.25rem; font-weight: 500; line-height: 1.25; }
.note-sum { color: var(--muted); font-size: 0.92rem; }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.8rem; color: var(--muted); font-size: 0.85rem; justify-content: flex-end; }
.access { display: inline-flex; align-items: center; gap: 0.35rem; min-width: 6.5rem; justify-content: flex-end; font-size: 0.875rem; font-weight: 600; }
.access .icon { width: 14px; height: 14px; }
.access-open { color: var(--teal); }
.access-free { color: var(--ok); }
.access-locked { color: var(--muted); }

/* lectures */
.lecture-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 1.1rem; width: 100%; padding: 1rem 0.25rem; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.lecture-row:hover { background: rgba(228, 239, 240, 0.7); }
.play { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--teal); color: #fff; }
.play .icon { margin-left: 2px; }
.lec-main { display: grid; }
.lec-main strong { font-family: var(--serif); font-size: 1.2rem; font-weight: 500; }
.lec-main span { color: var(--muted); font-size: 0.9rem; }
.lec-meta { color: var(--muted); font-size: 0.9rem; }
.lec-access { display: inline-flex; align-items: center; gap: 0.35rem; min-width: 6.5rem; justify-content: flex-end; font-size: 0.875rem; font-weight: 600; color: var(--teal); }
.lec-access .icon { width: 14px; height: 14px; }

/* membership */
.membership { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.plan { padding: clamp(1.5rem, 4vw, 2.25rem); background: var(--surface); border: 2px solid var(--teal); border-radius: var(--r-lg); }
.price { margin-top: 1rem; font-family: var(--serif); font-size: clamp(3.2rem, 8vw, 4.4rem); font-weight: 500; line-height: 1; letter-spacing: -0.03em; }
.price-note { margin-top: 0.4rem; color: var(--muted); }
.included { display: grid; gap: 0.55rem; margin: 1.5rem 0; }
.included li { position: relative; padding-left: 1.7rem; }
.included li::before { content: ''; position: absolute; left: 0.2rem; top: 0.38em; width: 0.5rem; height: 0.85rem; border: solid var(--teal); border-width: 0 2.5px 2.5px 0; transform: rotate(40deg); }
.how h3 { margin-bottom: 1rem; }
.steps { counter-reset: step; display: grid; gap: 1.25rem; }
.steps li { counter-increment: step; position: relative; display: grid; gap: 0.15rem; padding-left: 3rem; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border: 2px solid var(--teal); border-radius: 50%; font-weight: 600; color: var(--teal); }
.steps span { color: var(--muted); }
.how .fine { margin-top: 1.5rem; }

/* payment */
.qr-box { display: grid; justify-items: center; gap: 0.6rem; margin: 0.5rem 0 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; }
.qr-box svg { width: min(15rem, 100%); height: auto; }
.qr-small svg { width: 9.5rem; }
.qr-amount { font-weight: 600; }
.copy-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0 0 1rem; padding: 0.4rem 0.4rem 0.4rem 0.9rem; border: 1px solid var(--line-strong); border-radius: var(--r); }
.upi-id { font-family: var(--mono); font-size: 0.92rem; overflow-wrap: anywhere; }

/* footer */
.site-footer { padding: 2.5rem 0; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.875rem; }
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem; }
.foot .brand { color: var(--ink); }
.foot p { max-width: 38rem; }
.owner-link { color: var(--muted); }

/* ---------- reader ---------- */
dialog.reader {
  --rbg: #E9EEED; --rpage: #FFFFFF; --rink: #1B2B30; --rmuted: #52666B; --rline: #D4DDDB; --rbar: #FFFFFF; --rtint: #E4EFF0; --raccent: #0F4C55;
  width: 100%; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0;
  background: var(--rbg); color: var(--rink);
}
dialog.reader[open] { display: flex; flex-direction: column; }
dialog.reader.night { --rbg: #0D1517; --rpage: #152024; --rink: #DCE7E5; --rmuted: #9DB1B0; --rline: #2A3A3E; --rbar: #101B1E; --rtint: #1E3237; --raccent: #7CC4CE; }
.reader .btn-ghost { color: var(--rink); border-color: var(--rline); }
.reader .btn-ghost:hover:not(:disabled) { background: var(--rtint); }
.reader.night .btn-primary { background: #1F7380; }
.reader .icon-btn { color: var(--rink); }
.reader textarea { background: var(--rpage); color: var(--rink); border-color: var(--rline); }
.reader .muted-p, .reader .empty { color: var(--rmuted); }
.reader .link { color: var(--raccent); }
.reader-bar { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.9rem; background: var(--rbar); border-bottom: 1px solid var(--rline); }
.reader-title { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.reader-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-title span { color: var(--rmuted); font-size: 0.82rem; }
.reader-tools { display: flex; gap: 0.5rem; }
.reader-body { position: relative; display: flex; flex: 1; min-height: 0; }
.reader-view { position: relative; flex: 1; min-width: 0; }
.reader-stage { height: 100%; overflow: auto; padding: clamp(0.75rem, 3vw, 2.25rem); outline-offset: -3px; }
.page { max-width: 44rem; min-height: 60vh; margin: 0 auto; padding: clamp(1.25rem, 4vw, 3rem); background: var(--rpage); border: 1px solid var(--rline); border-radius: 4px; font-family: var(--serif); font-size: 1.15rem; line-height: 1.7; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.page h2 { margin-bottom: 1rem; font-size: clamp(1.7rem, 4vw, 2.2rem); }
.page h3 { margin: 1.5rem 0 0.5rem; font-size: 1.3rem; color: var(--raccent); }
.page p { margin: 0 0 1rem; }
.page ul, .page ol { margin: 0 0 1rem; padding-left: 1.5rem; }
.page ul { list-style: disc; }
.page ol { list-style: decimal; }
.page li { margin-bottom: 0.45rem; padding-left: 0.2rem; }
.page strong { font-weight: 600; }
.callout { margin: 1.25rem 0; padding: 0.85rem 1.1rem; border-left: 4px solid var(--raccent); border-radius: 0 6px 6px 0; background: var(--rtint); font-size: 1.05rem; line-height: 1.55; }
.table-wrap { margin: 0 0 1.25rem; overflow-x: auto; }
.page table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.95rem; line-height: 1.5; }
.page th, .page td { padding: 0.6rem 0.75rem; border: 1px solid var(--rline); text-align: left; vertical-align: top; }
.page th { background: var(--rtint); font-weight: 600; }
.page td:first-child { font-weight: 600; }
.sample-banner { margin: 0 0 1.25rem; padding: 0.4rem 0.75rem; border-radius: 6px; background: var(--warn-bg); color: var(--warn); font: 500 0.85rem var(--sans); }
.reader-fine { max-width: 44rem; margin: 0.9rem auto 0; color: var(--rmuted); font-size: 0.8rem; text-align: center; }
.wm { position: absolute; inset: 0; z-index: 2; pointer-events: none; background-repeat: repeat; }
.reader-side { width: 21rem; flex: none; overflow: auto; padding: 1.25rem; background: var(--rbar); border-left: 1px solid var(--rline); }
.reader-side h3 { margin-bottom: 0.75rem; font-size: 1.15rem; }
.ann-list { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.ann-list li { padding: 0.7rem 0.8rem; border: 1px solid var(--rline); border-radius: var(--r); background: var(--rpage); }
.ann-list p { margin-bottom: 0.4rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.ann-list div { display: flex; justify-content: space-between; color: var(--rmuted); font-size: 0.8rem; }
.reader-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.55rem 0.9rem; background: var(--rbar); border-top: 1px solid var(--rline); font-weight: 500; font-size: 0.92rem; }
.lecture-frame { aspect-ratio: 16 / 9; margin-top: 0.75rem; border-radius: var(--r); overflow: hidden; background: #000; }
.lecture-frame iframe, .lecture-frame video { display: block; width: 100%; height: 100%; border: 0; }
@media print { dialog.reader { display: none !important; } }

/* ---------- owner console ---------- */
.gate { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; background: var(--bg); }
.gate-card { width: min(26rem, 100%); padding: 2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 18px 40px -24px rgba(10, 56, 64, 0.4); }
.gate-card .brand { margin-bottom: 1.5rem; }
.gate-card h1 { font-size: 1.9rem; margin-bottom: 0.5rem; }
.gate-card p { margin-bottom: 1.25rem; color: var(--muted); }
.gate-card .btn-block { margin-top: 0.25rem; }
.back-link { display: block; margin-top: 1.25rem; text-align: center; color: var(--muted); font-size: 0.9rem; }
.console { min-height: 100vh; background: var(--bg); }
.console-bar { background: var(--teal-dark); color: #fff; }
.console-bar :focus-visible { outline-color: #fff; }
.brand-light { color: #fff; }
.console-main { padding-block: 1.5rem 4rem; }
.tabs { display: flex; gap: 0.25rem; margin-bottom: 1.25rem; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { position: relative; display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.75rem 1rem; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 600; white-space: nowrap; cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--teal); border-bottom-color: var(--teal); }
.tab-badge { min-width: 1.25rem; padding: 0 0.4rem; border-radius: 99px; background: var(--signal); color: #fff; font-size: 0.75rem; line-height: 1.25rem; text-align: center; }
.panel { padding: clamp(1.1rem, 3vw, 2rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel > h3, .panel > .table-scroll, .panel > .todo, .panel > .activity { margin-top: 1.75rem; }
.panel > h3 { margin-bottom: 0.6rem; }
.panel-title { font-size: 1.7rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.panel > .muted-p { margin: 0.4rem 0 0; }
.ledger { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 1.25rem; border: 1px solid var(--line); border-radius: var(--r); }
.ledger > div { padding: 1rem 1.15rem; border-right: 1px solid var(--line); }
.ledger > div:last-child { border-right: 0; }
.ledger dt { color: var(--muted); font-size: 0.85rem; }
.ledger dd { margin-top: 0.15rem; font-family: var(--serif); font-size: 2.2rem; font-weight: 500; line-height: 1.15; font-variant-numeric: tabular-nums; }
.ledger dd small { display: block; font: 400 0.85rem/1.4 var(--sans); color: var(--muted); }
.todo { display: grid; gap: 0.5rem; }
.todo li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.75rem 1rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.activity li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.activity time { color: var(--muted); white-space: nowrap; font-size: 0.85rem; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
table.data { width: 100%; min-width: 36rem; border-collapse: collapse; font-size: 0.93rem; }
table.data th { padding: 0.65rem 0.9rem; background: var(--bg); color: var(--muted); font-size: 0.82rem; font-weight: 600; text-align: left; white-space: nowrap; }
table.data td { padding: 0.75rem 0.9rem; border-top: 1px solid var(--line); vertical-align: middle; }
table.data .sub { display: block; max-width: 26rem; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
table.data .nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td:first-child { min-width: 11rem; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn + .btn { margin-left: 0.35rem; }
.toolbar { margin: 1rem 0; max-width: 24rem; }
.toolbar .search { margin: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1.5rem, 4vw, 3rem); margin-top: 1.75rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.settings-grid h3 { margin-bottom: 0.75rem; }
.settings-grid .muted-p { margin-bottom: 1rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.danger-zone h3 { color: var(--bad); }

/* ---------- loading, errors and server-backed pages ---------- */
.no-js { padding: 2rem; font-family: var(--sans); }
.page-loading { padding: 2rem 0; color: var(--muted); text-align: center; }
.load-error { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.load-card { width: min(26rem, 100%); padding: 2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 18px 40px -24px rgba(10, 56, 64, 0.4); }
.load-card .brand { margin-bottom: 1.25rem; }
.load-card h1 { margin-bottom: 0.5rem; font-size: 1.7rem; }
.load-card p { margin-bottom: 1.25rem; color: var(--muted); }
.gate-card code { padding: 0.05rem 0.35rem; background: var(--teal-tint); border-radius: 4px; font: 0.85em var(--mono); }
.page.is-loading { display: grid; place-items: center; }
.page.is-image { max-width: 62rem; min-height: 0; padding: 0; overflow: hidden; background: #fff; }
.page-img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; pointer-events: none; }
.page-note { display: grid; justify-items: start; gap: 0.75rem; font-family: var(--sans); font-size: 1rem; }
.page-note p { margin: 0; color: var(--bad); font-weight: 600; }
.reader-view:has(.page.is-image) .wm { display: none; } /* PDF pages already carry the stamp from the server */
.reader.night .page.is-image { filter: invert(0.9) hue-rotate(180deg); }
fieldset.field { padding: 0; border: 0; min-width: 0; }
fieldset.field legend { margin-bottom: 0.3rem; padding: 0; font-weight: 600; font-size: 0.9rem; }
.upload { display: grid; gap: 0.35rem; margin: 0.9rem 0; font-size: 0.9rem; color: var(--muted); }
progress { width: 100%; height: 0.6rem; accent-color: var(--teal); }
table.data .sub-bad { color: var(--bad); }
.facts { display: grid; gap: 0.5rem; }
.facts > div { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.facts dt { color: var(--muted); }
.facts dd { font-weight: 600; text-align: right; }
.temp-pass { font-size: 1.15rem; font-weight: 600; letter-spacing: 0.02em; }
input[type="file"] { padding: 0.5rem 0.6rem; }
input[type="radio"] { width: 1.15rem; height: 1.15rem; padding: 0; accent-color: var(--teal); flex: none; }

/* ---------- small screens ---------- */
@media (max-width: 62rem) {
  .library-grid { grid-template-columns: minmax(0, 1fr); }
  .contents { position: static; min-width: 0; }
  .contents ul { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.5rem; }
  .contents li { flex: none; }
  .contents-row { width: auto; border: 1px solid var(--line-strong); border-radius: 99px; padding: 0.4rem 0.9rem; white-space: nowrap; }
  .contents-row.is-active { border-color: var(--teal); }
  .c-lead { display: none; }
  .hero-grid, .membership { grid-template-columns: minmax(0, 1fr); }
  .specimen { max-width: 30rem; }
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger > div:nth-child(2) { border-right: 0; }
  .ledger > div:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 46rem) {
  .primary-nav, .pill-name, .hide-sm { display: none; }
  .bar-actions .btn-primary { padding-inline: 0.8rem; }
  .note-row { grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem 1rem; }
  .note-meta { grid-column: 1; justify-content: flex-start; order: 3; }
  .access { grid-column: 2; grid-row: 1; min-width: 0; }
  .lecture-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .lec-meta { display: none; }
  .lec-access { min-width: 0; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .dlg-body { padding: 1.35rem; }
  .reader-tools .btn span { display: none; }
  .reader-side { position: absolute; z-index: 3; top: 0; right: 0; bottom: 0; width: min(21rem, 92%); box-shadow: -12px 0 30px rgba(0, 0, 0, 0.3); }
  .foot { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 30rem) {
  .brand { font-size: 1.15rem; gap: 0.5rem; }
  .upi-id { font-size: 0.78rem; }
  .hero-actions .btn { width: 100%; }
  .ledger dd { font-size: 1.8rem; }
  .activity li { flex-direction: column; gap: 0.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toast { transition: none; }
}

/* Local-only reader markup tools */
.reader-markup-bar { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; padding:.45rem .8rem; background:var(--rbar); border-bottom:1px solid var(--rline); }
.reader-markup-bar [aria-pressed="true"] { background:var(--rtint); border-color:var(--raccent); }
.reader .page { position:relative; }
.reader-mark-canvas { position:absolute; inset:0; z-index:1; display:block; max-width:100%; cursor:crosshair; }
.reader .page.is-image .reader-mark-canvas { border-radius:3px; }
@media (max-width:640px) { .reader-markup-bar { gap:.3rem; } .reader-markup-bar .btn { padding:.4rem .55rem; font-size:.78rem; } }
