/* CharVault UI. No external fonts/CDNs. Dark theme is the default. */
:root {
  --bg: #f5f5f3; --surface: #ffffff; --surface-2: #f1f0ec; --surface-3: #e8e6e0; --border: #e3e1db; --border-strong: #cfccc4;
  --text: #1c1b19; --muted: #6f6c65; --faint: #9a978f;
  --accent: #5865f2; --accent-ink: #ffffff; --accent-soft: rgba(88,101,242,.12);
  --danger: #d14343; --danger-soft: rgba(209,67,67,.12); --ok: #2f9e5f; --ok-soft: rgba(47,158,95,.13);
  --warn: #c27c0e; --warn-soft: rgba(194,124,14,.14); --note: #8b5cf6; --note-soft: rgba(139,92,246,.13);
  --info: #0ea5e9; --info-soft: rgba(14,165,233,.13);
  --shadow: 0 1px 2px rgba(0,0,0,.05); --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --r: 10px; --r-lg: 14px; --h: 34px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f1013; --surface: #17181c; --surface-2: #1e2025; --surface-3: #272a30; --border: #2a2d33; --border-strong: #3a3e46;
  --text: #ecebe8; --muted: #9b9a95; --faint: #6c6b67;
  --accent: #8b95ff; --accent-ink: #0e1020; --accent-soft: rgba(139,149,255,.15);
  --danger: #ff7a7a; --danger-soft: rgba(255,122,122,.13); --ok: #5fd394; --ok-soft: rgba(95,211,148,.13);
  --warn: #f2b45a; --warn-soft: rgba(242,180,90,.13); --note: #b8a3ff; --note-soft: rgba(184,163,255,.14);
  --info: #5cc8f5; --info-soft: rgba(92,200,245,.13);
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 34px rgba(0,0,0,.5);
  color-scheme: dark;
}
[data-theme="dark"] .i-moon, [data-theme="light"] .i-sun { display: none; }

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; letter-spacing: -.005em; }
h3 { font-size: .98rem; margin: 0 0 .4rem; }
h2.inline { display: inline; margin: 0; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: .75rem .9rem; border-radius: var(--r); font: 13px/1.55 var(--mono); margin: .5rem 0; border: 1px solid var(--border); }
img { max-width: 100%; }
.mono { font-family: var(--mono); }
.pre { white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small, small { font-size: .84rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mt { margin-top: .9rem; }
.mb { margin-bottom: .9rem; }
.warn-text { color: var(--warn); }
.link-sm { font-size: .85rem; font-weight: 500; white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 1500px; margin: 0 auto; display: flex; align-items: center; gap: .75rem; padding: .55rem 1.25rem; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; color: var(--text); white-space: nowrap; font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 1.35rem; }
.brand-mark { color: var(--accent); }
.mainnav { display: flex; gap: .15rem; margin-left: .5rem; }
.mainnav a { padding: .42rem .7rem; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: .92rem; white-space: nowrap; }
.mainnav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.mainnav a.on { color: var(--text); background: var(--surface-3); }
.global-search { margin-left: auto; position: relative; flex: 0 1 240px; display: flex; align-items: center; }
.global-search svg { position: absolute; left: .65rem; color: var(--faint); pointer-events: none; }
.global-search input { width: 100%; padding-left: 2rem; height: 36px; background: var(--surface-2); border-color: transparent; }
.global-search input:focus { background: var(--surface); }
.topbar-actions { display: flex; gap: .15rem; align-items: center; }
.topbar-actions form { margin: 0; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 0; color: var(--muted); width: 36px; height: 36px; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-toggle { display: none; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.25rem 1.25rem 2rem; flex: 1; }
.container.wide { max-width: 1500px; }
.footer { text-align: center; color: var(--faint); font-size: .78rem; padding: 1.25rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head .sub { color: var(--muted); margin: .3rem 0 0; max-width: 72ch; font-size: .92rem; }
.page-head .actions, .actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.count { color: var(--faint); font-weight: 500; font-size: .85em; margin-left: .15rem; }
.cols { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
.cols.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.cols > * { min-width: 0; }
.grid { display: grid; gap: 1rem; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.grid.gallery.small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack > .card { margin-bottom: 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.space { justify-content: space-between; }
.row.end { justify-content: flex-end; margin-top: .5rem; }
form.inline { display: inline-flex; margin: 0; }

/* character layout */
.char-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.char-side { position: sticky; top: 72px; display: flex; flex-direction: column; gap: .8rem; max-height: calc(100vh - 88px); overflow-y: auto; padding-bottom: .5rem; scrollbar-width: thin; }
.char-id { display: flex; gap: .7rem; align-items: center; }
.char-avatar { flex: 0 0 52px; height: 52px; border-radius: 12px; overflow: hidden; background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; font-size: 1.3rem; }
.char-avatar img { width: 100%; height: 100%; object-fit: cover; }
.char-avatar:hover { text-decoration: none; }
.char-id-text { min-width: 0; }
.char-name { display: block; color: var(--text); font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.char-meta { margin-top: .25rem; display: flex; gap: .3rem; flex-wrap: wrap; }
.side-nav { display: flex; flex-direction: column; gap: .9rem; }
.side-group { display: flex; flex-direction: column; gap: 1px; }
.side-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; padding: 0 .65rem .3rem; }
.side-nav a { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .42rem .65rem; border-radius: 8px; color: var(--muted); font-size: .92rem; font-weight: 500; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-nav a.on { background: var(--accent-soft); color: var(--accent); }
.side-nav .n { font-size: .75rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.side-nav a.on .n { color: var(--accent); }
.side-nav .n.warn { color: var(--warn); font-weight: 700; }
.char-main { min-width: 0; }

/* ---------- forms ---------- */
input, select, textarea { font: inherit; font-size: .9rem; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: .35rem .6rem; max-width: 100%; min-height: var(--h); transition: border-color .12s, box-shadow .12s; }
textarea { width: 100%; resize: vertical; line-height: 1.5; min-height: 0; }
select { appearance: none; -webkit-appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; min-height: 0; margin: 0; flex: 0 0 auto; cursor: pointer; }
input[type=file] { min-height: 0; padding: .4rem; }
input[type=date], input[type=time] { min-width: 0; }
input.num { width: 4.5rem; }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea { width: 100%; }
.field.checkbox { flex-direction: row; align-items: center; gap: .55rem; }
.label { font-weight: 600; font-size: .8rem; color: var(--text); }
.hint { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.req { color: var(--danger); font-style: normal; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem .9rem; }
.form-grid.compact { gap: .7rem .8rem; }
.form-grid > h2 { margin: 0; }
.span-all { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: .7rem 0; background: var(--bg); border-top: 1px solid var(--border); }
fieldset { border: 1px solid var(--border); border-radius: var(--r); padding: .8rem 1rem 1rem; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: .84rem; padding: 0 .35rem; }
.checks { display: flex; flex-wrap: wrap; gap: .45rem 1.1rem; }
.checks label { display: inline-flex; gap: .45rem; align-items: center; font-size: .9rem; cursor: pointer; }
.title-input { font-size: 1.15rem; font-weight: 600; min-width: 0; width: min(520px, 100%); }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters .grow { flex: 1 1 220px; }
.filters select { min-width: 150px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; height: var(--h); padding: 0 .95rem; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, filter .12s; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.small { height: 32px; padding: 0 .7rem; font-size: .84rem; }
.btn.xs { height: 26px; padding: 0 .5rem; font-size: .78rem; }
.btn.icon { width: var(--h); padding: 0; font-size: 1.2rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; margin-bottom: .8rem; }
.card-head h2 { margin: 0; }
.card-head .hint { margin: .25rem 0 0; }
details.card > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "›"; color: var(--muted); font-size: 1.2rem; transition: transform .15s; display: inline-block; width: 1rem; }
details.card[open] > summary { margin-bottom: .9rem; }
details.card[open] > summary::before { transform: rotate(90deg); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }

.char-card, .item-card { padding: 0; overflow: hidden; color: var(--text); display: flex; flex-direction: column; transition: border-color .15s, transform .15s, box-shadow .15s; margin: 0; }
.char-card:hover, .item-card:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.char-card .thumb, .item-card .thumb { aspect-ratio: 4 / 3; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.char-card .thumb img, .item-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.ph { font-size: 2.2rem; color: var(--faint); font-weight: 700; text-transform: uppercase; }
.char-card .body, .item-card .body { padding: .85rem 1rem 1rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.char-card h3, .item-card h3 { margin: 0; font-size: 1rem; line-height: 1.3; }
.char-card .meta { display: flex; gap: .3rem; flex-wrap: wrap; }
.char-card .foot { margin-top: auto; padding-top: .2rem; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: 0; color: var(--muted); font-size: .88rem; }
.clamp-cell { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* looks */
.look-cover { position: relative; aspect-ratio: 4 / 3; background: linear-gradient(135deg, var(--surface-2), var(--surface-3)); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.look-main { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.look-strip { position: absolute; left: .6rem; bottom: .6rem; display: flex; gap: .3rem; z-index: 1; }
.piece-dot { width: 38px; height: 38px; border-radius: 9px; overflow: hidden; background: var(--surface); border: 2px solid var(--surface); display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; color: var(--muted); box-shadow: var(--shadow); }
.piece-dot img { width: 100%; height: 100%; object-fit: cover; }
.piece-dot.more { font-size: .72rem; }
.piece-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; }
.piece-opt { position: relative; display: flex; flex-direction: column; gap: .15rem; padding: .4rem; border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; background: var(--surface); transition: border-color .12s, background .12s; }
.piece-opt:hover { border-color: var(--border-strong); }
.piece-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.piece-opt input { position: absolute; top: .65rem; left: .65rem; z-index: 1; }
.piece-img { aspect-ratio: 4 / 3; border-radius: 7px; overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--faint); font-weight: 700; font-size: 1.3rem; }
.piece-img img { width: 100%; height: 100%; object-fit: cover; }
.piece-name { font-size: .84rem; font-weight: 600; line-height: 1.25; margin-top: .2rem; overflow-wrap: anywhere; }
.piece-cat { font-size: .74rem; color: var(--muted); }

/* ---------- badges, tags, chips, segmented ---------- */
.badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; font-weight: 600; padding: .14rem .5rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); vertical-align: middle; white-space: nowrap; line-height: 1.4; }
.badge.st-active, .badge.state-confirmed { background: var(--ok-soft); color: var(--ok); }
.badge.st-draft { background: var(--warn-soft); color: var(--warn); }
.badge.st-archived { background: var(--surface-3); color: var(--muted); }
.badge.state-superseded { background: var(--surface-3); color: var(--faint); text-decoration: line-through; }
.badge.state-note { background: var(--note-soft); color: var(--note); }
.badge.warn, .badge.demo { background: var(--warn-soft); color: var(--warn); }
.badge.use-auto { background: var(--accent-soft); color: var(--accent); }
.badge.use-constraint { background: var(--danger-soft); color: var(--danger); }
.badge.act-delete { background: var(--danger-soft); color: var(--danger); }
.badge.act-restore { background: var(--note-soft); color: var(--note); }
.badge.act-create { background: var(--ok-soft); color: var(--ok); }
.cs-idea { --c: var(--muted); --cs: var(--surface-3); }
.cs-planned { --c: var(--info); --cs: var(--info-soft); }
.cs-in_progress { --c: var(--warn); --cs: var(--warn-soft); }
.cs-ready { --c: var(--note); --cs: var(--note-soft); }
.cs-published { --c: var(--ok); --cs: var(--ok-soft); }
.cs-cancelled { --c: var(--faint); --cs: var(--surface-2); }
.badge[class*="cs-"] { background: var(--cs); color: var(--c); }
.tags { display: flex; flex-wrap: wrap; gap: .25rem; }
.tag { display: inline-block; font-size: .72rem; padding: .08rem .45rem; border-radius: 6px; background: var(--surface-3); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: 0 0 1rem; }
.chip { display: inline-flex; align-items: center; height: 30px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 0 .8rem; font-size: .84rem; font-weight: 500; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 1rem; }
.seg a { padding: .35rem .85rem; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: .88rem; white-space: nowrap; }
.seg a:hover { color: var(--text); text-decoration: none; }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg .n { color: var(--faint); font-weight: 500; margin-left: .2rem; }
.seg.small { margin: 0; }
.legend { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .35rem .5rem; align-items: center; margin-bottom: 1rem; }

/* ---------- notices & toasts ---------- */
.notice { padding: .7rem .95rem; border-radius: var(--r); background: var(--accent-soft); margin-bottom: 1rem; font-size: .9rem; }
.notice.warn { background: var(--warn-soft); color: var(--text); }
.notice.danger { background: var(--danger-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.notice pre { margin: .5rem 0 0; }
.block-link { display: block; color: var(--warn); font-weight: 600; margin: 0; }
.block-link:hover { text-decoration: none; filter: brightness(1.1); }
.demo-banner { background: var(--warn-soft); color: var(--warn); border-radius: var(--r); padding: .55rem .9rem; margin-bottom: 1rem; font-weight: 600; font-size: .86rem; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast { display: flex; gap: .75rem; align-items: flex-start; justify-content: space-between; padding: .7rem .9rem; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-left: 4px solid var(--accent); font-size: .9rem; animation: toast-in .2s ease-out; }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.15rem; line-height: 1; padding: 0 .1rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- breadcrumbs ---------- */
.crumbs { font-size: .8rem; color: var(--faint); margin-bottom: .9rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.crumbs a { color: var(--muted); }
.crumbs .sep { opacity: .6; }
.crumbs [aria-current] { color: var(--muted); max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- key/value, lists ---------- */
.kv { display: grid; grid-template-columns: minmax(130px, 32%) 1fr; gap: .55rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; padding-top: .05rem; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.timeline li { padding: .4rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .6rem; flex-wrap: wrap; align-items: baseline; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--faint); font-size: .78rem; font-variant-numeric: tabular-nums; min-width: 105px; }
.primary-ref .ref-big { display: block; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--surface-2); }
.primary-ref .ref-big img { width: 100%; height: 100%; object-fit: cover; display: block; }
.primary-ref .ref-big.ph { display: flex; align-items: center; justify-content: center; color: var(--muted); border: 1px dashed var(--border-strong); font-weight: 600; aspect-ratio: 4 / 3; }

/* ---------- attributes ---------- */
.attr-group { padding-bottom: .4rem; }
.attr-group h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .2rem; }
.attr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.attr:last-child { border-bottom: 0; }
.attr.conflict { background: var(--warn-soft); margin: 0 -1.25rem; padding: .8rem 1.25rem; }
.attr.st-superseded .attr-val { color: var(--faint); text-decoration: line-through; }
.attr-main { min-width: 0; }
.attr-key { font-weight: 600; font-size: .9rem; }
.attr.st-note .attr-key::after { content: " · идея"; color: var(--note); font-weight: 500; font-size: .78rem; }
.attr-val { margin-top: .15rem; overflow-wrap: anywhere; }
.attr-meta { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; margin-top: .4rem; }
.attr-meta .src { font-size: .78rem; color: var(--faint); }
.attr-edit { grid-column: 2; grid-row: 1; align-self: start; }
.attr-edit[open] { grid-column: 1 / -1; grid-row: auto; background: var(--surface-2); padding: .9rem; border-radius: var(--r); border: 1px solid var(--border); }
.attr-edit summary { list-style: none; }
.attr-edit summary::-webkit-details-marker { display: none; }
.attr-edit[open] summary { display: none; }
.attr-edit .edit-foot { display: flex; justify-content: space-between; gap: .5rem; margin-top: .8rem; flex-wrap: wrap; }
details > summary { cursor: pointer; }
.choice { display: flex; gap: .65rem; align-items: flex-start; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; background: var(--surface); }
.choice:hover { border-color: var(--border-strong); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: .2rem; }
.choice small { display: block; margin-top: .15rem; }
.conflict-row { padding: .8rem 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: .5rem; }
.conflict-row:last-child { border-bottom: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th { color: var(--faint); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table tr.overdue td:first-child { color: var(--danger); }
.diff-table td { vertical-align: top; }
.diff-table td.del { background: var(--danger-soft); }
.diff-table td.add { background: var(--ok-soft); }
.diff-table pre { margin: 0; background: transparent; padding: 0; border: 0; }
pre.diff span { display: block; }
pre.diff .add { background: var(--ok-soft); }
pre.diff .del { background: var(--danger-soft); }
.status-select { min-height: 30px; height: 30px; padding: 0 1.8rem 0 .6rem; font-size: .8rem; font-weight: 600; border-radius: 999px; background-color: var(--cs); color: var(--c); border-color: transparent; }

/* ---------- gallery ---------- */
.gitem { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; transition: border-color .12s; }
.gitem:hover { border-color: var(--border-strong); }
.gitem > a { display: block; }
.gitem img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--surface-2); }
.gitem figcaption { padding: .5rem .6rem .6rem; display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; min-width: 0; }
.gitem figcaption strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.gitem.is-primary { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.media-view { padding: .75rem; }
.media-view img { width: 100%; max-height: 70vh; object-fit: contain; background: var(--surface-2); border-radius: var(--r); display: block; margin-bottom: .9rem; }
.upload-card > summary h2 { font-size: 1rem; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--r); padding: 1.1rem; text-align: left; transition: border-color .12s, background .12s; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.upload-preview { display: flex; flex-wrap: wrap; gap: .5rem; }
.upload-preview:empty { display: none; }
.upload-preview figure { margin: 0; width: 84px; font-size: .7rem; color: var(--muted); }
.upload-preview figcaption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-preview img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; display: block; }
.upload-preview .bad { color: var(--danger); white-space: normal; }
.ref-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.ref-opt { position: relative; display: flex; flex-direction: column; gap: .15rem; font-size: .74rem; cursor: pointer; border: 2px solid transparent; border-radius: 10px; padding: 3px; min-width: 0; }
.ref-opt img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 7px; display: block; }
.ref-opt input { position: absolute; top: 8px; left: 8px; }
.ref-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ref-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.ref-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.ref-actions select { max-width: 280px; }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 2.75rem 1rem; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface) 50%, transparent); }
.empty-icon { font-size: 2rem; color: var(--accent); opacity: .7; line-height: 1; margin-bottom: .6rem; }
.empty h3 { color: var(--text); font-size: 1.05rem; margin-bottom: .35rem; }
.empty p { max-width: 46ch; margin: 0 auto .9rem; font-size: .9rem; }
.empty.small-empty { padding: 1.5rem 1rem; }

/* ---------- login ---------- */
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 380px; padding: 2rem; }
.login-card .muted { margin: .4rem 0 1.4rem; }
.login-theme { margin-top: 1rem; text-align: center; }

/* ---------- content plan ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.month-nav { display: flex; align-items: center; gap: .4rem; }
.month-title { min-width: 150px; text-align: center; font-size: 1.05rem; }
.inline-filters { margin: 0; }
.status-legend { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.calendar { margin-bottom: 1rem; }
.cal-head, .cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: .5rem .6rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-day { min-height: 112px; padding: .4rem .45rem .5rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.cal-week .cal-day:last-child { border-right: 0; }
.cal-week:last-child .cal-day { border-bottom: 0; }
.cal-day.weekend { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.cal-day.other { background: var(--bg); }
.cal-day.other .cal-dnum span { color: var(--faint); }
.cal-dnum { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; font-weight: 600; color: var(--muted); }
.cal-dnum span { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal-day.today .cal-dnum span { background: var(--accent); color: var(--accent-ink); }
.cal-add { opacity: 0; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--muted); font-weight: 700; }
.cal-day:hover .cal-add, .cal-add:focus { opacity: 1; }
.cal-add:hover { background: var(--surface-3); text-decoration: none; }
.plan-chip { display: flex; flex-direction: column; gap: 0; padding: .28rem .45rem; border-radius: 6px; background: var(--cs); border-left: 3px solid var(--c); color: var(--text); font-size: .76rem; line-height: 1.3; min-width: 0; }
.plan-chip:hover { text-decoration: none; filter: brightness(1.12); }
.plan-chip .tt { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-chip .tm, .plan-chip .who { color: var(--muted); font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idea-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.idea-list .plan-chip { padding: .5rem .65rem; font-size: .84rem; }
.plan-list { list-style: none; padding: 0; margin: 0; }
.plan-list li a { display: grid; grid-template-columns: 82px minmax(0, 1fr) auto; gap: .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--border); color: var(--text); font-size: .88rem; }
.plan-list li:last-child a { border-bottom: 0; }
.plan-list li a:hover { text-decoration: none; color: var(--accent); }
.plan-date { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.plan-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.upcoming .upcoming-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: .6rem; overflow-x: auto; padding-bottom: .2rem; scrollbar-width: thin; }
.up-item { display: flex; flex-direction: column; gap: .2rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: var(--r); color: var(--text); background: var(--surface-2); min-width: 0; }
.up-item:hover { text-decoration: none; border-color: var(--border-strong); }
.up-item.overdue .plan-date { color: var(--danger); }
.up-item .badge { align-self: flex-start; margin-top: .2rem; }

/* ---------- builder ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 1.25rem; align-items: start; }
.builder-form { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.builder-form > .card { margin: 0; }
.builder-form fieldset.card { display: flex; flex-direction: column; gap: .85rem; padding: 1.1rem 1.2rem 1.2rem; }
.builder-form legend { font-size: .95rem; padding: 0; float: left; width: 100%; margin-bottom: .2rem; }
.builder-form legend + * { clear: both; }
.builder-out { min-width: 0; }
.builder-out .sticky { position: sticky; top: 72px; margin: 0; }
.prompt-out { min-height: 240px; height: 42vh; font: 13px/1.6 var(--mono); }
.warnings { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .6rem; }
.warnings:empty { display: none; }
.warnings div { font-size: .82rem; background: var(--warn-soft); color: var(--warn); padding: .45rem .7rem; border-radius: 8px; }
.refs-strip { display: flex; gap: .45rem; flex-wrap: wrap; margin-bottom: .6rem; }
.refs-strip:empty { display: none; }
.refs-strip figure { margin: 0; width: 64px; font-size: .66rem; color: var(--muted); text-align: center; }
.refs-strip figcaption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.refs-strip img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; display: block; margin-bottom: .15rem; }
.out-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }
.attr-pick + .attr-pick { margin-top: .4rem; padding-top: .6rem; border-top: 1px solid var(--border); }
.attr-pick h4 { margin: 0 0 .35rem; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.attr-pick label { display: flex; gap: .55rem; align-items: flex-start; font-size: .87rem; padding: .25rem 0; cursor: pointer; }
.attr-pick label input { margin-top: .2rem; }
.attr-pick label .k { font-weight: 600; }
.attr-pick .tagline { font-size: .68rem; margin-left: .35rem; }
.block-list { margin-top: .7rem; font-size: .86rem; }
.block-list ol { padding-left: 1.3rem; margin: .5rem 0 0; color: var(--text); }
.block-list li { padding: .1rem 0; }
.block-list li.off { color: var(--faint); text-decoration: line-through; }
.block-list li.empty-block { color: var(--faint); }
.char-info { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; font-size: .84rem; }
.char-info:empty { display: none; }
.save-box { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .75rem; }
.prompt-text { max-height: 420px; overflow: auto; }
.version .card-head { flex-wrap: wrap; }
details.field > summary { padding: .2rem 0; }
details.field[open] > summary { margin-bottom: .4rem; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .mainnav a { padding: .42rem .5rem; font-size: .88rem; }
  .global-search { flex-basis: 170px; }
}
@media (max-width: 1020px) {
  .builder, .cols, .cols.two { grid-template-columns: minmax(0, 1fr); }
  .builder-out .sticky { position: static; max-height: none; }
  .builder-out { order: -1; }
  .nav-toggle { display: inline-flex; }
  .mainnav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; gap: 0; margin: 0; padding: .5rem; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); }
  .mainnav.open { display: flex; }
  .mainnav a { padding: .7rem .9rem; font-size: 1rem; }
  .topbar-in { position: relative; }
}
@media (max-width: 860px) {
  .char-layout { grid-template-columns: minmax(0, 1fr); gap: .8rem; }
  .char-side { position: static; max-height: none; overflow: visible; gap: .6rem; }
  .side-cta { display: none; }
  .side-nav { flex-direction: row; gap: .3rem; overflow-x: auto; margin: 0 -.9rem; padding: 0 .9rem .4rem; scrollbar-width: none; }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-group { flex-direction: row; gap: .3rem; }
  .side-title { display: none; }
  .side-nav a { white-space: nowrap; border: 1px solid var(--border); border-radius: 999px; padding: .3rem .75rem; font-size: .85rem; }
  .side-nav a.on { border-color: var(--accent); }
  .cal-day { min-height: 76px; padding: .3rem; }
  .plan-chip .who, .plan-chip .tm { display: none; }
}
@media (max-width: 640px) {
  .topbar-in { padding: .5rem .75rem; gap: .4rem; }
  .global-search { flex: 1 1 auto; }
  .brand span:last-child { display: none; }
  .container { padding: .9rem .9rem 1.5rem; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  .kv dd { margin-bottom: .6rem; }
  h1 { font-size: 1.3rem; }
  .card { padding: 1rem; }
  .attr.conflict { margin: 0 -1rem; padding: .8rem 1rem; }
  .grid.cards { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .7rem; }
  .char-card .body, .item-card .body { padding: .7rem .75rem .8rem; }
  .page-head .actions, .page-head > .btn { width: 100%; }
  .page-head > .btn { justify-content: center; }
  .filters select, .filters input { flex: 1 1 140px; min-width: 0; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .month-nav { justify-content: space-between; }
  .cal-head div { padding: .4rem .2rem; text-align: center; }
  .cal-day { min-height: 58px; padding: .2rem; }
  .cal-dnum { justify-content: center; }
  .cal-add { display: none; }
  .cal-day .plan-chip { padding: 0; height: 6px; border-left: 0; background: var(--c); border-radius: 3px; pointer-events: none; }
  .cal-day .plan-chip .tt { display: none; }
  .agenda { display: block; }
  .timeline time { min-width: 0; width: 100%; }
  .table th, .table td { padding: .55rem .6rem; }
}
.attr-edit > form + form { display: flex; justify-content: flex-end; margin-top: -2.4rem; }
.attr-edit > form:first-of-type .form-actions { min-height: var(--h); }

/* templates list */
.tpl-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tpl-card { display: flex; flex-direction: column; gap: .5rem; margin: 0; }
.tpl-top { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.tpl-top h3 { margin: 0; }
.tpl-top h3 a { color: var(--text); }
.tpl-card p { margin: 0; }
.tpl-meta { display: flex; flex-wrap: wrap; gap: .3rem; }
.tpl-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; padding-top: .5rem; }
@media (max-width: 640px) { .tpl-grid { grid-template-columns: minmax(0, 1fr); } }

/* mobile agenda under the calendar */
.agenda { display: none; margin-bottom: 1rem; }
.agenda h2 { margin-bottom: .4rem; }
.char-card .thumb.mini, .item-card .thumb.mini { aspect-ratio: auto; height: 64px; justify-content: flex-start; gap: .7rem; padding: 0 1rem; border-bottom: 1px solid var(--border); }
.thumb.mini .ph { font-size: 1.2rem; width: 36px; height: 36px; border-radius: 9px; background: var(--surface-3); display: inline-flex; align-items: center; justify-content: center; }
.legend-box { margin: -.4rem 0 1rem; font-size: .84rem; color: var(--muted); }
.legend-box summary { display: inline-block; color: var(--muted); }
.legend-box summary:hover { color: var(--text); }
.legend-box ul { list-style: none; padding: .7rem .9rem; margin: .5rem 0 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); display: grid; gap: .4rem; }
.link-list { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r); padding: .35rem; }
.link-list label { display: flex; gap: .55rem; align-items: center; padding: .35rem .45rem; border-radius: 6px; font-size: .88rem; cursor: pointer; }
.link-list label:hover { background: var(--surface-2); }
.link-list .muted { font-size: .76rem; min-width: 64px; }
.media-view .kv { margin-bottom: .8rem; }
input[type=file] { border-style: dashed; color: var(--muted); font-size: .86rem; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; font-size: .84rem; color: var(--text); background: var(--surface-3); border: 0; border-radius: 6px; padding: .35rem .75rem; margin-right: .7rem; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--border-strong); }
.table + .row, .table-wrap + details, .card > details { margin-top: .8rem; }
.card > form + .table-wrap { margin-top: .9rem; }
.card.char-card, .card.item-card { padding: 0; }

/* ======================= Telegram ======================= */
.pill { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .72rem; font-weight: 700; }
.badge.tgs-draft { background: var(--surface-3); color: var(--muted); }
.badge.tgs-publishing { background: var(--info-soft); color: var(--info); }
.badge.tgs-published { background: var(--ok-soft); color: var(--ok); }
.badge.tgs-failed { background: var(--danger-soft); color: var(--danger); }
.badge.tgs-scheduled { background: var(--note-soft); color: var(--note); }
.tg-list { display: flex; flex-direction: column; gap: .5rem; }
.tg-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto auto; gap: 1rem; align-items: center; padding: .8rem 1rem; margin: 0; color: var(--text); }
.tg-row:hover { border-color: var(--border-strong); }
.tg-row-main { color: var(--text); }
.tg-row-main:hover { text-decoration: none; }
.tg-row-main:hover .tg-row-title { color: var(--accent); }
.tg-row-end { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.mt-xs { margin-top: .3rem; }
.bot-state { display: flex; gap: .7rem; align-items: center; }
.discover { margin-top: .9rem; padding: .7rem; border: 1px dashed var(--accent); border-radius: var(--r); display: flex; flex-direction: column; gap: .5rem; }
.inline-details { display: inline-block; }
.inline-details summary { color: var(--muted); }
.tg-row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-row-main { min-width: 0; }
.tg-row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; white-space: nowrap; }
.tg-kind { display: inline-flex; justify-content: center; font-size: .72rem; font-weight: 600; padding: .2rem .5rem; border-radius: 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tg-kind.k-poll { background: var(--note-soft); color: var(--note); }
.tg-kind.k-repost { background: var(--info-soft); color: var(--info); }
.tg-kind.k-album, .tg-kind.k-photo, .tg-kind.k-video, .tg-kind.k-animation, .tg-kind.k-video_note { background: var(--ok-soft); color: var(--ok); }
.grow-input { flex: 1 1 260px; min-width: 0; }
.howto { padding-left: 1.2rem; margin: .6rem 0; display: grid; gap: .35rem; font-size: .9rem; }
.tg-channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.tg-ch { margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.tg-ch-head { display: flex; gap: .7rem; align-items: center; }
.tg-ch h3 { margin: 0; }
.tg-ch p { margin: 0; }
.tg-rights { display: flex; flex-wrap: wrap; gap: .3rem; }
.tg-inbox { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.tg-in { margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.tg-in-head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.tg-in-media { display: flex; gap: .3rem; flex-wrap: wrap; }
.tg-in-media:empty { display: none; }
.tg-in-media img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.tg-in-text { max-height: 140px; overflow: hidden; font-size: .88rem; }

/* editor */
.title-input.plain { border-color: transparent; background: transparent; padding-left: 0; font-size: 1.45rem; font-weight: 700; min-height: 0; height: auto; width: min(640px, 100%); }
.title-input.plain:hover { border-color: var(--border); padding-left: .5rem; }
.title-input.plain:focus { background: var(--surface); padding-left: .5rem; }
.tg-editor { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 1.25rem; align-items: start; }
.tg-form { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.tg-form > .card { margin: 0; }
.tg-form .card.dimmed { opacity: .55; }
.tg-side { min-width: 0; }
.sticky-side { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 1rem; }
.sticky-side > .card { margin: 0; }
.kind-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .4rem; }
.kind-opt { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .55rem .3rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--muted); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.kind-opt .ki { font-size: 1.15rem; line-height: 1.2; color: var(--text); }
.kind-opt:hover { border-color: var(--border-strong); color: var(--text); }
.kind-opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.kind-picker + .hint { margin: .7rem 0 0; }
.fmt-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--border-strong); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface-2); }
.fmt-bar button { min-width: 32px; height: 30px; border: 0; background: transparent; color: var(--text); border-radius: 6px; cursor: pointer; font: inherit; font-size: .9rem; }
.fmt-bar button:hover { background: var(--surface-3); }
.fmt-bar .sep { flex: 1; }
.tg-text { border-radius: 0 0 8px 8px; font: 14px/1.55 var(--mono); }
.counter { font-size: .78rem; color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); font-weight: 700; }
.ai-row { margin-top: .4rem; }
.ai-box { margin-top: .6rem; padding: .8rem; border: 1px dashed var(--accent); border-radius: var(--r); display: flex; flex-direction: column; gap: .5rem; }
.media-list { display: flex; flex-direction: column; gap: .5rem; }
.media-empty { padding: .9rem; border: 1px dashed var(--border-strong); border-radius: var(--r); text-align: center; }
.media-item { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: .75rem; align-items: center; padding: .5rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.mi-thumb { width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-size: .7rem; color: var(--muted); text-align: center; }
.mi-thumb img, .mi-thumb video { width: 100%; height: 100%; object-fit: cover; }
.mi-body { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.mi-head { display: flex; flex-direction: column; min-width: 0; }
.mi-name { font-weight: 600; font-size: .9rem; }
.mi-body input:not([type=checkbox]) { min-height: 32px; padding: .3rem .55rem; font-size: .85rem; }
.mi-spoiler { display: inline-flex; gap: .4rem; align-items: center; cursor: pointer; }
.mi-acts { display: flex; flex-direction: column; gap: 2px; }
.media-add { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .8rem; }
.upload-progress { margin-top: .5rem; font-size: .85rem; color: var(--info); }
.library-picker { margin-top: .9rem; padding: .8rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); display: flex; flex-direction: column; gap: .7rem; }
.library-picker .ref-opt { background: transparent; border: 2px solid transparent; color: var(--text); font: inherit; text-align: left; }
.library-picker .ref-opt:hover { border-color: var(--accent); }
.poll-opts { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.poll-opt { display: flex; gap: .5rem; align-items: center; }
.poll-opt input:not([type=checkbox]):not([type=radio]) { flex: 1; }
.tg-form .checks { margin: .6rem 0; }
.btn-rows { display: flex; flex-direction: column; gap: .7rem; margin-bottom: .6rem; }
.btn-row { border: 1px solid var(--border); border-radius: var(--r); padding: .55rem; display: flex; flex-direction: column; gap: .4rem; background: var(--surface-2); }
.btn-row-head { display: flex; justify-content: space-between; align-items: center; }
.btn-edit { display: grid; grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: .4rem; align-items: center; }
.btn-edit input, .btn-edit select { min-height: 34px; padding-top: .25rem; padding-bottom: .25rem; font-size: .86rem; }
.opt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1rem; margin-bottom: .8rem; }
.opt-grid label { display: flex; gap: .5rem; align-items: center; font-size: .9rem; cursor: pointer; }
.radio-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: .7rem 0; }
.tg-check { display: flex; flex-direction: column; gap: .7rem; }
.tg-issues { display: flex; flex-direction: column; gap: .35rem; }
.issue { font-size: .84rem; padding: .45rem .65rem; border-radius: 8px; line-height: 1.4; }
.issue.err { background: var(--danger-soft); color: var(--danger); }
.issue.warn { background: var(--warn-soft); color: var(--warn); }
.issue.ok { background: var(--ok-soft); color: var(--ok); }
.tg-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: .5rem; }
.tg-published { display: flex; flex-direction: column; gap: .5rem; }
.tg-published:empty { display: none; }
.tg-pub-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.tg-log .timeline li { font-size: .82rem; }
.ev-error span { color: var(--danger); }
.ev-success span { color: var(--ok); }

/* Telegram-like preview */
.phone { border-radius: 22px; padding: 10px; background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); }
.tgp { border-radius: 14px; overflow: hidden; background: #8fb58a linear-gradient(160deg, #a7c79a, #6f9b72); font-family: var(--font); }
[data-theme="dark"] .tgp { background: #0e1621 linear-gradient(160deg, #18263a, #0e1621); }
.tgp-head { display: flex; gap: .6rem; align-items: center; padding: .55rem .8rem; background: rgba(255,255,255,.92); color: #000; }
[data-theme="dark"] .tgp-head { background: #17212b; color: #fff; }
.tgp-ava, .tg-ch .tgp-ava { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #5b8def, #7b5cf0); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.tgp-name { font-weight: 600; font-size: .92rem; line-height: 1.2; }
.tgp-sub { font-size: .74rem; opacity: .6; }
.tgp-feed { padding: .9rem .7rem 1rem; display: flex; flex-direction: column; gap: .35rem; min-height: 240px; justify-content: flex-end; }
.tgp-msg { max-width: 92%; background: #fff; color: #000; border-radius: 12px 12px 12px 4px; overflow: hidden; box-shadow: 0 1px 1px rgba(0,0,0,.15); font-size: .9rem; line-height: 1.38; }
[data-theme="dark"] .tgp-msg { background: #182533; color: #f5f5f5; }
.tgp-text { padding: .45rem .7rem .1rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.tgp-text.above { padding-bottom: .4rem; }
.tgp-text.muted { opacity: .5; }
.tgp-text a { color: #2481cc; }
[data-theme="dark"] .tgp-text a { color: #6ab3f3; }
.tgp-text blockquote { margin: .2rem 0; padding: .15rem .55rem; border-left: 3px solid #2481cc; background: rgba(36,129,204,.08); border-radius: 4px; }
.tgp-text pre, .tgp-text code { font-family: var(--mono); font-size: .82rem; background: rgba(0,0,0,.06); border-radius: 4px; padding: 0 .2rem; border: 0; margin: 0; }
.tgp-text pre { display: block; padding: .4rem .5rem; }
.tgp-text tg-spoiler { background: #9aa2ab; color: transparent; border-radius: 3px; }
.tgp-meta { text-align: right; font-size: .7rem; opacity: .5; padding: .05rem .6rem .35rem; }
.tgp-grid { display: grid; gap: 2px; grid-template-columns: 1fr 1fr; }
.tgp-grid.n1 { grid-template-columns: 1fr; }
.tgp-grid.n3 > :first-child { grid-column: 1 / -1; }
.tgp-grid.nx { grid-template-columns: repeat(3, 1fr); }
.tgp-cell { position: relative; aspect-ratio: 1; background: #d9dee3; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.tgp-grid.n1 .tgp-cell { aspect-ratio: auto; max-height: 420px; }
.tgp-cell img, .tgp-cell video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tgp-grid.n1 .tgp-cell img, .tgp-grid.n1 .tgp-cell video { height: auto; max-height: 420px; object-fit: contain; }
.tgp-cell.spoiler img, .tgp-cell.spoiler video { filter: blur(18px) brightness(.8); }
.tgp-ph { font-size: .8rem; color: #555; padding: 2rem 1rem; }
.tgp-ph.small { padding: .3rem .5rem; border-radius: 8px; background: var(--surface-3); color: var(--muted); font-size: .72rem; }
.tgp-badge { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: .68rem; padding: .05rem .4rem; border-radius: 8px; }
.tgp-file { display: flex; gap: .6rem; align-items: center; padding: .55rem .7rem 0; }
.tgp-file-ic { width: 42px; height: 42px; border-radius: 50%; background: #3390ec; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.tgp-file-name { font-weight: 600; font-size: .86rem; }
.tgp-note { width: 210px; height: 210px; border-radius: 50%; overflow: hidden; background: #000; display: flex; align-items: center; justify-content: center; color: #fff; font-size: .8rem; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.tgp-note img, .tgp-note video { width: 100%; height: 100%; object-fit: cover; }
.tgp-link { margin: .3rem .7rem 0; padding: .3rem .55rem; border-left: 3px solid #2481cc; background: rgba(36,129,204,.08); border-radius: 4px; display: flex; flex-direction: column; font-size: .8rem; }
.tgp-link.large { min-height: 80px; }
.tgp-poll { padding: .55rem .75rem .1rem; min-width: 70%; }
.tgp-q { font-weight: 600; }
.tgp-pt { font-size: .74rem; opacity: .6; margin-bottom: .45rem; }
.tgp-opt { display: flex; gap: .5rem; align-items: center; padding: .28rem 0; font-size: .88rem; }
.tgp-radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #9aa4ae; flex: 0 0 auto; }
.tgp-radio.sq { border-radius: 5px; }
.tgp-ok { color: #3fa654; font-weight: 700; }
.tgp-votes { font-size: .74rem; opacity: .55; text-align: center; padding: .4rem 0 .1rem; }
.tgp-fwd { padding: .45rem .7rem 0; font-size: .8rem; color: #2481cc; }
.tgp-placeholder { padding: .8rem .7rem .2rem; font-size: .82rem; opacity: .75; }
.tgp-kb { display: flex; flex-direction: column; gap: 3px; max-width: 92%; }
.tgp-kb-row { display: flex; gap: 3px; }
.tgp-btn { flex: 1; position: relative; text-align: center; padding: .45rem .5rem; border-radius: 8px; background: rgba(0,0,0,.28); color: #fff; font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tgp-btn i { position: absolute; right: 5px; top: 2px; font-style: normal; font-size: .62rem; opacity: .8; }

@media (max-width: 1100px) {
  .tg-editor { grid-template-columns: minmax(0, 1fr); }
  .sticky-side { position: static; }
}
@media (max-width: 640px) {
  .kind-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .btn-edit { grid-template-columns: minmax(0, 1fr) auto; }
  .btn-edit select { grid-column: 1 / -1; }
  .btn-edit input { grid-column: 1; }
  .btn-edit button { grid-column: 2; grid-row: 2 / span 2; }
  .opt-grid, .radio-row { grid-template-columns: minmax(0, 1fr); }
  .tg-row { grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
  .tg-row-end { grid-row: 1; grid-column: 2; flex-direction: row; }
  .tg-row .tg-kind { grid-row: 1; grid-column: 1; justify-self: start; }
  .tg-row-main { grid-column: 1 / -1; }
  .tg-row-meta { display: none; }
  .media-item { grid-template-columns: 56px minmax(0, 1fr) auto; }
  .mi-thumb { width: 56px; height: 56px; }
}
.seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }

/* busy buttons & network card */
.btn.is-busy { opacity: .75; cursor: progress; }
.btn.is-busy::before { content: ""; width: .8em; height: .8em; margin-right: .45em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; vertical-align: -.1em; animation: cv-spin .7s linear infinite; }
@keyframes cv-spin { to { transform: rotate(360deg); } }
.net-state { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.net-state .mono { word-break: break-all; }

/* originals: video, badges, upload progress */
.media-view video { width: 100%; max-height: 70vh; background: #000; border-radius: var(--r); display: block; }
.original-note { margin: .8rem 0 .6rem; padding: .45rem .7rem; border-radius: var(--r); background: var(--ok-soft); color: var(--text); }
.gthumb { position: relative; display: block; }
.gbadge { position: absolute; left: .5rem; bottom: .5rem; padding: .1rem .45rem; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: .75rem; font-weight: 600; pointer-events: none; }
.upload-progress { display: flex; flex-direction: column; gap: .4rem; }
.upload-progress[hidden] { display: none; }
.pbar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.pbar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload-errors { margin: 0; padding-left: 1.1rem; color: var(--danger); font-size: .85rem; }
.upload-preview video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r); background: #000; display: block; }
.shot-kv dd { font-variant-numeric: tabular-nums; }

/* channel picker & schedule */
.chan-picker { display: flex; flex-direction: column; gap: .5rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { border: 1px dashed var(--border-strong); background: transparent; color: var(--text); border-radius: 99px; padding: .2rem .7rem; font: inherit; font-size: .82rem; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.on { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.chan-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.chan-opt { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .65rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); cursor: pointer; font-size: .9rem; }
.chan-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chan-opt.no-rights { opacity: .8; }
.tg-schedule { display: flex; flex-direction: column; gap: .45rem; padding-top: .8rem; margin-top: .8rem; border-top: 1px solid var(--border); }
.group-list { display: flex; flex-direction: column; gap: .5rem; }
.group-item { padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.autopost-state { display: flex; flex-wrap: wrap; gap: .4rem .8rem; align-items: center; }
.tg-mark { font-size: .72rem; padding: .05rem .4rem; border-radius: 6px; background: var(--note-soft); color: var(--note); white-space: nowrap; }
.tg-mark.done { background: var(--ok-soft); color: var(--ok); }
.tg-mark.fail { background: var(--danger-soft); color: var(--danger); }
.tight { margin: .3rem 0; padding-left: 1.1rem; }

/* drop zones */
.dz { display: flex; flex-direction: column; gap: .6rem; }
.dz-extra { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.dz-extra select, .dz-extra input { width: auto; min-width: 10rem; }
.dz-area { position: relative; display: flex; align-items: center; justify-content: center; gap: .9rem; padding: 1.4rem 1rem; border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); cursor: pointer; text-align: left; transition: border-color .12s, background .12s, transform .12s; }
.dz-area:hover { border-color: var(--accent); }
.dz-area.drag { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.005); }
.dz-area.has-files { border-style: solid; border-color: var(--accent); }
.dz-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dz-icon { font-size: 1.5rem; line-height: 1; width: 2.6rem; height: 2.6rem; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); flex: 0 0 auto; }
.dz-text { display: flex; flex-direction: column; gap: .15rem; }
.dz-title { font-weight: 600; }
.dz-sub { font-size: .8rem; color: var(--muted); }
.dz-compact .dz-area, .dz-area.dz-inline { padding: .8rem; }
.dz-compact .dz-icon { width: 2rem; height: 2rem; font-size: 1.1rem; }
body.drop-anywhere::after { content: ""; position: fixed; inset: 0; border: 3px dashed var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); pointer-events: none; z-index: 90; }
.upload-preview .ph { width: 84px; height: 84px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
/* item page: form left, photos right */
.item-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 1rem; align-items: start; }
.item-side { position: sticky; top: 4.2rem; }
.item-side .gallery.small { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
@media (max-width: 1100px) { .item-layout { grid-template-columns: minmax(0, 1fr); } .item-side { position: static; } }

/* batch editor */
.batch-bulk-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem .7rem; margin: .5rem 0 .6rem; }
.batch-bulk-row .field:last-child { grid-column: span 2; }
.batch-bulk-row .field:last-child .btn { white-space: nowrap; align-self: start; }
.batch-list { display: flex; flex-direction: column; gap: .6rem; }
.batch-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: .8rem; align-items: start; margin: 0; padding: .7rem .8rem; transition: box-shadow .3s; }
.batch-row.flash { box-shadow: 0 0 0 2px var(--accent); }
.batch-thumb { position: relative; }
.batch-thumb img, .batch-thumb .ph { width: 110px; height: 110px; object-fit: cover; border-radius: var(--r); display: grid; place-items: center; background: var(--surface-2); }
.batch-thumb .check { position: absolute; top: .35rem; left: .35rem; background: var(--surface); border-radius: 5px; padding: .15rem; }
.batch-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .45rem .6rem; }
.batch-fields .span2 { grid-column: span 2; }
.batch-actions { display: flex; flex-direction: column; gap: .35rem; }
@media (max-width: 700px) { .batch-row { grid-template-columns: 72px minmax(0, 1fr); } .batch-thumb img, .batch-thumb .ph { width: 72px; height: 72px; } .batch-actions { grid-column: 1 / -1; flex-direction: row; } .batch-fields .span2 { grid-column: auto; } }
.pack-steps { margin: 0 0 1rem; padding-left: 1.2rem; color: var(--muted); display: flex; flex-direction: column; gap: .2rem; }
.pack-prompt { max-height: 520px; overflow: auto; white-space: pre-wrap; font-size: .78rem; background: var(--surface-2); padding: .8rem; border-radius: var(--r); margin: 0; }
.voice-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.voice-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .8rem; align-items: center; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.voice-item audio, .voice-item video { grid-column: 1 / -1; width: 100%; max-height: 240px; }
.audio-view { display: flex; flex-direction: column; gap: .6rem; }
.audio-view img { max-height: 200px; object-fit: contain; margin: 0 !important; }
.audio-view audio { width: 100%; }

/* import picker */
.pick-group { border-top: 1px solid var(--border); padding: .4rem 0; }
.pick-group > summary { display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .3rem 0; font-weight: 600; list-style: none; }
.pick-group > summary::-webkit-details-marker { display: none; }
.pick-group > summary::before { content: "▸"; color: var(--muted); transition: transform .12s; }
.pick-group[open] > summary::before { transform: rotate(90deg); }
.pick-rows { display: flex; flex-direction: column; max-height: 420px; overflow: auto; margin: .2rem 0 .3rem 1.1rem; }
.pick-row { display: grid; grid-template-columns: auto minmax(120px, 240px) minmax(0, 1fr) auto auto; gap: .6rem; align-items: start; padding: .35rem .4rem; border-radius: 6px; font-size: .86rem; cursor: pointer; }
.pick-row:hover { background: var(--surface-2); }
.pick-row .pk { font-weight: 600; }
.pick-row .pv { color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.pick-row.is-same { opacity: .6; }
.pick-row:has(input:not(:checked)) .pk, .pick-row:has(input:not(:checked)) .pv { text-decoration: line-through; opacity: .55; }
@media (max-width: 700px) { .pick-row { grid-template-columns: auto minmax(0, 1fr); } .pick-row .pv { grid-column: 2; } }

/* photo strip (appearance header) */
.strip-wrap { position: relative; }
.strip { display: flex; gap: .6rem; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; padding-bottom: .3rem; }
.strip-item { position: relative; flex: 0 0 auto; width: 170px; aspect-ratio: 3 / 4; border-radius: var(--r); overflow: hidden; scroll-snap-align: start; background: var(--surface-2); border: 1px solid var(--border); }
.strip-item[hidden] { display: none; }
.strip-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.strip-item:hover img { transform: scale(1.03); }
.strip-cap { position: absolute; left: .4rem; bottom: .4rem; padding: .05rem .4rem; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: .72rem; }
.strip-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 1.3rem; line-height: 1; cursor: pointer; box-shadow: var(--shadow); }
.strip-nav.prev { left: -.6rem; } .strip-nav.next { right: -.6rem; }
.strip-nav[hidden] { display: none; }
.strip-filter { margin: 0; }
@media (max-width: 700px) { .strip-item { width: 120px; } .strip-nav { display: none; } }

/* materials */
.mat-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 1rem; align-items: start; }
.mat-side { position: sticky; top: 4.2rem; }
.mat-folders { display: flex; flex-direction: column; gap: .15rem; }
.mat-folders a { display: flex; justify-content: space-between; gap: .5rem; padding: .4rem .6rem; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .9rem; }
.mat-folders a:hover { background: var(--surface-2); }
.mat-folders a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mat-folders .n { color: var(--muted); font-size: .8rem; }
.mat-bar { display: flex; flex-wrap: wrap; gap: .4rem .5rem; align-items: center; padding: .55rem .7rem; margin-bottom: .7rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); position: sticky; top: 3.6rem; z-index: 5; }
.mat-bar select, .mat-bar .mat-tag { width: auto; min-width: 8rem; }
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .7rem; }
.mat-tile { position: relative; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; display: flex; flex-direction: column; }
.mat-tile:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.mat-thumb { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--surface-2); }
.mat-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mat-check { position: absolute; top: .45rem; left: .45rem; z-index: 2; background: var(--surface); border-radius: 6px; padding: .2rem; line-height: 0; }
.mat-status { position: absolute; top: .45rem; right: .45rem; padding: .05rem .45rem; border-radius: 6px; font-size: .72rem; font-weight: 600; background: var(--surface-3); color: var(--text); }
.mat-status.inline { position: static; }
.ms-ready { background: var(--ok-soft); color: var(--ok); } .ms-published { background: var(--accent-soft); color: var(--accent); }
.ms-draft { background: var(--note-soft); color: var(--note); } .ms-archived { opacity: .7; }
.mat-body { padding: .5rem .65rem .65rem; display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.mat-title { font-weight: 600; font-size: .9rem; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-dl { position: absolute; right: .45rem; bottom: .5rem; width: 1.9rem; height: 1.9rem; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--text); text-decoration: none; border: 1px solid var(--border); }
.mat-dl:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 900px) { .mat-layout { grid-template-columns: minmax(0, 1fr); } .mat-side { position: static; } .mat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .mat-bar { position: static; } }

/* avatar picker */
button.char-avatar { position: relative; padding: 0; border: 0; cursor: pointer; font: inherit; color: inherit; }
.avatar-edit { position: absolute; right: 2px; bottom: 2px; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--accent); color: #fff; font-size: .65rem; display: grid; place-items: center; opacity: 0; transition: opacity .12s; }
button.char-avatar:hover .avatar-edit, button.char-avatar:focus-visible .avatar-edit { opacity: 1; }
.pick-dialog { width: min(860px, 94vw); max-height: 86vh; border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--text); padding: 1rem 1.1rem; }
.pick-dialog::backdrop { background: rgba(0,0,0,.55); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; }
.pick-tile { position: relative; display: block; width: 100%; padding: 0; border: 2px solid transparent; border-radius: var(--r); overflow: hidden; background: var(--surface-2); cursor: pointer; aspect-ratio: 3 / 4; }
.pick-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-tile span { position: absolute; left: .35rem; bottom: .35rem; padding: 0 .35rem; border-radius: 5px; background: rgba(0,0,0,.6); color: #fff; font-size: .72rem; }
.pick-tile:hover { border-color: var(--accent); } .pick-tile.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* rich text values */
.rt p { margin: 0 0 .35rem; } .rt p:last-child { margin-bottom: 0; }
.rt ul { margin: .1rem 0 .4rem; padding-left: 1.1rem; } .rt li { margin: .12rem 0; } .rt li::marker { color: var(--accent); }
[data-clamp].clamped { max-height: 9.5rem; overflow: hidden; position: relative; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.clamp-toggle { margin-top: .2rem; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: .82rem; }

/* carousel */
.carousel { position: relative; border-radius: var(--r-lg); overflow: hidden; background: var(--surface-2); }
.c-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; height: 100%; }
.c-track::-webkit-scrollbar { display: none; }
.c-slide { position: relative; flex: 0 0 100%; scroll-snap-align: start; display: block; }
.carousel.r-34 .c-slide { aspect-ratio: 3 / 4; } .carousel.r-45 .c-slide { aspect-ratio: 4 / 5; }
.carousel.r-11 .c-slide { aspect-ratio: 1 / 1; } .carousel.r-43 .c-slide { aspect-ratio: 4 / 3; } .carousel.r-169 .c-slide { aspect-ratio: 16 / 9; }
.c-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.c-empty { display: grid; place-items: center; color: var(--muted); font-size: .85rem; text-align: center; padding: 1rem; }
.c-cap { position: absolute; left: .5rem; bottom: 1.7rem; max-width: calc(100% - 1rem); padding: .1rem .45rem; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: .74rem; }
.c-cap.wide { font-size: .78rem; line-height: 1.3; }
.c-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 2rem; height: 2rem; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 1.25rem; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; }
.c-nav.prev { left: .45rem; } .c-nav.next { right: .45rem; }
.carousel:hover .c-nav, .carousel:focus-within .c-nav { opacity: 1; }
@media (hover: none) { .c-nav { opacity: .85; } }
.c-dots { position: absolute; left: 0; right: 0; bottom: .5rem; display: flex; justify-content: center; gap: .3rem; pointer-events: none; }
.c-dots button { pointer-events: auto; width: 6px; height: 6px; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.5); cursor: pointer; }
.c-dots button.on { background: #fff; width: 16px; border-radius: 3px; }

/* character overview */
.hero { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 1.2rem; align-items: stretch; }
.hero-info { display: flex; flex-direction: column; gap: .9rem; justify-content: space-between; min-width: 0; }
.hero-info h1 { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.hero .sub { margin: .2rem 0 0; color: var(--muted); }
.fact-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.fact-chips span { padding: .15rem .55rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-size: .82rem; }
.lead { margin: .6rem 0 0; color: var(--text); max-width: 62ch; }
.row.wrap { flex-wrap: wrap; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .45rem; }
.stat-tiles a { display: flex; flex-direction: column; gap: .05rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); color: var(--text); text-decoration: none; }
.stat-tiles a:hover { border-color: var(--accent); }
.stat-tiles b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat-tiles span { font-size: .75rem; color: var(--muted); }
.showcase-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.showcase-row .card { margin: 0; }
.showcase-body { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); gap: .9rem; align-items: start; }
.kv.compact { grid-template-columns: minmax(90px, 34%) minmax(0, 1fr); gap: .3rem .7rem; font-size: .87rem; margin: 0; }
.kv.compact dt { color: var(--muted); }
.emo-list { display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.emo-row { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; padding-bottom: .4rem; border-bottom: 1px solid var(--border); }
.emo-row > div { display: flex; flex-direction: column; gap: .15rem; min-width: 0; font-size: .87rem; }
.emo-row pre { margin: 0; white-space: pre-wrap; font-size: .78rem; color: var(--muted); max-height: 4.8em; overflow: hidden; }
@media (max-width: 1100px) { .showcase-row { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .hero { grid-template-columns: minmax(0, 1fr); } .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .showcase-body { grid-template-columns: minmax(0, 1fr); } }

/* anketa */
.stats-big { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.stats-big .st { padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); display: flex; flex-direction: column; }
.stats-big b { font-size: 1.35rem; font-variant-numeric: tabular-nums; } .stats-big span { font-size: .76rem; color: var(--muted); }
.dist { display: inline-flex; gap: .3rem; margin: 0 .5rem .2rem 0; padding: .05rem .5rem; border-radius: 99px; background: var(--surface-2); font-size: .8rem; }
.anketa-shows { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.anketa-shows .card { margin: 0; }
.anketa-group { margin: .9rem 0 .4rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.anketa-sec .kv.compact { grid-template-columns: minmax(120px, 26%) minmax(0, 1fr); }
.anketa-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .5rem; }
.anketa-item { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem; border: 1px solid var(--border); border-radius: var(--r); color: var(--text); text-decoration: none; }
.anketa-item:hover { border-color: var(--accent); }
.anketa-item img, .anketa-item .ph { width: 64px; height: 64px; flex: 0 0 64px; object-fit: cover; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; }
.ai-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
@media (max-width: 900px) { .anketa-shows { grid-template-columns: minmax(0, 1fr); } }
@media print {
  .topbar, .char-side, .noprint, .anketa-head .actions, .c-nav, .c-dots, .flash-stack, footer { display: none !important; }
  .char-layout { display: block; } body { background: #fff; color: #000; }
  .card { break-inside: avoid; border-color: #ccc; background: #fff; }
}

/* showcase cards & shelves */
.sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; }
.sc-grid.looks { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.sc-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; transition: border-color .12s, transform .12s; }
.sc-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.sc-card .carousel { border-radius: 0; }
.sc-card .c-empty span { font-size: 2.2rem; font-weight: 700; color: var(--muted); }
.sc-body { display: flex; flex-direction: column; gap: .3rem; padding: .6rem .75rem .75rem; color: var(--text); text-decoration: none; min-width: 0; }
.sc-body h3 { margin: 0; font-size: .98rem; line-height: 1.3; }
.sc-body .clamp { -webkit-line-clamp: 2; color: var(--muted); }
.piece-chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.piece-chips span { font-size: .74rem; padding: .05rem .45rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.shelf { margin-bottom: 1.2rem; }
.shelf-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .45rem; }
.shelf-head h2 { margin: 0; font-size: 1.05rem; }
.shelf-head .btn[hidden] { display: none; }
.shelf-track { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 230px); gap: .75rem; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: .4rem; scrollbar-width: thin; }
.shelf-track > .sc-card { scroll-snap-align: start; }
@media (max-width: 700px) { .sc-grid, .sc-grid.looks { grid-template-columns: repeat(2, minmax(0, 1fr)); } .shelf-track { grid-auto-columns: 46%; } }

/* ---------- Dialogs ---------- */
.chat-tabs { margin-bottom: 1rem; }
.pad { padding: .8rem; }
.ok-text { color: var(--ok); font-weight: 600; }
.inbox { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 1rem; align-items: stretch; height: calc(100vh - 230px); min-height: 480px; }
.inbox > .card { padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.inbox-filters { padding: .7rem; border-bottom: 1px solid var(--border); display: grid; gap: .45rem; }
.inbox-filters .row select { flex: 1; min-width: 0; }
.inbox-rows { overflow-y: auto; flex: 1; }
.inbox-row { display: flex; gap: .6rem; padding: .6rem .7rem; border-bottom: 1px solid var(--border); color: var(--text); align-items: center; }
.inbox-row:hover { background: var(--surface-2); }
.inbox-row.on { background: var(--accent-soft); }
.inbox-row.unread b { color: var(--accent); }
.ir-av { flex: 0 0 36px; height: 36px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.ir-main { flex: 1; min-width: 0; font-size: .9rem; }
.ir-last { display: block; color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ir-side { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.ir-badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 0 .45rem; min-width: 1.3rem; text-align: center; }
.cs-badge { font-size: .68rem; font-weight: 600; padding: .05rem .4rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.cst-human { background: var(--warn-soft); color: var(--warn); }
.cst-done { background: var(--ok-soft); color: var(--ok); }
.cst-stopped { background: var(--danger-soft); color: var(--danger); }
.chat-head { display: flex; justify-content: space-between; gap: .8rem; align-items: center; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; background: var(--surface-2); min-height: 200px; }
.bubble { max-width: min(75%, 560px); padding: .5rem .7rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); align-self: flex-start; box-shadow: var(--shadow); }
.bubble.out { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.bubble.out.src-operator { background: var(--warn-soft); }
.bubble.out.src-ai { background: var(--note-soft); }
.bubble.src-system { align-self: center; background: transparent; border: 0; box-shadow: none; color: var(--muted); font-size: .82rem; }
.bubble .bt { white-space: pre-wrap; word-break: break-word; font-size: .93rem; line-height: 1.45; }
.bubble .bb { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.bubble .bb > * { font-size: .8rem; padding: .25rem .6rem; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.bubble .bb button { cursor: pointer; font: inherit; font-size: .8rem; }
.bubble .bb button:hover { border-color: var(--accent); color: var(--accent); }
.bubble .bm { font-size: .7rem; color: var(--faint); margin-top: .25rem; }
.chat-reply { padding: .7rem .9rem; border-top: 1px solid var(--border); display: grid; gap: .45rem; }
.chat-reply .row input { flex: 1; }
.chat-more { padding: .4rem .9rem .8rem; border-top: 1px solid var(--border); }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.funnel-card { display: block; color: var(--text); }
.funnel-card:hover { border-color: var(--accent); }
.funnel-nums { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: .6rem; font-size: .85rem; color: var(--muted); }
.funnel-nums b { color: var(--text); }
.funnel-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 1rem; align-items: start; }
.funnel-main { display: grid; gap: 1rem; min-width: 0; }
.funnel-side { position: sticky; top: 1rem; display: grid; gap: 1rem; }
.scheme-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .35rem; counter-reset: s; }
.scheme-node { border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 8px; padding: .45rem .65rem; background: var(--surface); }
.scheme-node > a { color: var(--text); display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.scheme-node.is-goal { background: var(--ok-soft); }
.k-message { border-left-color: var(--accent) !important; }
.k-ai { border-left-color: var(--note) !important; }
.k-handoff { border-left-color: var(--warn) !important; }
.k-end { border-left-color: var(--faint) !important; }
.sk { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.edges { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; padding-left: .3rem; }
.edge { font-size: .76rem; padding: .1rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.edge:hover { color: var(--accent); }
.node-card { border-left: 4px solid var(--border-strong); scroll-margin-top: 1rem; }
.node-head { display: flex; gap: .5rem; flex-wrap: wrap; }
.node-head .node-title { flex: 1 1 200px; font-weight: 600; }
.node-head .node-key { flex: 0 0 140px; }
.node-more summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.test-wrap { display: grid; grid-template-columns: minmax(0, 480px) minmax(240px, 1fr); gap: 1rem; align-items: start; }
.test-phone { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 260px); min-height: 460px; overflow: hidden; }
.stats-big { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.stats-big .st { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: .7rem .9rem; display: grid; }
.stats-big .st b { font-size: 1.5rem; }
.stats-big .st span { color: var(--muted); font-size: .8rem; }
.fbars { display: grid; gap: .45rem; }
.fbar { display: grid; grid-template-columns: minmax(140px, 240px) 1fr 90px; gap: .6rem; align-items: center; }
.fbar .ft { height: 12px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.fbar .fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .4s; }
.fbar.goal .fill { background: var(--ok); }
.fbar .fn { text-align: right; font-size: .85rem; font-variant-numeric: tabular-nums; }
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); }
.tbl th { color: var(--muted); font-weight: 600; font-size: .78rem; }
.tbl td:not(:first-child), .tbl th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.bot-row { display: grid; gap: .5rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.bot-row:last-child { border-bottom: 0; }
@media (max-width: 900px) {
  .inbox, .funnel-layout, .test-wrap { grid-template-columns: 1fr; height: auto; }
  .inbox-list { max-height: 45vh; }
  .inbox-chat { min-height: 70vh; }
  .funnel-side { position: static; }
  .fbar { grid-template-columns: 1fr 70px; } .fbar .fl { grid-column: 1 / -1; }
}
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.trace-dlg h3 { font-size: .85rem; margin: .8rem 0 .3rem; color: var(--muted); }
.trace-dlg details { margin-top: .6rem; } .trace-dlg summary { cursor: pointer; font-weight: 600; font-size: .88rem; }
.trace-pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: .78rem; line-height: 1.5; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; max-height: 40vh; overflow: auto; margin: 0; }
.trace-pre.tall { max-height: none; }
.trace-hist { display: grid; gap: .25rem; font-size: .82rem; margin-top: .4rem; max-height: 30vh; overflow: auto; }
.trace-hist .th-assistant b { color: var(--note); }
.mood-now { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.mood-title { font-size: 1.35rem; font-weight: 700; margin: .2rem 0; text-transform: capitalize; }
.mood-tbl td:not(:first-child), .mood-tbl th:not(:first-child) { text-align: left; }
.mood-tbl tr.ms-now td { background: var(--accent-soft); }
.mood-tbl tr.ms-past td { opacity: .6; }
/* funnel sub-nav, AI page, debugging */
.fnav { display: flex; gap: .3rem; flex-wrap: wrap; margin: -.4rem 0 1rem; border-bottom: 1px solid var(--border); }
.fnav a { padding: .5rem .8rem; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.fnav a:hover { color: var(--text); }
.fnav a.on { color: var(--accent); border-bottom-color: var(--accent); }
.ai-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); gap: 1rem; align-items: start; }
.ai-main { display: grid; gap: 1rem; min-width: 0; }
.ai-main > h2 { margin: .5rem 0 -.3rem; }
.ai-side { position: sticky; top: 1rem; display: grid; gap: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
.asm { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .4rem; counter-reset: a; }
.asm li { counter-increment: a; }
.asm li a { display: grid; gap: .1rem; padding: .45rem .6rem .45rem 2rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); position: relative; height: 100%; }
.asm li a::before { content: counter(a); position: absolute; left: .55rem; top: .5rem; font-size: .72rem; font-weight: 700; color: var(--accent); }
.asm li a span { font-size: .75rem; color: var(--muted); }
.asm li.off a { opacity: .5; border-style: dashed; }
.asm li.hl a { border-color: var(--accent); background: var(--accent-soft); }
.ai-params { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.pcard { border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: .6rem .7rem; margin-bottom: .6rem; background: var(--surface); display: grid; gap: .45rem; }
.pcard.pk-variant { border-left-color: var(--warn); }
.pcard.pk-example { border-left-color: var(--ok); }
.pcard.off { opacity: .55; border-style: dashed; }
.pcard-head { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.pcard-head .ptitle { flex: 1 1 200px; font-weight: 600; }
.pcard-head .pkind { flex: 0 0 auto; }
.pcard .pbody { font-family: var(--mono); font-size: .82rem; line-height: 1.5; }
.pcard-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.padd summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .88rem; padding: .3rem 0; }
.grow { flex: 1 1 200px; }
.notice.info { background: var(--info-soft); color: var(--text); border-color: transparent; }
.step-ai h3 { font-size: .95rem; }
.pg .pg-log { height: 380px; min-height: 0; border-radius: 8px; margin: .6rem 0; padding: .6rem; }
.pg [data-pg-form] input { flex: 1; }
.pg-sys summary { font-size: .72rem; color: var(--muted); cursor: pointer; margin-top: .3rem; }
.pg-sys .trace-pre { max-height: 260px; font-size: .7rem; }
.psec { padding: .7rem .8rem; }
.psec-head { display: flex; justify-content: space-between; margin-bottom: .4rem; }
.ps-step { border-color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: pre; }
.dbg-filters { margin-bottom: 1rem; }
.stats-big .st.ok b { color: var(--ok); } .stats-big .st.warn b { color: var(--warn); } .stats-big .st.bad b { color: var(--danger); }
.leaks h2 { margin: 0 0 .5rem; }
.leak-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.leak { display: grid; gap: .2rem; color: var(--text); border-color: var(--danger-soft); background: linear-gradient(180deg, var(--danger-soft), var(--surface) 70%); }
.leak:hover { border-color: var(--danger); }
.leak-n { font-size: 1.8rem; font-weight: 800; color: var(--danger); line-height: 1.1; }
.leak > span { color: var(--accent); }
.tbl-wrap { overflow-x: auto; }
.dbg-tbl td, .dbg-tbl th { white-space: nowrap; }
.dbg-tbl td:first-child { white-space: normal; min-width: 200px; }
.dbg-tbl tr.sel td { background: var(--accent-soft); }
.dbg-tbl tr.leak-row td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.dbg-tbl .w-bar { width: 180px; text-align: left !important; }
.fbar.mini { grid-template-columns: 1fr 40px; gap: .4rem; }
.pill { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-weight: 700; font-size: .8rem; }
.pill.bad { background: var(--danger-soft); color: var(--danger); } .pill.mid { background: var(--warn-soft); color: var(--warn); } .pill.good { background: var(--ok-soft); color: var(--ok); }
.warn-text { color: var(--warn); font-weight: 600; } .bad-text { color: var(--danger); font-weight: 600; }
.step-detail { margin-top: 1.2rem; padding: 1rem; border: 2px solid var(--accent); border-radius: var(--r-lg); scroll-margin-top: 1rem; }
.dbg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.dbg-grid h3, .step-detail h3 { font-size: .9rem; margin: 0 0 .5rem; }
.flow-row { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.flow-row .n, .ans-row .n { font-weight: 700; font-variant-numeric: tabular-nums; }
.ans-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 32px; gap: .5rem; align-items: center; font-size: .85rem; padding: .2rem 0; }
.ans-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ans-row .ft { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.ans-row .fill { display: block; height: 100%; width: 0; background: var(--note); }
.recent { display: grid; gap: .3rem; max-height: 520px; overflow: auto; }
.recent-row { display: grid; gap: .1rem; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: .88rem; }
.recent-row:hover { border-color: var(--accent); }
.recent-row .who { font-weight: 600; }
.recent-row.stuck { border-left: 3px solid var(--warn); }
.journey { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; padding: .45rem .9rem; border-bottom: 1px solid var(--border); font-size: .76rem; }
.jstep { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.jstep i { font-style: normal; color: var(--faint); font-size: .68rem; margin-right: .15rem; }
.jstep i::after { content: " →"; }
.jstep.cur { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.jstep.goal { background: var(--ok-soft); color: var(--ok); }
@media (max-width: 1000px) { .ai-layout { grid-template-columns: 1fr; } .ai-side { position: static; max-height: none; } }
