/* Layout: a quiet working surface — a slim sidebar for the organization,
   wide content area with cards only where something stands apart. */
:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --side: #eceef1;
  --ink: #171b22;
  --ink-2: #555e6b;
  --ink-3: #8a929e;
  --line: #e1e4e9;
  --line-2: #d2d6dd;
  --accent: #0f6a86;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0f4;
  --ok: #1d7a4a; --ok-soft: #e3f3ea;
  --warn: #9a6400; --warn-soft: #fbf0d9;
  --bad: #b3261e; --bad-soft: #fbe6e4;
  --shadow: 0 1px 2px rgba(20, 26, 36, .06), 0 8px 24px -12px rgba(20, 26, 36, .18);
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- app frame ---------- */
.frame { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px;
  padding: 16px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 6px; font-weight: 600; font-size: 15px; color: var(--ink); }
.brand-mark { width: 28px; height: 28px; display: block; flex: none; border-radius: 8px; box-shadow: 0 1px 2px rgba(8, 60, 77, .25), 0 4px 10px -4px rgba(8, 60, 77, .35); }
.brand { letter-spacing: -.02em; }

.org-switch { position: relative; }
.org-switch summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel);
}
.org-switch summary::-webkit-details-marker { display: none; }
.org-switch summary .chev { margin-left: auto; color: var(--ink-3); }
.org-avatar { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); flex: none; overflow: hidden; }
.org-avatar img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.org-name { display: block; font-weight: 600; font-size: 13px; line-height: 1.25; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-role { display: block; font-size: 11.5px; color: var(--ink-3); }
.org-menu {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 6px;
}
.org-menu form { margin: 0; }
.org-menu button, .org-menu a {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 7px 8px; border: 0; border-radius: 7px;
  background: none; color: var(--ink); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.org-menu button:hover, .org-menu a:hover { background: var(--bg); text-decoration: none; }
.org-menu .on { color: var(--accent); font-weight: 600; }
.org-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav a:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.nav a.on svg { color: var(--accent); }

.side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px 6px 0; border-top: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--line-2); font-size: 12px; font-weight: 600; flex: none; }
.side-foot .who { min-width: 0; flex: 1; }
.side-foot .who a { color: var(--ink); font-weight: 500; font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who span { color: var(--ink-3); font-size: 11.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot form { margin: 0; }

.main { min-width: 0; padding: 28px max(16px, 3vw) 64px; }
.wrap { max-width: 1120px; margin: 0 auto; display: grid; gap: 22px; }
.wrap.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .sub { margin-top: 4px; color: var(--ink-2); }
.crumb { font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumb a { color: var(--ink-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- notices ---------- */
.note { padding: 10px 14px; border-radius: 9px; font-size: 13.5px; border: 1px solid transparent; }
.note.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.note.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.note.info { background: var(--accent-soft); color: var(--ink); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--panel); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line-2)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: default; }
.linkbtn { border: 0; background: none; padding: 0; font: inherit; color: var(--ink-3); cursor: pointer; }
.linkbtn:hover { color: var(--ink); }

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 500; font-size: 13px; }
.hint { font-size: 12.5px; color: var(--ink-3); }
.input, select.input, textarea.input {
  width: 100%; min-width: 0; height: 38px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--panel); color: var(--ink); font: inherit;
}
textarea.input { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
.prefixed { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; background: var(--panel); }
.prefixed span { display: flex; align-items: center; padding: 0 10px; background: var(--bg); color: var(--ink-3); font-family: var(--mono); font-size: 12px; white-space: nowrap; border-right: 1px solid var(--line-2); max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.prefixed .input { border: 0; border-radius: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.choice { display: grid; gap: 8px; }
.choice label { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border: 1px solid var(--line-2); border-radius: 10px; cursor: pointer; }
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 3px; accent-color: var(--accent); }
.choice b { display: block; font-weight: 600; font-size: 13.5px; }
.choice small { color: var(--ink-2); font-size: 12.5px; }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; min-width: 0; }
.card > h2 { margin-bottom: 4px; }
.card > .sub { color: var(--ink-2); font-size: 13px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
.stack { display: grid; gap: 18px; }

/* ---------- publications grid ---------- */
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 22px 18px; }
.book-card { display: grid; gap: 10px; color: var(--ink); min-width: 0; }
.book-card:hover { text-decoration: none; }
.book-cover {
  position: relative; aspect-ratio: var(--ratio, 4 / 3); max-width: 100%; border-radius: 6px; overflow: hidden;
  background: color-mix(in srgb, var(--ink) 6%, var(--panel)); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 12px 24px -16px rgba(0,0,0,.4);
  transition: transform .18s, box-shadow .18s;
}
.book-card:hover .book-cover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 18px 32px -16px rgba(0,0,0,.45); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-cover .pill { position: absolute; left: 8px; top: 8px; }
.book-meta { display: grid; gap: 2px; min-width: 0; }
.book-meta b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-meta span { font-size: 12.5px; color: var(--ink-3); }
.placeholder-cover { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); }
.placeholder-cover svg { width: 34px; height: 34px; stroke: currentColor; fill: none; stroke-width: 1.4; }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ready { background: var(--ok-soft); color: var(--ok); }
.pill.processing, .pill.queued { background: var(--warn-soft); color: var(--warn); }
.pill.processing::before, .pill.queued::before { animation: pulse 1.2s infinite; }
.pill.failed { background: var(--bad-soft); color: var(--bad); }
.pill.neutral { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-2); }
.pill.neutral::before { display: none; }
@keyframes pulse { 50% { opacity: .3; } }

.empty { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 48px 24px; border: 1.5px dashed var(--line-2); border-radius: 16px; background: var(--panel); }
.empty p { max-width: 46ch; color: var(--ink-2); }

/* ---------- upload ---------- */
.drop {
  display: grid; justify-items: center; gap: 10px; text-align: center; padding: 40px 20px;
  border: 1.5px dashed var(--line-2); border-radius: 14px; background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 34px; height: 34px; stroke: var(--accent); fill: none; stroke-width: 1.5; }
.drop b { font-size: 15px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop .file { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.feature-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.feature-list li { display: grid; grid-template-columns: 20px 1fr; gap: 10px; color: var(--ink-2); font-size: 13.5px; }
.feature-list svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; stroke-width: 1.7; margin-top: 1px; }

/* ---------- book overview ---------- */
.overview { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 22px; align-items: start; }
.facts { display: grid; gap: 0; margin-top: 16px; }
.facts div { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 500; text-align: right; }
.copyrow { display: flex; gap: 8px; }
.copyrow .input { font-family: var(--mono); font-size: 12.5px; }
.embed { font-family: var(--mono); font-size: 12px; min-height: 72px; }
.share-grid { display: grid; grid-template-columns: minmax(0, 1fr) 132px; gap: 20px; align-items: start; }
.qr { display: grid; gap: 8px; justify-items: center; }
.qr canvas { width: 132px; height: 132px; border-radius: 8px; background: #fff; padding: 6px; border: 1px solid var(--line); image-rendering: pixelated; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.kpi { padding: 14px 16px; border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi span { display: block; font-size: 12px; color: var(--ink-2); }
.kpi b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.spark { width: 100%; height: 56px; display: block; margin-top: 14px; overflow: visible; }
.spark-area { fill: color-mix(in srgb, var(--accent) 14%, transparent); }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.8; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-dot { fill: var(--accent); }
.spark-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.bars { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 13px; }
.bars li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars li i { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bars li i::after { content: ""; display: block; height: 100%; width: var(--w); background: var(--accent); border-radius: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.working { display: flex; gap: 14px; align-items: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- team ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-3); padding: 0 10px 8px; }
.table td { padding: 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.table td form { margin: 0; display: inline; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person b { display: block; font-weight: 500; }
.person span { color: var(--ink-3); font-size: 12.5px; }
.scroll-x { overflow-x: auto; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline-form .field { flex: 1 1 200px; }

/* ---------- branding ---------- */
.logo-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-box { width: 132px; height: 72px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; display: grid; place-items: center; overflow: hidden; }
.logo-box img { max-width: 112px; max-height: 56px; object-fit: contain; }
.logo-box span { color: #8a929e; font-size: 12px; }
.color-row { display: flex; gap: 10px; align-items: center; }
.color-row input[type=color] { width: 44px; height: 38px; padding: 2px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; }
.preview-cta { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 999px; color: #fff; font-weight: 600; font-size: 13px; }

/* ---------- auth & public ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px max(16px, env(safe-area-inset-left, 0px)); }
.auth-card { width: min(420px, 100%); display: grid; gap: 20px; }
.auth-card .card { padding: 26px; }
.auth-card .brand { justify-content: center; font-size: 17px; }
.auth-card h1 { font-size: 20px; text-align: center; }
.auth-card .alt { text-align: center; color: var(--ink-2); font-size: 13.5px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .overview, .two { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .frame { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { display: none; }
  .org-switch { flex: 1 1 200px; }
  .nav { grid-auto-flow: column; overflow-x: auto; flex: 1 1 100%; }
  .nav a { white-space: nowrap; }
  .side-foot { display: none; }
  .row, .share-grid { grid-template-columns: 1fr; }
  .main { padding-top: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- link & contents editor ---------- */
.wrap.wide { max-width: 1480px; }
.ed { display: grid; grid-template-columns: 132px minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.ed-pages { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; display: grid; gap: 10px; padding-right: 4px; }
.ed-thumb { position: relative; display: grid; gap: 4px; padding: 4px; border: 1.5px solid transparent; border-radius: 8px; background: none; cursor: pointer; font: inherit; color: var(--ink-2); text-align: left; }
.ed-thumb img { width: 100%; display: block; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.ed-thumb span { font-size: 11.5px; font-family: var(--mono); }
.ed-thumb .ed-count { position: absolute; top: 8px; right: 8px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font: 600 11px/20px var(--font); text-align: center; }
.ed-thumb.on { border-color: var(--accent); color: var(--ink); background: var(--panel); }
.ed-stage { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; position: sticky; top: 16px; }
.ed-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.ed-toolbar .num { min-width: 92px; text-align: center; font-weight: 500; }
.ed-hint { margin-left: auto; color: var(--ink-3); font-size: 12.5px; }
.ed-canvas { display: grid; place-items: center; background: color-mix(in srgb, var(--ink) 5%, var(--bg)); border-radius: 10px; padding: 18px; min-height: 360px; }
.ed-page { position: relative; width: 100%; max-width: 100%; box-shadow: 0 2px 6px rgba(0,0,0,.12), 0 18px 40px -20px rgba(0,0,0,.45); cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; background: #fff; }
.ed-page img { display: block; width: 100%; height: 100%; pointer-events: none; }
.ed-box { position: absolute; border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 3px; cursor: move; }
.ed-box.auto { border-style: dashed; }
.ed-box.off { border-color: #8a929e; background: rgba(138, 146, 158, .14); }
.ed-box.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 24%, transparent); }
.ed-box .tag { position: absolute; left: -2px; top: -22px; max-width: 220px; padding: 2px 6px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); font: 600 10.5px/16px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.ed-box.off .tag { background: #8a929e; color: #fff; }
.ed-box .h { position: absolute; width: 11px; height: 11px; background: #fff; border: 2px solid var(--accent); border-radius: 3px; }
.ed-box .h.nw { left: -6px; top: -6px; cursor: nwse-resize; } .ed-box .h.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.ed-box .h.sw { left: -6px; bottom: -6px; cursor: nesw-resize; } .ed-box .h.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.ed-box:not(.sel) .h { display: none; }
.ed-draft { position: absolute; border: 2px dashed var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); pointer-events: none; }
.ed-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.ed-tabs { display: flex; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.ed-tabs button { flex: 1; padding: 9px 8px; border: 0; border-bottom: 2px solid transparent; background: none; font: inherit; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.ed-tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.ed-tabpanel { padding: 16px; overflow-y: auto; display: grid; gap: 14px; align-content: start; }
.ed-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ed-item { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; background: none; font: inherit; text-align: left; color: var(--ink); width: 100%; }
.ed-item:hover { background: var(--bg); }
.ed-item .ic { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.ed-item .ic svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ed-item b { display: block; font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-item small { display: block; color: var(--ink-3); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-item.off { opacity: .55; }
.ed-sect { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.ed-badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ed-save { font-size: 12.5px; color: var(--ink-3); align-self: center; }
.ed-save.busy { color: var(--warn); } .ed-save.bad { color: var(--bad); }
.toc-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.toc-row .input { height: 34px; }
.toc-row .tools { display: flex; gap: 0; }
.toc-row .tools button { width: 26px; height: 30px; border: 0; background: none; color: var(--ink-3); cursor: pointer; border-radius: 6px; font-size: 15px; }
.toc-row .tools button:hover { background: var(--bg); color: var(--ink); }
@media (max-width: 1100px) { .ed { grid-template-columns: minmax(0, 1fr) 300px; } .ed-pages { display: none; } }
@media (max-width: 820px) { .ed { grid-template-columns: 1fr; } .ed-stage, .ed-panel { position: static; max-height: none; } .ed-hint { display: none; } }

/* ---------- plans & billing ---------- */
.plan-tag { display: inline-flex; align-items: center; height: 19px; padding: 0 7px; border-radius: 99px; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-2); vertical-align: 1px; }
.plan-tag.pro { background: var(--accent-soft); color: var(--accent); }
.plan-tag.unlimited { background: #f3ecfd; color: #6a3fb5; }
.nav a .plan-tag { margin-left: auto; }
.choice label.locked { cursor: default; opacity: .75; }
.upsell { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: linear-gradient(120deg, var(--accent-soft), var(--panel) 70%); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.upsell .sub { margin: 4px 0 0; }

.usage { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 28px; align-items: center; }
.usage-plan { display: grid; gap: 6px; justify-items: start; }
.usage-plan b { font-size: 30px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.usage-plan b small { font-size: 14px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.usage-plan .muted { font-size: 13px; }
.meters { display: grid; gap: 16px; }
.meter { display: grid; gap: 7px; }
.meter-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.meter-head b { font-weight: 600; }
.progress.full i { background: var(--warn); }

.plans-form { display: grid; gap: 18px; }
.plans-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.interval { display: inline-flex; padding: 3px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.interval input { position: absolute; opacity: 0; pointer-events: none; }
.interval label { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 99px; font-weight: 500; font-size: 13px; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s; }
.interval input:checked + label { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(20, 26, 36, .1), 0 2px 8px -2px rgba(20, 26, 36, .1); }
.interval input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; }
.interval .save { font-size: 11px; font-weight: 600; color: var(--ok); background: var(--ok-soft); padding: 1px 7px; border-radius: 99px; }

.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.plan { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 24px 22px 22px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.plan.featured { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 1px 2px rgba(20,26,36,.04), 0 24px 48px -28px color-mix(in srgb, var(--accent) 60%, transparent); }
.plan.wanted { outline: 2px solid var(--accent); outline-offset: 2px; }
.plan.current { background: color-mix(in srgb, var(--accent) 3%, var(--panel)); }
.plan-flag { position: absolute; top: -11px; left: 22px; height: 22px; padding: 0 10px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; }
.plan.current .plan-flag { background: var(--ink); color: var(--panel); }
.plan h3 { font-size: 17px; }
.plan-tagline { color: var(--ink-2); font-size: 13.5px; min-height: 2.9em; }
.price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 4px 0 6px; }
.price b { font-size: 38px; font-weight: 600; letter-spacing: -.04em; line-height: 1; }
.price span { color: var(--ink-3); font-size: 13px; }
.plan-feats { list-style: none; margin: 4px 0 14px; padding: 14px 0 0; border-top: 1px solid var(--line); display: grid; gap: 9px; flex: 1; align-content: start; }
.plan-feats li { display: grid; grid-template-columns: 18px 1fr; gap: 9px; font-size: 13.5px; color: var(--ink-2); }
.plan-feats svg { width: 17px; height: 17px; stroke: var(--accent); fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; margin-top: 1px; }
.plan-btn { width: 100%; height: 40px; }
.plans-foot { text-align: center; }
/* monthly / yearly prices follow the toggle */
.p-year { display: none; }
:has(> .plans-head #iv-year:checked) .p-year { display: flex; }
:has(> .plans-head #iv-year:checked) .p-month { display: none; }
.when-diff { display: none; }
.plans-form[data-cur="month"]:has(#iv-year:checked) .when-diff,
.plans-form[data-cur="year"]:has(#iv-month:checked) .when-diff { display: inline-flex; }
.plans-form[data-cur="month"]:has(#iv-year:checked) .when-same,
.plans-form[data-cur="year"]:has(#iv-month:checked) .when-same { display: none; }

@media (max-width: 960px) {
  .plan-grid { grid-template-columns: minmax(0, 1fr); max-width: 480px; }
  .usage { grid-template-columns: 1fr; gap: 20px; }
}
