/* =====================================================================
   Medverion app area (#/app) - app.css v1
   App shell in the Medverion design: navy sidebar, calm light
   content, optional dark theme. Uses the tokens from site.css.
   ===================================================================== */
/* the hidden attribute must win over component display rules (.field, .btn, .auth-row) */
.modal [hidden], .app-shell [hidden] { display: none !important; }

body.in-app #nav, body.in-app #foot, body.in-app #progress { display: none !important; }
body.in-app { background: var(--paper); }
.view[data-view="app"] { animation: none; }

.app-shell { --sb-w: 264px; display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .3s var(--ease); }
.app-shell.collapsed { --sb-w: 78px; }
/* the sidebar column keeps its navy colour all the way down (long pages, full-page captures) */
@media (min-width: 901px) { .app-shell { background-image: linear-gradient(90deg, var(--navy) var(--sb-w), transparent 0); } }

/* ---------- sidebar ---------- */
.sb { position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; background: var(--navy);
  color: #c9d3ea; display: flex; flex-direction: column; padding: 16px 12px; border-right: 1px solid rgba(255, 255, 255, .06); z-index: 60; }
.sb::before { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(80% 40% at 0% 0%, rgba(59, 110, 245, .22), transparent 70%), radial-gradient(70% 30% at 100% 100%, rgba(124, 108, 246, .16), transparent 70%); }
.sb > * { position: relative; }
.sb-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 16px; }
.sb-top .brand { color: #fff; min-width: 0; }
/* brand kit: full horizontal logo (dark-bg artwork) when open, the #logo mark when collapsed; no filters on the logo */
.sb-top .brand .sb-logo { height: 28px; width: auto; max-width: 100%; display: block; }
.sb-top .brand .sb-mark { width: 34px; height: 34px; flex: none; display: none; }
.collapsed .sb-top .brand .sb-logo { display: none; }
.collapsed .sb-top .brand .sb-mark { display: block; }
.sb-col { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #8f9dbb; flex: none; }
.sb-col:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sb-col svg { width: 16px; height: 16px; transition: transform .3s var(--ease); }
.collapsed .sb-col svg { transform: rotate(180deg); }
.sb nav { display: grid; gap: 2px; }
.sb .grp { font: 600 10.5px/1 var(--font); letter-spacing: .16em; text-transform: uppercase; color: #66749a; margin: 18px 12px 8px; white-space: nowrap; }
.sb nav a { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 12px; font: 500 14.5px/1 var(--font); color: #b9c4dc;
  white-space: nowrap; transition: background-color .2s, color .2s; position: relative; }
.sb nav a svg { width: 19px; height: 19px; flex: none; color: #8f9dbb; transition: color .2s; }
.sb nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sb nav a:hover svg { color: #fff; }
.sb nav a.on { background: linear-gradient(90deg, rgba(59, 110, 245, .34), rgba(59, 110, 245, .14)); color: #fff; }
.sb nav a.on svg { color: var(--blue-3); }
.sb nav a.on::before { content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--blue-2); }
.sb nav a .cnt { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; font: 700 11px/1 var(--font); background: var(--blue); color: #fff; }
.sb-foot { margin-top: auto; padding-top: 16px; }
.sb-card { padding: 14px; border-radius: 14px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); font-size: 13px; color: #9aa7c2; line-height: 1.5; }
.sb-card b { display: block; color: #fff; font: 700 14px/1.3 var(--font-d); margin-bottom: 4px; }
.sb-card .xpbar { margin-top: 10px; }
.collapsed .sb nav a { justify-content: center; padding: 0; }
.collapsed .sb nav a span, .collapsed .sb nav a .cnt, .collapsed .sb .grp, .collapsed .sb-card { display: none; }
.collapsed .sb .grp + a, .collapsed .sb nav { margin-top: 0; }
.collapsed .sb-top { flex-direction: column; padding-bottom: 10px; }
.collapsed .sb nav a.on::before { left: -12px; }

/* ---------- top bar ---------- */
.app-main { min-width: 0; display: flex; flex-direction: column; }
.tb { position: sticky; top: 0; z-index: 50; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 clamp(14px, 2.4vw, 28px);
  background: rgba(247, 248, 252, .86); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); border-bottom: 1px solid var(--line); }
.tb .tb-menu { display: none; }
.tb-title { font: 700 17px/1.2 var(--font-d); letter-spacing: -.015em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-search { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px 0 14px; min-width: 240px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: 14px; transition: border-color .2s, box-shadow .2s; }
.tb-search:hover { border-color: #c4d1ee; }
.tb-search svg { width: 16px; height: 16px; }
.tb-search .kbd { margin-left: auto; }
.tb-ib { position: relative; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--text-2); transition: background-color .2s; flex: none; }
.tb-ib:hover { background: rgba(127, 140, 170, .14); }
.tb-ib svg { width: 19px; height: 19px; }
.tb-ib .dot { position: absolute; right: -2px; top: 1px; min-width: 12px; height: 15px; padding: 0 3px; border-radius: 9px; background: var(--red); color: #fff; font: 700 9.5px/15px var(--font); text-align: center; border: 2px solid var(--paper); box-sizing: content-box; }
.tb-user { display: inline-flex; align-items: center; gap: 9px; height: 42px; padding: 0 10px 0 4px; border-radius: 999px; font: 600 14px/1 var(--font); color: var(--text); flex: none; }
.tb-user:hover { background: rgba(127, 140, 170, .12); }
.ava { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; background: linear-gradient(135deg, var(--blue), var(--violet)); color: #fff; font: 700 13px/1 var(--font); font-style: normal; }
.ava.sm { width: 28px; height: 28px; font-size: 11px; }
.ava.lg { width: 64px; height: 64px; font-size: 22px; }
.tb-user .ch { width: 10px; height: 10px; color: var(--muted); }

/* dropdowns */
.dd { position: relative; }
.dd-pop { position: absolute; right: 0; top: calc(100% + 10px); width: 300px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 8px; opacity: 0; pointer-events: none; transform: translateY(6px); transition: opacity .2s, transform .25s var(--ease); z-index: 70; }
.dd.open .dd-pop { opacity: 1; pointer-events: auto; transform: none; }
.dd-pop .hd { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dd-pop .hd b { display: block; font: 700 15px/1.3 var(--font-d); }
.dd-pop .hd span { font-size: 13px; color: var(--muted); word-break: break-all; }
.dd-pop a, .dd-pop button.it { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 10px; font-size: 14px; color: var(--text-2); text-align: left; }
.dd-pop a:hover, .dd-pop button.it:hover { background: var(--paper); color: var(--text); }
.dd-pop a svg, .dd-pop button.it svg { width: 17px; height: 17px; color: var(--muted); }
.dd-pop.wide { width: 360px; }
.ntf-list { max-height: 360px; overflow-y: auto; }
.ntf { display: grid; grid-template-columns: 10px 1fr; gap: 10px; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; color: var(--text-2); }
.ntf:hover { background: var(--paper); }
.ntf i { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: transparent; }
.ntf.unread i { background: var(--blue); }
.ntf b { display: block; color: var(--text); font-weight: 600; }
.ntf small { color: var(--muted); font-size: 12px; }

/* ---------- content ---------- */
.app-content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px clamp(14px, 3vw, 36px) 90px; animation: viewIn .45s var(--ease) both; }
.ap-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 24px; }
.ap-head h1 { font-size: clamp(28px, 3vw, 38px); font-weight: 800; letter-spacing: -.03em; }
.ap-head p { color: var(--muted); margin-top: 8px; font-size: 15.5px; max-width: 70ch; }
.ap-head .acts { display: flex; gap: 10px; flex-wrap: wrap; }
.ap-crumbs { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.ap-crumbs a:hover { color: var(--blue); }
.ap-grid { display: grid; gap: 20px; }
.ap-grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ap-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ap-grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ap-grid.c21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.ap-grid.c12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.ap-sec { margin-top: 22px; }
.kpi { padding: 20px; display: grid; gap: 6px; }
.kpi small { font: 600 12.5px/1.2 var(--font); color: var(--muted); display: flex; align-items: center; gap: 8px; }
.kpi small svg { width: 16px; height: 16px; color: var(--blue); }
.kpi b { font: 800 30px/1.1 var(--font-d); letter-spacing: -.02em; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi-goal { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 14px; }
.kpi-goal .ring.goal { width: 96px; height: 96px; }
.kpi-goal .ring.goal b { font-size: 20px; }
.kpi.acc-good b { color: #0f8a50; } .kpi.acc-mid b { color: #a96800; } .kpi.acc-low b { color: #c7282e; }
.cont-card { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; padding: 22px 24px; color: #eaf0ff;
  background: radial-gradient(70% 140% at 100% 0%, rgba(124, 108, 246, .45), transparent 60%), linear-gradient(120deg, #0f1b35, #16274a); border: 0; }
.cont-card .ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 255, 255, .1); }
.cont-card .ic svg { width: 24px; height: 24px; color: var(--blue-3); }
.cont-card h3 { font-size: 20px; }
.cont-card p { color: #b9c4dc; font-size: 14.5px; margin-top: 4px; }
.qlinks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.qlink { display: grid; gap: 10px; padding: 16px; border-radius: 16px; background: #fff; border: 1px solid var(--line); transition: transform .3s var(--ease), box-shadow .3s, border-color .2s; }
.qlink:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #c9d6f3; }
.qlink i { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--sky); color: var(--blue); }
.qlink i svg { width: 19px; height: 19px; }
.qlink b { font: 700 14.5px/1.25 var(--font-d); }
.qlink span { font-size: 12.5px; color: var(--muted); line-height: 1.4; }

/* trend chart */
.trend { width: 100%; height: 180px; display: block; }
.trend .grid-l { stroke: var(--line); stroke-width: 1; }
.trend .area { fill: url(#trendFill); }
.trend .ln { fill: none; stroke: var(--blue); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.trend .bar { fill: rgba(59, 110, 245, .16); }
.trend .pt { fill: #fff; stroke: var(--blue); stroke-width: 2; }
.trend text { font: 500 10.5px var(--font); fill: var(--muted); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* tables / lists */
.tbl-wrap { overflow-x: auto; border-radius: var(--r); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font: 600 12px/1.2 var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfcfe; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f8faff; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.li-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: #fff; transition: border-color .2s, box-shadow .2s; }
.li-row:hover { border-color: #c9d6f3; box-shadow: var(--shadow); }
.li-row .grow { flex: 1; min-width: 0; }
.li-row .grow b { display: block; font: 600 14.5px/1.35 var(--font); }
.li-row .grow span { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.list { display: grid; gap: 10px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { height: 42px; width: auto; min-width: 180px; flex: 1; max-width: 340px; }
.toolbar .grow { flex: 1; }
.toolbar .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.toolbar .seg::-webkit-scrollbar { display: none; }
.toolbar .seg button { flex: none; }
.pager { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

/* skeleton + states */
.skel { border-radius: 12px; background: linear-gradient(90deg, #eef1f8 25%, #f7f9fd 50%, #eef1f8 75%); background-size: 200% 100%; animation: skel 1.2s linear infinite; }
@keyframes skel { to { background-position: -200% 0; } }
.skel.h20 { height: 20px; } .skel.h40 { height: 40px; } .skel.h90 { height: 90px; } .skel.h180 { height: 180px; } .skel.h300 { height: 300px; }
.loading-pane { display: grid; gap: 16px; }
.state-box { text-align: center; padding: 48px 20px; color: var(--muted); }
.state-box svg { width: 44px; height: 44px; color: var(--blue); margin: 0 auto 14px; display: block; }
.state-box h3 { color: var(--text); font-size: 20px; margin-bottom: 8px; }
.state-box p { max-width: 46ch; margin: 0 auto; font-size: 14.5px; }
.state-box .btn { margin-top: 18px; }
.state-box.err svg { color: var(--red); }
.toast.err { background: #3a1015; }
.toast.err svg { color: #ff8a8f; }
.form-err { display: none; padding: 10px 14px; border-radius: 12px; background: #fdeceb; color: #a5232a; font-size: 13.5px; line-height: 1.45; }
.form-err.on { display: block; }
.form-ok { display: none; padding: 12px 14px; border-radius: 12px; background: #e6f8ef; color: #0d6e41; font-size: 14px; line-height: 1.5; }
.form-ok.on { display: block; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.auth-row label { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); cursor: pointer; }
.auth-row input { width: 16px; height: 16px; accent-color: var(--blue); }
.auth-row button { color: var(--blue); font-weight: 600; }
.btn.busy { pointer-events: none; opacity: .75; }
.btn.busy::after { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pill-note { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: var(--sky); color: #1d4ed8; font-size: 13px; }
.pill-note svg { width: 15px; height: 15px; }

/* ---------- QBank player (API) ---------- */
.qb-create { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 22px; align-items: start; }
.pool-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pool-seg button { padding: 12px 10px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; text-align: left; transition: all .2s; }
.pool-seg button b { display: block; font: 700 18px/1.1 var(--font-d); }
.pool-seg button span { font-size: 12.5px; color: var(--muted); }
.pool-seg button[aria-pressed="true"] { border-color: var(--blue); background: #f3f7ff; box-shadow: 0 0 0 3px rgba(59, 110, 245, .12); }
.pool-seg button:disabled { opacity: .45; cursor: not-allowed; }
.player { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.player .side { position: sticky; top: 84px; display: grid; gap: 16px; }
.qcard .qmeta { display: flex; gap: 8px; flex-wrap: wrap; }
.qcard .qtools { display: flex; gap: 8px; }
.qopt[disabled] { cursor: default; }
.qopt .why { display: block; margin-top: 6px; font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.qopt-wrap { display: grid; gap: 4px; }
.rat { padding: 0 16px 6px 60px; font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.rat.good { color: #0d6e41; }
.qexp .obj { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: #fff; border-left: 3px solid var(--blue); font-size: 14.5px; }
.note-box { display: grid; gap: 8px; }
.note-box textarea { min-height: 90px; font-size: 14px; }
.note-box .meta { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); }
.timer.big { font-size: 15px; color: var(--text); }
.timer.big.low { color: var(--red); }
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.res-grid a { height: 42px; border-radius: 10px; display: grid; place-items: center; font: 600 13px/1 var(--font); border: 1.5px solid var(--line); background: #fff; }
.res-grid a.ok { background: #e6f8ef; border-color: #b7ead0; color: #0f8a50; }
.res-grid a.no { background: #fdeceb; border-color: #f5c5c6; color: #c7282e; }
.res-grid a.skip { background: #f4f5f8; color: var(--muted); }
.kbd-help { font-size: 13px; color: var(--muted); }
.kbd-help dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; margin-top: 10px; }
.kbd-help dt { white-space: nowrap; } .kbd-help dd { margin: 0; }

/* library */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.lib-card { display: grid; grid-template-rows: auto 1fr; overflow: hidden; transition: transform .3s var(--ease), box-shadow .3s; }
.lib-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.lib-card .th { aspect-ratio: 16 / 9; background: var(--ink); position: relative; overflow: hidden; }
.lib-card .th img { width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.lib-card .th .kind { position: absolute; left: 12px; top: 12px; }
.lib-card .bd { padding: 16px 18px 18px; display: grid; gap: 8px; align-content: start; }
.lib-card .bd b { font: 700 16px/1.3 var(--font-d); }
.lib-card .bd p { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.lib-card .bd .meta { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); }
.reader { max-width: 760px; }
.reader .rd-body { font-size: 16.5px; line-height: 1.75; color: var(--text); }
.rd-body h2 { font-size: 24px; margin: 28px 0 12px; }
.rd-body h3 { font-size: 19px; margin: 22px 0 10px; }
.rd-body p { margin: 0 0 14px; }
.rd-body ul, .rd-body ol { margin: 0 0 16px 22px; }
.rd-body ul { list-style: disc; } .rd-body ol { list-style: decimal; }
.rd-body li { margin: 6px 0; }
.rd-body blockquote { margin: 0 0 16px; padding: 12px 16px; border-left: 3px solid var(--amber); background: #fffaf0; border-radius: 0 12px 12px 0; }
.rd-body code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; background: #eef1f8; padding: 1px 6px; border-radius: 6px; }
.rd-body table { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 14.5px; }
.rd-body th, .rd-body td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.rd-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reader.fs-s .rd-body { font-size: 15px; } .reader.fs-l .rd-body { font-size: 18.5px; }

/* community */
.comp { padding: 20px; display: grid; gap: 12px; }
.comp .row { display: flex; gap: 10px; flex-wrap: wrap; }
.comp .row .input { flex: 1; min-width: 200px; }
.comp .row .select { width: auto; min-width: 170px; }
.comp .comp-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.post .ttl { font: 700 17px/1.35 var(--font-d); margin-top: 12px; display: block; }
.post .ttl:hover { color: var(--blue); }
.post .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.post .acts .sp { flex: 1; }
.post.hidden-post { opacity: .55; }
.cmt-form { display: flex; gap: 10px; margin-top: 14px; }
.cmt-form .input { height: 44px; }
.post .cmt { white-space: pre-wrap; overflow-wrap: anywhere; }
.post .cmt small { color: var(--muted); margin-left: 6px; font-size: 12px; }

/* account */
.acc-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: start; }
.acc-nav { display: grid; gap: 4px; padding: 10px; position: sticky; top: 84px; }
.acc-nav a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; font-size: 14.5px; color: var(--text-2); }
.acc-nav a svg { width: 17px; height: 17px; color: var(--muted); }
.acc-nav a.on, .acc-nav a:hover { background: var(--sky); color: var(--blue); }
.acc-nav a.on svg { color: var(--blue); }
.acc-card { padding: 26px; display: grid; gap: 18px; }
.acc-card h2 { font-size: 21px; }
.acc-card .sub { color: var(--muted); font-size: 14px; margin-top: -10px; }
.danger { border-color: #f5c5c6; }
.danger h2 { color: #b42318; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c7282e; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: #d6dcea; transition: background-color .2s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .25s var(--ease); }
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { transform: translateX(18px); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row b { display: block; font-weight: 600; font-size: 14.5px; }
.set-row span { font-size: 13px; color: var(--muted); }

/* admin */
.adm-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.adm-tabs a { height: 38px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; font: 600 13.5px/1 var(--font); color: var(--text-2); background: #fff; border: 1px solid var(--line); }
.adm-tabs a svg { width: 15px; height: 15px; }
.adm-tabs a.on { background: var(--text); color: #fff; border-color: var(--text); }
.adm-tabs a .cnt { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; display: grid; place-items: center; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.editor .card { padding: 22px; }
.editor .opt-row { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: start; }
.editor .opt-row .radio { width: 34px; height: 46px; display: grid; place-items: center; }
.editor .opt-row .radio input { width: 18px; height: 18px; accent-color: var(--green); }
.editor .opt-row .stack { display: grid; gap: 6px; }
.editor textarea.input { height: auto; min-height: 70px; padding: 10px 14px; resize: vertical; line-height: 1.5; }
.editor .preview { position: sticky; top: 84px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.badge.gray { background: #eef1f8; color: var(--muted); }
.tag-temp { font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: .06em; padding: 14px; border-radius: 12px; background: var(--paper); border: 1px dashed #b9c8ea; text-align: center; user-select: all; }

/* ---------- embedded marketing views inside the shell ---------- */
.app-embed .phead { padding: 34px 0 34px; border-radius: var(--r-lg); margin-bottom: 4px; }
.app-embed .phead h1 { font-size: clamp(28px, 3.2vw, 42px); margin: 10px 0 8px; }
.app-embed .phead p { font-size: 15.5px; }
.app-embed .phead .crumbs { display: none; }
.app-embed .phead .wrap, .app-embed .sec .wrap { width: 100%; padding: 0 clamp(18px, 3vw, 34px); }
.app-embed .sec { padding: 24px 0 !important; }
.app-embed .sec .wrap { padding: 0; }
.app-embed .sticky { top: 84px; }
.app-embed .viewer.full { height: calc(100vh - 220px); }

/* ---------- bottom tab bar (phone) ---------- */
.tabbar { display: none; }
.sb-scrim { display: none; }

@media (max-width: 1100px) {
  .ap-grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player { grid-template-columns: minmax(0, 1fr); }
  .player .side { position: static; grid-row: 1; grid-template-columns: 1fr 1fr; }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor .preview { position: static; }
}
@media (max-width: 900px) {
  .app-shell, .app-shell.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sb { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-102%); transition: transform .35s var(--ease); box-shadow: var(--shadow-lg); }
  .app-shell.drawer .sb { transform: none; }
  .app-shell.drawer .sb-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(5, 8, 17, .5); }
  .collapsed .sb nav a span, .collapsed .sb .grp, .collapsed .sb-card { display: revert; }
  .collapsed .sb-top .brand .sb-logo { display: block; } .collapsed .sb-top .brand .sb-mark { display: none; }
  .collapsed .sb-top { flex-direction: row; }
  /* dropdowns: pinned to the viewport on phones so they never push the page sideways */
  .dd-pop, .dd-pop.wide { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; max-height: calc(100vh - 140px); overflow-y: auto; }
  .dd:not(.open) .dd-pop { visibility: hidden; }
  .collapsed .sb nav a { justify-content: flex-start; padding: 0 12px; }
  .sb-col { display: none; }
  .tb .tb-menu { display: grid; }
  .tb-search { min-width: 0; width: 40px; padding: 0; justify-content: center; border: 0; background: transparent; }
  .tb-search span, .tb-search .kbd { display: none; }
  .tb-user .nm, .tb-user .ch { display: none; }
  .tb-ib.theme { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: rgba(255, 255, 255, .95); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
  .tabbar a { display: grid; place-items: center; align-content: center; gap: 4px; font: 600 10.5px/1 var(--font); color: var(--muted); }
  .tabbar a svg { width: 21px; height: 21px; }
  .tabbar a.on { color: var(--blue); }
  .app-content { padding-bottom: 110px; }
  .ap-grid.c3, .ap-grid.c2, .ap-grid.c21, .ap-grid.c12 { grid-template-columns: minmax(0, 1fr); }
  .qb-create { grid-template-columns: minmax(0, 1fr); }
  .acc-grid { grid-template-columns: minmax(0, 1fr); }
  .acc-nav { position: static; grid-template-columns: repeat(2, 1fr); }
  .cont-card { grid-template-columns: auto 1fr; }
  .cont-card .btn { grid-column: 1 / -1; }
  .pool-seg { grid-template-columns: repeat(2, 1fr); }
  .toast { bottom: 84px; }
}
@media (max-width: 560px) {
  .ap-grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi-goal { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .kpi-goal .ring.goal { width: 64px; height: 64px; } .kpi-goal .ring.goal b { font-size: 14px; }
  .li-row { flex-wrap: wrap; } .li-row .acts { width: 100%; justify-content: flex-start !important; }
  .kpi { padding: 14px; } .kpi b { font-size: 24px; }
  .player .side { grid-template-columns: minmax(0, 1fr); }
  .qcard { padding: 18px; }
  .rat { padding-left: 16px; }
  .tbl th, .tbl td { padding: 10px; }
  .dd-pop, .dd-pop.wide { width: min(330px, calc(100vw - 24px)); right: -40px; }
  .sys-bars div { grid-template-columns: 110px 1fr 54px; }
  .acc-nav { grid-template-columns: 1fr; }
}

/* ---------- dark theme for the app area ---------- */
.app-shell[data-theme="dark"] { --paper: #070c18; --text: #e7ecf8; --text-2: #b6c0d6; --muted: #8592ad; --line: #1d2842; --sky: rgba(111, 155, 255, .14); color: var(--text); background: #070c18; }
body.in-app.theme-dark { background: #070c18; }
.app-shell[data-theme="dark"] .tb { background: rgba(7, 12, 24, .82); }
.app-shell[data-theme="dark"] .tb-search, .app-shell[data-theme="dark"] .card, .app-shell[data-theme="dark"] .qlink, .app-shell[data-theme="dark"] .li-row,
.app-shell[data-theme="dark"] .qopt, .app-shell[data-theme="dark"] .chip, .app-shell[data-theme="dark"] .input, .app-shell[data-theme="dark"] .select,
.app-shell[data-theme="dark"] .textarea, .app-shell[data-theme="dark"] .qgrid button, .app-shell[data-theme="dark"] .res-grid a, .app-shell[data-theme="dark"] .pool-seg button,
.app-shell[data-theme="dark"] .quest-row, .app-shell[data-theme="dark"] .adm-tabs a, .app-shell[data-theme="dark"] .dd-pop, .app-shell[data-theme="dark"] .kbd { background: #0e1629; border-color: var(--line); color: var(--text); }
.app-shell[data-theme="dark"] .card { box-shadow: none; }
.app-shell[data-theme="dark"] .tbl th { background: #0b1324; }
.app-shell[data-theme="dark"] .tbl tr.click:hover td, .app-shell[data-theme="dark"] .dd-pop a:hover, .app-shell[data-theme="dark"] .ntf:hover { background: #121d36; }
.app-shell[data-theme="dark"] .chip.on, .app-shell[data-theme="dark"] .chip[aria-pressed="true"], .app-shell[data-theme="dark"] .adm-tabs a.on { background: #e7ecf8; color: #0d1426; }
.app-shell[data-theme="dark"] .qopt .l { background: #18233d; }
.app-shell[data-theme="dark"] .qopt.sel { background: #13224a; }
.app-shell[data-theme="dark"] .qopt.good { background: #0d2a1e; }
.app-shell[data-theme="dark"] .qopt.bad { background: #2c1216; }
.app-shell[data-theme="dark"] .qexp { background: #0d1830; border-color: #1f2d52; }
.app-shell[data-theme="dark"] .qexp .hy, .app-shell[data-theme="dark"] .qexp .obj { background: #0a1224; }
.app-shell[data-theme="dark"] .qprog, .app-shell[data-theme="dark"] .sys-bars i, .app-shell[data-theme="dark"] .seg { background: #18233d; }
.app-shell[data-theme="dark"] .seg button[aria-pressed="true"] { background: #e7ecf8; color: #0d1426; }
.app-shell[data-theme="dark"] .skel { background: linear-gradient(90deg, #121b30 25%, #19243d 50%, #121b30 75%); background-size: 200% 100%; }
.app-shell[data-theme="dark"] .post .cmt, .app-shell[data-theme="dark"] .tag-temp { background: #0b1324; }
.app-shell[data-theme="dark"] .tabbar { background: rgba(10, 16, 30, .95); }
.app-shell[data-theme="dark"] .rd-body blockquote { background: #1c1608; }
.app-shell[data-theme="dark"] .rd-body code { background: #18233d; }
.app-shell[data-theme="dark"] .trend .pt { fill: #070c18; }
.app-shell[data-theme="dark"] .badge.gray { background: #18233d; }
.app-shell[data-theme="dark"] .form-err { background: #2c1216; color: #ff9aa0; }
.app-shell[data-theme="dark"] .form-ok { background: #0d2a1e; color: #7be0aa; }
.app-shell[data-theme="dark"] .qopt.good .l, .app-shell[data-theme="dark"] .qopt.bad .l, .app-shell[data-theme="dark"] .qopt.sel .l { color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .app-content, .skel { animation: none; }
  .sb, .app-shell { transition: none; }
}
@media (min-width: 901px) { .app-shell[data-theme="dark"] { background-image: linear-gradient(90deg, var(--navy) var(--sb-w), transparent 0); } }

/* PWA v1: install controls follow html[data-pwa] (prompt | ios | installed | none) */
[data-pwa-install], .pwa-installed, .pwa-none { display: none !important; }
html[data-pwa="prompt"] [data-pwa-install], html[data-pwa="ios"] [data-pwa-install] { display: inline-flex !important; }
html[data-pwa="prompt"] .sb nav a[data-pwa-install], html[data-pwa="ios"] .sb nav a[data-pwa-install] { display: flex !important; }
html[data-pwa="installed"] .pwa-installed { display: inline-flex !important; align-items: center; gap: 6px; color: var(--green, #16a36a); font-weight: 600; font-size: 14px; }
html[data-pwa="installed"] .pwa-installed svg { width: 16px; height: 16px; }
html[data-pwa="none"] .pwa-none { display: block !important; color: var(--text-2, #6a7389); font-size: 13.5px; max-width: 34ch; text-align: right; }
.pwa-cta { margin-top: 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pwa-cta .pwa-none { text-align: left; max-width: 46ch; color: #6a7389; }
.pwa-cta [data-pwa-install] svg, .pwa-ctl [data-pwa-install] svg { width: 17px; height: 17px; }
.pwa-ios .box { max-width: 420px; }
.pwa-ios-warn { background: #fff4e0; color: #7a4a00; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 6px 0 12px; }
.pwa-steps { list-style: none; padding: 0; margin: 14px 0 16px; display: grid; gap: 12px; }
.pwa-steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.5; }
.pwa-steps li i { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--blue, #2f6efc); color: #fff; font: 700 13px/1 var(--font, system-ui); font-style: normal; }
.pwa-share { width: 18px; height: 18px; vertical-align: -3px; color: var(--blue, #2f6efc); }
.pwa-upd { position: fixed; left: 50%; bottom: 24px; z-index: 230; transform: translate(-50%, 30px); opacity: 0; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px; border-radius: 14px; background: #0d1426; color: #fff; font-size: 14.5px; box-shadow: 0 18px 50px rgba(5, 8, 17, .35); transition: all .35s ease; max-width: calc(100% - 32px); }
.pwa-upd.on { opacity: 1; transform: translate(-50%, 0); }
.pwa-upd-x { background: none; border: 0; color: #9fb0d4; font-size: 22px; line-height: 1; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; }
.pwa-upd-x:hover { color: #fff; background: rgba(255, 255, 255, .08); }
@media (max-width: 640px) { html[data-pwa="none"] .pwa-none { text-align: left; } .pwa-ctl { width: 100%; } }
