/* App Kit UI -- tokens, then layout, then components. No external assets. */
:root {
  --primary: #4f46e5; --primary-ink: #fff; --primary-soft: color-mix(in srgb, var(--primary) 12%, transparent);
  --bg: #f6f7fb; --panel: #fff; --panel-2: #f1f3f9; --ink: #161a2b; --ink-2: #4a5169; --ink-3: #7b8299;
  --line: #e3e6f0; --danger: #d92d3a; --danger-soft: #fde8ea; --ok: #12875a; --ok-soft: #dff5ea; --warn: #b7791f; --warn-soft: #fdf3dc;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(20,24,45,.06), 0 8px 24px rgba(20,24,45,.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --side: 248px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --bg: #0f1220; --panel: #171b2e; --panel-2: #1e2339; --ink: #eef0f8; --ink-2: #b4bad1; --ink-3: #8189a6; --line: #2a3050;
    --danger-soft: #3a1a20; --ok-soft: #123226; --warn-soft: #3a2f12; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-mode="dark"] {
  --bg: #0f1220; --panel: #171b2e; --panel-2: #1e2339; --ink: #eef0f8; --ink-2: #b4bad1; --ink-3: #8189a6; --line: #2a3050;
  --danger-soft: #3a1a20; --ok-soft: #123226; --warn-soft: #3a2f12; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--ink-3); } .small { font-size: .85rem; } .right { margin-left: auto; }
.hidden { display: none !important; }
.boot { display: grid; place-items: center; height: 100vh; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* shell */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; align-items: center; gap: .65rem; padding: 1.1rem 1.1rem .8rem; font-weight: 700; font-size: 1.05rem; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 800; }
.nav { padding: .4rem .6rem; display: flex; flex-direction: column; gap: 2px; }
.nav .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: .9rem .6rem .3rem; }
.nav a { display: flex; align-items: center; gap: .65rem; padding: .5rem .65rem; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.side .foot { margin-top: auto; padding: .8rem; border-top: 1px solid var(--line); font-size: .85rem; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.5rem; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line); }
.burger { display: none; }
.content { padding: 1.5rem; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-3); }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(82vw, 300px); transform: translateX(-100%); transition: transform .2s; z-index: 30; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .burger { display: inline-flex; }
  .content { padding: 1rem; }
}

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .pad, .pad { padding: 1.1rem 1.25rem; }
.card-head { display: flex; align-items: center; gap: .6rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--line); }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { padding: 1rem 1.2rem; }
.stat .v { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--ink-3); font-size: .85rem; }
.btn { display: inline-flex; align-items: center; gap: .45rem; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: .5rem .9rem; border-radius: var(--radius-sm); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); } .btn.danger.solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: .3rem .6rem; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { padding: .4rem; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--ink-2); cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--panel-2); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .5rem .65rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 96px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; }
label.f .help { font-weight: 400; color: var(--ink-3); font-size: .82rem; }
label.f .err, .err { color: var(--danger); font-weight: 500; font-size: .85rem; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .search { flex: 1; min-width: 180px; max-width: 360px; position: relative; }
.badge { display: inline-flex; align-items: center; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--panel-2); color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--primary-soft); color: var(--primary); }
.table-wrap { overflow: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: .6rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: default; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t td { padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover { background: var(--panel-2); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-3); }
.pager { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--line); color: var(--ink-3); font-size: .9rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow: auto; }
.tabs a { padding: .6rem .9rem; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-color: var(--primary); text-decoration: none; }
.toast-wrap { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: var(--ink); color: var(--bg); padding: .7rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); max-width: 340px; }
.toast.bad { background: var(--danger); color: #fff; }
.overlay { position: fixed; inset: 0; background: rgba(10,12,25,.5); display: grid; place-items: center; z-index: 60; padding: 1rem; }
.modal { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); width: min(640px, 100%); max-height: 90vh; display: flex; flex-direction: column; }
.modal.wide { width: min(860px, 100%); }
.modal .mh { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .6rem; }
.modal .mb { padding: 1.25rem; overflow: auto; }
.modal .mf { padding: .85rem 1.25rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; justify-content: flex-end; }
.change { display: flex; gap: .6rem; padding: .55rem .7rem; border-radius: var(--radius-sm); background: var(--panel-2); margin-bottom: .4rem; align-items: flex-start; }
.change.destructive { background: var(--danger-soft); }
.callout { padding: .75rem 1rem; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); margin-bottom: .8rem; }
.callout.bad { background: var(--danger-soft); color: var(--danger); } .callout.info { background: var(--primary-soft); color: var(--primary); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: min(400px, 100%); padding: 2rem; }
.login .logo { width: 48px; height: 48px; margin-bottom: 1rem; border-radius: 14px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-size: 1.4rem; font-weight: 800; }
.chart { width: 100%; height: 220px; }
.chart text { fill: var(--ink-3); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: .75rem; font-size: .82rem; color: var(--ink-2); margin-top: .5rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: .35rem; }
.field-row { display: flex; align-items: center; gap: .75rem; padding: .65rem .85rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); margin-bottom: .5rem; }
.field-row .grow { flex: 1; min-width: 0; }
.field-row .ty { font-size: .78rem; color: var(--ink-3); }
.block-row { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); margin-bottom: .6rem; }
.block-row .bh { display: flex; align-items: center; gap: .5rem; padding: .55rem .75rem; background: var(--panel-2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; font-weight: 600; }
.block-row .bb { padding: .8rem .9rem; }
.perm-grid { display: grid; grid-template-columns: minmax(140px, 1.4fr) repeat(5, minmax(60px, 1fr)); gap: .25rem .5rem; align-items: center; font-size: .9rem; }
.perm-grid .h { font-size: .75rem; text-transform: uppercase; color: var(--ink-3); letter-spacing: .05em; }
.perm-grid select { padding: .25rem .4rem; font-size: .85rem; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: .5rem 1rem; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.pill-input { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill-input label { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; cursor: pointer; background: var(--panel); }

@media print {
  body > *:not(.overlay):not(.toast-wrap) { display: none !important; }
  .overlay { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; width: 100%; max-height: none; }
  .modal .mh, .modal .mf { display: none; }
  body { background: #fff; color: #000; }
}
svg.i.flip { transform: rotate(180deg); }

/* ───────── live editor ───────── */
.ed { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; grid-template-rows: 56px 54px 1fr; }
.ed-top { display: flex; align-items: center; gap: .6rem; padding: 0 .9rem; border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0; }
.ed-name { white-space: nowrap; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.ed-grow { flex: 1; }
.ed-select { width: auto; max-width: 16rem; padding: .35rem .6rem; }
.ed-ib { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); cursor: pointer; }
.ed-ib:hover:not([disabled]) { background: var(--panel-2); }
.ed-ib[disabled] { opacity: .35; cursor: default; }
svg.i.flip-x { transform: scaleX(-1); }
.ed-seg { display: inline-flex; background: var(--panel-2); border-radius: var(--radius-sm); padding: 2px; }
.ed-seg button { border: 0; background: transparent; padding: .3rem .55rem; border-radius: 6px; color: var(--ink-2); cursor: pointer; }
.ed-seg button.on { background: var(--panel); color: var(--primary); box-shadow: var(--shadow); }
.ed-status { color: var(--ink-3); font-size: .85rem; display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.ed-main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; min-height: 0; }
.ed-main.hide-side { grid-template-columns: minmax(0, 1fr) 0; }
.ed-main.hide-side .ed-side { display: none; }
.ed-stage-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ed-hint { display: flex; align-items: center; gap: .5rem; padding: .45rem .9rem; background: var(--primary-soft); color: var(--primary); font-size: .85rem; border-bottom: 1px solid var(--line); }
.ed-hint .ed-ib { margin-left: auto; width: 26px; height: 26px; }
.ed-stage { flex: 1; min-height: 0; background: color-mix(in srgb, var(--bg) 70%, #000 6%); overflow: auto; display: flex; justify-content: center; padding: 1rem; }
.ed-frame-wrap { transition: width .2s; max-width: none; height: 100%; min-height: 400px; background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--line); }
.ed-frame { width: 100%; height: 100%; border: 0; background: var(--bg); }
.ed-side { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ed-tabs { display: flex; gap: 2px; padding: .4rem; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.ed-tabs button { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .6rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ed-tabs button.on { background: var(--primary-soft); color: var(--primary); }
.ed-body-panel { padding: 1rem; overflow: auto; flex: 1; min-height: 0; }
.ed-body-panel .page-head { margin-bottom: .6rem; }
.ed-body-panel .grid.cols-2 { grid-template-columns: 1fr; }
.ed-body-panel .form-grid { grid-template-columns: 1fr; }
.ed-body-panel .perm-grid { grid-template-columns: minmax(90px, 1.2fr) repeat(5, minmax(48px, 1fr)); font-size: .8rem; }
.ed-body-panel .builder-split { grid-template-columns: 1fr !important; }
.ed-body-panel .modal { max-width: 94vw; }
.block-row.sel { outline: 2px solid var(--primary); }
@media (max-width: 1000px) { .ed-main { grid-template-columns: 1fr; grid-template-rows: 45% 55%; } .ed-side { border-left: 0; border-top: 1px solid var(--line); } .ed-name { display: none; } }
/* edit mode inside the preview iframe */
body.ab-edit [data-path] { cursor: pointer; border-radius: 12px; transition: outline-color .1s; outline: 2px dashed transparent; outline-offset: 4px; position: relative; }
body.ab-edit [data-path]:hover { outline-color: color-mix(in srgb, var(--primary) 60%, transparent); }
body.ab-edit [data-path].ab-sel { outline: 2px solid var(--primary); }
body.ab-edit [data-path] [data-path]:hover { outline-color: color-mix(in srgb, var(--primary) 60%, transparent); }
.ab-bar { position: absolute; top: -18px; right: 8px; z-index: 30; display: flex; gap: 2px; padding: 3px; background: var(--panel); border: 1px solid var(--primary); border-radius: 10px; box-shadow: var(--shadow); }
.ab-bar button { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: .82rem; font-weight: 600; padding: .25rem .5rem; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.ab-bar button:hover { background: var(--primary-soft); color: var(--primary); }
.ab-bar button.ai { background: var(--primary); color: var(--primary-ink); }
.ab-bar button.ai:hover { filter: brightness(1.1); background: var(--primary); color: var(--primary-ink); }
/* Ask AI */
.ai-wrap { display: flex; flex-direction: column; gap: .8rem; height: 100%; }
.ai-log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: .6rem; min-height: 200px; }
.ai-msg.user { align-self: flex-end; max-width: 88%; }
.ai-msg.assistant { align-self: flex-start; max-width: 94%; }
.ai-bubble { padding: .6rem .8rem; border-radius: 12px; background: var(--panel-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg.user .ai-bubble { background: var(--primary); color: var(--primary-ink); }
.ai-card { margin-top: .4rem; padding: .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.ai-card ul { margin: .3rem 0 .6rem; padding-left: 1.1rem; font-size: .88rem; }
.ai-ideas { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: .25rem .6rem; font: inherit; font-size: .8rem; color: var(--ink-2); cursor: pointer; text-align: left; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.ai-compose { display: flex; gap: .5rem; align-items: flex-end; }
.ai-input { min-height: 64px; }

.ed-main.wide { grid-template-columns: minmax(0, 1fr) minmax(520px, 56vw); }
table.grid-edit td { padding: .25rem .4rem; }
.cell-input { border-color: transparent; background: transparent; padding: .3rem .4rem; min-width: 90px; }
.cell-input:hover { border-color: var(--line); }
.cell-input.saved { background: var(--ok-soft); }
.cell-input.bad { border-color: var(--danger); }
pre.code { background: #0f172a; color: #e2e8f0; padding: .8rem; border-radius: 10px; overflow: auto; font-size: .78rem; max-height: 280px; }
.ed-body-panel h3 { margin: 0 0 .4rem; font-size: 1rem; }
.ed-body-panel h4 { margin: .8rem 0 .3rem; font-size: .9rem; }

.nav a.edit-cta { background: var(--primary); color: var(--primary-ink); font-weight: 700; margin-bottom: .4rem; }
.nav a.edit-cta:hover { filter: brightness(1.08); text-decoration: none; }

.ai-scope { display: flex; align-items: center; gap: .5rem; justify-content: space-between; padding: .45rem .6rem; background: var(--primary-soft); color: var(--primary); border-radius: var(--radius-sm); font-size: .88rem; }
/* roomier content: the app should breathe, never feel crowded */
.content { padding: 2rem 2.25rem; }
.page-head { margin-bottom: 1.4rem; }
.blk { margin-bottom: 1.35rem !important; }
.grid { gap: 1.25rem; }
.stat { padding: 1.15rem 1.35rem; }
.stat .v { font-size: 2rem; }
.card.pad, .card > .pad { padding: 1.3rem 1.5rem; }
.card-head { padding: 1rem 1.4rem; }
table.t th { padding: .75rem 1.1rem; }
table.t td { padding: .85rem 1.1rem; }
@media (max-width: 900px) { .content { padding: 1.1rem; } }

.bell-wrap { position: relative; }
.bell { position: relative; }
.bell-count { position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; }
.bell-list { position: absolute; right: 0; top: calc(100% + 6px); width: 320px; max-height: 360px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 40; }
.bell-item { padding: .65rem .9rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.bell-item.unread { background: var(--primary-soft); }

.ai-fab { position: absolute; right: 410px; bottom: 22px; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--primary); color: var(--primary-ink); font-size: 1.4rem; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.28); z-index: 5; }
.ed-main.hide-side ~ .ai-fab, .ai-fab.hidden { display: none; }
.ai-x { color: var(--primary); }
.ai-ask:hover { filter: brightness(1.06); }
.block-row .bh .ai-x { width: 28px; height: 28px; font-size: .95rem; }

/* top bar menus + slim tools bar (the Site Builder arrangement) */
.ed-menu { display: flex; align-items: center; gap: 2px; background: var(--panel-2); border-radius: 14px; padding: 4px; flex: none; }
.ed-menu button, .ed-menu-btn { display: inline-flex; align-items: center; gap: .45rem; border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: .85rem; font-weight: 600; padding: .4rem .7rem; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.ed-menu button:hover, .ed-menu-btn:hover { color: var(--primary); }
.ed-menu button.on, .ed-menu-btn.on { background: var(--panel); color: var(--primary); box-shadow: var(--shadow); }
.ed-menu.ai button { background: var(--primary); color: var(--primary-ink); }
.ed-more-wrap { position: relative; }
.ed-more { position: absolute; top: calc(100% + 6px); left: 0; z-index: 70; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .35rem; min-width: 190px; }
.ed-more button { display: flex; width: 100%; align-items: center; gap: .55rem; border: 0; background: transparent; color: var(--ink); font: inherit; padding: .5rem .65rem; border-radius: 8px; cursor: pointer; text-align: left; }
.ed-more button:hover, .ed-more button.on { background: var(--primary-soft); color: var(--primary); }
.ed-tools { display: flex; align-items: center; gap: .75rem; padding: 0 .9rem; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.ed-div { width: 1px; height: 28px; background: var(--line); flex: none; }
.ed-ctx { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.ed-ctx::-webkit-scrollbar { display: none; }
.ed-chip { background: var(--primary-soft); color: var(--primary); border-radius: 9px; padding: .3rem .65rem; font-size: .82rem; white-space: nowrap; margin-right: .3rem; }
.ed-ctx-btn { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: .84rem; font-weight: 600; padding: .4rem .6rem; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.ed-ctx-btn:hover { background: var(--panel-2); }
.ed-ctx-btn.ai { color: var(--primary); }
.ed-ctx-btn.danger { color: var(--danger); }
.ed-muted { color: var(--ink-3); font-size: .85rem; white-space: nowrap; }
.ed-switch { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.ed-side-head { display: flex; align-items: center; border-bottom: 1px solid var(--line); padding-right: .3rem; flex: none; }
.ed-side-head .ed-tabs { flex: 1; border-bottom: 0; }
.ed-tabs button { padding: .45rem .55rem; }
.ed-handle { position: absolute; right: 0; top: 50%; z-index: 40; width: 22px; height: 64px; border: 1px solid var(--line); border-right: 0; background: var(--panel); border-radius: 12px 0 0 12px; cursor: pointer; color: var(--ink-2); display: none; }
.ed.side-hidden .ed-handle { display: grid; place-items: center; }
.ed.side-hidden .ai-fab { right: 40px; }
@media (max-width: 1250px) { .ed-menu button span, .ed-top .btn .lbl { display: none; } }
@media (max-width: 900px) { .ed-switch span { display: none; } }

/* visitors */
.pub { min-height: 100vh; background: var(--bg); }
.pub-head { display: flex; align-items: center; gap: 1rem; padding: .8rem 1.5rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.pub-head a:not(.btn) { color: var(--ink-2); font-weight: 600; }
.pub-body { max-width: 980px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.pub-title { margin-bottom: 1.4rem; }
.pub.embed .pub-body { padding: 1rem; max-width: none; }
.pub.embed { background: transparent; }
.pub-thanks { text-align: center; padding: 1.6rem 1rem; }
.pub-thanks p { font-size: 1.05rem; color: var(--ink); margin: .4rem 0 0; }
.pub-tick { width: 52px; height: 52px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center; font-size: 1.6rem; background: var(--primary); color: var(--primary-ink); }

body.ab-edit .ab-bar button.grip { cursor: grab; }
.ab-drop-before { box-shadow: 0 -4px 0 var(--primary); }
.ab-drop-after { box-shadow: 0 4px 0 var(--primary); }
body.ab-edit [data-type="heading"]:hover, body.ab-edit [data-type="text"]:hover { cursor: text; }

body.ab-opening-editor #app { visibility: hidden; }
body.ab-opening-editor::before { content: ""; position: fixed; inset: 0; background: var(--bg); z-index: 900; }
body.ab-opening-editor::after { content: ""; position: fixed; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; z-index: 901; animation: ab-spin .8s linear infinite; }
@keyframes ab-spin { to { transform: rotate(360deg); } }
