/* =====================================================================
   Dashboard styles. One system, in this order:
   1 tokens  2 fonts  3 base  4 frame (sidebar, main)  5 controls  6 surfaces and tables
   7 chips, badges, tabs  8 dialogs, drawers, toasts  9 feature blocks  10 Website editor
   11 shared controls (WP-A2)  12 loading (WP-A3)  13 responsive and touch  14 utilities
   Blocks added by other packages go at the very end, each under its own WP-Axx heading.
   Spacing: 4 px label to field, 8 px between lines, 12 px between fields, 24 px between sections.
   Radius: 4 px (small marks), 6 px (controls), 10 px (panels, cards, dialogs), pill (chips).
   Shadow: --sh-1 (raised), --sh-2 (menus), --sh-3 (dialogs).
   ===================================================================== */

/* ---------- 1. tokens ---------- */
:root {
  --bg: #f3f1ea;            /* page */
  --panel: #fcfbf8;         /* paper surface */
  --field: #ffffff;         /* inputs */
  --ink: #162124;
  --muted: #566467;
  --line: #ddd9cc;
  --line-strong: #c4bfae;
  --accent: #af9453;        /* brand gold: fills, borders, rings */
  --accent-text: #7a6016;   /* gold as text on paper */
  --accent-ink: #14110a;    /* text on gold */
  --focus: #7a6016;
  --good: #1f6b40;
  --warn: #8a5110;
  --bad: #a42d2d;
  --chip: color-mix(in srgb, var(--ink) 6%, var(--panel));
  --sel-bg: var(--ink);     /* selected tab and similar */
  --sel-ink: var(--bg);
  --radius: 10px;
  --r-1: 4px; --r-2: 6px; --r-3: 10px;
  --sh-1: 0 1px 2px rgba(13,23,25,.08);
  --sh-2: 0 8px 24px rgba(13,23,25,.16);
  --sh-3: 0 24px 60px rgba(13,23,25,.32);
  --scrim: rgba(13,23,25,.6);
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: Lora, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ctl-h: 32px; --ctl-pad: 5px 10px; --row-pad: 6px 10px; --panel-pad: 14px 16px;
  --gap-field: 12px; --gap-section: 24px;
  /* sidebar and gold buttons: applyTheme (js/01-core.js) overrides these per company */
  --side-bg: #0d1719; --side-ink: #d9e2df; --side-muted: #8fa09c; --side-line: rgba(255,255,255,.10); --side-hi: #ffffff;
  --btn-a: #d6c284; --btn-b: #af9453; --btn-c: #9a8248; --btn-ink: #14110a;
  --btn-a-hover: #ebda98; --btn-b-hover: #cbb473;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101b1e; --panel: #172326; --field: #0e171a; --ink: #e7ebe8; --muted: #a1aeab; --line: #29393d; --line-strong: #3a4d52;
    --accent: #cbb473; --accent-text: #d6c284; --focus: #d6c284; --good: #6fc194; --warn: #e3ab60; --bad: #f09090;
    --sel-bg: #e7ebe8; --sel-ink: #101b1e;
    --sh-1: 0 1px 2px rgba(0,0,0,.4); --sh-2: 0 8px 24px rgba(0,0,0,.5); --sh-3: 0 24px 60px rgba(0,0,0,.65); --scrim: rgba(0,0,0,.65);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101b1e; --panel: #172326; --field: #0e171a; --ink: #e7ebe8; --muted: #a1aeab; --line: #29393d; --line-strong: #3a4d52;
  --accent: #cbb473; --accent-text: #d6c284; --focus: #d6c284; --good: #6fc194; --warn: #e3ab60; --bad: #f09090;
  --sel-bg: #e7ebe8; --sel-ink: #101b1e;
  --sh-1: 0 1px 2px rgba(0,0,0,.4); --sh-2: 0 8px 24px rgba(0,0,0,.5); --sh-3: 0 24px 60px rgba(0,0,0,.65); --scrim: rgba(0,0,0,.65);
  color-scheme: dark;
}

/* ---------- 2. fonts: Inter for the interface, Lora for names and headings (SIL Open Font License) ---------- */
@font-face { font-family: 'Inter'; src: url(fonts/Inter-Regular.otf) format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url(fonts/Inter-Medium.otf) format('opentype'); font-weight: 500 700; font-display: swap; }
@font-face { font-family: 'Lora'; src: url(fonts/Lora-Variable.ttf) format('truetype'); font-weight: 400 700; font-display: swap; }
/* the graphic maker draws with these two names; keep them */
@font-face { font-family: 'GfxSerif'; src: url(fonts/Lora-Variable.ttf) format('truetype'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'GfxSans'; src: url(fonts/Inter-Regular.otf) format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'GfxSans'; src: url(fonts/Inter-Medium.otf) format('opentype'); font-weight: 500; font-display: swap; }

/* ---------- 3. base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
a { color: var(--accent-text); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; }
h1 { font-size: 22px; line-height: 1.2; margin: 0 0 4px; }
h2 { font-size: 16px; line-height: 1.3; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 0 0 6px; }
strong, b { font-weight: 600; }
.muted { color: var(--muted); }
.boot { padding: 40px; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.hint.low { color: var(--warn); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.side :focus-visible, .livebar :focus-visible, .help-h :focus-visible { outline-color: var(--btn-a); }
::placeholder { color: var(--muted); opacity: 1; }
.skip-link { position: absolute; left: 12px; top: -80px; z-index: 100; padding: 10px 16px; background: var(--ink); color: var(--bg); border-radius: var(--r-2); border: 0; font: inherit; font-weight: 600; text-decoration: none; box-shadow: var(--sh-2); }
.skip-link:focus { top: 10px; }
main:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media print { .help, .lib-btn, .livebar, .skip-link { display: none !important; } }

/* ---------- 4. frame: sidebar and main column ---------- */
.shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side-bg); color: var(--side-ink); border-right: 1px solid var(--side-line); padding: 20px 14px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 18px; letter-spacing: .01em; color: var(--side-hi); padding: 4px 10px 12px; }
.brand small { display: block; font-family: var(--sans); font-weight: 400; font-style: italic; font-size: 12px; color: var(--btn-a); letter-spacing: 0; }
.nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 4px -6px 0; padding: 4px 6px 28px; scrollbar-width: thin; display: flex; flex-direction: column; gap: 2px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); }
.nav a { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; margin: 0; border-radius: var(--r-2); color: var(--side-ink); text-decoration: none; font-size: 14px; line-height: 1.25; }
.nav a:hover { background: rgba(255,255,255,.08); color: var(--side-hi); }
.nav a.on { background: linear-gradient(135deg, var(--btn-a) 0%, var(--btn-b) 55%, var(--btn-c) 100%); color: var(--btn-ink); font-weight: 600; }
.navtop { margin-bottom: 4px; }
.navgrp { border-top: 1px solid var(--side-line); padding-top: 4px; }
.navgrp > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 9px 12px 5px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); border-radius: var(--r-2); user-select: none; }
.navgrp > summary::-webkit-details-marker { display: none; }
.navgrp > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.navgrp[open] > summary::after { transform: rotate(45deg); }
.navgrp > summary:hover { color: var(--side-hi); background: rgba(255,255,255,.05); }
.navitems { display: flex; flex-direction: column; padding: 0 0 4px 6px; margin-left: 10px; border-left: 1px solid var(--side-line); }
.navcount { margin-left: 8px; background: var(--btn-b); color: var(--btn-ink); border-radius: 10px; font-size: 11px; line-height: 1; padding: 3px 7px; font-weight: 600; }
.navcount.alert { background: #c0392b; color: #fff; }
.side select { width: 100%; background: rgba(255,255,255,.08); color: var(--side-hi); border: 1px solid var(--side-line); border-radius: var(--r-2); padding: 6px; }
.side select option { color: #162124; background: #fff; }
.searchbtn { margin: 0 0 8px; width: 100%; text-align: left; background: rgba(255,255,255,.08); color: var(--side-ink); border: 1px solid rgba(255,255,255,.18); border-radius: var(--r-2); padding: 7px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.searchbtn:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.18); }
.side .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding: 10px 12px 2px; border-top: 1px solid var(--side-line); font-size: 12px; color: var(--side-muted); }
.side .foot .who { min-width: 0; line-height: 1.3; }
.side .foot .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .foot button { margin: 0; padding: 4px 10px; font-size: 12px; flex: none; background: transparent; color: var(--side-ink); border: 1px solid rgba(255,255,255,.3); }
.side .foot button:hover { border-color: var(--btn-a); color: var(--btn-a); }
.menu-btn { display: none; background: transparent; color: var(--side-ink); border: 1px solid rgba(255,255,255,.3); }
.menu-btn:hover { border-color: var(--btn-a); color: var(--btn-a); }
.main { padding: 20px 24px 60px; max-width: 1100px; width: 100%; min-width: 0; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.backbtn { display: inline-block; margin: 0 0 6px; padding: 2px 8px; min-height: 0; font-size: 13px; background: transparent; border: 1px solid var(--line-strong); border-radius: var(--r-2); cursor: pointer; }
.backbtn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.lede { color: var(--muted); max-width: 75ch; margin: 0 0 18px; }

/* ---------- 5. controls ---------- */
button, .btn, .btnlink { font: inherit; padding: var(--ctl-pad); min-height: var(--ctl-h); border-radius: var(--r-2); border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); cursor: pointer; }
.btnlink { display: inline-block; text-decoration: none; }
button:hover, .btnlink:hover { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: linear-gradient(135deg, var(--btn-a) 0%, var(--btn-b) 55%, var(--btn-c) 100%); color: var(--btn-ink); border-color: transparent; font-weight: 600; }
button.primary:hover { background: linear-gradient(135deg, var(--btn-a-hover) 0%, var(--btn-b-hover) 55%, var(--btn-b) 100%); border-color: transparent; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
:root[data-theme="dark"] button.danger { color: #1a0d0d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.danger { color: #1a0d0d; } }
button.danger:hover { filter: brightness(1.08); border-color: var(--bad); }
button.ghost-danger { background: none; border: 1px solid color-mix(in srgb, var(--bad) 55%, var(--line)); color: var(--bad); }
button.ghost-danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
button.ghost-danger:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0 6px; color: var(--accent-text); text-decoration: underline; cursor: pointer; box-shadow: none; min-height: 0; }
input[type=text], input[type=email], input[type=search], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=url], input[type=tel], input[type=password], input:not([type]), select, textarea {
  font: inherit; width: 100%; padding: var(--ctl-pad); min-height: var(--ctl-h); border-radius: var(--r-2); border: 1px solid var(--line-strong); background: var(--field); color: var(--ink); }
input:hover, select:hover, textarea:hover { border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; max-height: 40vh; field-sizing: content; line-height: 1.45; }
select.mini { font-size: 12px; padding: 2px 4px; min-height: 0; width: auto; }
input.note { width: 100%; min-width: 220px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
input[type=file] { font: inherit; font-size: 13px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; padding: 6px 12px; margin-right: 10px; border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--panel); color: var(--ink); cursor: pointer; }
label { font-size: 13px; color: var(--muted); display: block; margin: 6px 0 2px; }
.panel label.muted { display: inline-flex; gap: 8px; align-items: center; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap-field) 14px; max-width: 760px; align-items: end; }
.field { display: grid; gap: 4px; margin: 0; font-size: 13px; color: var(--muted); }
.field.full, .form-actions { grid-column: 1 / -1; }
.field > input, .field > select, .field > textarea { width: 100%; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.checks { display: grid; gap: 6px; margin: 6px 0; }
.checkrow { display: flex; gap: 6px 16px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.checkrow label, label.check { margin: 0; display: inline-flex; gap: 6px; align-items: center; }
.stack > * + * { margin-top: 8px; }
.counter { font-size: 12px; color: var(--muted); }
.counter.over { color: var(--bad); font-weight: 600; }
.warn { color: var(--bad); }
.sayWhen { margin: 8px 0 0; font-size: 15px; }
.autolabel { min-width: 150px; }
.autolabel > input, .autolabel > select { width: 100%; }
.modebox { display: grid; gap: 4px; }
label.mode { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; margin: 0; border: 1px solid var(--line); border-radius: var(--r-2); cursor: pointer; color: var(--ink); font-size: 14px; }
label.mode.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
label.mode input { margin-top: 4px; }
.mvrow { display: flex; justify-content: space-between; align-items: center; }
.mv { padding: 0 6px; font-size: 10px; line-height: 18px; height: 20px; min-height: 0; min-width: 22px; margin-left: 3px; border-radius: var(--r-1); }
.mv:disabled { opacity: .4; }
.mvcol { display: inline-flex; flex-direction: column; gap: 2px; }
.mvcol .mv { margin: 0; height: 16px; line-height: 12px; padding: 0 5px; }

/* ---------- 6. surfaces, tables ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--panel-pad); margin-bottom: var(--gap-section); }
.panel .panel { border: 0; padding: 0; margin-bottom: 8px; background: transparent; }
.panel > :last-child { margin-bottom: 0; }
.panel p, .panel li { max-width: 75ch; }
.panel td { vertical-align: top; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.card .n { font-size: 20px; font-weight: 600; line-height: 1.15; }
.card .l { color: var(--muted); font-size: 13px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.cols > .panel { margin: 0; }
.callout { border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 9%, transparent); padding: 10px 12px; border-radius: 0 var(--r-2) var(--r-2) 0; max-width: 75ch; margin: 10px 0; }
.rowcard { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r-2); padding: 8px 12px; margin-top: 6px; }
.statusline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; }
.herocard { align-items: stretch; gap: 8px 16px; }
.herocard .heroinfo { display: flex; gap: 16px; align-items: center; flex: 1 1 auto; }
.herocard .herobtns { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; padding-top: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--row-pad); border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr.link { cursor: pointer; }
tr.link:hover td { background: color-mix(in srgb, var(--ink) 5%, transparent); }
tr.link:focus-visible { outline-offset: -2px; }
.tablewrap { overflow-x: auto; max-width: 100%; }
td.actions { white-space: nowrap; text-align: right; width: 1%; }
td.actions button + button { margin-left: 6px; }
td.status { white-space: nowrap; width: 1%; }
td.meta { width: 220px; font-size: 13px; color: var(--muted); }
td.meta > * + * { margin-top: 2px; }
td .muted { font-size: 12px; }
td.qa { max-width: 75ch; }
td.qa .q { font-weight: 600; margin-bottom: 4px; }
td.qa .a { white-space: pre-wrap; }
table.kv td.k { width: 190px; font-weight: 600; }
table.kv textarea { width: 100%; min-height: 0; field-sizing: content; max-height: 40vh; resize: vertical; }
.thumb { display: block; width: 150px; max-width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: var(--r-2); background: var(--bg); border: 1px solid var(--line); }
.thumb.wide { width: 180px; aspect-ratio: 21 / 9; }
.figgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.figgrid.one { grid-template-columns: minmax(0, 520px); }
.figcard { border: 1px solid var(--line); border-radius: var(--r-2); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.figcard .thumb { width: 100%; aspect-ratio: 16 / 9; }
.figcard textarea { width: 100%; font: inherit; resize: vertical; }
.permlist dt { font-weight: 600; margin-top: 10px; }
.permlist dd { margin: 2px 0 0; color: var(--muted); max-width: 75ch; }
details.tips { font-size: 13px; color: var(--muted); }
details.tips summary { cursor: pointer; width: fit-content; }
details.tips ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }
/* folding headings (foldPanels, details.fold, project folds) */
details.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > summary h2 { margin: 0; }
.fold-b { margin-top: 12px; }
.panel > h2.foldh { cursor: pointer; display: flex; align-items: center; gap: 8px; user-select: none; }
.panel > h2.foldh::before { content: '▸'; color: var(--muted); font-size: 14px; transition: transform .15s; }
.panel:not(.collapsed) > h2.foldh::before { transform: rotate(90deg); }
.panel.collapsed > :not(h2:first-child) { display: none !important; }
.panel.collapsed > h2 { margin-bottom: 0; }
details.projfold { margin: 26px 0 0; padding: 0; }
details.projfold > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 12px; padding: 10px 4px; border-bottom: 2px solid var(--line); }
details.projfold > summary::-webkit-details-marker { display: none; }
details.projfold > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
details.projfold[open] > summary::before { transform: rotate(90deg); }
details.projfold > summary h2 { margin: 0; font-size: 22px; }
details.projfold > .projbody { margin-top: 14px; }
details.projfold > summary .projadd { margin-left: auto; align-self: center; }
.wfield:not(:focus-within):not(:has([data-chg="1"])) .hidebox { display: none; }
.wfield .stack > * + *, .wfield > * + * { margin-top: 2px; }

/* ---------- 7. chips, badges, tabs ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; border: 1px solid var(--line-strong); color: var(--muted); }
.badge.approved, .badge.active, .badge.live, .badge.passed, .badge.tone-good { color: var(--good); border-color: var(--good); }
.badge.pending, .badge.sending, .badge.expiring, .badge.soon, .badge.tone-warn { color: var(--warn); border-color: var(--warn); }
.badge.expired, .badge.rejected, .badge.bounced, .badge.failed, .badge.complained, .badge.tone-bad { color: var(--bad); border-color: var(--bad); }
.badge.passed { background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.failed { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.badge.tone-info { color: var(--ink); border-color: var(--accent); }
.badge.tone-muted { color: var(--muted); border-color: var(--line-strong); }
.nowrap { white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 0; padding: 2px 10px; margin: 2px 4px 2px 0; border: 1px solid var(--line-strong); background: var(--panel); color: var(--muted); border-radius: 999px; font: inherit; font-size: 12.5px; cursor: pointer; }
.chip.on { background: color-mix(in srgb, var(--accent) 24%, var(--panel)); color: var(--ink); border-color: var(--accent); }
.chip button { border: 0; background: none; cursor: pointer; padding: 0 2px; min-height: 0; font-size: 14px; line-height: 1; color: inherit; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.tabset { margin: 0 0 12px; }
.tab { display: inline-block; padding: 5px 12px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); border-radius: 999px; font: inherit; cursor: pointer; text-decoration: none; }
.tab:hover { border-color: var(--accent); }
.tabs > button { border-radius: 999px; padding: 5px 14px; }
.tab.on, a.tab.on { background: var(--sel-bg); color: var(--sel-ink); border-color: var(--sel-bg); }

/* ---------- 8. dialogs, drawers, toasts, help ---------- */
.overlay { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; z-index: 20; padding: 16px; }
.dialog { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-3); padding: 24px; max-width: 520px; width: 100%; box-shadow: var(--sh-3); }
.dialog .choice { display: grid; gap: 4px; text-align: left; padding: 14px 16px; border-radius: var(--r-3); }
.ui-ov { z-index: 40; }
.ui-dialog { max-width: 520px; background: var(--panel); border: 1px solid var(--line); }
.ui-dialog.wide { max-width: 760px; }
.ui-dialog > h2 { font-size: 18px; margin: 0 0 10px; }
.ui-dialog p { margin: 0 0 8px; }
.ui-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.ui-err { color: var(--bad); margin: 4px 0 0; }
.ui-err:empty { display: none; }
.toast { position: fixed; bottom: 78px; right: 18px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r-2); max-width: 80vw; z-index: 60; box-shadow: var(--sh-2); }
.toast.err { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .toast.err { color: #1a0d0d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast.err { color: #1a0d0d; } }
.ui-toasts { position: fixed; right: 18px; bottom: 78px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: min(520px, calc(100vw - 36px)); pointer-events: none; }
.ui-toasts .toast { position: static; display: flex; align-items: center; gap: 12px; pointer-events: auto; max-width: 100%; }
.toast .toast-b { background: transparent; color: inherit; border: 1px solid currentColor; min-height: 0; padding: 2px 10px; opacity: .9; }
.toast .toast-x { border: 0; font-size: 18px; line-height: 1; padding: 0 4px; }
.ui-drawerov { position: fixed; inset: 0; z-index: 35; display: flex; justify-content: flex-end; background: var(--scrim); }
.ui-drawer { background: var(--panel); color: var(--ink); width: min(460px, 100%); height: 100%; display: flex; flex-direction: column; box-shadow: var(--sh-3); transform: translateX(28px); opacity: 0; transition: transform .18s ease, opacity .18s ease; }
.ui-drawer.wide { width: min(720px, 100%); }
.ui-drawer.in { transform: none; opacity: 1; }
.ui-drawer > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ui-drawer > header h2 { margin: 0; font-size: 17px; }
.ui-drawerx { border: 0; background: none; font-size: 22px; line-height: 1; padding: 0 8px; }
.ui-drawerbody { padding: 14px 16px 24px; overflow: auto; flex: 1; }
.ui-menu, .ws-menu { position: fixed; z-index: 50; min-width: 168px; display: flex; flex-direction: column; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--sh-2); }
.livebar { position: fixed; right: 16px; bottom: 16px; z-index: 60; max-width: 420px; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-3); background: var(--side-bg); color: var(--side-ink); box-shadow: var(--sh-2); font-size: 13px; line-height: 1.45; }
.livebar strong { color: var(--btn-a); }
.livebar .iconbtn { flex: none; background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.25); min-height: 0; padding: 0 8px; }
.help { position: fixed; right: 18px; bottom: 18px; z-index: 30; }
.help-btn { background: linear-gradient(135deg, var(--btn-a), var(--btn-b) 55%, var(--btn-c)); color: var(--btn-ink); border: 0; border-radius: 999px; padding: 8px 16px; min-height: 0; font-weight: 600; cursor: pointer; box-shadow: var(--sh-2); }
.help-box { display: none; width: min(360px, calc(100vw - 24px)); max-height: min(540px, calc(100vh - 40px)); background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--sh-3); flex-direction: column; overflow: hidden; }
.help-box.on { display: flex; }
.help-h { background: var(--side-bg); color: var(--side-ink); padding: 11px 14px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.help-h button { background: none; border: 0; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; min-height: 0; }
.help-log { padding: 12px 14px; overflow: auto; flex: 1; display: grid; gap: 8px; align-content: start; min-height: 120px; }
.help-m { padding: 8px 11px; border-radius: var(--r-3); max-width: 94%; white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.help-m.u { background: color-mix(in srgb, var(--accent) 22%, var(--panel)); justify-self: end; }
.help-m.a { background: color-mix(in srgb, var(--ink) 7%, var(--panel)); }
.help-ideas { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.help-ideas button { font-size: 12.5px; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; min-height: 0; }
.help-f { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.help-f input { flex: 1; width: auto; }
.help-f button { background: var(--side-bg); color: var(--side-ink); border: 0; padding: 0 14px; font-weight: 600; cursor: pointer; }
.lib-btn { position: fixed; right: 104px; bottom: 18px; z-index: 30; background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 18px; min-height: 0; font-weight: 600; cursor: pointer; box-shadow: var(--sh-2); }

/* ---------- 9. feature blocks ---------- */
/* login: neutral platform look, deliberately fixed colours (the person is not signed in yet) */
.login { position: fixed; inset: 0; max-width: none; margin: 0; padding: 20px; display: grid; place-items: center; overflow: auto;
  background: radial-gradient(1200px 600px at 50% -10%, #1d3438 0%, #0d1719 60%), #0d1719; }
.login .panel { width: min(420px, 100%); margin: 0; padding: 36px 34px 30px; background: #fbfcfb; color: #1f2328; border: 0; border-top: 3px solid #af9453; border-radius: var(--r-1); box-shadow: var(--sh-3); }
.login .panel h1 { font-weight: 600; font-size: 28px; line-height: 1.2; margin: 0 0 14px; color: #0d1719; letter-spacing: .2px; }
.login .panel h1::after { content: ''; display: block; width: 44px; height: 2px; background: #af9453; margin-top: 14px; }
.login .panel .muted { color: #4d5d60; }
.login .panel label { font-size: 13px; color: #4d5d60; }
.login .panel input { width: 100%; padding: 12px 14px; border: 1px solid #c9d3cf; border-radius: var(--r-1); background: #fff; color: #1f2328; font-size: 15px; }
.login .panel input:focus-visible { outline: 2px solid #7a6016; outline-offset: 1px; }
.login .panel button.primary { width: 100%; padding: 13px 16px; border: 1px solid #af9453; border-radius: var(--r-1); background: #0d1719; color: #cbb473; font-weight: 600; letter-spacing: .4px; cursor: pointer; }
.login .panel button.primary:hover { background: #172a2d; }
.login .panel button.primary:disabled { opacity: .6; cursor: default; }

/* modules */
.modgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mod { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.mod.later { border-style: dashed; }
.mod .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mod p { margin: 0; color: var(--muted); font-size: 14px; }

/* drafts, previews, editors */
.draft { display: grid; grid-template-columns: 1fr; gap: 6px; }
.draft .bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.draft .bar .grow { flex: 1; }
.preview { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: var(--r-2); background: #fff; margin-top: 10px; }
iframe.preview { width: 100%; min-height: 420px; border: 1px solid var(--line); border-radius: var(--r-2); background: #fff; }
.editor { min-height: 280px; max-height: 60vh; overflow: auto; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--field); line-height: 1.55; }
.editor:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.editor table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.editor td, .editor th { border: 1px solid var(--line); padding: 5px 8px; vertical-align: top; }
.editor p { margin: 0 0 10px; }
.editor figure { margin: 14px 0; padding: 8px; border: 1px dashed var(--line-strong); border-radius: var(--r-2); text-align: center; }
.editor figure img { max-width: 100%; height: auto; }
.editor figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.editor figcaption:empty::before { content: 'Type a caption (optional)'; opacity: .8; }
.editor.wordfmt { background: #fff; color: #000; }
.toolbar { display: flex; gap: 6px; }
.compose { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 18px; align-items: start; }
.compose-preview { position: sticky; top: 16px; }
.compose-preview iframe.preview { height: calc(100vh - 150px); min-height: 520px; margin-top: 8px; }
.compose-form textarea { width: 100%; resize: vertical; }
.compose-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compose-form .checks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 6px 0; }
.compose-form .check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }

/* social previews: these imitate each network, so they keep fixed light colours in both themes */
.sp-wrap { margin-top: 12px; }
.sp { background: #fff; color: #0f1419; border: 1px solid var(--line); border-radius: 12px; padding: 14px; max-width: 520px; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.sp.x { display: flex; gap: 10px; }
.sp-main { min-width: 0; flex: 1; }
.sp-row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.sp-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; background: #eee; }
.sp.x .sp-avatar { width: 40px; height: 40px; }
.sp-init { display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.sp-dim { color: #5b6573; font-size: 13px; }
.sp-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0; }
.sp-link, .sp-tag { color: #1763a6; }
.sp-img { display: block; width: 100%; border-radius: 12px; margin: 8px 0; }
.sp.li .sp-img, .sp.fb .sp-img, .sp.ig .sp-img { border-radius: 0; }
.sp-img.x, .sp-img.linkedin, .sp-img.facebook { aspect-ratio: 1.91 / 1; object-fit: cover; }
.sp-img.instagram { aspect-ratio: 1 / 1; object-fit: cover; margin: 8px -14px; width: calc(100% + 28px); }
.sp-none { display: grid; place-items: center; background: #f0f2f5; color: #5b6573; font-size: 13px; border: 1px dashed #c4cad3; }
.sp.x .sp-none { display: none; }
.sp-acts { margin-top: 10px; letter-spacing: .02em; }
.sp-linkcard { background: #f0f2f5; padding: 8px 12px; margin: 0 -14px; }
.sp-host { text-transform: uppercase; font-size: 12px; color: #5b6573; }
.sp-ttl { font-weight: 600; }
.sp-note { font-size: 12px; margin: 6px 0 0; }

/* library (media modal) */
.ml-ov { z-index: 40; }
.ml-modal { width: min(1100px, 100%); max-height: 92vh; overflow: auto; margin: 0; }
.ml-dlg { width: min(640px, 100%); max-height: 92vh; overflow: auto; margin: 0; }
.ml-mh { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ml-mh h2 { margin: 0; }
.ml-dz { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 12px; text-align: center; background: var(--panel); }
.ml-dz.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.ml-dz.busy { opacity: .7; pointer-events: none; }
.ml-dz-t { font-weight: 600; }
.ml-dz-b { display: flex; gap: 8px; justify-content: center; margin-top: 6px; flex-wrap: wrap; }
.ml-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ml-bar input[type=search], .ml-bar select { width: auto; }
.ml-bar input[type=search] { flex: 1; min-width: 200px; }
.ml-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ml-chip { border-radius: 999px; padding: 5px 12px; min-height: 0; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); cursor: pointer; }
.ml-chip.on { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.ml-chip.on .muted { color: inherit; opacity: .8; }
.ml-chip.add { border-style: dashed; }
.ml-chip.drop { outline: 2px dashed var(--accent); outline-offset: 1px; }
.ml-bulk { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--panel); }
.ml-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
.ml-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ml-card[draggable=true] { cursor: grab; }
.ml-card.sel { outline: 2px solid var(--accent); }
.ml-th { position: relative; display: block; width: 100%; aspect-ratio: 4/3; padding: 0; border: 0; border-radius: 0; background: #0d1719; cursor: pointer; }
.ml-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ml-ph { display: grid; place-items: center; height: 100%; color: #a9b8b4; }
.ml-vid, .ml-flag { position: absolute; top: 6px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; }
.ml-vid { left: 6px; background: rgba(0,0,0,.7); color: #fff; }
.ml-flag { right: 6px; background: #8a5110; color: #fff; }
.ml-cap { display: flex; gap: 6px; align-items: flex-start; padding: 7px 9px; font-size: 13px; line-height: 1.3; }
.ml-empty { grid-column: 1/-1; padding: 24px; text-align: center; }
.ml-prev { max-width: 100%; max-height: 52vh; border-radius: var(--r-2); display: block; margin: 0 auto; background: #0d1719; }
.ml-warn { padding: 8px 12px; border-radius: var(--r-2); background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); font-weight: 600; }
.ml-act { display: flex; gap: 8px; flex-wrap: wrap; }
.ml-tip { position: fixed; z-index: 60; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-3); padding: 6px; box-shadow: var(--sh-2); max-width: min(560px, 60vw); font-size: 13px; }
.ml-tip img { display: block; max-width: 100%; max-height: 60vh; border-radius: var(--r-2); }
.ml-tip div { padding: 6px 4px 2px; }
.ml-hv { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.fr-dlg { width: min(760px, 100%); }
.fr-stage { position: relative; width: fit-content; max-width: 100%; margin: 0 auto; overflow: hidden; border-radius: var(--r-2); background: #0d1719; line-height: 0; }
.fr-stage.pick { cursor: grab; touch-action: none; }
.fr-img { display: block; max-width: 100%; max-height: 46vh; user-select: none; }
.fr-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); pointer-events: none; }
.fr-cmp { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.fr-prev { width: 100%; margin-top: 4px; border-radius: var(--r-2); background-size: cover; background-repeat: no-repeat; background-color: #0d1719; }

/* analytics */
.achart { position: relative; }
.alane { position: relative; margin-bottom: 4px; }
.amark { position: absolute; width: 11px; height: 11px; border-radius: 50%; transform: translateX(-50%); cursor: default; color: #fff; font-size: 9px; line-height: 11px; text-align: center; font-weight: 700; border: 1.5px solid var(--panel); box-sizing: content-box; }
.amark:hover, .amark:focus-visible { outline: 2px solid var(--btn-b); z-index: 5; }
.amark::after { content: attr(data-tip); display: none; position: absolute; top: 16px; left: 50%; transform: translateX(-50%); width: 230px; padding: 6px 8px; border-radius: var(--r-2); background: #162124; color: #fff; font-size: 12px; line-height: 1.35; font-weight: 400; text-align: left; z-index: 9; box-shadow: var(--sh-2); }
.amark.r::after { left: auto; right: -6px; transform: none; }
.amark:hover::after, .amark:focus-visible::after { display: block; }
.achart .axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.alegend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.alegend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.minibar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.minibar i { display: block; height: 8px; border-radius: var(--r-1); background: var(--btn-b); min-width: 2px; }
.tip { padding: 10px 0; border-top: 1px solid var(--line); }
.tip:first-of-type { border-top: 0; }
.amap { margin: 6px 0 12px; }

/* QP review and website tree */
.qpcard { border-left: 4px solid #c0392b; }
.qpcard.done { border-left-color: var(--line); }
.qpask { font-weight: 600; margin: 0; }
.qpcheck { margin: 4px 0 0; padding-left: 18px; }
.qpcheck li { margin: 2px 0; }
.qpchg { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
.qpchg dt { color: var(--muted); }
.qpchg dd { margin: 0; }
.qpbtn.alert { background: #c0392b; border-color: #c0392b; color: #fff; }
.qpbtn .navcount { background: #fff; color: #a8321f; margin-left: 8px; }
.tree { display: flex; flex-direction: column; gap: 2px; }
.treerow { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--r-2); padding: 2px 6px 2px 2px; background: var(--panel); }
.treerow.on { border-color: var(--accent); }
.treemain { flex: 1; display: flex; align-items: center; gap: 10px; text-align: left; background: none; border: 0; padding: 8px 6px; cursor: pointer; min-width: 0; color: inherit; font: inherit; }
.treemain .treesum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.treemain .caret { width: 12px; color: var(--muted); }
.treepub { padding: 2px 12px; }
.treeitem { margin-bottom: 6px; }
.treebody { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r-2) var(--r-2); padding: 12px; margin-top: -2px; }
.treerow .rowmove { display: flex; gap: 2px; margin-left: auto; flex: none; }
.treerow .iconbtn { padding: 2px 7px; min-width: 0; min-height: 0; font-size: 11px; line-height: 1.2; }
.treerow[draggable=true] { cursor: grab; }
.treerow.dragging { opacity: .45; }
.treerow.dropat { box-shadow: 0 -3px 0 0 var(--accent); }

/* ---------- 13. responsive and touch ---------- */
/* Collapsed menu at 1000 px and below; the Website editor keeps its own panes. */
@media (max-width: 1000px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--side-line); }
  .brand { padding: 0 10px 0 0; }
  .menu-btn { display: inline-block; margin-left: auto; }
  .searchbtn { margin: 0; flex: 1 1 100%; width: auto; }
  .side:not(.open) .searchbtn { order: 1; flex: 1 1 180px; }
  .side:not(.open) .menu-btn { order: 2; }
  .side:not(.open) .nav, .side:not(.open) .foot, .side:not(.open) > select, .side:not(.open) > label { display: none; }
  .side.open { max-height: 100vh; overflow: auto; }
  .side select { flex: 1 1 100%; width: auto; }
  .nav { flex: 1 1 100%; overflow: visible; margin: 0; padding: 0; -webkit-mask-image: none; mask-image: none; max-width: 100%; }
  .navgrp { min-width: 0; }
  .side .foot { flex: 1 1 100%; margin-top: 0; }
  .main { padding: 16px 20px 56px; }
  .compose { grid-template-columns: 1fr; }
  .compose-preview { position: static; }
  .compose-form .two { grid-template-columns: 1fr; }
  table.kv tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.kv td { border: 0; padding: 0; }
  table.kv td.k, table.kv td.v { grid-column: 1 / -1; width: auto; }
}
@media (max-width: 600px) { .side:not(.open) .searchbtn { order: 3; flex-basis: 100%; } }
@media (max-width: 760px) {
  .main { padding: 14px 16px 48px; }
  .form { grid-template-columns: 1fr; }
  .rowcard, .herocard .heroinfo { flex-wrap: wrap; }
  .thumb.wide { width: 100%; max-width: 260px; }
  .ui-drawer, .ui-drawer.wide { width: 100%; }
  .dialog, .ui-dialog { padding: 18px; }
  .help { right: 12px; bottom: 12px; }
  .lib-btn { right: 92px; bottom: 12px; }
  .ui-toasts { right: 12px; bottom: 64px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Tables turn into stacked cards on a phone (cells carry data-label from ui.list). */
@media (max-width: 600px) {
  .ui-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ui-table, .ui-table tbody, .ui-table tr, .ui-table td { display: block; width: 100%; }
  .ui-table tr { border: 1px solid var(--line); border-radius: var(--r-2); padding: 6px 10px; margin-bottom: 8px; background: var(--panel); }
  .ui-table td { display: flex; gap: 12px; justify-content: space-between; align-items: baseline; border: 0; padding: 4px 0; text-align: right; width: auto; white-space: normal; }
  .ui-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; max-width: 45%; }
  .ui-table td.ui-chk, .ui-table td.ui-menucol { width: auto; text-align: left; }
  .ui-table td.ui-menucol { justify-content: flex-end; }
}
/* Touch screens and narrow windows: every control a finger needs is at least 40 px; desktop spacing is unchanged. */
@media (max-width: 1000px), (pointer: coarse) {
  button:not(.ws *), .btn:not(.ws *), .btnlink:not(.ws *), .tab, .chip:not(.ws *), .ml-chip, .backbtn, .menu-btn, .help-btn, .lib-btn, .searchbtn { min-height: 40px !important; }
  button:not(.ws *), .btn:not(.ws *), .btnlink:not(.ws *), .tab, .menu-btn, .help-btn { min-width: 40px; }
  button.link { padding: 0 8px; }
  input[type=text], input[type=email], input[type=search], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=url], input[type=tel], input[type=password], input:not([type]), select:not(.ws *) { min-height: 40px; }
  .nav a, .navgrp > summary { min-height: 40px; }
  label.check, .checkrow label, label.mode, label:has(> input[type=checkbox]), label:has(> input[type=radio]) { min-height: 40px; align-items: center; }
  label:has(> input[type=checkbox]), label:has(> input[type=radio]) { display: inline-flex; gap: 8px; }
  summary.muted, details.tips summary { padding-block: 10px; }
  input[type=checkbox]:not(.ws *), input[type=radio]:not(.ws *) { width: 20px; height: 20px; }
  td.ui-chk input[type=checkbox], th.ui-chk input[type=checkbox], .ml-cap input[type=checkbox] { width: 24px; height: 24px; }
  input[type=file] { min-height: 40px; }
  input[type=file]::file-selector-button { min-height: 32px; }
  td.ui-chk, th.ui-chk { width: 44px; }
  .ui-rowlink, .ui-sort { display: inline-flex; align-items: center; min-height: 40px !important; }
  .ui-panelbtn { min-height: 40px !important; }
  .mv, .mvcol .mv { height: 36px; min-height: 36px !important; min-width: 40px; line-height: 1; }
  details.fold > summary, details.projfold > summary, .panel > h2.foldh, details.tips summary { min-height: 40px; }
  .treemain { min-height: 40px; }
  .amark { width: 14px; height: 14px; }
}

/* ---------- 14. utilities (new code uses these instead of inline style attributes) ---------- */
.row { display: flex; gap: 8px; align-items: center; }
.row-wrap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.gap-xs { gap: 4px !important; } .gap-s { gap: 8px !important; } .gap-m { gap: 12px !important; } .gap-l { gap: 24px !important; }
.max-form { max-width: 760px; }
.max-text { max-width: 75ch; }
.grow { flex: 1 1 auto; min-width: 0; }
.right { margin-left: auto; text-align: right; }
.center { text-align: center; }
.m0 { margin: 0 !important; }
.mt-s { margin-top: 8px !important; } .mt-m { margin-top: 16px !important; } .mt-l { margin-top: 24px !important; }
.mb-s { margin-bottom: 8px !important; } .mb-m { margin-bottom: 16px !important; }
.small { font-size: 12.5px; }
.break { overflow-wrap: anywhere; }
.ui-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* ---------- Website editor (#/site): tree, editor and preview side by side ----------
   Spacing: 4px label to control, 6px between fields, 24px between groups, 32px between sections. */
.main.ws-main, .main:has(> .ws) { max-width: none; padding: 0; }
.ws { --ws-f: 6px; --ws-l: 4px; --ws-g: 24px; --ws-s: 32px; display: flex; flex-direction: column; height: 100vh; min-height: 0; background: var(--bg); }
@media (max-width: 1000px) { .ws { height: calc(100vh - 64px); } }
.ws-top { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.ws-title { display: flex; align-items: baseline; gap: 10px; }
.ws-title h1 { margin: 0; font-size: 18px; }
.ws-title .backbtn { margin: 0; }
.ws-count { color: var(--muted); font-size: 13px; margin-left: auto; }
.ws-count.on { color: var(--ink); font-weight: 600; }
.ws-acts { display: flex; gap: 6px; }
.ws-panes, .ws-drawerbtn, .ws-drawerclose { display: none; }
.ws-drawerclose { width: 100%; text-align: left; margin-bottom: 6px; min-height: 40px; }
.ws-banner { padding: 6px 16px; font-size: 13px; background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ws-banner[hidden] { display: none; }
.ws-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 270px minmax(380px, 480px) minmax(0, 1fr); }
.ws-tree, .ws-ed, .ws-pv { min-height: 0; overflow: auto; }
.ws-tree { border-right: 1px solid var(--line); background: var(--panel); padding: 8px 6px 40px; font-size: 13.5px; }
.ws-ed { border-right: 1px solid var(--line); padding: 0 16px 60px; background: var(--bg); }
.ws-pv { display: flex; flex-direction: column; background: color-mix(in srgb, var(--line) 45%, var(--bg)); }

/* tree */
.ws-g + .ws-g { margin-top: 2px; }
.ws-gh, .ws-node { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: 5px 8px; min-height: 0; color: var(--ink); font: inherit; cursor: pointer; }
.ws-gh { font-weight: 600; }
.ws-gh:hover, .ws-node:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ws-gh.on, .ws-node.on { background: color-mix(in srgb, var(--accent) 20%, var(--panel)); font-weight: 600; }
.ws-kids { margin-left: 12px; padding-left: 6px; border-left: 1px solid var(--line); }
.ws-node-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-caret { width: 12px; flex: none; color: var(--muted); font-size: 11px; }
.ws-sub { font-size: 13px; }
.ws-pset { color: var(--muted); }
.ws-add { color: var(--accent); }
.ws-rem { color: var(--muted); font-style: italic; }
.ws-secrow { display: flex; align-items: center; border-radius: 6px; }
.ws-secrow.hidden .ws-node-t { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.ws-secrow[draggable=true] { cursor: grab; }
.ws-secrow.dragging { opacity: .45; }
.ws-secrow.dropat { box-shadow: 0 -2px 0 0 var(--accent); }
.ws-more { flex: none; min-height: 0; padding: 0 6px; border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; opacity: .5; }
.ws-secrow:hover .ws-more, .ws-more:focus-visible { opacity: 1; }
.ws-hid { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
.ws-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; display: inline-block; }
.ws-cnt { margin-left: auto; font-size: 11px; color: var(--muted); }
.ws-prev { margin-top: 18px; padding: 8px; border-top: 1px solid var(--line); font-size: 12.5px; }

/* editor */
.ws-edh { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 10px 0 8px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.ws-crumbs { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline; }
.ws-crumbs a { color: var(--muted); }
.ws-crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.ws-sep { opacity: .6; }
.ws-saved { display: block; font-size: 12px; color: var(--muted); min-height: 16px; margin-top: 2px; }
.ws-saved.err { color: var(--bad); font-weight: 600; }
.ws-acc-i { border-bottom: 1px solid var(--line); }
.ws-top-i.open { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); margin: 8px 0 var(--ws-s); }
.ws-top-i.hidden > .ws-acc-h .ws-acc-t { color: var(--muted); }
.ws-acc-h { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: 8px 6px; min-height: 0; font: inherit; color: var(--ink); cursor: pointer; }
.ws-acc-h:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ws-top-i > .ws-acc-h { font-weight: 600; }
.ws-acc-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-acc-m { font-size: 12px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.ws-top-i > .ws-acc-b { padding: 4px 12px 14px; }
.ws-parts { margin-top: var(--ws-g); border-top: 1px solid var(--line); }
.ws-parts .ws-acc-b { padding: 4px 0 var(--ws-g) 18px; }
.ws-fields { display: flex; flex-direction: column; gap: var(--ws-f); }
.ws-f { display: flex; flex-direction: column; gap: var(--ws-l); margin: 0; font-size: 13px; color: var(--muted); }
.ws-fl { color: var(--ink); font-weight: 500; font-size: 13px; }
.ws-f input[type=text], .ws-f input[type=email], .ws-f input[type=number], .ws-f input[type=date], .ws-f select, .ws-f textarea { width: 100%; }
.ws-help { font-size: 12px; color: var(--muted); line-height: 1.4; }
.ws-help.low, .ws-count.over { color: var(--warn); }
.ws-toggle { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--ink); }
.ws-toggle .ws-help { flex-basis: 100%; }
.ws-check { display: flex; gap: 6px; align-items: center; margin: 0; font-size: 13px; color: var(--ink); }
.ws-sub { display: flex; flex-direction: column; gap: 2px; margin: 0; font-size: 12px; color: var(--muted); }
.ws-sub-l { font-size: 12px; color: var(--muted); }
.ws-linkrow, .ws-imgrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ws-linksum { flex: 1; min-width: 140px; color: var(--ink); font-size: 13px; }
.ws-thumbbox { width: 120px; aspect-ratio: 16/10; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; display: grid; place-items: center; overflow: hidden; }
.ws-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.ws-imgbtns { display: flex; flex-direction: column; gap: 6px; }
.ws-rich { min-height: 32px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 0 0 6px 6px; background: var(--panel); color: var(--ink); line-height: 1.45; font-size: 14px; outline: none; overflow-wrap: anywhere; }
.ws-rich.multi { min-height: 84px; max-height: 50vh; overflow: auto; }
.ws-rich p { margin: 0 0 8px; } .ws-rich p:last-child { margin-bottom: 0; }
.ws-rich a { color: var(--accent); text-decoration: underline; }
.ws-rich:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ws-rich[contenteditable=false] { background: var(--bg); color: var(--muted); }
.ws-rtb { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; background: var(--bg); }
.ws-rtb button { min-height: 0; padding: 1px 8px; font-size: 12px; border: 0; background: none; }
.ws-rtb button:hover { background: var(--panel); }
.ws-richwrap { display: flex; flex-direction: column; }
.ws-swatches { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.ws-sw { width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 5px; border: 1px solid rgba(0,0,0,.25); }
.ws-sw[aria-checked=true] { outline: 2px solid var(--accent); outline-offset: 2px; }
.ws-sw.none { background: var(--panel); font-size: 12px; }
.ws-custom { display: inline-flex; gap: 6px; align-items: center; margin: 0 0 0 6px; font-size: 12px; color: var(--muted); }
.ws-custom input { width: 30px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: none; }
.ws-contrast.ok { color: var(--good); } .ws-contrast.low { color: var(--bad); font-weight: 600; }
.ws-bound .ws-boundv { padding: 5px 10px; border: 1px dashed var(--line); border-radius: 6px; color: var(--ink); background: var(--bg); font-size: 13.5px; }
.ws-group { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px 10px; margin: 0; display: flex; flex-direction: column; gap: var(--ws-f); }
.ws-group legend { font-size: 13px; color: var(--ink); font-weight: 500; padding: 0 4px; }
.ws-note { font-size: 13px; padding: 8px 10px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); border-radius: 0 6px 6px 0; margin-bottom: 10px; }
.ws-empty { color: var(--muted); font-size: 13px; padding: 10px 0; }
.ws-secact { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--ws-g); padding-top: 10px; border-top: 1px solid var(--line); }
.ws-secact button, .ws-pagefoot button, .ws-list-a button { min-height: 28px; padding: 3px 10px; font-size: 13px; }
.ws-pagefoot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.ws-list { display: flex; flex-direction: column; gap: 4px; }
.ws-li { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.ws-li-h { display: flex; align-items: center; gap: 4px; padding: 0 4px; }
.ws-li-h.dragging { opacity: .45; } .ws-li-h.dropat { box-shadow: 0 -2px 0 0 var(--accent); }
.ws-grip { cursor: grab; color: var(--muted); padding: 0 2px; font-size: 12px; letter-spacing: -2px; user-select: none; }
.ws-li-t { flex: 1; min-width: 0; display: flex; gap: 6px; align-items: center; text-align: left; background: none; border: 0; min-height: 0; padding: 6px 2px; font: inherit; font-size: 13px; color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ws-li-a { display: flex; gap: 2px; flex: none; }
.ws-li-a .iconbtn { min-height: 0; padding: 1px 6px; font-size: 11px; }
.ws-li-b { padding: 6px 10px 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--ws-f); }
.ws-list-a { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.ws-dochead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.ws-dochead h2 { margin: 0; font-size: 16px; }
.ws-h3 { font-size: 14px; margin: var(--ws-g) 0 6px; }
.ws-state { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); width: fit-content; }
.ws-state.changed, .ws-state.new { color: var(--warn); border-color: var(--warn); }
.ws-state.ok { color: var(--good); border-color: var(--good); }
.ws-rows { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.ws-rowbtn { display: flex; align-items: center; gap: 10px; justify-content: space-between; text-align: left; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); text-decoration: none; font: inherit; font-size: 13.5px; min-height: 0; cursor: pointer; }
.ws-rowbtn.static { cursor: default; }
.ws-rowbtn > span:first-child { flex: 1; min-width: 0; }
.ws-appears { margin-bottom: 10px; }

/* preview */
.ws-pvh { display: flex; gap: 8px; align-items: center; padding: 8px 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--panel); }
.ws-pvnote { margin-right: auto; }
.ws-devs, .ws-tabs { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.ws-tab { min-height: 0; padding: 3px 12px; border: 0; border-radius: 999px; background: none; font-size: 13px; }
.ws-tab.on { background: var(--ink); color: var(--bg); }
.ws-stage { flex: 1; min-height: 0; overflow: hidden; position: relative; display: flex; justify-content: center; padding: 0; }
.ws-frame, .ws-frame-next { border: 0; background: #fff; transform-origin: top center; flex: none; box-shadow: 0 0 0 1px var(--line); }
.ws[data-device=desktop] .ws-frame, .ws[data-device=desktop] .ws-frame-next { transform-origin: top left; align-self: flex-start; }
.ws-frame-next { position: absolute; visibility: hidden; pointer-events: none; }
.ws[data-device=desktop] .ws-stage { justify-content: flex-start; }

/* dialogs and menus */
.ws-ov { z-index: 45; }
.ws-dlg { width: min(560px, 100%); max-height: 90vh; overflow: auto; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.ws-dlg.wide { width: min(880px, 100%); }
.ws-dlg-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ws-dlg-h h2 { margin: 0; }
.ws-dlg-b { display: flex; flex-direction: column; gap: 10px; }
.ws-dlg-a { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ws-lp { display: flex; flex-direction: column; gap: 10px; }
.ws-lp .ws-tabs { flex-wrap: wrap; border-radius: 10px; }
.ws-lp-pane { display: flex; flex-direction: column; gap: var(--ws-f, 6px); }
.ws-menu { position: fixed; z-index: 50; min-width: 200px; display: flex; flex-direction: column; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.ws-menu button { text-align: left; border: 0; background: none; min-height: 0; padding: 6px 10px; font-size: 13.5px; }
.ws-menu button:hover, .ws-menu button:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ws-menu button.danger { color: var(--bad); }
.ws-chooser { display: flex; flex-direction: column; gap: 16px; }
.ws-cat h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.ws-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.ws-card { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; gap: 2px 10px; text-align: left; padding: 10px; min-height: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.ws-card:hover { border-color: var(--accent); }
.ws-card-i { grid-row: span 2; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 6px; background: var(--bg); color: var(--accent); font-weight: 700; }
.ws-pubd { display: flex; flex-direction: column; gap: 10px; }
.ws-pubg ul { margin: 4px 0 0; padding-left: 18px; font-size: 13.5px; }

/* narrower screens: preview becomes a tab beside the editor; below 760px the tree becomes a drawer */
@media (max-width: 1100px) {
  .ws-body { grid-template-columns: 250px minmax(0, 1fr); }
  .ws-panes { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; }
  .ws[data-pane=edit] .ws-pv { display: none; }
  .ws[data-pane=preview] .ws-ed { display: none; }
  .ws-ed { border-right: 0; }
}
@media (max-width: 760px) {
  .ws { height: auto; min-height: calc(100vh - 60px); }
  .ws-body { grid-template-columns: minmax(0, 1fr); }
  .ws-drawerbtn { display: inline-block; }
  .ws.drawer .ws-drawerclose { display: block; }
  .ws-count { margin-left: 0; flex-basis: 100%; order: 5; }
  .ws-tree { display: none; }
  .ws.drawer .ws-tree { display: block; position: fixed; inset: 0 20% 0 0; z-index: 30; box-shadow: 0 0 0 100vmax rgba(15,26,28,.45); padding-top: 14px; }
  .ws-ed { padding: 0 12px 60px; overflow: visible; }
  .ws-pv { min-height: 70vh; }
  .ws-acts { flex-wrap: wrap; }
}
/* touch screens and narrow windows: every control a finger needs is at least 40 px; the tight desktop spacing is unchanged */
@media (max-width: 1100px), (pointer: coarse) {
  .ws-top button, .ws-tab, .ws-secact button, .ws-pagefoot button, .ws-list-a button, .ws-ed button.primary, .ws-ed .ws-rowbtn, .ws-dlg button { min-height: 40px; }
  .ws-top button, .ws-tab, .ws-secact button, .ws-pagefoot button, .ws-list-a button { min-width: 40px; }
  .ws-acc-h, .ws-li-t, .ws-tree .ws-node, .ws-tree .ws-gh, .ws-tree .ws-grp2 { min-height: 40px; }
  .ws-li-a .iconbtn, .ws-tree .ws-more { min-height: 40px; min-width: 40px; }
  .ws-more { opacity: .8; }
}
.ws-f input[type=number], .ws-f input[type=date] { font: inherit; padding: var(--ctl-pad); min-height: var(--ctl-h); border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }

/* ---------- WP-A2: shared controls (01b-ui.js) ---------- */
.ui-listbar { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.ui-listbar .ui-search { width: min(280px, 100%); }
.ui-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ui-chips .chip { cursor: pointer; min-height: 0; padding: 2px 10px; }
.ui-bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; margin-bottom: 8px; border: 1px solid var(--accent); border-radius: var(--r-2); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.ui-bulk[hidden] { display: none; }
.ui-bulkn { font-weight: 600; margin-right: 4px; }
.ui-listfoot { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.ui-table tr.sel td { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.ui-chk { width: 34px; }
.ui-menucol { width: 44px; text-align: right; }
.ui-rowlink { color: inherit; font: inherit; font-weight: 600; text-decoration: none; background: none; border: 0; padding: 0; min-height: 0; text-align: left; cursor: pointer; }
.ui-rowlink:hover { text-decoration: underline; color: var(--accent-text); }
.ui-sort { background: none; border: 0; padding: 0; min-height: 0; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; cursor: pointer; }
.ui-more { min-width: 32px; padding: 0 8px; }
.ui-menu button { border: 0; background: none; text-align: left; border-radius: 6px; }
.ui-menu button:hover, .ui-menu button:focus { background: var(--bg); }
.ui-menu button.danger { color: var(--bad); background: none; }
.ui-empty { padding: 22px 12px; text-align: center; }
.ui-empty p { margin: 6px auto 10px; }
.uipanel > h2 { margin: 0; }
.uipanel:not(.closed) > h2 { margin-bottom: 8px; }
.ui-panelbtn { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; padding: 0; min-height: 0; font: inherit; font-weight: 600; color: inherit; }
.ui-caret { color: var(--muted); font-size: 13px; transition: transform .15s; }
.ui-panelbtn[aria-expanded="true"] .ui-caret { transform: rotate(90deg); }
.ui-pcount { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }
.ui-panelbody[hidden] { display: none; }
.ui-demorow { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- WP-A3: loading placeholder ---------- */
.skel { padding: 4px 0; }
.skel-h, .skel-p { border-radius: 6px; background: linear-gradient(90deg, var(--line) 25%, color-mix(in srgb, var(--line) 50%, var(--panel)) 50%, var(--line) 75%); background-size: 200% 100%; animation: skel 1.3s linear infinite; }
.skel-h { height: 26px; width: 38%; margin-bottom: 18px; }
.skel-p { height: 70px; margin-bottom: 12px; }
.skel-p.short { width: 62%; }
@keyframes skel { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel-h, .skel-p { animation: none; } }

/* ---------- WP-A5: search button hint ---------- */
.searchbtn { display: flex; justify-content: space-between; align-items: center; }
.searchbtn .searchkey { font: inherit; font-size: 12px; opacity: .7; border: 0; background: none; padding: 0; }

/* ---------- WP-A6: search dialog ---------- */
.a6-input { width: 100%; box-sizing: border-box; }
.a6-results { max-height: 52vh; overflow: auto; margin-top: 8px; }
.a6-gh { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 10px 2px; }
.a6-opt { display: flex; flex-direction: column; gap: 0; padding: 6px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.a6-opt:hover, .a6-opt.on { background: var(--line); }
.a6-opt.on { outline: 2px solid var(--btn-b, #af9453); outline-offset: -2px; }
.a6-h { font-size: 12px; }
.a6-more { font-size: 13px; color: var(--muted); }
.a6-none { padding: 14px 10px; }
.a6-help { font-size: 12px; margin: 8px 0 0; }
.a6-opt mark { background: color-mix(in srgb, var(--btn-b, #af9453) 35%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.a6-hit { outline: 2px solid var(--btn-b, #af9453); outline-offset: 2px; }

/* ---------- WP-A7: company settings ---------- */
.a7-form, .a7-body { max-width: 760px; }
.a7-field { margin: 0; }
.a7-field > label, .a7-lab { display: block; font-weight: 600; margin-bottom: 4px; }
.a7-hint { margin: 4px 0 0; font-size: 13px; }
.a7-sub { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.a7-sub h3, .a7-body > .stack > h3 { margin: 0 0 4px; font-size: 15px; }
.a7-qrow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.a7-colour { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.a7-colour input[type=text] { width: 110px; }
.a7-pick { width: 44px; height: 34px; padding: 2px; }
.a7-cols { display: grid; grid-template-columns: 1fr 240px; gap: 24px; align-items: start; }
.a7-prev { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.a7-side { padding: 10px 12px; }
.a7-sidei { padding: 4px 0; font-size: 13px; }
.a7-sidei.on { font-weight: 600; }
.a7-btn { margin: 10px 12px; padding: 7px 12px; border-radius: 6px; text-align: center; font-weight: 600; font-size: 13px; }
.a7-contrast { font-size: 13px; margin: 0; }
.a7-contrast.bad { color: #b3261e; }
.a7-contrast.good { color: var(--muted); }
:root[data-theme="dark"] .a7-contrast.bad { color: #f2b8b5; }
.a7-net { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.a7-net strong { min-width: 90px; }
.a7-conn { color: var(--ink); }
.a7-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.a7-frame { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.a7-pre { white-space: pre-wrap; word-break: break-all; margin: 8px 0; }
.a7-tech { margin-top: 12px; }
.a7-tech summary { cursor: pointer; font-weight: 600; }
@media (max-width: 760px) { .a7-cols { grid-template-columns: 1fr; } .a7-qrow { grid-template-columns: 1fr; } }

/* ---------- WP-A19: permission comparison table ---------- */
.a19-matrix th[scope=row] { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 400; color: var(--ink); }
.a19-matrix td { text-align: center; }
.a19-yes { color: var(--ink); font-weight: 600; }
.a19-no { color: var(--muted); }

/* ---------- WP-A21: library paging, unused filter, website pictures ---------- */
.ml-more { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 12px 0; }
.ml-unused { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-size: 14px; white-space: nowrap; }
.ml-import { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: 320px; }
.ml-import-row { display: flex; gap: 6px; align-items: center; }
.ml-import-help { margin: 0; font-size: 12px; text-align: right; }
.ml-card .ui-menubtn { margin-left: auto; }
@media (max-width: 760px) { .ml-import { align-items: flex-start; max-width: none; } .ml-import-help { text-align: left; } }

/* ---------- WP-A22: activity, guide, help ---------- */
.a22-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.a22-foot { text-align: center; margin-top: 10px; }
.a22-restore { margin-top: 6px; }
.a22-other { margin-top: 4px; }
.a22-job { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.a22-jobt { flex: 1; min-width: 240px; }
.a22-guidelink { margin-top: 24px; }
.help-ic { display: none; }
@media (max-width: 760px) {
  .help { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .help-btn { width: 44px; height: 44px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
  .help-tx { display: none; }
  .help-ic { display: inline; font-size: 20px; font-weight: 700; line-height: 1; }
  .help-box { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: auto; max-height: 70vh; }
  .main { padding-bottom: 96px; }
  body.help-typing .help-btn { display: none; }
}
/* WP-A21 */ .ml-modal .ml-ov { z-index: auto; position: static; }
/* ---------- WP-A8: news release flow ---------- */
.a8-flow { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
.a8-rail ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; position: sticky; top: 12px; }
.a8-step { display: grid; grid-template-columns: 26px 1fr; grid-template-areas: "n l" ". c"; gap: 2px 8px; width: 100%; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); cursor: pointer; }
.a8-step.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.a8-num { grid-area: n; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.a8-lab { grid-area: l; font-weight: 600; }
.a8-chip { grid-area: c; }
.a8-next { margin: 0 0 12px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--panel); border-radius: 0 8px 8px 0; }
.a8-go { margin-left: 6px; }
.a8-row { display: flex; gap: 8px 10px; align-items: center; flex-wrap: wrap; }
.a8-saved { font-size: 13px; color: var(--muted); }
.a8-cards { display: grid; gap: 12px; }
.a8-draftgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.a8-draftedit textarea, .a8-draftedit input { width: 100%; }
.a8-preview iframe.preview { height: 420px; width: 100%; }
.a8-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }
.a8-check { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.a8-check li.ok .a8-mark { color: var(--good); }
.a8-check li.todo .a8-mark { color: var(--warn); }
.a8-livehead { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.a8-headtools { display: flex; gap: 12px; align-items: center; }
.a8-livenote { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }
.a8-stepbody > .panel { margin-bottom: 10px; }
@media (max-width: 800px) {
  .a8-flow { grid-template-columns: 1fr; }
  .a8-rail ol { grid-template-columns: repeat(2, minmax(0, 1fr)); position: static; }
  .a8-draftgrid { grid-template-columns: 1fr; }
}

/* ---------- WP-A9: social posts ---------- */
.a9-vhead { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.a9-composer textarea, .a9-composer input[type=text] { width: 100%; }
.a9-actions { justify-content: flex-start; padding-top: 6px; }

/* WP-A10 */
.compose-form input[type=text], .compose-form input[type=url], .compose-form textarea { width: 100%; }
.compose-form .a8-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.compose-form .grow { flex: 1; }

/* WP-A10 */
.compose-form input[type=text], .compose-form input[type=url], .compose-form textarea { width: 100%; }
.compose-form .a8-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.compose-form .grow { flex: 1; }

/* WP-A11 */
.a11-form input, .a11-form select, .a11-form textarea { width: 100%; }
.a11-times { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.a11-err { color: var(--bad, #a33); margin: 0; min-height: 1em; }

/* WP-A12 */
.a12-form input, .a12-form select { width: 100%; }
.a12-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.a12-two { display: grid; grid-template-columns: 1fr 180px; gap: 8px; }
@media (max-width: 560px) { .a12-two { grid-template-columns: 1fr; } }
/* ---------- WP-A13: contacts ---------- */
.a13-drop { border: 2px dashed var(--line); border-radius: 10px; padding: 18px 14px; text-align: center; cursor: pointer; color: var(--muted, inherit); background: var(--panel); }
.a13-drop.over, .a13-drop:focus-visible { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); outline: none; }
.a13-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.a13-meta { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.a13-statusline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.a13-acts { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.a13-also { margin: 4px 0; padding: 4px 10px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.a13-add { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: flex-end; margin-top: 10px; }
.a13-off td { opacity: .65; }
.a13-switch { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

/* ---------- WP-A14: shareholders ---------- */
/* Uses the drop zone defined in the WP-A13 block. */

/* ---------- WP-A15: insights ---------- */
:root { --mk-release: #b8923a; --mk-email: #2f6f8f; --mk-social: #7a4f9c; --mk-event: #3d8a5a; --mk-note: #6f7a7d; --mk-spike: #c0392b; --mk-investor: #a85c3a; --mk-spend: #1f7a6d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --mk-release: #d9b45c; --mk-email: #6fb0d2; --mk-social: #b894d6; --mk-event: #6fc08c; --mk-note: #a3adb0; --mk-spike: #ef7b6d; --mk-investor: #e09a78; --mk-spend: #5cc2b2; } }
:root[data-theme="dark"] { --mk-release: #d9b45c; --mk-email: #6fb0d2; --mk-social: #b894d6; --mk-event: #6fc08c; --mk-note: #a3adb0; --mk-spike: #ef7b6d; --mk-investor: #e09a78; --mk-spend: #5cc2b2; }
.a15-tbtn { margin-top: 8px; font-size: 13px; min-height: 0; padding: 3px 10px; }
.a15-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 12px; align-items: end; }
/* ---------- WP-A16: Facts and share structure ---------- */
.a16-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0 10px; }
.a16-search { flex: 1 1 240px; max-width: 420px; }
.a16-secs { gap: 10px; }
.a16-secbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.a16-fact { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr) auto; gap: 6px 12px; align-items: start; padding: 6px 0; border-top: 1px solid var(--line); }
.a16-fact:first-of-type { border-top: 0; }
.a16-lab { min-width: 0; overflow-wrap: anywhere; }
.a16-note { font-size: 12px; }
.a16-val { display: flex; gap: 6px 8px; flex-wrap: wrap; align-items: center; min-width: 0; }
.a16-val input, .a16-val textarea { flex: 1 1 260px; min-width: 0; }
.a16-uses { display: flex; gap: 4px; flex-wrap: wrap; }
.a16-side { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 760px) { .a16-fact { grid-template-columns: minmax(0, 1fr); } .a16-side { justify-content: flex-start; } }
.a16-review { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow: auto; }
.a16-rv { padding: 6px 0; border-top: 1px solid var(--line); }
.a16-was { text-decoration: line-through; color: var(--muted); }
.a16-now { font-weight: 600; }
.a16-sharesrow { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.a16-big { font-family: Lora, Georgia, serif; font-size: 28px; line-height: 1.2; }
.a16-wait { margin-top: 4px; }
.a16-sharesbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.a16-waiting { border-color: var(--accent); }
.a16-waiting ul { margin: 4px 0 8px; padding-left: 18px; }
.a16-pend { font-size: 12px; color: var(--warn); }
.a16-logrow { padding: 5px 0; border-top: 1px solid var(--line); }

/* ---------- WP-A17: Filings and reports ---------- */
.a17-chips { margin-bottom: 8px; }
.a17-files { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.a17-chat { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.a17-sw { display: inline-flex; align-items: center; gap: 6px; }
.a17-pend { font-size: 12px; color: var(--warn); }
.a17-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.a17-drop { border: 2px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; }
.a17-drop.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.a17-drop p { margin: 0 0 6px; }
.a17-picked { display: flex; flex-direction: column; gap: 6px; }
.a17-pick { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.a17-pn { overflow-wrap: anywhere; }
.a17-ver { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
@media (max-width: 1000px) { .a17-pick { grid-template-columns: minmax(0, 1fr); } }
.shell > .main { min-width: 0; }

/* ---------- WP-A18: Presentation ---------- */
.a18-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 8px 0; }
.a18-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.a18-slide { align-items: flex-start; flex-wrap: wrap; gap: 6px 10px; }
.a18-slide.hid { opacity: .65; }
.a18-slide.drag { opacity: .5; }
.a18-slide.over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.a18-main { display: flex; gap: 8px; flex: 1 1 240px; min-width: 0; align-items: flex-start; }
.a18-grip { cursor: grab; color: var(--muted); font-size: 18px; line-height: 1.2; user-select: none; }
.a18-prev { position: relative; width: 100%; max-width: 560px; aspect-ratio: 16 / 9; margin-top: 8px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #0f1a1c; }
.a18-prev iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.a18-slide > .a18-btns { flex: 0 1 auto; justify-content: flex-end; }
.a18-slide > div:not(.a18-main):not(.a18-btns) { flex: 1 1 100%; }
.a18-words { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.a18-wf label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.a18-wf input, .a18-wf textarea { width: 100%; }
.a18-wnote { font-size: 12px; margin-top: 2px; }
.a18-steps { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.a18-file { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
.a18-draftfile { margin-top: 6px; }
.a18-ver { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.a18-dbox { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.a18-dbox h3 { margin: 0 0 4px; }
.a18-dslide { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.a18-dhead { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.a18-dpic { display: flex; gap: 10px; align-items: center; }
.a18-dpic img { height: 70px; border-radius: 6px; }
.a18-saved { display: inline-block; margin-top: 8px; }

/* ---------- WP-A20: Investor chat ---------- */
.a20-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.a20-checks li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--line); }
.a20-checks li:first-child { border-top: 0; }
.a20-mark { width: 22px; height: 22px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.a20-checks li.ok .a20-mark { color: var(--good); border-color: var(--good); }
.a20-why { margin: 6px 0 0; }
.a20-dl { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 4px 12px; margin: 0 0 8px; }
.a20-dl dt { color: var(--muted); }
.a20-dl dd { margin: 0; }
.a20-rm { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
@media (max-width: 600px) { .a20-dl { grid-template-columns: 1fr; } }
/* figure versions */
.ws-fg-dl { min-height: 0; padding: 1px 9px; font-size: 12px; }
.ws-fg-bi .ws-fg-add { margin-top: 0; }
.ws-fv { display: flex; flex-direction: column; gap: 6px; }
.ws-fv-rows { display: flex; flex-direction: column; gap: 4px; }
.ws-fv-row { display: flex; align-items: flex-start; gap: 8px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); flex-wrap: wrap; }
.ws-fv-row.cur { border-color: var(--accent); }
.ws-fv-main { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.ws-fv-main input { width: 100%; }
.ws-fv-t { font-size: 13.5px; font-weight: 500; }
.ws-fv-act { flex-wrap: wrap; }
.ws-fv-act button { min-height: 0; padding: 1px 7px; font-size: 12px; }
.ws-fv-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ws-fv-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ws-fv-img { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); min-height: 160px; overflow: hidden; }
.ws-fv-img img { max-width: 100%; max-height: 60vh; object-fit: contain; display: block; }
@media (max-width: 640px) { .ws-fv-cmp { grid-template-columns: 1fr; } }
