/* TakPedia — Taktikal Directional brand (light + dark themes) */
:root {
  --olive: #626B3E; --olive-dark: #4C5430; --sand: #CEA588; --teal: #2E464A; --red: #8A2E2B;
  --head: "Bebas Neue", "Arial Narrow", sans-serif;
  --body: "Barlow", "Segoe UI", Arial, sans-serif;
  /* light theme */
  --bg: #FAFAF7; --surface: #FFFFFF; --surface2: #F4F4EF; --text: #282820; --text2: #3d3d34;
  --muted: #6B6B62; --line: #E4E4DC; --bar: #282820; --bar-text: #FFFFFF;
  --olive-tint: #EEF0E4; --sand-tint: #F3E9DF; --red-tint: #F6E8E7; --teal-tint: #EDF2F2;
  --mark: #F5E4A8; --shadow: rgba(40,40,32,.13); --accent-on-dark: #CEA588;
}
[data-theme="dark"] {
  --bg: #191914; --surface: #22221C; --surface2: #2A2A23; --text: #EAEAE2; --text2: #D5D5CA;
  --muted: #A2A294; --line: #3A3A31; --bar: #121210; --bar-text: #EAEAE2;
  --olive-tint: #2C3122; --sand-tint: #332A21; --red-tint: #33211F; --teal-tint: #20302F;
  --mark: #6b5c1e; --shadow: rgba(0,0,0,.5);
  --olive: #8B9660; --sand: #D8B491; --red: #C96B66; --teal: #7FA6AC; --olive-dark: #A5B175;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--body); color: var(--text); background: var(--bg);
  transition: background .35s ease, color .35s ease; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- top bar ---------- */
#topbar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 12px;
  background: var(--bar); padding: 10px 18px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.spacer { flex: 1; }
#navToggle { display: none; background: none; border: 1px solid #555; color: var(--bar-text); font-size: 18px; border-radius: 8px; padding: 4px 11px; cursor: pointer; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 6px 10px; margin: -6px -4px; border-radius: 8px; cursor: pointer; }
.brand:hover { background: rgba(255,255,255,.08); }
.brand img { height: 30px; filter: brightness(0) invert(1); }
.brand-name { font-family: var(--head); font-size: 26px; color: #fff; letter-spacing: 1px; }
.brand-name span { color: var(--accent-on-dark); }
/* Mono theme toggle: one SVG in currentColor, morphing moon ⇄ sun. */
#themeToggle { background: none; border: none; padding: 5px 6px; opacity: .55; color: var(--bar-text);
  cursor: pointer; line-height: 0; transition: opacity .2s; }
#themeToggle:hover { opacity: 1; }
/* Phone-only shortcut to the manual page and its search box; same monochrome look as the theme toggle. */
#searchGo { display: none; background: none; border: none; padding: 5px 6px; opacity: .55; color: var(--bar-text);
  cursor: pointer; line-height: 0; transition: opacity .2s; }
#searchGo:hover { opacity: 1; }
.tt-ico { display: block; }
.tt-ico .tt-core { transition: r .45s cubic-bezier(.4,0,.2,1); }
.tt-ico .tt-rays { transform-origin: 12px 12px;
  transition: transform .45s cubic-bezier(.4,0,.2,1), opacity .3s ease; }
.tt-ico .tt-maskwrap { transition: transform .45s cubic-bezier(.4,0,.2,1); }
/* Light shows the moon (click for dark): rays hidden, mask bite in place. */
[data-theme="light"] .tt-ico .tt-rays { opacity: 0; transform: rotate(-50deg) scale(.4); }
[data-theme="light"] .tt-ico .tt-maskwrap { transform: translate(0, 0); }
/* Dark shows the sun: bite slides away, rays fan out, core tightens. */
[data-theme="dark"] .tt-ico .tt-core { r: 4.6px; }
[data-theme="dark"] .tt-ico .tt-rays { opacity: 1; transform: none; }
[data-theme="dark"] .tt-ico .tt-maskwrap { transform: translate(9px, -9px); }
.quiz-cta { font-family: var(--head); font-size: 18px; letter-spacing: 1px; color: #282820; background: var(--accent-on-dark);
  padding: 7px 16px; border-radius: 8px; text-decoration: none; transition: filter .2s, transform .15s; }
.quiz-cta:hover { filter: brightness(1.07); transform: translateY(-1px); }

/* ---------- expanding search panel ---------- */
#searchPanel { position: sticky; top: 56px; z-index: 55; background: var(--surface); border-bottom: 1px solid var(--line);
  max-height: 0; overflow: hidden; transition: max-height .35s cubic-bezier(.4,0,.2,1), box-shadow .35s; }
#searchPanel.open { max-height: 90px; box-shadow: 0 10px 26px var(--shadow); }
.sp-inner { display: flex; gap: 10px; max-width: 780px; margin: 0 auto; padding: 16px 18px; }
.sp-inner input { flex: 1; padding: 11px 16px; font: 15px var(--body); border: 2px solid var(--olive); border-radius: 10px;
  background: var(--bg); color: var(--text); outline: none; transition: box-shadow .2s; }
.sp-inner input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--olive) 25%, transparent); }
.sp-inner button { border: none; border-radius: 10px; cursor: pointer; font-family: var(--head); letter-spacing: 1px; }
#searchBtn { background: var(--olive); color: #fff; font-size: 17px; padding: 0 22px; transition: background .2s; }
#searchBtn:hover { background: var(--olive-dark); }
#searchClose { background: var(--surface2); color: var(--muted); font-size: 15px; padding: 0 14px; }

/* ---------- global reading progress bar ---------- */
/* The global readbar under the topbar is gone — the sidebar carries progress. */

/* ---------- layout ---------- */
#layout { display: flex; min-height: calc(100vh - 60px); }
#sidebar { width: 300px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); padding: 0 0 60px;
  overflow-y: auto; max-height: calc(100vh - 60px); position: sticky; top: 60px; transition: background .35s; }
#content { flex: 1; min-width: 0; padding: 28px 44px 90px; max-width: 1020px; margin: 0 auto; }
#content > * { animation: viewin .35s ease backwards; }
@keyframes viewin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 58; opacity: 0; pointer-events: none; transition: opacity .25s; }
#scrim.show { opacity: 1; pointer-events: auto; }

/* sidebar progress */
.side-progress { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.sp-label { display: flex; justify-content: space-between; font-family: var(--head); font-size: 13px; letter-spacing: 1.2px; color: var(--muted); margin-bottom: 6px; }
.sp-label span:last-child { color: var(--olive); }
.sp-track { height: 8px; background: var(--surface2); border-radius: 6px; overflow: hidden; }
.sp-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--olive), var(--sand)); border-radius: 6px;
  transition: width .8s cubic-bezier(.4,0,.2,1); }

/* sidebar nav */
.side-part { margin: 0; }
.side-part > button { width: 100%; text-align: left; background: none; border: none; border-left: 4px solid transparent; cursor: pointer;
  padding: 10px 16px 10px 12px; font-family: var(--head); font-size: 17px; letter-spacing: .5px; color: var(--text);
  display: flex; align-items: baseline; gap: 8px; transition: background .2s, border-color .2s; }
.side-part > button .pn { color: var(--sand); font-size: 13px; min-width: 78px; }
.side-part > button .caret { margin-left: auto; font-size: 11px; color: var(--muted); transition: transform .25s ease; }
.side-part.open > button .caret { transform: rotate(90deg); }
.side-part > button:hover { background: var(--olive-tint); }
.side-part > button:hover { border-left-color: var(--olive); }
.side-part.open > button { background: var(--olive-tint); border-left-color: var(--olive); }
.side-chapters { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s ease; }
.side-chapters > div { overflow: hidden; }
.side-part.open .side-chapters { grid-template-rows: 1fr; }
.side-chapters a { display: flex; gap: 8px; align-items: baseline; width: 100%; margin: 0;
  padding: 7px 16px 7px 34px; font-size: 13.5px; border-left: 4px solid transparent;
  color: var(--text); text-decoration: none; line-height: 1.3; transition: background .15s, border-color .15s; }
.side-chapters a:hover { background: var(--sand-tint); border-left-color: var(--sand); }
.side-chapters a.active { background: var(--sand-tint); border-left: 4px solid var(--sand); font-weight: 600; }
.side-chapters .cno { color: var(--muted); font-size: 12px; min-width: 20px; }
/* Read mark sits at the row's right edge — it never shifts the number or title. */
.side-chapters a { position: relative; padding-right: 30px; }
.side-chapters a.read::after { content: "✓"; position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); color: var(--olive); font-weight: 700; }
.side-partbar { height: 3px; margin: 0 16px 0 16px; padding: 0; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.side-part.open .side-partbar { margin-bottom: 4px; }
.side-partbar > div { height: 100%; background: var(--olive); border-radius: 3px; transition: width .5s ease; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 40px 10px 6px; }
.hero img { height: 104px; animation: heroPop .6s cubic-bezier(.34,1.4,.64,1) both; }
[data-theme="dark"] .hero img { filter: brightness(0) invert(.92); }
@keyframes heroPop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
.hero h1 { font-family: var(--head); font-size: 54px; margin: 12px 0 4px; letter-spacing: 1px; }
.hero h1 span { color: var(--olive); }
.hero p.sub { color: var(--muted); margin: 0 0 18px; font-size: 16px; }
.hero .bigsearch { display: flex; max-width: 640px; margin: 0 auto 8px; box-shadow: 0 4px 18px var(--shadow); border-radius: 10px;
  transition: box-shadow .25s, transform .25s; }
.hero .bigsearch:focus-within { box-shadow: 0 8px 28px var(--shadow); transform: translateY(-2px); }
.hero .bigsearch input { flex: 1; padding: 15px 18px; font-size: 16px; border: 2px solid var(--olive); border-right: none;
  border-radius: 10px 0 0 10px; background: var(--surface); color: var(--text); outline: none; min-width: 0; }
.hero .bigsearch button { border: none; background: var(--olive); color: #fff; font-family: var(--head); font-size: 20px;
  padding: 0 26px; border-radius: 0 10px 10px 0; cursor: pointer; transition: background .2s; }
.hero .bigsearch button:hover { background: var(--olive-dark); }
.hero .hints { font-size: 13px; color: var(--muted); }
.hero .hints a { color: var(--teal); text-decoration: none; border-bottom: 1px dotted var(--teal); margin: 0 6px; cursor: pointer; }
.statrow { display: flex; justify-content: center; gap: 34px; margin: 24px 0 4px; flex-wrap: wrap; }
.stat .n { font-family: var(--head); font-size: 40px; color: var(--olive); line-height: 1; text-align: center; }
.stat .l { font-size: 12px; letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; text-align: center; }
.home-progress { max-width: 560px; margin: 14px auto 0; }
.home-progress .sp-label { margin-bottom: 5px; }
.home-progress .sp-track { height: 10px; }
.partgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 26px; }
@media (max-width: 900px) { .partgrid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .partgrid { grid-template-columns: 1fr; } }
.pcard { background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--olive); border-radius: 10px;
  padding: 22px 22px 18px; cursor: pointer; transition: transform .22s cubic-bezier(.34,1.3,.64,1), background .35s;
  animation: viewin .4s ease backwards; display: flex; flex-direction: column; }
.partgrid .pcard:nth-child(2) { animation-delay: .04s } .partgrid .pcard:nth-child(3) { animation-delay: .08s }
.partgrid .pcard:nth-child(4) { animation-delay: .12s } .partgrid .pcard:nth-child(5) { animation-delay: .16s }
.partgrid .pcard:nth-child(6) { animation-delay: .2s } .partgrid .pcard:nth-child(7) { animation-delay: .24s }
.partgrid .pcard:nth-child(8) { animation-delay: .28s } .partgrid .pcard:nth-child(n+9) { animation-delay: .32s }
.pcard:hover { transform: scale(1.04); }
.pcard .pn { font-family: var(--head); font-size: 14px; color: var(--sand); letter-spacing: 1.5px; }
.pcard h3 { font-family: var(--head); font-size: 28px; margin: 3px 0 8px; letter-spacing: .5px; line-height: 1.05; }
.pcard p { font-size: 13.5px; color: var(--muted); margin: 0 0 12px; font-style: italic; flex: 1; line-height: 1.45; }
.pcard .meta { font-size: 12.5px; color: var(--olive); font-weight: 600; margin-bottom: 8px; }
.pcard .pbar { height: 6px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.pcard .pbar > div { height: 100%; background: linear-gradient(90deg, var(--olive), var(--sand)); border-radius: 4px; transition: width .7s ease; }

/* ---------- chapter view ---------- */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--teal); text-decoration: none; }
.ch-title { font-family: var(--head); font-size: 40px; letter-spacing: .5px; margin: 0 0 2px;
  border-bottom: 3px solid var(--olive); padding-bottom: 8px; }
.ch-title .no { color: var(--sand); margin-right: 8px; }
.ch-ref { font-size: 12.5px; color: var(--muted); font-style: italic; margin: 6px 0 20px; }
.keycard { background: var(--olive-tint); border-left: 6px solid var(--olive); border-radius: 8px; padding: 14px 18px; margin: 0 0 24px; }
.keycard h4 { font-family: var(--head); font-size: 18px; letter-spacing: 1px; color: var(--olive-dark); margin: 0 0 8px; }
.keycard ul { margin: 0; padding-left: 20px; }
.keycard li { margin-bottom: 6px; font-size: 14.5px; }
.keycard .kp-label { font-family: var(--head); font-size: 13px; letter-spacing: .5px; margin-right: 6px; }
.keycard .kp-warn { color: var(--red); } .keycard .kp-policy { color: var(--olive-dark); } .keycard .kp-info { color: var(--teal); }

.ch-body h2 { font-family: var(--head); font-size: 27px; color: var(--olive); letter-spacing: .5px; margin: 30px 0 10px; }
.ch-body h3 { font-size: 16.5px; color: var(--teal); margin: 22px 0 8px; }
.ch-body p, .ch-body li { font-size: 15px; line-height: 1.55; color: var(--text2); }
.ch-body ul, .ch-body ol { padding-left: 24px; }
.ch-body li { margin-bottom: 6px; }
.ch-body strong { color: var(--text); }
.callout { border-radius: 8px; padding: 12px 16px; margin: 14px 0; border-left: 6px solid; }
.callout .clabel { font-family: var(--head); font-size: 15px; letter-spacing: 1px; margin-bottom: 4px; }
.callout p { margin: 4px 0; }
.callout.warn { background: var(--red-tint); border-color: var(--red); } .callout.warn .clabel { color: var(--red); }
.callout.note { background: var(--sand-tint); border-color: var(--sand); } .callout.note .clabel { color: var(--sand); }
.callout.policy { background: var(--olive-tint); border-color: var(--olive); } .callout.policy .clabel { color: var(--olive-dark); }
.tablewrap { overflow-x: auto; margin: 14px 0; border-radius: 8px; }
table.tk { border-collapse: collapse; width: 100%; font-size: 14px; min-width: 480px; }
table.tk th { background: var(--bar); color: var(--bar-text); font-family: var(--head); font-weight: 400; letter-spacing: 1px;
  text-align: left; padding: 8px 12px; font-size: 14px; }
table.tk td { border-bottom: 1px solid var(--line); padding: 8px 12px; vertical-align: top; color: var(--text2); }
table.tk tr:nth-child(even) td { background: var(--surface2); }
figure.tkimg { margin: 18px 0; text-align: center; }
figure.tkimg img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; cursor: zoom-in;
  transition: transform .2s ease, box-shadow .2s ease; }
figure.tkimg img:hover { transform: scale(1.012); box-shadow: 0 6px 20px var(--shadow); }
figure.tkimg figcaption { font-size: 12.5px; color: var(--muted); font-style: italic; margin-top: 6px; }
.imgrow { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.imgrow figure { flex: 1 1 280px; max-width: 460px; }
.smalltext { font-size: 13px; color: var(--muted); }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 2px; }
/* Landing from search: a soft ring around the found block that lets go after a
   beat — the term-level <mark>s carry the real highlight. The old full-block
   --mark slab read as a rendering glitch on long paragraphs. */
.blk.hl { animation: flash 2.4s ease-out; border-radius: 6px; }
@keyframes flash {
  0%, 55% { background: var(--sand-tint); outline: 2px solid var(--sand); outline-offset: 6px; }
  100% { background: transparent; outline: 2px solid transparent; outline-offset: 6px; }
}

.ch-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 44px; border-top: 1px solid var(--line); padding-top: 18px; }
.ch-nav a { text-decoration: none; color: var(--teal); font-size: 14px; max-width: 44%; transition: transform .15s; }
.ch-nav a:hover { transform: translateY(-2px); }
.ch-nav a .dir { font-family: var(--head); letter-spacing: 1px; font-size: 14px; color: var(--sand); display: block; }
.markread { display: inline-block; margin-top: 26px; background: none; border: 2px solid var(--olive); color: var(--olive);
  font-family: var(--head); font-size: 16px; letter-spacing: 1px; padding: 8px 18px; border-radius: 8px; cursor: pointer;
  transition: background .25s, color .25s, transform .15s; }
.markread:hover { transform: translateY(-1px); }
.markread.done { background: var(--olive); color: #fff; }

/* ---------- search results ---------- */
.sr-head { font-family: var(--head); font-size: 32px; margin: 6px 0 2px; }
.sr-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.scard { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--olive); border-radius: 8px;
  padding: 14px 18px; margin-bottom: 14px; cursor: pointer; transition: transform .18s cubic-bezier(.34,1.3,.64,1); animation: viewin .35s ease backwards; }
.scard:nth-child(3) { animation-delay: .04s } .scard:nth-child(4) { animation-delay: .08s }
.scard:nth-child(5) { animation-delay: .12s } .scard:nth-child(n+6) { animation-delay: .16s }
.scard:hover { transform: scale(1.015); }
.scard .where { font-size: 12px; letter-spacing: 1px; color: var(--sand); font-family: var(--head); }
.scard h3 { margin: 3px 0 6px; font-size: 17px; color: var(--teal); }
.scard p { margin: 0; font-size: 14px; color: var(--text2); line-height: 1.5; }
.scard .type { float: right; font-size: 11px; background: var(--olive-tint); color: var(--olive-dark);
  border-radius: 20px; padding: 2px 10px; letter-spacing: .5px; }
.scard.warnhit { border-left-color: var(--red); }
.scard.bestcard { border: 2px solid var(--olive); border-left-width: 6px; background: var(--olive-tint); box-shadow: 0 6px 20px var(--shadow); }
.scard.bestcard .type { background: var(--olive); color: #fff; }
.noresults { text-align: center; color: var(--muted); padding: 50px 0; }

/* ---------- quiz ---------- */
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin-top: 20px; }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; cursor: pointer;
  transition: transform .22s cubic-bezier(.34,1.3,.64,1); animation: viewin .4s ease backwards; }
.qgrid .qcard:nth-child(2) { animation-delay: .04s } .qgrid .qcard:nth-child(3) { animation-delay: .08s }
.qgrid .qcard:nth-child(4) { animation-delay: .12s } .qgrid .qcard:nth-child(n+5) { animation-delay: .16s }
.qcard:hover { transform: scale(1.04); }
.qcard h3 { font-family: var(--head); font-size: 22px; margin: 4px 0 6px; letter-spacing: .5px; }
.qcard .qmeta { font-size: 13px; color: var(--muted); }
.qcard .best { margin-top: 8px; font-size: 13px; color: var(--olive); font-weight: 700; }
.qcard.master { border-top: 5px solid var(--sand); }
.qcard.rapid { border-top: 5px solid var(--teal); }
.qmode-head { font-family: var(--head); font-size: 19px; letter-spacing: 1px; color: var(--muted); margin: 26px 0 -6px; }
.quiz-run .qq { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px; animation: viewin .3s ease backwards; }
.quiz-run .prog { height: 8px; background: var(--surface2); border-radius: 6px; margin-bottom: 14px; overflow: hidden; }
.quiz-run .prog > div { height: 100%; background: var(--olive); transition: width .4s cubic-bezier(.4,0,.2,1); }
.qtimer { height: 5px; background: var(--surface2); border-radius: 4px; margin-bottom: 16px; overflow: hidden; }
.qtimer > div { height: 100%; background: linear-gradient(90deg, var(--teal), var(--red)); width: 100%; }
.qtimer.run > div { animation: timebar linear forwards; }
@keyframes timebar { from { width: 100%; } to { width: 0; } }
.quiz-run h3.qtext { font-size: 18px; margin: 0 0 16px; line-height: 1.45; }
.qbadge { display: inline-block; font-size: 11px; letter-spacing: 1px; font-family: var(--head); background: var(--teal-tint);
  color: var(--teal); border-radius: 20px; padding: 2px 10px; margin-bottom: 8px; }
.opt { display: block; width: 100%; text-align: left; background: var(--bg); border: 2px solid var(--line); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 10px; font: 15px var(--body); color: var(--text); cursor: pointer;
  transition: border-color .15s, transform .12s, background .2s; }
.opt:hover:not(:disabled) { border-color: var(--olive); transform: translateX(4px); }
.opt.correct { border-color: var(--olive); background: var(--olive-tint); font-weight: 600; animation: popIn .3s ease; }
.opt.wrong { border-color: var(--red); background: var(--red-tint); animation: shake .35s ease; }
.opt:disabled { cursor: default; color: var(--text); opacity: .92; }
@keyframes popIn { 0% { transform: scale(.98); } 60% { transform: scale(1.015); } 100% { transform: none; } }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.exp { border-left: 5px solid var(--teal); background: var(--teal-tint); border-radius: 6px; padding: 10px 14px; font-size: 14px;
  margin: 10px 0 4px; animation: viewin .3s ease backwards; }
.qnextbtn, .qbtn { background: var(--olive); color: #fff; border: none; font-family: var(--head); font-size: 18px;
  letter-spacing: 1px; padding: 10px 26px; border-radius: 8px; cursor: pointer; margin-top: 10px; transition: background .2s, transform .15s; }
.qnextbtn:hover, .qbtn:hover { background: var(--olive-dark); transform: translateY(-1px); }
.qresult { text-align: center; padding: 30px 10px; animation: viewin .4s ease backwards; }
.qresult .score { font-family: var(--head); font-size: 74px; line-height: 1; animation: heroPop .55s cubic-bezier(.34,1.4,.64,1) both; }
.qresult .grade { font-family: var(--head); font-size: 26px; letter-spacing: 1px; margin: 6px 0 2px; }
.qresult .pass { color: var(--olive); } .qresult .fail { color: var(--red); }
.qcounter { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

/* lightbox */
#lightbox[hidden] { display: none; }
#lightbox { position: fixed; inset: 0; background: rgba(15,15,12,.93); z-index: 100; display: flex;
  align-items: center; justify-content: center; flex-direction: column; cursor: zoom-out; animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
#lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 6px; animation: heroPop .25s ease both; }
#lightbox .lb-close { position: absolute; top: 16px; right: 22px; color: #fff; font-size: 26px; cursor: pointer; }
#lightbox .lb-cap { color: #d9d9cf; font-size: 14px; margin-top: 10px; font-style: italic; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  #navToggle { display: block; }
  #searchGo { display: block; }
  .brand-name { display: none; }
  .brand img { height: 26px; }
  .quiz-cta { font-size: 16px; padding: 7px 12px; }
  #searchPanel { top: var(--tbh, 52px); }
  #searchPanel.open { max-height: 130px; }
  .sp-inner { flex-wrap: wrap; padding: 12px; }
  .sp-inner input { flex: 1 1 100%; }
  #sidebar { position: fixed; left: -320px; top: var(--tbh, 52px); bottom: 0; z-index: 59; transition: left .28s cubic-bezier(.4,0,.2,1); max-height: none; width: 290px; }
  #sidebar.open { left: 0; box-shadow: 4px 0 30px rgba(0,0,0,.35); }
  #content { padding: 18px 14px 80px; }
  .hero h1 { font-size: 42px; }
  .hero img { height: 80px; }
  .statrow { gap: 22px; }
  .ch-title { font-size: 30px; }
  .ch-body h2 { font-size: 24px; }
  .imgrow figure { flex: 1 1 100%; max-width: 100%; }
  .ch-nav a { max-width: 48%; font-size: 13px; }
  .qgrid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  #topbar { padding: 8px 10px; gap: 8px; }
  .hero h1 { font-size: 36px; }
  .hero .bigsearch input { font-size: 14px; padding: 12px 12px; }
  .hero .bigsearch button { font-size: 17px; padding: 0 16px; }
  .stat .n { font-size: 32px; }
}

/* ---------- watermark ---------- */
/* Sits BEHIND all content: negative z-index paints below in-flow text and blocks. */
#watermark { position: fixed; right: 26px; bottom: 20px; width: 130px; opacity: .08; pointer-events: none;
  z-index: -1; user-select: none; transition: opacity .35s; }
[data-theme="dark"] #watermark { filter: brightness(0) invert(1); opacity: .07; }
@media (max-width: 900px) { #watermark { width: 84px; right: 12px; bottom: 12px; } }

/* ---------- auth gate (login + password change) ---------- */
/* Chrome stays hidden until /api/me answers, so nothing flashes before sign-in. */
[data-auth="loading"] #topbar, [data-auth="loading"] #layout,
[data-auth="loading"] #searchPanel, [data-auth="out"] #topbar, [data-auth="out"] #layout,
[data-auth="out"] #searchPanel { display: none; }
[data-auth="in"] #bootspinner, [data-auth="out"] #bootspinner { display: none; }

#bootspinner { position: fixed; inset: 0; display: grid; place-items: center; }
#bootspinner span { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--olive);
  border-radius: 50%; animation: bootspin .8s linear infinite; }
@keyframes bootspin { to { transform: rotate(360deg); } }

.gate-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px 90px; }
.gate-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-top: 6px solid var(--olive); border-radius: 12px; padding: 30px 28px 24px; text-align: center;
  box-shadow: 0 18px 50px var(--shadow); animation: viewin .4s ease backwards; }
.gate-logo { height: 34px; filter: brightness(0); opacity: .85; margin-bottom: 14px; }
[data-theme="dark"] .gate-logo { filter: brightness(0) invert(1); }
.gate-title { font-family: var(--head); font-size: 44px; letter-spacing: 2px; margin: 0; line-height: 1; }
.gate-title span { color: var(--olive); }
.gate-sub { color: var(--muted); font-size: 13.5px; margin: 6px 0 20px; font-style: italic; }
.gate-head { font-family: var(--head); font-size: 19px; letter-spacing: 1.5px; color: var(--text2);
  border-top: 1px solid var(--line); padding-top: 16px; margin-bottom: 14px; }
.gate-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.gate-label { font-family: var(--head); font-size: 14px; letter-spacing: 1.2px; color: var(--muted);
  display: flex; flex-direction: column; gap: 5px; }
.gate-label input { font: 16px var(--body); padding: 11px 13px; border: 2px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s; }
.gate-label input:focus { border-color: var(--olive); box-shadow: 0 0 0 4px color-mix(in srgb, var(--olive) 22%, transparent); }
.gate-btn { background: var(--olive); color: #fff; border: none; font-family: var(--head); font-size: 19px;
  letter-spacing: 1.5px; padding: 12px 18px; border-radius: 9px; cursor: pointer; margin-top: 4px;
  transition: background .2s, transform .15s; }
.gate-btn:hover:not(:disabled) { background: var(--olive-dark); transform: translateY(-1px); }
.gate-btn:disabled { opacity: .6; cursor: default; }
.gate-btn.ghost { background: var(--surface2); color: var(--muted); }
.gate-btn.ghost:hover { background: var(--line); transform: none; }
.gate-err { background: var(--red-tint); color: var(--red); border-left: 5px solid var(--red); border-radius: 6px;
  padding: 9px 12px; font-size: 13.5px; font-weight: 600; animation: viewin .25s ease backwards; }
.gate-foot { color: var(--muted); font-size: 12.5px; margin: 16px 0 0; }

/* ---------- topbar identity ---------- */
#userSlot { display: flex; align-items: center; gap: 10px; }
.admin-cta { font-family: var(--head); font-size: 18px; letter-spacing: 1px; color: #282820;
  background: var(--accent-on-dark); padding: 7px 14px; border-radius: 8px; text-decoration: none;
  transition: filter .2s, transform .15s; }
.admin-cta:hover { filter: brightness(1.07); transform: translateY(-1px); }
.userchip { position: relative; }
.userchip > button { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid #4a4a40;
  color: var(--bar-text); border-radius: 20px; padding: 4px 12px 4px 4px; cursor: pointer; font: 14px var(--body);
  transition: background .2s; }
.userchip > button:hover { background: #33332b; }
.uc-ini { width: 26px; height: 26px; border-radius: 50%; background: var(--olive); color: #fff;
  display: grid; place-items: center; font-family: var(--head); font-size: 13px; letter-spacing: .5px; }
.usermenu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; min-width: 210px; box-shadow: 0 14px 34px var(--shadow); overflow: hidden; z-index: 70;
  animation: viewin .18s ease backwards; }
.um-head { padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface2);
  display: flex; flex-direction: column; gap: 2px; }
.um-head strong { font-size: 14px; } .um-head span { font-size: 12px; color: var(--muted); }
.usermenu button { display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 10px 14px; font: 14px var(--body); color: var(--text2); }
.usermenu button:hover { background: var(--olive-tint); color: var(--text); }
@media (max-width: 700px) { .uc-name { display: none; } .slabel { display: none; } }

/* ---------- admin area ---------- */
.pcard.adm { border-top-color: var(--sand); }
.adm-table { min-width: 620px; }
.adm-table .u-user { font-size: 12px; color: var(--muted); }
.adm-table tr.u-off td { opacity: .55; }
.adm-table td.nowrap { white-space: nowrap; }
.adm-table td.au-meta { font-size: 12.5px; color: var(--muted); }
.tag { font-family: var(--head); font-size: 12px; letter-spacing: 1px; padding: 2px 9px; border-radius: 20px; }
.tag.on { background: var(--olive-tint); color: var(--olive-dark); }
.tag.new { background: var(--sand-tint); color: var(--sand); }
.tag.off { background: var(--red-tint); color: var(--red); }
.tag.upd { background: var(--teal-tint); color: var(--teal); }   /* UPDATED */
.u-acts { white-space: nowrap; } .u-self { color: var(--muted); }
.minibtn { font-family: var(--head); font-size: 12.5px; letter-spacing: .8px; background: var(--surface2);
  border: 1px solid var(--line); color: var(--text2); border-radius: 6px; padding: 5px 9px; cursor: pointer;
  margin-right: 5px; transition: background .18s, color .18s; }
.minibtn:hover { background: var(--olive); color: #fff; border-color: var(--olive); }
.minibtn.danger:hover { background: var(--red); border-color: var(--red); }
.adm-form { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--olive);
  border-radius: 10px; padding: 18px 20px; margin: 16px 0; animation: viewin .3s ease backwards; }
.adm-form h3 { font-family: var(--head); font-size: 20px; letter-spacing: 1px; margin: 0 0 12px; }
.af-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
/* Breathing room between stacked form rows — inputs were touching the next label. */
.af-grid + .af-grid, .af-grid + .ed-upload, .ed-upload + .af-grid { margin-top: 14px; }
.af-grid label { font-family: var(--head); font-size: 13px; letter-spacing: 1.2px; color: var(--muted);
  display: flex; flex-direction: column; gap: 5px; }
.af-grid input, .af-grid select { font: 15px var(--body); padding: 9px 11px; border: 2px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--text); outline: none; transition: border-color .2s; }
.af-grid input:focus, .af-grid select:focus { border-color: var(--olive); }
@media (max-width: 620px) { .af-grid { grid-template-columns: 1fr; } }
.qbtn.ghost { background: var(--surface2); color: var(--muted); }
.qbtn.ghost:hover { background: var(--line); color: var(--text); }
.am-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.admin-modal { position: fixed; inset: 0; background: rgba(20,20,16,.62); display: none; place-items: center;
  z-index: 120; padding: 20px; }
.admin-modal.open { display: grid; }
.am-card { background: var(--surface); border-radius: 12px; border-top: 6px solid var(--sand); padding: 24px;
  max-width: 460px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.4); animation: viewin .3s ease backwards; }
.am-card h3 { font-family: var(--head); font-size: 24px; letter-spacing: 1px; margin: 0 0 4px; }
.am-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
.am-cred { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.am-cred > div { display: flex; flex-direction: column; gap: 3px; background: var(--surface2); border-radius: 8px; padding: 10px 13px; }
.am-cred span { font-family: var(--head); font-size: 12px; letter-spacing: 1.2px; color: var(--muted); }
.am-cred code { font: 600 17px ui-monospace, "SFMono-Regular", Menlo, monospace; color: var(--text); word-break: break-all; }

.admin-toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); z-index: 130;
  background: var(--bar); color: var(--bar-text); padding: 11px 20px; border-radius: 24px; font-size: 14px;
  box-shadow: 0 10px 30px var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.admin-toast.show { opacity: 1; transform: translate(-50%, 0); }
.admin-toast.good { border-left: 5px solid var(--olive); }
.admin-toast.bad { border-left: 5px solid var(--red); }

/* Narrow phones: the topbar now carries QUIZZES, ADMIN and the user chip on top
   of v1's controls, so everything tightens up rather than overflowing. */
@media (max-width: 560px) {
  #topbar { gap: 6px; padding: 8px 9px; }
  .brand img { height: 22px; }
  #navToggle { padding: 3px 9px; font-size: 16px; }
  #themeToggle, #searchGo { padding: 5px 8px; font-size: 13px; }
  .quiz-cta, .admin-cta { font-size: 15px; padding: 6px 9px; letter-spacing: .5px; }
  #userSlot { gap: 6px; }
  .userchip > button { padding: 3px; }
  .uc-ini { width: 24px; height: 24px; font-size: 12px; }
  .usermenu { right: -4px; }
}
/* Under ~430px the two call-to-action pills go icon-only so the bar still fits. */
@media (max-width: 430px) {
  #topbar { gap: 5px; padding: 8px 7px; }
  #navToggle { padding: 3px 7px; }
  .brand { padding: 4px 6px; margin: -4px -2px; }
  .brand img { height: 18px; }
  .quiz-cta, .admin-cta { font-size: 0; padding: 6px 9px; }
  .quiz-cta::before { content: "🎯"; font-size: 14px; }
  .admin-cta::before { content: "⚙"; font-size: 15px; }
}

/* ---------- content list ---------- */
.ct-part { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  margin: 12px 0; overflow: hidden; animation: viewin .3s ease backwards; }
.ct-parthead { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--surface2);
  border-bottom: 1px solid var(--line); font-family: var(--body); }
.ct-parthead .pn { font-family: var(--head); font-size: 13px; letter-spacing: 1.2px; color: var(--sand); }
.ct-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.ct-row:last-child { border-bottom: none; }
.ct-row:hover { background: var(--olive-tint); }
.ct-no { font-family: var(--head); font-size: 15px; color: var(--muted); min-width: 26px; }
.ct-title { font-size: 14px; color: var(--text2); }
a.tag { text-decoration: none; }

/* ---------- revision rows ---------- */
.rv-row { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--olive);
  border-radius: 8px; padding: 11px 14px; margin-bottom: 9px; cursor: pointer;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  transition: transform .18s cubic-bezier(.34,1.3,.64,1); animation: viewin .3s ease backwards; }
.rv-row:hover { transform: scale(1.008); }
.rv-main { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 2px; }
.rv-kind { font-family: var(--head); font-size: 12px; letter-spacing: 1.2px; color: var(--sand); }
.rv-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.rv-when { white-space: nowrap; }
.rv-assigned { color: var(--teal); font-weight: 600; }
.rv-filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.rv-filters select { font: 14px var(--body); padding: 7px 10px; border: 2px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--text); }
.rv-comments { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.rv-comment { background: var(--surface2); border-left: 5px solid var(--olive); border-radius: 8px; padding: 9px 13px; }
.rv-comment.flag { border-left-color: var(--red); background: var(--red-tint); }
.rv-comment p { margin: 4px 0 0; font-size: 14px; color: var(--text2); }
.rv-comment .rv-when { font-size: 12px; color: var(--muted); margin-left: 8px; }

/* ---------- diff ---------- */
.difftable td { font-size: 13.5px; }
.difftable th:first-child { width: 150px; }
.difftable tr.df-changed td.df-after { background: var(--olive-tint); font-weight: 600; }
.difftable tr.df-changed td.df-before { background: var(--red-tint); text-decoration: line-through; opacity: .8; }
.diff-head { font-family: var(--head); font-size: 15px; letter-spacing: 1.2px; color: var(--muted); margin: 16px 0 6px; }
.difflines { border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 520px;
  background: var(--surface); font: 13px/1.5 ui-monospace, "SFMono-Regular", Menlo, monospace; }
.dl { padding: 2px 12px; white-space: pre-wrap; word-break: break-word; display: flex; gap: 8px; }
.dl-mark { color: var(--muted); user-select: none; }
.dl-add { background: var(--olive-tint); color: var(--olive-dark); }
.dl-del { background: var(--red-tint); color: var(--red); text-decoration: line-through; }
[data-theme="dark"] .dl-add { color: var(--olive-dark); }

/* ---------- editors ---------- */
.ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1000px) { .ed-grid { grid-template-columns: 1fr; } }
.ed-form { min-width: 0; }
.ed-preview { position: sticky; top: 74px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px; max-height: calc(100vh - 110px); overflow: auto; }
.ed-section { font-family: var(--head); font-size: 17px; letter-spacing: 1.3px; color: var(--text2);
  border-bottom: 1px solid var(--line); padding-bottom: 5px; margin: 20px 0 10px; }
.af-grid.one { grid-template-columns: 1fr; }
.af-grid textarea { font: 15px var(--body); padding: 9px 11px; border: 2px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); outline: none; resize: vertical; }
.qbtn.danger { background: var(--red); }
.qbtn.danger:hover { background: var(--red); filter: brightness(1.1); }

.bk { border: 1px solid var(--line); border-radius: 9px; margin-bottom: 10px; background: var(--surface);
  animation: viewin .25s ease backwards; }
.bk.dragging { opacity: .45; }
.bk.dragover { border-color: var(--olive); box-shadow: 0 0 0 3px color-mix(in srgb, var(--olive) 25%, transparent); }
.bk-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--surface2);
  border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.bk-grip { cursor: grab; color: var(--muted); font-size: 15px; }
.bk-type { font-family: var(--head); font-size: 13px; letter-spacing: 1.1px; color: var(--olive-dark); }
.bk-spacer { flex: 1; }
.bk-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.bk-body textarea, .bk-body input, .bk-body select { font: 14px var(--body); padding: 8px 10px;
  border: 2px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--text);
  outline: none; width: 100%; resize: vertical; }
.bk-body textarea:focus, .bk-body input:focus, .bk-body select:focus { border-color: var(--olive); }
.bk-hint { font-size: 12px; color: var(--muted); }
.bk-item { display: flex; gap: 6px; align-items: flex-start; }
.bk-item .bk-itemtext { flex: 2; } .bk-item .bk-itemsub { flex: 1; }
.bk-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.bk-img { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bk-img .bk-file { flex: 1; min-width: 180px; } .bk-img .bk-cap { flex: 1; min-width: 160px; }
.bk-prev { height: 46px; border-radius: 5px; border: 1px solid var(--line); }
.bk-imgrow { display: flex; flex-direction: column; gap: 8px; }
.bk-empty { color: var(--muted); font-style: italic; padding: 14px; text-align: center;
  border: 1px dashed var(--line); border-radius: 9px; }
.ed-add { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.ed-add select { font: 15px var(--body); padding: 9px 11px; border: 2px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); }

.kp-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; flex-wrap: wrap; }
.kp-row input { font: 14px var(--body); padding: 8px 10px; border: 2px solid var(--line); border-radius: 7px;
  background: var(--bg); color: var(--text); outline: none; }
.kp-row .kp-kind { width: 140px; } .kp-row .kp-label { width: 150px; } .kp-row .kp-text { flex: 1; min-width: 200px; }

.qo-row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.qo-pick { display: flex; align-items: center; gap: 5px; font-family: var(--head); font-size: 12px;
  letter-spacing: 1px; color: var(--muted); white-space: nowrap; }
.qo-text { flex: 1; font: 15px var(--body); padding: 9px 11px; border: 2px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--text); outline: none; }
.qo-row input[type="radio"]:checked ~ span { color: var(--olive-dark); }

.apv-list { display: flex; flex-wrap: wrap; gap: 10px; }
.apv { display: flex; align-items: center; gap: 6px; background: var(--surface2); border: 1px solid var(--line);
  border-radius: 20px; padding: 6px 13px; font-size: 14px; cursor: pointer; }
.apv:has(input:checked) { background: var(--olive-tint); border-color: var(--olive); color: var(--olive-dark); font-weight: 600; }

/* ---------- dashboard ---------- */
.dash-tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.dtab { font-family: var(--head); font-size: 15px; letter-spacing: 1.1px; color: var(--muted);
  text-decoration: none; padding: 9px 14px; border-bottom: 3px solid transparent; transition: color .2s, border-color .2s; }
.dtab:hover { color: var(--text); }
.dtab.on { color: var(--olive-dark); border-bottom-color: var(--olive); }

.chart-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.ctile { background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--olive);
  border-radius: 10px; padding: 16px 18px; animation: viewin .35s ease backwards; }
.ctile.tone-good { border-top-color: var(--olive); }
.ctile.tone-mid { border-top-color: var(--sand); }
.ctile.tone-bad { border-top-color: var(--red); }
.ct-num { font-family: var(--head); font-size: 40px; line-height: 1; color: var(--text); }
.ct-label { font-family: var(--head); font-size: 14px; letter-spacing: 1.2px; color: var(--muted); margin-top: 4px; }
.ct-sub { font-size: 12.5px; color: var(--muted); font-style: italic; margin-top: 3px; }

.dash-split { display: grid; grid-template-columns: auto auto minmax(220px, 1fr); gap: 22px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
@media (max-width: 800px) { .dash-split { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.dash-notes h3 { font-family: var(--head); font-size: 18px; letter-spacing: 1.2px; margin: 0 0 8px; }
.dash-notes ul { margin: 0; padding-left: 18px; color: var(--text2); font-size: 14px; line-height: 1.7; }
.dash-notes a { color: var(--teal); }

.chart-donut { text-align: center; animation: viewin .4s ease backwards; }
.cd-track { stroke: var(--surface2); }
.cd-fill { transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1); }
.cd-fill.tone-good { stroke: var(--olive); }
.cd-fill.tone-mid { stroke: var(--sand); }
.cd-fill.tone-bad { stroke: var(--red); }
.cd-fill.tone-none { stroke: var(--line); }
.cd-num { font-family: var(--head); font-size: 27px; fill: var(--text); }
.cd-label { font-family: var(--head); font-size: 14px; letter-spacing: 1.2px; color: var(--muted); margin-top: 6px; }
.cd-sub { font-size: 12px; color: var(--muted); font-style: italic; }

.chart-bars { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.cb-row { display: grid; grid-template-columns: minmax(180px, 32%) 1fr 58px; gap: 10px 14px; align-items: center;
  animation: viewin .3s ease backwards; }
/* Labels are names — they wrap to a second line rather than losing their ending. */
.cb-label { font-size: 14px; color: var(--text2); line-height: 1.25; }
.cb-track { height: 20px; background: var(--surface2); border-radius: 6px; overflow: hidden; }
.cb-fill { height: 100%; border-radius: 6px; transition: width 1s cubic-bezier(.4,0,.2,1); }
.cb-fill.tone-good { background: linear-gradient(90deg, var(--olive), var(--sand)); }
.cb-fill.tone-mid { background: var(--sand); }
.cb-fill.tone-bad { background: var(--red); }
.cb-fill.tone-none { background: var(--line); }
.cb-value { font-family: var(--head); font-size: 17px; color: var(--text); text-align: right; }
.cb-sub { grid-column: 2 / -1; font-size: 12px; color: var(--muted); margin-top: -4px; }
@media (max-width: 620px) {
  /* Phone: label on its own line, then track + value, then the note full width. */
  .cb-row { grid-template-columns: 1fr 52px; gap: 6px 10px; }
  .cb-label { grid-column: 1 / -1; white-space: normal; }
  .cb-sub { grid-column: 1 / -1; margin-top: -2px; }
}
.chart-empty { color: var(--muted); font-style: italic; padding: 16px; text-align: center;
  border: 1px dashed var(--line); border-radius: 9px; margin-bottom: 16px; }

.lb-scoring { font-size: 12.5px; color: var(--muted); font-style: italic; align-self: center; }
.lb-rank { font-family: var(--head); font-size: 19px; }

/* ---------- what's new (home) ---------- */
.whatsnew { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--sand);
  border-radius: 10px; padding: 16px 20px; margin: 0 0 24px; animation: viewin .4s ease backwards; }
.whatsnew h3 { font-family: var(--head); font-size: 19px; letter-spacing: 1.2px; margin: 0 0 8px; color: var(--text); }
.whatsnew ul { margin: 0; padding-left: 18px; }
.whatsnew li { font-size: 14px; color: var(--text2); line-height: 1.7; }
.whatsnew a { color: var(--teal); text-decoration: none; }
.whatsnew a:hover { text-decoration: underline; }
.wn-when { color: var(--muted); font-size: 12px; margin-left: 8px; }

/* ---------- videos & cheatsheets ---------- */
.side-library { border-top: 1px solid var(--line); margin-top: 6px; padding: 8px 0 20px; }
.side-library a { display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 12px;
  border-left: 4px solid transparent; text-decoration: none; color: var(--text);
  font-family: var(--head); font-size: 17px; letter-spacing: .5px; transition: background .2s, border-color .2s; }
.side-library a:hover { background: var(--sand-tint); border-left-color: var(--sand); }
.side-library a.active { background: var(--sand-tint); border-left-color: var(--sand); }

.pcard.vcard, .pcard.ccard { border-top-color: var(--teal); }
.pcard.ccard { border-top-color: var(--sand); }
.vthumb { font-size: 26px; line-height: 1; margin-bottom: 4px; color: var(--teal); }

.videowrap { position: relative; background: #000; border-radius: 10px; overflow: hidden;
  margin: 14px 0 18px; box-shadow: 0 10px 30px var(--shadow); }
.videowrap video, .videowrap iframe { display: block; width: 100%; aspect-ratio: 16 / 9;
  border: none; background: #000; }
.videowrap .callout { margin: 0; border-radius: 0; }
.vlink { margin: 12px 0 18px; }
.vlink a { display: inline-block; background: var(--olive-tint); color: var(--olive-dark); text-decoration: none;
  padding: 10px 16px; border-radius: 9px; font-weight: 600; font-size: 14.5px; transition: background .2s, transform .15s; }
.vlink a:hover { background: var(--olive); color: #fff; transform: translateY(-1px); }
.cs-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.cs-tags .tag { background: var(--teal-tint); color: var(--teal); }

/* ---------- upload widget ---------- */
.ed-upload { background: var(--surface2); border: 1px dashed var(--line); border-radius: 9px;
  padding: 13px 15px; margin: 14px 0; }
.up-label { font-family: var(--head); font-size: 13px; letter-spacing: 1.2px; color: var(--muted); display: block; margin-bottom: 8px; }
.up-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.up-row input[type="file"] { font: 13.5px var(--body); color: var(--text2); flex: 1; min-width: 200px; }
.up-bar { height: 8px; background: var(--line); border-radius: 5px; overflow: hidden; margin-top: 10px; }
.up-bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--olive), var(--sand));
  transition: width .25s ease; }
.up-state { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---------- user menu badge + review pill ---------- */
.uc-badge { background: var(--red); color: #fff; font: 700 11px var(--body); min-width: 18px; height: 18px;
  border-radius: 10px; display: inline-grid; place-items: center; padding: 0 5px; }
/* ---------- inline edit affordances ---------- */
.inline-edit { font-family: var(--head); font-size: 13px; letter-spacing: 1px; color: var(--sand);
  text-decoration: none; margin-left: 12px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; }
.inline-edit:hover { background: var(--sand-tint); }
.q-fix { display: inline-block; margin-left: 10px; }
.card-edit { position: absolute; top: 10px; right: 10px; z-index: 2; }
.pcard { position: relative; }
.pcard.qadd { border-style: dashed; border-top-style: solid; opacity: .85; }
.pcard.qadd:hover { opacity: 1; }
.qcard { position: relative; }
.qcard .qmanage, .qcard .qmanage-mode { position: absolute; top: 10px; right: 10px; }
.qcard.qadd { border: 1px dashed var(--line); border-top: 5px solid var(--sand); opacity: .85; }

/* ---------- sidebar add links ---------- */
.side-add { display: flex; gap: 8px; align-items: baseline; padding: 7px 16px 7px 34px; font-size: 13px;
  color: var(--muted); text-decoration: none; border-left: 4px solid transparent; font-style: italic; }
.side-add:hover { background: var(--olive-tint); color: var(--olive-dark); border-left-color: var(--olive); }
.side-add-part { padding: 10px 16px 10px 12px; font-family: var(--head); font-style: normal;
  font-size: 15px; letter-spacing: 1px; }

/* ---------- notion-style canvas ---------- */
.ed-tools { position: sticky; top: 60px; z-index: 40; display: flex; gap: 6px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  margin: 8px 0 14px; box-shadow: 0 6px 18px var(--shadow); }
.ed-tools button { width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg); color: var(--text); font-size: 14px; cursor: pointer; }
.ed-tools button:hover { background: var(--olive-tint); border-color: var(--olive); }
.ed-hint { font-size: 12.5px; color: var(--muted); margin-left: 8px; }
.ed-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.ed-meta > label { font-family: var(--head); font-size: 12px; letter-spacing: 1.2px; color: var(--muted);
  display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; }
.ed-meta input, .ed-meta select { font: 14px var(--body); padding: 8px 10px; border: 2px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--text); outline: none; }
.ed-meta input:focus, .ed-meta select:focus { border-color: var(--olive); }
.ed-filecell { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-family: var(--body); }
.ed-filecell input[type="file"] { font-size: 12.5px; max-width: 210px; }

.ed-page { background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 26px 34px 34px; }
.eb-title { outline: none; border-radius: 6px; }
.eb-title:focus { background: var(--olive-tint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--olive) 20%, transparent); }
[contenteditable][data-ph]:empty::before { content: attr(data-ph); color: var(--muted); opacity: .6; font-style: italic; }

.ed-canvas { min-height: 120px; }
.eb { position: relative; border-radius: 8px; }
.eb:hover { background: color-mix(in srgb, var(--olive-tint) 45%, transparent); }
.eb.dragover { box-shadow: 0 -3px 0 var(--olive); }
.eb-grip { position: absolute; left: -26px; top: 6px; color: var(--muted); opacity: 0; cursor: grab;
  font-size: 14px; padding: 2px 4px; user-select: none; }
.eb:hover .eb-grip { opacity: .7; }
.eb-grip:hover { opacity: 1 !important; }
.eb-ed { outline: none; }
.eb-ed:focus { background: color-mix(in srgb, var(--olive-tint) 70%, transparent); border-radius: 6px; }
.eb .blk { animation: none; }               /* no entry animation while editing */
.eb .tk th.eb-ed:focus, .eb .tk td.eb-ed:focus { outline: 2px solid var(--olive); outline-offset: -2px; background: var(--olive-tint); }
.eb img[data-pick] { cursor: pointer; }
.eb img[data-pick]:hover { outline: 3px solid var(--olive); outline-offset: 2px; }
.ed-endzone { color: var(--muted); font-size: 13px; font-style: italic; text-align: center;
  border: 1px dashed var(--line); border-radius: 9px; padding: 13px; margin-top: 16px; cursor: pointer; }
.ed-endzone:hover { background: var(--olive-tint); color: var(--olive-dark); }
.ed-keycard h4 { display: flex; align-items: center; gap: 10px; }
.kp-empty { color: var(--muted); font-size: 13px; font-style: italic; }

.vblock-chip { display: flex; gap: 10px; align-items: center; background: var(--teal-tint);
  border: 1px solid var(--teal); border-radius: 9px; padding: 12px 16px; cursor: pointer; margin: 10px 0; }
.vblock-chip .vc-title { font-weight: 600; color: var(--teal); }
.vblock-chip .vc-hint { margin-left: auto; font-size: 12px; color: var(--muted); font-style: italic; }
.vblock-title { font-family: var(--head); font-size: 14px; letter-spacing: 1px; color: var(--muted); margin: 6px 0 14px; }
.vblock-load { color: var(--muted); font-style: italic; padding: 20px; text-align: center;
  border: 1px dashed var(--line); border-radius: 9px; margin: 10px 0; }

.ed-bar { position: sticky; bottom: 0; z-index: 45; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px 12px 0 0;
  padding: 12px 16px; margin-top: 18px; box-shadow: 0 -8px 24px var(--shadow); }
.ed-err { flex: 1; min-width: 200px; }

/* block context menu */
.eb-menu { position: fixed; z-index: 200; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 16px 44px var(--shadow); padding: 5px; min-width: 210px;
  max-height: 70vh; overflow: auto; animation: viewin .12s ease backwards; }
.ebm-head { font-family: var(--head); font-size: 11px; letter-spacing: 1.4px; color: var(--muted);
  padding: 7px 10px 3px; }
.eb-menu button { display: block; width: 100%; text-align: left; background: none; border: none;
  font: 13.5px var(--body); color: var(--text2); padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.eb-menu button:hover { background: var(--olive-tint); color: var(--text); }
.eb-menu button.danger:hover { background: var(--red-tint); color: var(--red); }

/* pickers */
.am-wide { max-width: 720px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px;
  max-height: 55vh; overflow: auto; margin: 8px 0; }
.img-cell { border: 2px solid var(--line); border-radius: 8px; background: var(--bg); cursor: pointer;
  padding: 4px; display: flex; flex-direction: column; gap: 4px; }
.img-cell:hover { border-color: var(--olive); }
.img-cell img { width: 100%; height: 72px; object-fit: cover; border-radius: 5px; }
.img-cell span { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vid-list { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow: auto; margin: 8px 0; }
.vid-row { display: flex; gap: 10px; align-items: center; border: 2px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); cursor: pointer; padding: 10px 13px; font: 14px var(--body); text-align: left; }
.vid-row:hover { border-color: var(--olive); background: var(--olive-tint); }

.minibtn.ghosted { opacity: .6; }
.ct-add { color: var(--muted); font-style: italic; cursor: pointer; font-size: 13px; }
.ct-add:hover { color: var(--olive-dark); background: var(--olive-tint); }

/* Empty editable lines must stay clickable — a zero-height contenteditable is unreachable. */
.eb-lines { min-height: 22px; }
.eb-lines > div { min-height: 20px; }
/* Empty text blocks stay reachable — but table cells must keep table-cell display,
   or empty rows collapse under the first column. */
.eb-ed:empty:not(td):not(th) { min-height: 20px; display: block; }
.uc-badge[hidden] { display: none; }

/* ---------- visual track-changes diff ---------- */
.diffview .diff-body { background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px 32px 30px; }
.df-add { background: color-mix(in srgb, var(--olive-tint) 80%, transparent);
  border-left: 4px solid var(--olive); border-radius: 6px; padding: 2px 10px; margin: 6px 0; }
.df-del { background: var(--red-tint); border-left: 4px solid var(--red); border-radius: 6px;
  padding: 2px 10px; margin: 6px 0; opacity: .8; }
.df-del, .df-del * { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--red) 65%, transparent); }
.df-del img { opacity: .5; filter: grayscale(.6); }
.diffview del, .df-mod del { background: var(--red-tint); color: var(--red);
  text-decoration: line-through; border-radius: 3px; padding: 0 3px; }
.diffview ins, .df-mod ins { background: var(--olive-tint); color: var(--olive-dark);
  text-decoration: none; font-weight: 600; border-radius: 3px; padding: 0 3px; }
.keycard li.df-add { list-style: none; }
.keycard li.df-del { list-style: none; }

/* ---------- what's-new chips ---------- */
.wn-chip { font-family: var(--head); font-size: 11px; letter-spacing: 1.1px; padding: 1px 8px;
  border-radius: 12px; margin-right: 4px; vertical-align: 1px; }
.wn-add { background: var(--olive-tint); color: var(--olive-dark); }
.wn-upd { background: var(--sand-tint); color: var(--sand); }
.wn-del { background: var(--red-tint); color: var(--red); }
.whatsnew s { color: var(--muted); }

/* ---------- toolbar groups + draft state ---------- */
.ed-tools { flex-wrap: wrap; }
.ed-tools .tg { display: flex; gap: 4px; padding-right: 8px; margin-right: 4px;
  border-right: 1px solid var(--line); }
.ed-tools .tg:last-of-type { border-right: none; }
.ed-tools [data-turn], .ed-tools [data-ins] { width: auto; min-width: 34px; padding: 0 8px;
  font-family: var(--head); font-size: 13px; letter-spacing: .5px; }
.draft-state { margin-left: auto; font-size: 12px; color: var(--muted); font-style: italic; white-space: nowrap; }
.draft-banner .am-actions { margin-top: 8px; }

/* ---------- callout gaps (hover ＋) ---------- */
/* Zero layout shift: the strip keeps its height, the ＋ and the chip popover are
   absolutely positioned on top of it. */
.eb-gap { position: relative; height: 14px; margin: -3px 0; z-index: 6; }
.eb-gap::before { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 2px;
  border-radius: 2px; background: var(--olive); opacity: 0; transition: opacity .15s; }
.eb-gap:hover::before, .eb-gap.open::before { opacity: .35; }
.gap-plus { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); opacity: 0;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 0; padding: 0;
  transition: opacity .15s, border-color .15s, color .15s; z-index: 7; }
/* The plus is drawn, not typed — a glyph never sits dead center. */
.gap-plus::before, .gap-plus::after { content: ""; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); background: currentColor; border-radius: 1px; }
.gap-plus::before { width: 10px; height: 2px; }
.gap-plus::after { width: 2px; height: 10px; }
.eb-gap:hover .gap-plus, .eb-gap.open .gap-plus { opacity: 1; }
.gap-plus:hover { border-color: var(--olive); color: var(--olive-dark); }
.gap-chips { display: none; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  margin-top: 4px; z-index: 80; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; box-shadow: 0 12px 30px var(--shadow); white-space: nowrap; }
.eb-gap.open .gap-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
  width: max-content; max-width: min(92vw, 720px); }
.gap-chip { font-family: var(--head); font-size: 12px; letter-spacing: 1px; border-radius: 14px;
  border: 1px solid; padding: 4px 12px; cursor: pointer; background: var(--surface); }
.gc-policy { color: var(--olive-dark); border-color: var(--olive); background: var(--olive-tint); }
.gc-warn { color: var(--red); border-color: var(--red); background: var(--red-tint); }
.gc-note { color: var(--text2); border-color: var(--sand); background: var(--sand-tint); }
.gap-chip:hover { filter: brightness(1.05); transform: translateY(-1px); }

/* Callout headings are fixed — make that visually obvious in the editor. */
.eb-fixedlabel { user-select: none; cursor: default; }

/* ---------- table editing polish ---------- */
/* Focused header cells must be readable in the light theme too. */
.eb .tk th.eb-ed:focus { color: var(--text); }
.tbl-tools { display: flex; gap: 6px; margin: 6px 0 0; opacity: 0; transition: opacity .15s; }
.eb:hover .tbl-tools, .eb:focus-within .tbl-tools { opacity: 1; }
.tbl-tools button { font-family: var(--head); font-size: 12px; letter-spacing: .8px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--text2);
  border-radius: 6px; padding: 4px 9px; cursor: pointer; }
.tbl-tools button:hover { background: var(--olive); color: #fff; border-color: var(--olive); }

/* ---------- picker upload strips ---------- */
.pk-upload { background: var(--surface2); border: 1px dashed var(--line); border-radius: 9px;
  padding: 12px 14px; margin-bottom: 4px; }
.pk-or { text-align: center; color: var(--muted); font-size: 12px; font-style: italic; margin: 12px 0 8px; }

/* ---------- preview mode + history arrows ---------- */
.previewing .ed-tools, .previewing .ed-meta, .previewing .ed-page,
.previewing .draft-banner, .previewing .ed-pending { display: none; }
#edPreviewPane { animation: viewin .25s ease backwards; }
#edPreviewPane .ed-page { display: block; }
.pv-note { margin-bottom: 14px; }
.ed-tools button:disabled { opacity: .35; cursor: default; }
.ed-tools button:disabled:hover { background: var(--bg); border-color: var(--line); }

/* ---------- per-block trash + part dropdown ---------- */
.eb-del { position: absolute; right: -4px; top: 2px; z-index: 8; opacity: 0; border: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font-size: 12px;
  padding: 3px 6px; cursor: pointer; transition: opacity .15s; }
.eb:hover .eb-del { opacity: .8; }
.eb-del:hover { opacity: 1 !important; background: var(--red-tint); border-color: var(--red); }

.ed-numnote { font-size: 12px; color: var(--muted); font-style: italic; align-self: center; }
.partsel { position: relative; min-width: 280px; }
.partsel-btn { display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--olive);
  border-radius: 9px; padding: 10px 14px; cursor: pointer; font-family: var(--head);
  font-size: 16px; letter-spacing: .5px; color: var(--text); transition: background .15s; }
.partsel-btn:hover { background: var(--olive-tint); }
.partsel .pn { color: var(--sand); font-size: 12.5px; letter-spacing: 1.2px; min-width: 84px; }
.partsel .pt { flex: 1; }
.partsel .caret { color: var(--muted); font-size: 11px; }
.partsel-menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 90;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  box-shadow: 0 14px 36px var(--shadow); max-height: 320px; overflow-y: auto;
  animation: viewin .15s ease backwards; }
.partsel-menu button { display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; border-left: 4px solid transparent; padding: 9px 14px; cursor: pointer;
  font-family: var(--head); font-size: 15px; letter-spacing: .5px; color: var(--text); }
.partsel-menu button:hover { background: var(--olive-tint); border-left-color: var(--olive); }
.partsel-menu button.on { background: var(--sand-tint); border-left-color: var(--sand); }
.gap-chip.gc-plain { color: var(--text2); border-color: var(--line); background: var(--surface2); }

/* ---------- key-point kind dropdown ---------- */
.kpsel { position: relative; width: 150px; }
.kpsel-btn { display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
  background: var(--bg); border: 2px solid var(--line); border-radius: 7px; padding: 8px 10px;
  cursor: pointer; font-family: var(--head); font-size: 13px; letter-spacing: 1px; color: var(--text2);
  transition: border-color .15s; }
.kpsel-btn:hover { border-color: var(--olive); }
.kpsel-btn .caret { margin-left: auto; color: var(--muted); font-size: 10px; }
.kpsel-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 95;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; overflow: hidden;
  box-shadow: 0 12px 30px var(--shadow); animation: viewin .12s ease backwards; }
.kpsel-menu button { display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
  background: none; border: none; border-left: 3px solid transparent; padding: 8px 10px; cursor: pointer;
  font-family: var(--head); font-size: 13px; letter-spacing: 1px; color: var(--text2); }
.kpsel-menu button:hover { background: var(--olive-tint); border-left-color: var(--olive); }
.kpsel-menu button.on { background: var(--sand-tint); border-left-color: var(--sand); }
.kp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex-shrink: 0; }
.kp-dot.kpd-warn { background: var(--red); }
.kp-dot.kpd-policy { background: var(--olive); }
.kp-dot.kpd-info { background: var(--teal); }

/* ---------- in-app dialogs ---------- */
.am-card.am-danger { border-top-color: var(--red); }
.dlg-input { width: 100%; font: 14px var(--body); padding: 10px 12px; border: 2px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--text); outline: none; resize: vertical;
  margin-bottom: 4px; }
.dlg-input:focus { border-color: var(--olive); }

/* ---------- topbar navigation ---------- */
/* Right-aligned, next to the controls — centering it looked off against the
   sidebar-shifted content below. */
#topnav { display: flex; align-items: center; gap: 4px; margin-right: 10px; }
#topnav a { font-family: var(--head); font-size: 16px; letter-spacing: 1.2px; color: var(--bar-text);
  opacity: .62; text-decoration: none; padding: 7px 12px; border-radius: 8px; position: relative;
  transition: opacity .2s, background .2s; }
#topnav a:hover { opacity: 1; background: rgba(255,255,255,.08); }
#topnav a.on { opacity: 1; background: rgba(255,255,255,.1); box-shadow: inset 0 -3px 0 var(--accent-on-dark); }
/* Narrow screens: the topbar can't hold the nav — everything stays reachable
   through the sidebar and the user menu's Admin entry. */
@media (max-width: 900px) { #topnav { display: none; } }

/* ---------- review dot + add button + add menu ---------- */
.nav-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); display: inline-block;
  margin-left: 7px; vertical-align: 2px; animation: navpulse 1.6s ease-in-out infinite; }
.nav-dot[hidden] { display: none; }
@keyframes navpulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 55%, transparent); }
  55% { box-shadow: 0 0 0 6px transparent; }
}

#addBtn { font-family: var(--head); font-size: 16px; letter-spacing: 1px; color: #282820;
  background: var(--accent-on-dark); border: none; padding: 7px 14px; border-radius: 8px;
  cursor: pointer; transition: filter .2s, transform .15s; }
#addBtn:hover { filter: brightness(1.07); transform: translateY(-1px); }
@media (max-width: 700px) { #addBtn { font-size: 0; padding: 7px 10px; }
  #addBtn::before { content: "＋"; font-size: 15px; } }

.add-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0 6px; }
.add-grid button { display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 18px 10px;
  cursor: pointer; font-family: var(--head); font-size: 15px; letter-spacing: 1.2px; color: var(--text2);
  transition: transform .18s cubic-bezier(.34,1.3,.64,1), border-color .15s, background .15s; }
.add-grid button:hover { transform: scale(1.04); border-color: var(--olive); background: var(--olive-tint); }
.add-grid .ag-ico { font-size: 24px; line-height: 1; }
/* The memo tile rides full-width under the 2×2 — it is the loud one. */
.add-grid .ag-wide { grid-column: 1 / -1; padding: 14px 10px; }
.add-grid .ag-wide:hover { border-color: var(--red); background: var(--red-tint, rgba(138,46,43,.07)); }
.add-grid .ag-sub { font-family: var(--body); font-size: 12px; letter-spacing: 0; color: var(--muted); }

/* ---------- field memos ---------- */
/* The sidebar "!" while a hand owes an UNDERSTOOD. */
.side-alert { margin-left: auto; background: var(--red); color: #fff; font: 700 11px var(--body);
  width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center;
  animation: navpulse 1.6s ease-out infinite; }
.side-alert[hidden] { display: none; }
.memocard { border-top: 5px solid var(--teal); }
.memocard.memo-due { border-top-color: var(--red); }

/* The document sign-off under memos, cheatsheets and videos. */
.byline { margin: 30px 0 4px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--muted); }
.byline strong { color: var(--text2); font-weight: 600; }

/* The chapter's ⬇ PDF link in the crumbs — teal cousin of the ✎ edit link. */
.pdf-link { font-family: var(--head); font-size: 13px; letter-spacing: 1px; color: var(--teal);
  text-decoration: none; margin-left: 12px; }
.pdf-link:hover { text-decoration: underline; }

/* The whole-manual PDF link under the home progress bar. */
.pdf-all { display: inline-block; margin-top: 14px; font-family: var(--head); font-size: 14px;
  letter-spacing: 1.2px; color: var(--teal); text-decoration: none; border: 1px solid var(--line);
  border-radius: 18px; padding: 7px 16px; transition: border-color .15s, transform .15s; }
.pdf-all:hover { border-color: var(--olive); transform: translateY(-1px); }

/* Brand-styled selects and file pickers — the native control hides inside. */
.tsel { position: relative; display: inline-block; min-width: 150px; }
.tsel select { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.tsel-btn { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  font: 15px var(--body); color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; cursor: pointer; transition: border-color .15s; }
.tsel-btn:hover { border-color: var(--olive); }
.tsel-btn .caret { color: var(--muted); }
.tsel-menu { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: auto;
  max-height: 260px; box-shadow: 0 12px 30px var(--shadow); }
.tsel-menu button { display: block; width: 100%; text-align: left; padding: 9px 12px;
  font: 14.5px var(--body); color: var(--text); background: none; border: 0; cursor: pointer;
  white-space: nowrap; }
.tsel-menu button:hover { background: var(--sand-tint); }
.tsel-menu button.on { background: var(--olive-tint); font-weight: 600; }
.tfile { display: inline-flex; align-items: center; gap: 10px; position: relative; }
.tfile input[type="file"] { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.tfile-name { font-size: 13px; color: var(--muted); max-width: 220px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

/* Filter bars on list pages (videos, memos, cheatsheets, users): the search box
   and the pills are one family — same height, same pill shape, one row. */
.listbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 20px; }
.listbar input { flex: 0 1 300px; min-width: 190px; height: 36px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  color: var(--text); font: 14.5px var(--body); }
.listbar input::placeholder { color: var(--muted); }
.listbar input:focus { outline: none; border-color: var(--olive); box-shadow: 0 0 0 3px var(--olive-tint); }
.cat-row.lb-pills { margin: 0; gap: 8px; }   /* outweighs .cat-row's own bottom margin */
.listbar .cat-pill, .lb-pills .cat-pill { height: 36px; display: inline-flex; align-items: center; padding: 0 16px; }
.listbar .qbtn { height: 36px; display: inline-flex; align-items: center; padding: 0 16px;
  margin-left: auto; }   /* + NEW ACCOUNT hugs the right edge */

/* ---------- search categories ---------- */
.cat-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 20px; }
.cat-pill { font-family: var(--head); font-size: 14.5px; letter-spacing: 1.2px; color: var(--text2);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 7px 14px;
  cursor: pointer; transition: transform .15s, border-color .15s, background .15s, color .15s; }
.cat-pill span { color: var(--muted); font-size: 12.5px; margin-left: 2px; }
.cat-pill:hover:not(:disabled) { border-color: var(--olive); transform: translateY(-1px); }
.cat-pill.on { background: var(--olive); border-color: var(--olive); color: #fff; }
.cat-pill.on span { color: rgba(255,255,255,.75); }
.cat-pill:disabled { opacity: .4; cursor: default; }

/* Dashboard MEMOS tab: one row per hand, click for the detail popup. */
.hm-row { cursor: pointer; }
.hm-row:hover td { background: var(--sand-tint); }
.hm-barcell { width: 34%; min-width: 140px; }
.hm-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.hm-bar > div { height: 100%; border-radius: 4px; background: var(--sand); transition: width .4s ease; }
.hm-bar > div.full { background: var(--olive); }
.am-card.hand-card { max-width: 520px; text-align: center; border-top-color: var(--red); }
/* Collapsible USERS sections. */
.u-sect { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px; }
.u-sect .caret { color: var(--muted); font-size: 12px; transition: transform .18s ease; }
.u-sect.closed .caret { transform: rotate(-90deg); }
.u-sect:hover { color: var(--olive-dark, var(--olive)); }
.u-group.closed { display: none; }

/* The USERS stats popup: neutral accent, tile grid, left-aligned lists. */
.am-card.hand-stats { border-top-color: var(--olive); max-width: 680px; max-height: 92vh; overflow-y: auto; }
tr.u-hand { cursor: pointer; }
tr.u-hand:hover td { background: var(--sand-tint); }
.hs-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.hs-tiles > div { background: var(--surface2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.hs-n { font-family: var(--head); font-size: 22px; letter-spacing: .5px; }
.hs-l { font-size: 11.5px; color: var(--muted); }
/* Every section fits: two tight columns instead of a clipped scroll well. */
.hs-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hs-list li { margin-bottom: 0; padding: 8px 10px; font-size: 13px; }
.hs-list li span { font-size: 12px; }
@media (max-width: 700px) { .hs-list { grid-template-columns: 1fr; } }
.am-card.hand-card.hand-ok { border-top-color: var(--olive); }
.hand-card.hand-ok .mn-badge { color: var(--olive); background: var(--olive-tint); animation: none; }
.hand-card .mn-list a { color: inherit; text-decoration: none; }
.hand-card .mn-list a:hover { text-decoration: underline; }
.hand-card .callout { text-align: left; }

/* The can't-miss popups: field memos for hands, waiting reviews for reviewers.
   Same bones, same volume. */
.am-card.memo-nag, .am-card.review-nag { border-top-color: var(--red); max-width: 470px; text-align: center; }
.mn-badge { font-size: 40px; line-height: 1; margin-bottom: 6px; color: var(--red);
  animation: navpulse 1.6s ease-out infinite; border-radius: 50%; width: 64px; height: 64px;
  display: inline-grid; place-items: center; background: var(--red-tint, rgba(138,46,43,.09)); }
.memo-nag h3, .review-nag h3 { color: var(--red); }
.mn-head { font-family: var(--head); font-size: 13.5px; letter-spacing: 1.4px; color: var(--muted);
  margin: 14px 0 2px; text-align: left; }
.mn-list { list-style: none; margin: 12px 0 4px; padding: 0; text-align: left; }
.mn-head + .mn-list { margin-top: 6px; }
.mn-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
  font-weight: 600; background: var(--surface2); }
.mn-list li span { font-weight: 400; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.memo-nag .am-actions, .review-nag .am-actions { justify-content: center; }

/* Keyboard reach for hover-revealed editor controls (audit follow-up). */
.eb-gap:focus-within .gap-plus, .eb:focus-within .eb-del { opacity: 1; }

/* Table column resize affordance in the editor. */
.ed-canvas .tk th { position: relative; }
.ed-canvas .tk th:not(:last-child)::after { content: ""; position: absolute; right: -4px; top: 0;
  bottom: 0; width: 8px; cursor: col-resize; }

/* Chapter search tags — reader chips and the editor's tag line */
.ch-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 18px; }
.ch-ref + .ch-tags { margin-top: -10px; }   /* tuck under the source line when there is one */
.ch-tags span { font-family: var(--head); font-size: 12px; letter-spacing: 1px; color: var(--muted);
  background: var(--surface2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.ed-tags { display: flex; align-items: center; gap: 10px; margin: 8px 0 16px; }
.ed-tags-label { font-family: var(--head); font-size: 12px; letter-spacing: 1.2px; color: var(--muted); white-space: nowrap; }
.ed-tags input { flex: 1; font: 14px var(--body); padding: 7px 10px; border: 2px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); outline: none; }
.ed-tags input:focus { border-color: var(--olive); }
.sr-more { display: block; margin: 6px auto 0; }
.dash-hint { font-size: 13.5px; color: var(--muted); margin: -4px 0 12px; line-height: 1.5; }

/* Overview: daily columns, two-column sections, nudge list, activity feed */
.chart-cols { margin-bottom: 0; }
.chart-cols svg { width: 100%; display: block; background: var(--surface2); border-radius: 8px; padding: 6px 4px 0; box-sizing: border-box; }
.chart-cols g:hover rect:not([fill]) { opacity: .8; }
.col-good { fill: var(--olive); } .col-mid { fill: var(--sand); } .col-teal { fill: var(--teal); } .col-bad { fill: var(--red); }
.cc-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.cc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text2); margin-top: 6px; align-items: center; }
.cc-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.cc-legend i.col-good { background: var(--olive); } .cc-legend i.col-mid { background: var(--sand); }
.cc-legend i.col-teal { background: var(--teal); } .cc-legend i.col-bad { background: var(--red); }
.cc-peak { margin-left: auto; color: var(--muted); font-style: italic; }
.dash-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 36px; margin-top: 30px; align-items: start; }
/* Below ~1270px the pane is too narrow for two honest columns (bars shrink to slivers,
   names wrap under their chips) — stack them, and keep the tile grid to even rows. */
@media (max-width: 1269px) {
  .dash-grid2 { grid-template-columns: 1fr; }
  .dash-grid2 > div + div { margin-top: 30px; }
  .tiles-even .chart-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dtab { font-size: 13.5px; padding: 8px 9px; letter-spacing: 1px; }
  .dash-tabs { gap: 2px; margin-bottom: 22px; }
}
@media (max-width: 480px) { .tiles-even .chart-tiles { gap: 10px; } .tiles-even .ct-num { font-size: 32px; } .tiles-even .ctile { padding: 12px 12px 10px; } }
.att-list, .act-list { list-style: none; margin: 0 0 8px; padding: 0; }
.att-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.att-list li:hover { background: var(--olive-tint); }
.att-list .att-name { font-weight: 600; font-size: 14px; }
.att-list .att-region { font-size: 12px; color: var(--muted); }
.att-list .att-why { margin-left: auto; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.att-list .att-why span { font-family: var(--head); font-size: 11.5px; letter-spacing: .8px; padding: 2px 8px; border-radius: 999px;
  background: var(--red-tint); color: var(--red); }
.att-list .att-why span.soft { background: var(--sand-tint, var(--surface2)); color: var(--text2); }
.act-list li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 7px 6px;
  border-bottom: 1px solid var(--line); font-size: 14px; }
.act-list .act-ico { text-align: center; }
.act-list .act-when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.act-list b { font-weight: 600; }
/* Two dials under the spread bars: no card, no border — the column already frames them. */
.dash-split-2 { grid-template-columns: auto auto; justify-content: space-evenly; gap: 20px; margin: 18px 0 0;
  background: none; border: 0; padding: 0; }
.sr-matched { color: var(--text2); font-family: var(--body); letter-spacing: 0; text-transform: none; font-size: 12.5px; }
.sr-matched mark { background: var(--olive-tint); color: var(--olive-dark); padding: 0 2px; border-radius: 3px; }
.sr-partial-head { margin-top: 18px; }

/* Dashboard rhythm: one gap size between blocks, no gap before the first header of a pane or column. */
#dashPane .ed-section { margin: 30px 0 12px; }
#dashPane .ed-section:first-child { margin-top: 0; }
#dashPane .chart-tiles { margin-bottom: 30px; }
#dashPane .att-list li:last-child, #dashPane .act-list li:last-child { border-bottom: 0; }
#dashPane > .dash-hint { margin-top: 14px; }
#dashPane .chart-bars + .tablewrap { margin-top: 20px; }
.hs-owed li { border-left: 3px solid var(--red); }
.hs-owed li a { color: var(--text); text-decoration: none; }
.hs-owed li a:hover { color: var(--red); }
.hs-ok { color: var(--olive-dark); }

/* Phones and small tablets: reading only. Authoring — the ＋ ADD button, add-chapter /
   add-part rows, ✎ edit links, MANAGE and the dashed "add" cards — is desktop work. */
@media (max-width: 900px) {
  #addBtn, .side-add, .inline-edit, .qmanage, .qmanage-mode, .qadd { display: none !important; }
  /* Dashboard tabs: one swipeable row instead of three ragged ones. */
  .dash-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .dash-tabs::-webkit-scrollbar { display: none; }
  .dtab { flex: 0 0 auto; white-space: nowrap; }
}
@media (max-width: 620px) {
  /* Nudge list: reasons drop under the name instead of squeezing beside it. */
  .att-list li { flex-wrap: wrap; }
  .att-list .att-why { margin-left: 0; width: 100%; justify-content: flex-start; }
}

/* Phone tables: let cells wrap and tighten padding so three columns fit the screen. */
@media (max-width: 620px) {
  .adm-table td, .adm-table th { padding: 8px 8px; font-size: 13px; }
  .adm-table td.nowrap, .adm-table th { white-space: normal; }
  /* Three-column tables share the screen instead of scrolling off it. */
  .adm-table.t-fit { table-layout: fixed; width: 100%; min-width: 0; }
  .adm-table.t-fit th:first-child { width: 46%; }
}

/* Notification nudge — a quiet strip, not a wall */
.push-nudge { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 12px; max-width: min(720px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--sand); border-radius: 12px;
  padding: 10px 12px 10px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.14); font-size: 14px; color: var(--text);
  animation: viewin .35s ease backwards; }
.push-nudge .pn-ico { font-size: 20px; }
.push-nudge .pn-text { flex: 1; min-width: 0; line-height: 1.35; }
.push-nudge .qbtn { padding: 8px 12px; font-size: 13px; }
@media (max-width: 620px) { .push-nudge { flex-wrap: wrap; bottom: 12px; } .push-nudge .pn-text { flex-basis: 100%; } }
/* Finish-a-part prompt: an achievement, not an alarm */
.part-done .am-card.memo-nag { border-top-color: var(--olive); }
.part-done .memo-nag h3 { color: var(--olive-dark); }
.part-done .mn-badge { color: var(--olive); background: var(--olive-tint); animation: none; }
