/* Accent palettes. --a is the fill (white text sits on it), --a-lt is the accent used as text on dark surfaces. */
:root { --a: #5b4ad8; --a-lt: #a99bff; }
:root[data-accent="indigo"] { --a: #3f5bd8; --a-lt: #93a8ff; }
:root[data-accent="ocean"] { --a: #0f73b8; --a-lt: #6cc0f5; }
:root[data-accent="teal"] { --a: #0a7576; --a-lt: #4fd1c5; }
:root[data-accent="emerald"] { --a: #16804f; --a-lt: #5fd39a; }
:root[data-accent="rose"] { --a: #c2336b; --a-lt: #ff8fb6; }
:root[data-accent="amber"] { --a: #a85a00; --a-lt: #ffb760; }
:root[data-accent="graphite"] { --a: #3d4452; --a-lt: #c3c9d6; }

/* ADOBEA: clean, flat surfaces with one accent colour. Every rule reads tokens; themes only change tokens. */
:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f7f7fc;
  --line: #e7e8f1;
  --ink: #1d1e2c;
  --ink-2: #4a4c5e;
  --muted: #6c6f84;
  --accent-fill: var(--a);
  --accent: var(--a);
  --accent-ink: #fff;
  --accent-grad: linear-gradient(135deg, color-mix(in srgb, var(--accent-fill) 88%, #fff), var(--accent-fill));
  --accent-soft: color-mix(in srgb, var(--accent-fill) 10%, transparent);
  --accent-deep: color-mix(in srgb, var(--accent-fill) 72%, #0b0b1a);
  --chart: var(--accent);
  --chart-zero: #e2e3ec;
  --danger: #d03a52;
  --paper: #ffffff;
  --paper-ink: #1d1d22;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(22, 22, 60, 0.04), 0 10px 30px rgba(32, 32, 90, 0.07);
  --shadow-sm: 0 1px 2px rgba(22, 22, 60, 0.05), 0 4px 12px rgba(32, 32, 90, 0.06);
  --shadow-accent: 0 6px 16px color-mix(in srgb, var(--accent-fill) 30%, transparent);
  --glass: var(--surface);
  --glass-strong: var(--surface);
  --glass-line: var(--line);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: var(--sans);
  --hl-yellow: #ffe680;
  --hl-green: #b9f0c4;
  --hl-pink: #ffc7e3;
  --hl-blue: #c4dcff;
  --deco-1: #22c58b;
  --deco-2: #38bdf8;
  --deco-3: #f59e0b;
  --deco-4: #f472b6;
  color-scheme: light;
}
:root[data-font="rounded"] { --sans: ui-rounded, "SF Pro Rounded", "Nunito", -apple-system, "Segoe UI", sans-serif; --display: var(--sans); }
:root[data-font="classic"] { --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
:root[data-scale="small"] { font-size: 15px; }
:root[data-scale="large"] { font-size: 17.5px; }
:root.sepia {
  --bg: #f1e8d6;
  --surface: #fbf6ec;
  --surface-2: #f6eedd;
  --line: #e3d6bd;
  --ink: #3b2e22;
  --ink-2: #5d4a38;
  --muted: #7a664f;
  --paper: #fbf3e2;
  --paper-ink: #3b2e22;
  --chart-zero: #e6d9c0;
  --shadow: 0 1px 2px rgba(80, 50, 20, 0.05), 0 10px 30px rgba(80, 50, 20, 0.08);
  --shadow-sm: 0 1px 2px rgba(80, 50, 20, 0.06), 0 4px 12px rgba(80, 50, 20, 0.07);
}
:root.dark {
  --bg: #101118;
  --surface: #181a24;
  --surface-2: #1f2130;
  --line: #2a2d3d;
  --ink: #ececf4;
  --ink-2: #b8bacb;
  --muted: #8d90a6;
  --accent: var(--a-lt);
  --accent-soft: color-mix(in srgb, var(--a-lt) 14%, transparent);
  --accent-deep: color-mix(in srgb, var(--accent-fill) 60%, #000);
  --chart-zero: #2c2f40;
  --paper: #1b1d27;
  --paper-ink: #e6e9f0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
  --hl-yellow: rgba(255, 214, 64, 0.38);
  --hl-green: rgba(90, 220, 130, 0.32);
  --hl-pink: rgba(255, 110, 190, 0.32);
  --hl-blue: rgba(100, 160, 255, 0.36);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans); color: var(--ink); font-size: 0.906rem; line-height: 1.45; min-height: 100vh; background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h2 { font-size: 1.12rem; }
h3 { font-size: 0.98rem; }
kbd { font: 600 0.75em var(--sans); background: var(--glass-strong); border: 1px solid var(--line); border-radius: 5px; padding: 0.1em 0.4em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Controls */
button, .button-like, input, select, textarea { font: inherit; color: inherit; }
button, .button-like, summary {
  border: 1px solid var(--line); background: var(--glass-strong); border-radius: 12px; padding: 0.5em 0.95em;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.35em; white-space: nowrap; transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
}
button:hover:not(:disabled), .button-like:hover, summary:hover { box-shadow: var(--shadow-sm); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent-grad); border-color: transparent; color: var(--accent-ink); box-shadow: var(--shadow-accent); }
button.danger, .danger { color: var(--danger); }
input, select, textarea { border: 1px solid var(--line); background: var(--glass-strong); border-radius: 12px; padding: 0.55em 0.75em; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input[type="color"] { padding: 3px; height: 2.4em; }
label { display: flex; flex-direction: column; gap: 0.3em; font-size: 0.86rem; color: var(--ink-2); }
label.check { flex-direction: row; align-items: center; gap: 0.5em; }
.hint { color: var(--muted); font-size: 0.84rem; }
.ok { color: #2c9a5b; }
.row { display: flex; gap: 0.5em; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > label { flex: 1 1 180px; }
.row.small button { font-size: 0.8rem; padding: 0.3em 0.65em; border-radius: 9px; }
.stack { display: flex; flex-direction: column; gap: 0.8em; }
.grow { flex: 1; }
.card, .glass { background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }
.pill { display: inline-block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.15em 0.6em; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.round { width: 36px; height: 36px; padding: 0; border-radius: 50%; justify-content: center; font-size: 1.1rem; }
.round svg { width: 17px; height: 17px; }
.round.primary svg { stroke: #fff; }
.round.big { width: 54px; height: 54px; }
.round.big svg { width: 22px; height: 22px; }
.round.ghost { background: transparent; border-color: transparent; color: inherit; }
.icon-btn { width: 42px; height: 42px; padding: 0; justify-content: center; border-radius: 13px; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.primary svg { stroke: #fff; stroke-width: 2.2; }

/* Menus built from <details> */
details.menu, details.book-menu { position: relative; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; min-width: 210px; display: flex; flex-direction: column; padding: 6px; gap: 2px;
  background: var(--glass-strong); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
details.menu:not([open]) .menu-list, details.book-menu:not([open]) .menu-list { display: none; }
.menu-list button { border: 0; background: none; justify-content: space-between; border-radius: 9px; text-align: left; width: 100%; box-shadow: none; }
.menu-list button:hover { background: var(--accent-soft); box-shadow: none; }
.swatches .sw { width: 16px; height: 16px; border-radius: 5px; display: inline-block; border: 1px solid var(--line); margin-right: auto; order: -1; }
.swatches button { justify-content: flex-start; gap: 0.6em; }
.sw.hl-yellow { background: var(--hl-yellow); } .sw.hl-green { background: var(--hl-green); } .sw.hl-pink { background: var(--hl-pink); } .sw.hl-blue { background: var(--hl-blue); }

/* ---------- Workspace top bar and tabs ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: 0.6rem 1.4rem;
  background: var(--glass); border-bottom: 1px solid var(--line); }
body.on-dashboard .topbar { display: none; }
.brand { background: none; border: 0; box-shadow: none !important; font-family: var(--display); font-weight: 700; letter-spacing: 0.16em; font-size: 1rem; padding: 0.2em 0; }
.brand img { width: 28px; height: 28px; }
.project-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state { margin-left: auto; font-size: 0.8rem; color: var(--muted); }
.top-btn { padding: 0.4em 0.8em; font-size: 0.85rem; }

.tabs { display: flex; gap: 0.3rem; padding: 0.6rem 1.4rem 0.2rem; position: sticky; top: 55px; z-index: 5; background: var(--glass); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button, .type-tabs button { border: 0; background: none; box-shadow: none !important; padding: 0.5em 0.9em 0.75em; color: var(--muted); position: relative; font-weight: 500; }
.tabs button[aria-selected="true"], .type-tabs button.active { color: var(--ink); font-weight: 600; }
.tabs button[aria-selected="true"]::after, .type-tabs button.active::after { content: ""; position: absolute; left: 50%; bottom: 0.15em; width: 22px; height: 3px; margin-left: -11px; border-radius: 3px; background: var(--accent); }
.tabs button:hover, .type-tabs button:hover { color: var(--ink); }
.view { padding: 1.6rem; max-width: 1240px; margin: 0 auto; }

/* ---------- Dashboard ---------- */
.dash { display: grid; grid-template-columns: 248px minmax(0, 1fr) 340px; min-height: 100vh; max-width: 1640px; margin: 0 auto; gap: 0; }
.dash > * { min-width: 0; }
.dash-side { margin: 16px 0 16px 16px; padding: 24px 0 18px; display: flex; flex-direction: column; position: sticky; top: 16px; height: calc(100vh - 32px); align-self: start; border-radius: 24px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.dash-main { padding: 28px 32px 40px; }
.dash-right { padding: 28px 24px 24px 4px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; overflow: auto; align-self: start; }
.dash-right > .activity { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.dash-brand { display: flex; align-items: center; gap: 12px; padding: 0 22px 26px; }
.dash-brand img { width: 38px; height: 38px; border-radius: 12px; background: #fff; padding: 4px; }
.dash-brand b { display: block; font-family: var(--display); font-weight: 700; letter-spacing: 0.14em; font-size: 1.02rem; }
.dash-brand small { display: block; font-size: 0.72rem; opacity: 0.75; }
.nav-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 0 26px 8px; margin: 0; opacity: 0.7; }
.side-nav { display: flex; flex-direction: column; gap: 4px; padding: 0 14px; }
.side-nav button { border: 0; background: none; box-shadow: none !important; justify-content: flex-start; gap: 12px; padding: 10px 12px; color: var(--ink-2); border-radius: 12px; font-weight: 500; width: 100%; }
.side-nav .ico { width: 22px; height: 22px; display: grid; place-items: center; flex: none; }
.side-nav .ico svg { width: 19px; height: 19px; }
.side-nav button:hover { background: var(--surface-2); color: var(--ink); }
.side-nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-spacer { flex: 1; min-height: 16px; }

/* Coloured sidebar (the default): a deep accent panel with a white pill for the active item. */
:root[data-sidebar="colour"] .dash-side { background: linear-gradient(170deg, var(--accent-fill), var(--accent-deep)); border-color: transparent; color: #fff; box-shadow: var(--shadow-accent); }
:root[data-sidebar="colour"] .side-nav button { color: rgba(255, 255, 255, 0.86); }
:root[data-sidebar="colour"] .side-nav button:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
:root[data-sidebar="colour"] .side-nav button.active { background: #fff; color: var(--a); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14) !important; }
:root[data-sidebar="colour"] .profile-card { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.18); color: #fff; }
:root[data-sidebar="colour"] .profile-card .pc-role { color: rgba(255, 255, 255, 0.75); }
:root[data-sidebar="colour"] .profile-card .pc-btn { background: #fff; color: var(--a); border-color: transparent; }
:root[data-sidebar="colour"] .goal-card { background: rgba(255, 255, 255, 0.12); color: #fff; }
:root[data-sidebar="colour"] .goal-card .hint { color: rgba(255, 255, 255, 0.78); }
:root[data-sidebar="colour"] .goal-bar { background: rgba(255, 255, 255, 0.25); }
:root[data-sidebar="colour"] .goal-bar div { background: #fff; }

/* Profile and goal cards at the foot of the sidebar */
.goal-card { margin: 0 14px 12px; padding: 14px; border-radius: 16px; background: var(--surface-2); }
.goal-card p { margin: 0; }
.goal-card b { font-size: 1.05rem; }
.goal-bar { height: 6px; border-radius: 4px; background: var(--chart-zero); margin: 8px 0 4px; overflow: hidden; }
.goal-bar div { height: 100%; border-radius: 4px; background: var(--accent-fill); }
.profile-card { margin: 0 14px; display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); }
.pc-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pc-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-role { font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-btn { padding: 0.3em 0.6em; font-size: 0.75rem; border-radius: 9px; }
.me { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden; color: #fff; font-weight: 700; font-size: 0.9rem;
  background: linear-gradient(135deg, hsl(var(--h, 250) 70% 60%), hsl(calc(var(--h, 250) + 40) 65% 42%)); border: 2px solid var(--surface); }
.me img { width: 100%; height: 100%; object-fit: cover; }
.me.sm { width: 30px; height: 30px; font-size: 0.72rem; border-width: 0; }
.me.lg { width: 84px; height: 84px; font-size: 1.6rem; }
.me-btn { padding: 2px; border-radius: 50%; border: 0; background: none; box-shadow: none !important; }

/* Greeting and stat tiles */
.dash-hello { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.dash-hello > div:first-child { flex: 1 1 260px; min-width: 0; }
.dash-hello .grow { display: none; }
.dash-hello .search { min-width: 0; flex: 0 1 240px; }
.dash-hello > button, .dash-hello .sync-state { flex: none; }
@media (min-width: 901px) { .dash-hello { flex-wrap: nowrap; } }
.dash-hello h1 { font-family: var(--display); font-size: 1.7rem; margin: 0; letter-spacing: -0.02em; }
.dash-hello p { margin: 4px 0 0; color: var(--muted); }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 30px; }
.tile { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.tile-ico { width: 48px; height: 48px; border-radius: 14px; flex: none; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.tile-ico svg { width: 22px; height: 22px; }
.tile b { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tile span { font-size: 0.8rem; color: var(--muted); }
.new-btn { padding: 0.65em 1.1em; border-radius: 12px; font-weight: 600; }
.new-btn svg { width: 17px; height: 17px; stroke-width: 2.2; }

.dash-top { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; flex-wrap: wrap; }
.type-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.search { flex-direction: row; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; min-width: 240px; }
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input { border: 0; background: none; padding: 0.7em 0; outline: none; box-shadow: none; }
.search:focus-within { outline: 2px solid var(--accent); }

.dash-block { margin-bottom: 30px; }
.block-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.block-head h2, .dash-h { margin: 0; font-size: 1.15rem; }
.dash-h { margin-bottom: 14px; }
.block-head .dash-h { margin: 0; }
.count { font-size: 0.78rem; font-weight: 600; color: var(--muted); background: var(--glass-strong); border: 1px solid var(--line); border-radius: 99px; padding: 0.1em 0.6em; vertical-align: middle; margin-left: 4px; }
.arrows { display: flex; gap: 8px; }
.arrows .round { width: 30px; height: 30px; font-size: 1.15rem; line-height: 1; }
.sort { flex-direction: row; align-items: center; gap: 8px; }
.sort select { width: auto; padding: 0.35em 0.6em; }
.dash-title { font-size: 1.6rem; }

.welcome { padding: 2.2rem; margin-bottom: 26px; background: linear-gradient(120deg, var(--accent-soft), transparent 70%), var(--surface); }
.welcome h1 { font-size: 2.1rem; margin: 0.2em 0 0.4em; }
.welcome em, .continue-card em { font-style: normal; color: var(--accent); }
.kicker { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem; font-weight: 600; color: var(--muted); margin: 0; }

/* Characters: round avatars */
.char-row { display: flex; gap: 18px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: thin; }
.char { flex-direction: column; border: 0; background: none; box-shadow: none !important; padding: 0; gap: 6px; width: 74px; }
.avatar { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: 0.02em;
  background: linear-gradient(135deg, hsl(var(--h) 75% 62%), hsl(calc(var(--h) + 50) 70% 42%)); box-shadow: 0 6px 16px hsla(var(--h), 70%, 40%, 0.35); border: 3px solid var(--glass-strong); }
.char-name { font-size: 0.8rem; font-weight: 600; color: var(--ink); max-width: 74px; overflow: hidden; text-overflow: ellipsis; }
.char-book { font-size: 0.68rem; color: var(--muted); max-width: 74px; overflow: hidden; text-overflow: ellipsis; margin-top: -4px; }

/* Covers */
.cover-thumb { aspect-ratio: 2 / 3; width: 100%; border-radius: 16px; overflow: hidden; position: relative; display: block; }
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-thumb.gen { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 14% 10%; color: #fff; gap: 0.5em;
  background: radial-gradient(120% 80% at 20% 10%, hsl(calc(var(--h) + 30) 85% 70% / 0.9), transparent 60%), linear-gradient(160deg, hsl(var(--h) 70% 52%), hsl(calc(var(--h) + 40) 65% 30%)); }
.cover-thumb.gen.frame::before { content: ""; position: absolute; inset: 7%; border: 1.5px solid rgba(255, 255, 255, 0.7); border-radius: 8px; }
.cover-thumb.gen.band::before { content: ""; position: absolute; left: 0; right: 0; top: 38%; height: 30%; background: rgba(0, 0, 0, 0.22); }
.g-type { position: relative; font-size: 0.6rem; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.85; }
.g-title { position: relative; font-family: var(--serif); font-size: 1.25rem; line-height: 1.12; font-weight: 600; text-wrap: balance; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); }
.g-rule { position: relative; width: 26px; height: 2px; background: rgba(255, 255, 255, 0.8); border-radius: 2px; }
.g-author { position: relative; font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; }
.cover-thumb.xs, .cover-thumb.xxs { border-radius: 50%; aspect-ratio: 1; padding: 0; }
.cover-thumb.xs > span, .cover-thumb.xxs > span, .cover-thumb.wide > .g-type, .cover-thumb.wide > .g-author { display: none; }
.cover-thumb.wide { justify-content: flex-start; align-items: flex-start; text-align: left; padding: 18px; }
.cover-thumb.wide { aspect-ratio: auto; height: 100%; border-radius: 20px; }
.cover-thumb.fill { aspect-ratio: auto; height: 100%; border-radius: 0; }
.cover-thumb.fill > span { display: none; }
.cover-thumb.lg .g-title { font-size: 1.5rem; }

/* Book cards */
.book-row { display: grid; grid-auto-flow: column; grid-auto-columns: 172px; gap: 26px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 4px 16px; scrollbar-width: thin; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 26px 22px; }
.book { scroll-snap-align: start; min-width: 0; }
.book-cover { position: relative; }
.cover-btn { padding: 0; border: 0; background: none; border-radius: 16px; width: 100%; display: block; box-shadow: 0 12px 26px rgba(30, 40, 80, 0.22); transition: transform 0.18s, box-shadow 0.18s; }
.cover-btn:hover { transform: translateY(-4px); box-shadow: 0 18px 34px rgba(30, 40, 80, 0.28) !important; }
.book-menu { position: absolute !important; top: 8px; right: 8px; }
.book-menu summary { width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: 50%; background: rgba(255, 255, 255, 0.85); color: #222; border: 0; opacity: 0; font-weight: 700; }
.book:hover .book-menu summary, .book-menu[open] summary, .book-menu summary:focus-visible { opacity: 1; }
.book-info { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; }
.book-info > div { flex: 1; min-width: 0; }
.book h3 { font-size: 0.92rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book .by { margin: 2px 0 0; font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book .meta { margin: 6px 0 0; font-size: 0.75rem; color: var(--muted); }
.heart { border: 0; background: none; box-shadow: none !important; padding: 2px; color: var(--muted); }
.heart svg { width: 19px; height: 19px; }
.heart.on { color: #ef5a5a; }
.heart.on svg { fill: currentColor; }

/* Recently edited */
.recent { display: grid; grid-template-columns: 200px 1fr; gap: 18px; }
.recent-big { padding: 0; border: 0; border-radius: 20px; height: 176px; position: relative; overflow: hidden; box-shadow: 0 12px 26px rgba(30, 40, 80, 0.22); }
.recent-big .cover-thumb .g-title { font-size: 1.3rem; }
.play-ring { position: absolute; right: 14px; bottom: 14px; width: 46px; height: 46px; border-radius: 50%; background: rgba(20, 24, 34, 0.55); display: grid; place-items: center; color: #fff; }
.play-ring svg { width: 19px; height: 19px; }
.recent-list { display: flex; flex-direction: column; gap: 12px; }
.recent-item { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 18px; box-shadow: var(--shadow-sm); }
.disc { width: 44px; height: 44px; flex: none; border-radius: 50%; padding: 3px; background: #111; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25); }
.ri-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ri-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark { width: 66px; height: 22px; flex: none; }
.spark rect { fill: var(--chart); stroke: none; }
.spark rect.zero { fill: var(--chart-zero); }

/* Right column */
.activity h2 { font-size: 1.15rem; margin: 0; }
.week-card { margin: 14px 0 6px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hero-number { font-size: 1.6rem; font-weight: 700; margin: 0; }
.hero-number span { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.streak { font-size: 0.78rem; color: var(--ink-2); background: var(--accent-soft); padding: 0.2em 0.7em; border-radius: 99px; white-space: nowrap; }
.chart-box { position: relative; }
.week-chart { width: 100%; height: auto; display: block; overflow: visible; }
.week-chart .grid { stroke: var(--line); stroke-width: 1; }
.week-chart .yl, .week-chart .xl { fill: var(--muted); stroke: none; font-size: 10px; font-family: var(--sans); }
.week-chart .yl { text-anchor: end; }
.week-chart .xl { text-anchor: middle; }
.week-chart path { fill: var(--chart); stroke: none; }
.week-chart .hit { fill: transparent; stroke: none; }
.week-chart .bar.on .hit { fill: var(--accent-soft); }
.chart-tip { position: absolute; transform: translate(-50%, -100%); background: var(--glass-strong); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 6px 10px; font-size: 0.8rem; pointer-events: none; white-space: nowrap; }
.chart-tip span { color: var(--muted); }
.activity-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.activity-list button { border: 0; background: none; box-shadow: none !important; width: 100%; padding: 8px 4px; gap: 12px; border-radius: 12px; }
.activity-list button:hover { background: var(--accent-soft); }
.ring { width: 44px; height: 44px; border-radius: 50%; padding: 3px; flex: none; background: conic-gradient(hsl(var(--h) 80% 60%), hsl(calc(var(--h) + 90) 80% 60%), hsl(var(--h) 80% 60%)); }
.ring .cover-thumb { border: 2px solid var(--glass-strong); }
.act-text { display: flex; flex-direction: column; flex: 1; min-width: 0; text-align: left; }
.act-text b { font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-text .hint { font-size: 0.75rem; }

.continue-card { position: relative; border-radius: 24px; overflow: hidden; min-height: 400px; display: flex; flex-direction: column; justify-content: flex-end; box-shadow: var(--shadow); flex: none; }
.cc-art { position: absolute; inset: 0; }
.cc-panel { position: relative; margin: 12px; padding: 18px 18px 14px; border-radius: 20px; text-align: center; color: #fff;
  background: rgba(14, 14, 28, 0.78); border: 1px solid rgba(255, 255, 255, 0.2); }
.cc-panel .kicker { color: rgba(255, 255, 255, 0.75); }
.cc-panel h2 { margin: 6px 0 4px; font-size: 1.2rem; }
.cc-sub { margin: 0 0 14px; font-size: 0.8rem; color: rgba(255, 255, 255, 0.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-progress { position: relative; height: 4px; background: rgba(255, 255, 255, 0.3); border-radius: 4px; }
.cc-progress div { height: 100%; border-radius: 4px; background: #fff; }
.cc-progress span { position: absolute; top: 50%; width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 3px solid var(--a-lt); transform: translate(-50%, -50%); }
.cc-times { display: flex; justify-content: space-between; font-size: 0.72rem; color: rgba(255, 255, 255, 0.8); margin: 8px 0 6px; }
.cc-controls { display: flex; align-items: center; justify-content: center; gap: 22px; }
.cc-controls .ghost { color: #fff; }
.cc-controls .ghost svg { width: 18px; height: 18px; fill: currentColor; }

/* Journal */
.journal-grid { display: grid; grid-template-columns: 260px 1fr; gap: 20px; margin-top: 16px; }
.journal-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow: auto; }
.journal-list button { width: 100%; flex-direction: column; align-items: flex-start; white-space: normal; text-align: left; gap: 2px; border-radius: 14px; }
.journal-list button.active { background: var(--accent-soft); border-color: var(--accent); }
.journal-prompt { display: flex; gap: 12px; align-items: center; background: var(--accent-soft); border-radius: 14px; padding: 10px 14px; margin-bottom: 12px; }
.journal-prompt p { margin: 0; flex: 1; font-family: var(--serif); font-size: 1.05rem; font-style: italic; }
#journal-moods { margin-bottom: 12px; }
#journal-moods button { border-radius: 99px; padding: 0.3em 0.9em; font-size: 0.82rem; }
#journal-moods button.active { background: var(--accent-grad); color: #fff; border-color: transparent; }
#journal-text { font-family: var(--serif); font-size: 1.05rem; line-height: 1.7; }

/* New book dialog */
.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.6rem; }
.new-dialog { max-width: 860px; }
.type-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5em; }
.type-pick label { position: relative; }
.type-pick input { position: absolute; opacity: 0; }
.type-pick span { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; padding: 0.65em 0.8em; cursor: pointer; color: var(--muted); font-size: 0.8rem; background: var(--glass-strong); }
.type-pick b { color: var(--ink); font-size: 0.95rem; }
.type-pick input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.type-pick input:focus-visible + span { outline: 2px solid var(--accent); }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 2.4rem 1rem; text-align: center; align-items: center; cursor: pointer; color: var(--ink-2); transition: background 0.15s; background: var(--glass-strong); }
.dropzone strong { font-size: 1.1rem; color: var(--ink); }
.dropzone small { color: var(--muted); margin-top: 0.6em; max-width: 30em; }
.dropzone.over, .dropzone:hover { background: var(--accent-soft); border-color: var(--accent); }

/* Review */
.review-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.review-head p { color: var(--ink-2); margin: 0; }
.review-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.2rem; align-items: start; }
.review-list { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-direction: column; gap: 0.6rem; }
.review-list li { border: 1px solid var(--line); border-radius: 14px; padding: 0.8rem 0.9rem; background: var(--glass-strong); }
.review-list li.is-divider { background: var(--accent-soft); }
.review-list .r-title { font-family: var(--serif); font-size: 1.02rem; }
.review-list .r-kind { width: 120px; flex: none; }
.review-list .row .hint { white-space: nowrap; }
.r-snip { margin: 0.45em 0; font-size: 0.85rem; color: var(--muted); font-family: var(--serif); }
.report ul { padding-left: 1.1em; margin: 0; display: flex; flex-direction: column; gap: 0.5em; font-size: 0.88rem; color: var(--ink-2); }
.report { position: sticky; top: 1.5rem; }

/* ---------- Write ---------- */
.workspace { max-width: none; padding: 0; }
.tab-panel { padding: 1.4rem; }
.tab-panel[data-panel="write"] { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1.2rem; padding: 0; min-height: calc(100vh - 100px); }
body.show-comments .tab-panel[data-panel="write"] { grid-template-columns: 280px minmax(0, 1fr) 300px; }
.comments-panel { display: none; }
body.show-comments .comments-panel { display: flex; }

.outline { border-right: 1px solid var(--line); background: var(--glass); padding: 1rem; display: flex; flex-direction: column; gap: 0.8rem; position: sticky; top: 100px; height: calc(100vh - 100px); overflow: auto; }
.outline-head { display: flex; flex-direction: column; gap: 0.5rem; }
.outline-head h2 { margin: 0; }
.outline-head .row button { font-size: 0.82rem; padding: 0.35em 0.7em; }
.outline-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow: auto; }
.outline-list li { display: flex; align-items: center; gap: 0.4em; padding: 0.45em 0.6em; border-radius: 10px; cursor: pointer; font-size: 0.9rem; border-top: 2px solid transparent; border-bottom: 2px solid transparent; }
.outline-list li:hover { background: var(--accent-soft); }
.outline-list li:focus-visible { outline: 2px solid var(--accent); }
.outline-list li.active { background: var(--accent-grad); color: #fff; box-shadow: var(--shadow-accent); }
.outline-list li.active .o-words, .outline-list li.active .grip { color: rgba(255, 255, 255, 0.8); }
.outline-list li.divider { font-weight: 700; margin-top: 0.4em; text-transform: uppercase; font-size: 0.76rem; letter-spacing: 0.07em; }
.outline-list li:not(.divider) { padding-left: 1em; }
.outline-list li.drop-before { border-top-color: var(--accent); }
.outline-list li.drop-after { border-bottom-color: var(--accent); }
.outline-list .grip { color: var(--muted); opacity: 0.5; cursor: grab; font-size: 0.75rem; }
.outline-list .fold { border: 0; background: none; box-shadow: none !important; padding: 0 0.2em; color: inherit; font-size: 0.8rem; }
.outline-list .o-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline-list .o-words { color: var(--muted); font-size: 0.75rem; font-weight: normal; }
.outline-list .o-del { border: 0; background: none; padding: 0 0.3em; color: inherit; visibility: hidden; font-size: 1rem; box-shadow: none !important; }
.outline-list li:hover .o-del { visibility: visible; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: transparent; border: 1.5px solid var(--muted); opacity: 0.6; }
.status-todo { background: #f2b544; border-color: #f2b544; opacity: 1; }
.status-draft { background: #4a9ef0; border-color: #4a9ef0; opacity: 1; }
.status-revised { background: #9b6ef0; border-color: #9b6ef0; opacity: 1; }
.status-final { background: #3cb878; border-color: #3cb878; opacity: 1; }
.stats { border-top: 1px solid var(--line); padding-top: 0.8rem; display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.85rem; }
.today-row { display: flex; justify-content: space-between; align-items: baseline; }
.stats .goal { flex-direction: row; align-items: center; }
.stats .goal input { width: 90px; padding: 0.25em 0.45em; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent-grad); width: 0; transition: width 0.3s; border-radius: 3px; }

.editor-wrap { display: flex; flex-direction: column; min-width: 0; padding: 0.8rem 0 3rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; position: sticky; top: 100px; z-index: 6; padding: 0.55rem 0.7rem; margin-right: 1.2rem;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 16px; box-shadow: var(--shadow-sm); }
.toolbar .section-title { width: auto; flex: 1 1 200px; font-weight: 600; margin: 0; }
.toolbar select { width: auto; }
.toolbar button, .toolbar summary { padding: 0.38em 0.7em; border-radius: 10px; font-size: 0.86rem; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 0.2rem; }
.section-words { color: var(--muted); font-size: 0.8rem; }
.wc { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
body:not(.is-play) .script-only, body:not(.is-play) .play-only { display: none !important; }
.sprint-bar { display: flex; align-items: center; gap: 0.7rem; margin: 0.6rem 1.2rem 0 0; padding: 0.45rem 0.8rem; border-radius: 14px; background: var(--accent-soft); font-variant-numeric: tabular-nums; font-size: 0.86rem; }
.sprint-progress { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.sprint-progress div { height: 100%; background: var(--accent-grad); }

.page-sheet { background: var(--paper); color: var(--paper-ink); box-shadow: var(--shadow); border-radius: 14px; max-width: 760px; width: 100%; margin: 1rem auto 0; padding: 3.5rem 4rem 5rem; min-height: 70vh; }
.editor { outline: none; font-family: var(--serif); font-size: 1.12rem; line-height: 1.75; min-height: 60vh; }
.editor p { margin: 0 0 0.9em; }
.editor > p:only-child:has(> br:only-child)::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; position: absolute; }
.editor blockquote { margin: 1em 2em; color: var(--ink-2); }
.editor img { max-width: 100%; display: block; margin: 1em auto; border-radius: 6px; }
.editor .scene-break { text-align: center; letter-spacing: 0.4em; color: var(--muted); }
.editor h2, .editor h3, .editor h4 { text-align: center; font-family: var(--serif); }
.editor ul, .editor ol { margin: 0 0 0.9em 1.4em; padding: 0; }
.editor .fn { display: inline-block; vertical-align: super; font-size: 0; width: 1.25rem; height: 1.25rem; margin: 0 1px; border-radius: 50%; background: var(--accent-soft); cursor: pointer; position: relative; top: -0.15em; }
.editor .fn::before { content: "†"; font: 600 0.75rem/1.25rem var(--sans); color: var(--accent); display: block; text-align: center; }
.editor .fn:hover::after { content: attr(data-preview); }
mark.hl { color: inherit; border-radius: 3px; padding: 0 1px; }
mark.hl-yellow { background: var(--hl-yellow); } mark.hl-green { background: var(--hl-green); } mark.hl-pink { background: var(--hl-pink); } mark.hl-blue { background: var(--hl-blue); }
mark.cmt { color: inherit; background: transparent; border-bottom: 2px solid #f0a53a; cursor: pointer; }
mark.cmt.active { background: rgba(240, 165, 58, 0.25); }
::highlight(adobea-mark) { background: rgba(255, 196, 0, 0.45); }
::highlight(adobea-fix) { background: rgba(74, 120, 238, 0.25); text-decoration: underline 2px var(--accent); }
/* Script lines in the editor */
.is-play .editor { font-family: "Courier Prime", "Courier New", Courier, monospace; font-size: 1rem; line-height: 1.45; }
.is-play .editor p { margin: 0 0 0.2em; position: relative; }
.editor .heading { text-transform: uppercase; font-weight: bold; margin-top: 1.4em !important; }
.editor .action { margin-top: 0.8em !important; }
.editor .character { text-transform: uppercase; margin: 1em 0 0 37% !important; }
.editor .paren { margin-left: 30% !important; }
.editor .dialogue { margin: 0 15% 0 22% !important; }
.editor .transition { text-transform: uppercase; text-align: right; margin-top: 1em !important; }
.is-play .editor p[class]::after { content: attr(class); position: absolute; right: calc(100% + 0.6rem); top: 0.2em; font-family: var(--sans); font-size: 0.6rem; color: var(--muted); opacity: 0.7; text-transform: uppercase; letter-spacing: 0.04em; font-weight: normal; white-space: nowrap; }
.is-play .editor p.scene-break::after { content: none; }
.is-poetry .editor p { margin-bottom: 1.2em; }

/* Comments */
.comments-panel { flex-direction: column; gap: 0.6rem; padding: 1rem; border-left: 1px solid var(--line); background: var(--glass); position: sticky; top: 100px; height: calc(100vh - 100px); overflow: auto; }
.comments-panel h2 { margin: 0; }
.comments-panel select { width: auto; padding: 0.3em 0.5em; font-size: 0.82rem; }
.comment-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.comment { background: var(--glass-strong); border: 1px solid var(--line); border-left: 3px solid #f0a53a; border-radius: 12px; padding: 0.7rem; cursor: pointer; }
.comment.active { box-shadow: 0 0 0 2px var(--accent); }
.comment.resolved { border-left-color: #3cb878; opacity: 0.8; }
.comment blockquote { margin: 0 0 0.4rem; font-family: var(--serif); font-size: 0.85rem; color: var(--ink-2); font-style: italic; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.comment textarea { font-size: 0.88rem; padding: 0.4em 0.55em; }
.comment .reply { margin: 0.4rem 0 0; font-size: 0.85rem; padding-left: 0.6rem; border-left: 2px solid var(--line); }
.comment .c-where { margin: 0 0 0.3rem; }
.comment .row { flex-wrap: wrap; }
.comment .row > .hint { flex-basis: 100%; }
.comment-list .empty { padding: 0.5rem; }

/* Focus mode */
body.focus-mode .topbar, body.focus-mode .tabs, body.focus-mode .outline, body.focus-mode .toolbar, body.focus-mode .comments-panel, body.focus-mode .sprint-bar { display: none !important; }
body.focus-mode .tab-panel[data-panel="write"] { grid-template-columns: 1fr !important; }
body.focus-mode .page-sheet { box-shadow: none; background: transparent; max-width: 720px; padding-top: 18vh; padding-bottom: 60vh; }
body.focus-mode .editor { font-size: 1.22rem; }
.focus-bar { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 0.8rem; padding: 0.5rem 0.7rem 0.5rem 1rem; font-size: 0.82rem; color: var(--ink-2);
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 99px; box-shadow: var(--shadow); opacity: 0.35; transition: opacity 0.2s; z-index: 40; }
.focus-bar:hover { opacity: 1; }
.focus-bar select { width: auto; padding: 0.25em 0.5em; border-radius: 99px; }
.focus-bar button { border-radius: 99px; padding: 0.3em 0.8em; }

/* Plan: corkboard and mind map */
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-line); margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.seg button { border: 0; background: none; box-shadow: none !important; border-radius: 10px; }
.seg button.active { background: var(--accent-grad); color: #fff; }
.plan-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.plan-head p { margin: 0; max-width: 46em; }
#board-filter button { border-radius: 99px; font-size: 0.8rem; padding: 0.3em 0.8em; }
#board-filter button.active { background: var(--accent-grad); color: #fff; border-color: transparent; }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.cardx { background: var(--glass-strong); border: 1px solid var(--line); border-top: 4px solid var(--muted); border-radius: 16px; padding: 0.8rem; display: flex; flex-direction: column; gap: 0.5rem; box-shadow: var(--shadow-sm); cursor: grab; }
.cardx.divider { grid-column: 1 / -1; background: var(--accent-soft); border-top-color: var(--accent); }
.cardx.status-todo { border-top-color: #f2b544; } .cardx.status-draft { border-top-color: #4a9ef0; } .cardx.status-revised { border-top-color: #9b6ef0; } .cardx.status-final { border-top-color: #3cb878; }
.cardx header { display: flex; gap: 0.5rem; align-items: center; }
.cardx .c-title { font-weight: 600; border: 0; background: transparent; padding: 0.2em 0; }
.cardx textarea { font-size: 0.86rem; font-family: var(--serif); background: transparent; }
.cardx footer { display: flex; gap: 0.5rem; }
.cardx footer select { font-size: 0.8rem; padding: 0.3em 0.5em; }
.cardx footer button { font-size: 0.8rem; padding: 0.3em 0.7em; }
.mindmap-wrap { overflow: auto; background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 60vh; }
.mindmap { position: relative; min-width: 100%; }
.mm-lines { position: absolute; left: 0; top: 0; pointer-events: none; }
.mm-lines path { stroke: var(--accent); stroke-width: 2; opacity: 0.45; fill: none; }
.mm-node { position: absolute; display: flex; align-items: center; gap: 4px; max-width: 200px; padding: 6px 12px; border-radius: 99px; background: var(--glass-strong); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-size: 0.9rem; }
.mm-node.depth-0 { background: var(--accent-grad); color: #fff; font-weight: 700; padding: 10px 18px; border: 0; box-shadow: var(--shadow-accent); }
.mm-node.depth-1 { font-weight: 600; }
.mm-node.sel { outline: 2px solid var(--accent); outline-offset: 2px; }
.mm-text { outline: none; min-width: 3ch; }
.mm-text:empty::before { content: "New idea"; color: var(--muted); }
.mm-fold { border: 0; padding: 0 0.4em; font-size: 0.72rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); box-shadow: none !important; }

/* Story bible */
.bible { display: grid; grid-template-columns: 300px 1fr; gap: 1.2rem; align-items: start; }
.bible-list { display: flex; flex-direction: column; gap: 0.7rem; position: sticky; top: 110px; max-height: calc(100vh - 130px); overflow: auto; }
.bible-list .row button { font-size: 0.8rem; padding: 0.35em 0.7em; }
.bible-list h3 { margin: 0.8rem 0 0.3rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.bible-list ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.bible-list li button { width: 100%; border: 0; background: none; box-shadow: none !important; justify-content: flex-start; border-radius: 10px; white-space: normal; text-align: left; }
.bible-list li button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ai-btn { justify-content: center; }
.bible-form h3 { margin-top: 1.2rem; }
.mentions { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.mentions button { font-size: 0.82rem; padding: 0.3em 0.7em; }

/* Check */
.checks-panel { display: grid; gap: 1.2rem; max-width: 1100px; margin: 0 auto; }
.check-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.check-head p { margin: 0; max-width: 40em; }
.check-head select { width: auto; }
.issues { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.8rem; }
.issue { background: var(--glass-strong); border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 14px; padding: 0.8rem 1rem; }
.issue.sev-high { border-left-color: #e0485f; } .issue.sev-medium { border-left-color: #f0a53a; } .issue.sev-low { border-left-color: #8a90a3; }
.issue header { display: flex; align-items: center; gap: 0.6rem; }
.issue.sev-high .pill { background: rgba(224, 72, 95, 0.14); color: #c63249; }
.issue.sev-medium .pill { background: rgba(240, 165, 58, 0.18); color: #b66f0b; }
.issue p { margin: 0.5rem 0; }
.issue .quote { display: block; width: 100%; text-align: left; white-space: normal; font-family: var(--serif); margin-top: 0.35rem; background: var(--accent-soft); border: 0; }
.issue .quote.other { background: transparent; border: 1px dashed var(--line); }
.issue .quote .hint { font-family: var(--sans); display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.issue .suggest { color: var(--ink-2); font-size: 0.88rem; }
.issue .suggest::before { content: "Fix: "; font-weight: 600; }
.issue .dismiss { font-size: 0.78rem; padding: 0.25em 0.6em; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.7rem; margin: 1rem 0; }
.metrics div { background: var(--glass-strong); border: 1px solid var(--line); border-radius: 14px; padding: 0.8rem; display: flex; flex-direction: column; }
.metrics b { font-size: 1.5rem; }
.metrics span { font-size: 0.78rem; color: var(--muted); }
.style-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0.8rem; }
.style-grid section { background: var(--glass-strong); border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem; }
.style-grid section.wide { grid-column: 1 / -1; }
.style-grid h3 { margin: 0 0 0.3rem; }
.style-grid p { margin: 0 0 0.5rem; }
.ex { display: block; width: 100%; text-align: left; white-space: normal; font-size: 0.84rem; margin-bottom: 0.3rem; font-family: var(--serif); border-radius: 10px; }
.words-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.words-cloud span { background: var(--accent-soft); border-radius: 99px; padding: 0.2em 0.7em; font-size: 0.85rem; }

/* Design */
.design { display: grid; grid-template-columns: minmax(380px, 560px) 1fr; gap: 1.2rem; align-items: start; }
.theme-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1.4rem; }
.theme { flex-direction: column; align-items: flex-start; text-align: left; white-space: normal; padding: 0.75em 0.85em; border-radius: 14px; }
.theme b { font-size: 1.1rem; font-weight: normal; }
.theme span { font-size: 0.78rem; color: var(--muted); }
.theme.active { border-color: var(--accent); background: var(--accent-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 0.8rem; }
.form-grid .check { grid-column: 1 / -1; }
.sample { position: sticky; top: 110px; }
.design-sample iframe { width: 100%; height: calc(100vh - 210px); border: 0; background: rgba(0, 0, 0, 0.06); border-radius: 12px; }

/* Cover */
.cover { display: grid; grid-template-columns: minmax(360px, 560px) 1fr; gap: 1.2rem; align-items: start; }
.cover .card > h2:not(:first-child) { margin-top: 1.4rem; }
.cover .check { margin: 0.8rem 0 0.2rem; }
.cover .form-grid { margin-bottom: 0.8rem; }
.cover-preview { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 420px; }
.cover-preview img { max-width: 100%; max-height: calc(100vh - 230px); box-shadow: 6px 10px 30px rgba(0, 0, 0, 0.35); border-radius: 4px 12px 12px 4px; }

.matter .card { max-width: 720px; margin: 0 auto; }
.matter h2:not(:first-child) { margin-top: 1rem; }

/* Preview */
.preview { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 100px); }
.preview-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; padding: 0.7rem 1.4rem; background: var(--glass); border-bottom: 1px solid var(--line); }
#preview-frame { flex: 1; width: 100%; border: 0; background: #57514b; }

/* Dialogs */
dialog { border: 1px solid var(--line); border-radius: 22px; padding: 1.5rem; max-width: 660px; width: 92vw; background: var(--glass-strong); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(16, 16, 36, 0.42); }
dialog > form[method="dialog"] { margin-top: 1rem; text-align: right; }
.versions-list, .split-list, .find-results, .proof-list { list-style: none; padding: 0; margin: 0; max-height: 55vh; overflow: auto; display: flex; flex-direction: column; gap: 0.4rem; }
.versions-list li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.8rem; }
.split-list li:empty { display: none; }
.split-list button, .find-results button { width: 100%; text-align: left; white-space: normal; font-family: var(--serif); font-size: 0.9rem; display: block; }
.find-results .hint { font-family: var(--sans); display: block; font-size: 0.72rem; }
.find-results mark { background: var(--hl-yellow); color: inherit; border-radius: 3px; }
.find-dialog .form-grid { margin-bottom: 0.7rem; }
.find-dialog .row { margin-bottom: 0.5rem; }
.find-dialog select { width: auto; }
.snippet-list { list-style: none; padding: 0; margin: 0.6rem 0 1rem; display: flex; flex-direction: column; gap: 0.4rem; max-height: 45vh; overflow: auto; }
.snippet-list li { display: flex; gap: 0.4rem; align-items: center; }
.snippet-list .sn-k, .snippet-list .ac-k { width: 140px; flex: none; font-family: ui-monospace, Menlo, monospace; }
.snippet-list button { padding: 0.3em 0.6em; }
.ac-rules { margin: 0.6rem 0 0.8rem 1.6rem; gap: 0.45rem; }
.proof-dialog { max-width: 760px; }
.proof-list li { border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.8rem; }
.proof-list label { align-items: flex-start; color: var(--ink); font-size: 0.92rem; }
.proof-list del { color: #c63249; text-decoration-thickness: 1.5px; }
.proof-list ins { color: #2c9a5b; text-decoration: none; font-weight: 600; }
.plain-list { padding-left: 1.2em; font-size: 0.9rem; }
.keys { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.keys td { padding: 0.45rem 0.3rem; border-bottom: 1px solid var(--line); }
.keys td:first-child { white-space: nowrap; width: 45%; }

.toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); background: #1d1e2c; color: #fff; padding: 0.75em 1.3em; border-radius: 14px; z-index: 100; max-width: 90vw; box-shadow: var(--shadow); }

@media (max-width: 1250px) {
  .dash { grid-template-columns: 230px minmax(0, 1fr); }
  .dash-right { grid-column: 2; position: static; height: auto; display: grid; grid-template-columns: 1fr 320px; padding: 0 32px 32px; }
  .continue-card { min-height: 340px; }
}
@media (max-width: 900px) {
  .dash { grid-template-columns: 1fr; }
  .dash-side { position: static; height: auto; margin: 10px 10px 0; padding: 12px 0; }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .side-nav button { width: auto; padding: 8px 14px; }
  .dash-right { grid-column: auto; padding: 0 18px 18px; }
  .dash-brand, .goal-card, .nav-label, .side-spacer { display: none; }
  .profile-card { margin-top: 10px; }
  .dash-main { padding: 18px; }
  .dash-right { grid-template-columns: 1fr; }
  .recent { grid-template-columns: 1fr; }
  .tab-panel[data-panel="write"], body.show-comments .tab-panel[data-panel="write"], .design, .cover, .review-grid, .bible, .journal-grid { grid-template-columns: 1fr; }
  .outline, .comments-panel { position: static; height: auto; border-right: 0; }
  .toolbar { margin: 0 0.6rem; top: 92px; }
  .page-sheet { padding: 2rem 1.4rem; }
  .is-play .editor p[class]::after { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) { .side-nav button.active { forced-color-adjust: none; background: Highlight; color: HighlightText; } }

/* Word counts */
.target { flex-direction: row; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--muted); }
.target input { width: 78px; padding: 0.25em 0.45em; font-size: 0.8rem; }
.section-words.met { color: #2c9a5b; font-weight: 600; }
.counts-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.counts-table th, .counts-table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; }
.counts-table thead th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.counts-table .num { text-align: right; white-space: nowrap; }
.counts-table .row-target { width: 86px; text-align: right; padding: 0.25em 0.45em; }
.counts-table .div-row th, .counts-table .div-row td { background: var(--accent-soft); font-weight: 600; }
.counts-table .bar-col { width: 34%; }
.bar-wrap { display: flex; align-items: center; gap: 8px; }
.hbar { position: relative; flex: 1; height: 10px; border-radius: 0 4px 4px 0; background: transparent; }
.hbar .fill { height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .fill.met { background: #2c9a5b; }
.goal-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-2); border-radius: 1px; }
.pct { font-size: 0.78rem; color: var(--muted); width: 3em; text-align: right; }
button.link { border: 0; background: none; box-shadow: none !important; padding: 0; color: var(--ink); font-weight: 500; text-align: left; white-space: normal; }
button.link:hover { color: var(--accent); text-decoration: underline; }

/* Grammar checker */
::highlight(adobea-grammar) { text-decoration: underline wavy #e0485f; text-decoration-thickness: 1.5px; text-underline-offset: 3px; background: rgba(224, 72, 95, 0.07); }
.grammar-pop { position: fixed; z-index: 60; width: 320px; padding: 0.9rem 1rem; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.grammar-pop p { margin: 0 0 0.5rem; }
.gp-fix { font-family: var(--serif); font-size: 1rem; }
.grammar-pop del, .g-item del { color: #c63249; text-decoration-thickness: 1.5px; }
.grammar-pop ins, .g-item ins { color: #2c9a5b; text-decoration: none; font-weight: 600; }
.grammar-list { display: flex; flex-direction: column; gap: 0.9rem; margin: 0.6rem 0; }
.g-group h3 { margin: 0 0 0.4rem; }
.g-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 12px; background: var(--glass-strong); margin-bottom: 0.35rem; }
.g-item .g-text { flex: 1; border: 0; background: none; box-shadow: none !important; flex-direction: column; align-items: flex-start; white-space: normal; text-align: left; font-family: var(--serif); padding: 0.1rem; }
.g-item .g-text .hint { font-family: var(--sans); }
.g-item > button:not(.g-text) { font-size: 0.8rem; padding: 0.3em 0.7em; }

/* ---------- Version 0.3 ---------- */
.sync-state { font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
.sync-state::before { content: "●"; margin-right: 5px; color: #3cb878; }
.sync-state[data-state="pending"]::before { color: #f0a53a; }
.sync-state[data-state="offline"]::before, .sync-state[data-state="error"]::before { color: #e0485f; }
.sync-state:empty::before { content: none; }
.agent-btn { background: var(--accent-grad) !important; color: #fff; border-color: transparent !important; }
.provider-pick { border: 1px solid var(--line); border-radius: 14px; padding: 0.7rem 0.9rem; margin: 0 0 0.9rem; display: flex; flex-direction: column; gap: 0.4rem; }
.provider-pick legend { font-size: 0.82rem; color: var(--muted); padding: 0 0.3rem; }
#ai-dialog > label { margin-bottom: 0.7rem; }
.track-flag { color: #2c9a5b; font-size: 0.8rem; font-weight: 600; }

/* Tracked changes */
.editor ins.tc { color: #1f7a45; text-decoration: underline 2px rgba(44, 154, 91, 0.6); background: rgba(44, 154, 91, 0.08); }
.editor del.tc { color: #c63249; text-decoration: line-through 2px rgba(198, 50, 73, 0.7); background: rgba(198, 50, 73, 0.06); }
.changes-list { list-style: none; padding: 0; margin: 0.6rem 0; max-height: 55vh; overflow: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.change { border: 1px solid var(--line); border-left: 3px solid #2c9a5b; border-radius: 12px; padding: 0.6rem 0.8rem; cursor: pointer; }
.change.del { border-left-color: #c63249; }
.change p { margin: 0 0 0.4rem; }
.change ins { color: #1f7a45; } .change del { color: #c63249; }

/* Live pages beside the editor */
.live-pane { display: none; flex-direction: column; gap: 0.4rem; padding: 0.8rem; border-left: 1px solid var(--line); background: var(--glass); position: sticky; top: 100px; height: calc(100vh - 100px); }
.live-pane h2 { margin: 0; }
.live-pane button { padding: 0.2em 0.6em; }
#live-frame { flex: 1; width: 100%; border: 0; border-radius: 12px; background: #57514b; }
body.show-live .tab-panel[data-panel="write"] { grid-template-columns: 260px minmax(0, 1fr) minmax(340px, 38%); }
body.show-live .live-pane { display: flex; }
body.show-live .comments-panel { display: none; }

/* Timeline */
.tl-add { display: grid; grid-template-columns: 1fr 2fr 1fr 1fr auto; gap: 0.5rem; padding: 0.8rem; margin-bottom: 1rem; }
.timeline { list-style: none; padding: 0 0 0 1.4rem; margin: 0; position: relative; display: flex; flex-direction: column; gap: 0.8rem; max-width: 900px; }
.timeline::before { content: ""; position: absolute; left: 0.45rem; top: 0.5rem; bottom: 0.5rem; width: 2px; background: var(--accent-soft); border-radius: 2px; }
.tl-item { position: relative; }
.tl-item.dim { opacity: 0.35; }
.tl-dot { position: absolute; left: -1.25rem; top: 1.05rem; width: 12px; height: 12px; border-radius: 50%; background: var(--accent-grad); box-shadow: 0 0 0 4px var(--glass-strong); }
.tl-card { background: var(--glass-strong); border: 1px solid var(--line); border-radius: 14px; padding: 0.7rem 0.8rem; display: flex; flex-direction: column; gap: 0.45rem; box-shadow: var(--shadow-sm); cursor: grab; }
.tl-when { width: 170px; flex: none; font-weight: 600; color: var(--accent); }
.tl-title { font-weight: 600; }
.tl-notes { font-size: 0.86rem; }
.tl-del { padding: 0.2em 0.6em; }
.chip { display: inline-flex; align-items: center; font-size: 0.76rem; padding: 0.15em 0.65em; border-radius: 99px; background: var(--accent-soft); color: var(--accent); border: 0; box-shadow: none !important; }
.chip.person { background: rgba(155, 110, 240, 0.14); color: #7a4fd6; }
.chip.warn { background: rgba(240, 165, 58, 0.18); color: #b66f0b; }

/* Compare versions */
.compare-dialog { max-width: 1100px; }
.compare-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 0.8rem; }
.compare-text { max-height: 60vh; overflow: auto; font-family: var(--serif); font-size: 0.95rem; line-height: 1.6; padding: 0.8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--paper-ink); }
.compare-text p { margin: 0 0 0.8em; }
.compare-text del { background: rgba(198, 50, 73, 0.14); color: #a3263b; }
.compare-text ins { background: rgba(44, 154, 91, 0.16); color: #1f6e40; text-decoration: none; }
.compare-text .gap { min-height: 1.2em; border-left: 2px dashed var(--line); }

/* Cover studio and print wrap */
.cover { grid-template-columns: minmax(360px, 560px) 1fr; }
.cover .studio, .cover .wrap-card { grid-column: 1 / -1; }
.studio-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 0.8rem; }
.studio-opt { margin: 0; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 16px; padding: 0.7rem; display: flex; flex-direction: column; gap: 0.5rem; }
.studio-opt .thumb canvas { width: 100%; height: auto; border-radius: 10px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2); display: block; }
.studio-opt figcaption { display: flex; flex-direction: column; gap: 0.4rem; }
.studio-opt select, .studio-opt input[type="color"] { width: auto; font-size: 0.8rem; padding: 0.25em 0.4em; }
.wrap-canvas canvas { max-width: 100%; height: auto; margin-top: 0.8rem; border-radius: 6px; box-shadow: var(--shadow); }

/* Design */
.design .card > .row input { flex: 1; }
.form-grid .wide { grid-column: 1 / -1; }

/* Publish */
.pub-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, 1fr); gap: 1.2rem; align-items: start; }
.pub-side { display: flex; flex-direction: column; gap: 1.2rem; }
#pub-form input.bad { border-color: #e0485f; background: rgba(224, 72, 95, 0.06); }
.checklist { list-style: none; padding: 0; margin: 0.6rem 0 1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.checklist li { display: grid; grid-template-columns: 22px auto 1fr; gap: 0.5rem; align-items: baseline; font-size: 0.88rem; }
.checklist .tick { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--muted); display: inline-grid; place-items: center; font-size: 0.7rem; color: #fff; }
.checklist li.ok .tick { background: #2c9a5b; border-color: #2c9a5b; }
.checklist .hint { text-align: right; }
.links { list-style: none; padding: 0; margin: 0.6rem 0 0; display: flex; flex-direction: column; gap: 0.45rem; }
.links li { display: flex; flex-direction: column; }
.links a { color: var(--accent); font-weight: 600; text-decoration: none; }
.links a:hover { text-decoration: underline; }
.drafts { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.6rem; }
.draft { border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 0.9rem; background: var(--glass-strong); }
.draft p { margin: 0.4rem 0 0; font-family: var(--serif); }
#brief-out { margin-top: 0.6rem; font-family: ui-monospace, Menlo, monospace; font-size: 0.82rem; }
.epub-report { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.epub-report li { padding: 0.5rem 0.7rem; border-radius: 10px; background: var(--glass-strong); border-left: 3px solid var(--muted); font-size: 0.9rem; }
.epub-report .ok { border-left-color: #2c9a5b; } .epub-report .warn { border-left-color: #f0a53a; } .epub-report .error { border-left-color: #e0485f; }
.tpl-pick { margin-top: 0.3rem; font-size: 0.8rem; width: auto; align-self: flex-start; }

/* Assistant */
.agent-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 45; display: flex; flex-direction: column; background: var(--glass-strong); border-left: 1px solid var(--line); box-shadow: -10px 0 40px rgba(20, 30, 60, 0.18); transform: translateX(105%); transition: transform 0.25s ease; }
body.show-agent .agent-panel { transform: none; }
.agent-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.9rem 1rem; border-bottom: 1px solid var(--line); }
.agent-head button { padding: 0.3em 0.7em; }
.agent-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.7rem 1rem 0; }
.agent-chips button { font-size: 0.78rem; border-radius: 99px; padding: 0.3em 0.8em; }
.agent-log { flex: 1; overflow: auto; padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.msg { max-width: 92%; padding: 0.6rem 0.85rem; border-radius: 16px; font-size: 0.92rem; line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--accent-grad); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--glass); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.assistant.error { border-color: #e0485f; color: #c63249; }
.msg.action { align-self: center; font-size: 0.74rem; color: var(--muted); padding: 0.1rem 0.6rem; }
.msg.action::before { content: "✦ "; color: var(--accent); }
.msg.card { align-self: stretch; max-width: none; background: var(--glass); border: 1px solid var(--accent); border-radius: 14px; }
.msg.card p { margin: 0 0 0.4rem; font-family: var(--serif); }
.msg.card .hint { font-family: var(--sans); }
.msg.card del { color: #c63249; } .msg.card ins { color: #1f7a45; text-decoration: none; }
.agent-form { display: flex; gap: 0.5rem; padding: 0.8rem 1rem 1rem; border-top: 1px solid var(--line); }
.agent-form textarea { resize: none; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; } .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Captions in the editor */
.editor figure { margin: 1em 0; text-align: center; }
.editor figcaption { font-size: 0.9rem; font-style: italic; color: var(--muted); }

@media (max-width: 900px) {
  .pub-grid, .compare-cols, .tl-add { grid-template-columns: 1fr; }
  body.show-live .tab-panel[data-panel="write"] { grid-template-columns: 1fr; }
}

.cover .cover-preview { grid-column: 2; grid-row: 1; }
@media (max-width: 900px) { .cover .cover-preview { grid-column: auto; grid-row: auto; } }

/* Built-in spelling and grammar */
::highlight(adobea-spell) { text-decoration: underline wavy #e0303e; text-decoration-thickness: 1.4px; text-underline-offset: 3px; text-decoration-skip-ink: none; }
::highlight(adobea-gram) { text-decoration: underline double #2f6fde; text-decoration-thickness: 1.4px; text-underline-offset: 3px; text-decoration-skip-ink: none; }
.proof-btn { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: 0.02em; }
.proof-btn.has-issues { color: #c63249; }
.proof-menu { position: fixed; z-index: 80; min-width: 230px; max-width: 320px; padding: 6px; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.proof-menu button { display: flex; width: 100%; border: 0; background: none; box-shadow: none !important; border-radius: 8px; padding: 0.4em 0.7em; text-align: left; }
.proof-menu button:hover { background: var(--accent-soft); }
.proof-menu .pm-sug b { color: var(--ink); }
.proof-menu .pm-msg { margin: 0.2rem 0.6rem 0.4rem; font-size: 0.82rem; color: var(--ink-2); }
.proof-menu .pm-none { margin: 0.3rem 0.7rem; color: var(--muted); font-size: 0.85rem; }
.proof-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.proof-pane { position: fixed; inset: 110px 18px auto auto; margin: 0; width: 360px; max-height: calc(100vh - 130px); overflow: auto; z-index: 70; }
.proof-pane h2 { margin: 0; }
.pp-kind { font-weight: 600; margin: 0.6rem 0 0; }
.pp-kind.spell { color: #c63249; } .pp-kind.gram { color: #2f6fde; }
.pp-where { margin: 0.1rem 0 0.5rem; }
.pp-context { font-family: var(--serif); font-size: 1rem; line-height: 1.55; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--paper-ink); margin-bottom: 0.6rem; }
.pp-context mark.sp { background: none; color: inherit; text-decoration: underline wavy #e0303e; text-underline-offset: 3px; }
.pp-context mark.gr { background: none; color: inherit; text-decoration: underline double #2f6fde; text-underline-offset: 3px; }
#pp-sugg { width: 100%; }
.pp-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin: 0.7rem 0; }
.pp-done { font-size: 1.05rem; color: #2c9a5b; font-weight: 600; margin: 1rem 0 0.3rem; }
.pp-options { margin-top: 0.6rem; border-top: 1px solid var(--line); padding-top: 0.6rem; }
.pp-options summary { border: 0; background: none; padding: 0.2em 0; box-shadow: none !important; font-weight: 600; }
.pp-options label { margin: 0.4rem 0; }
.pp-dict { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.pp-dict li { background: var(--accent-soft); border-radius: 99px; padding: 0.1em 0.3em 0.1em 0.7em; font-size: 0.82rem; display: flex; align-items: center; gap: 0.2em; }
.pp-dict button { border: 0; background: none; padding: 0 0.3em; box-shadow: none !important; }
#pp-restart { margin-top: 0.6rem; font-size: 0.85rem; color: var(--accent); }
.proof-item .g-text b.sp { text-decoration: underline wavy #e0303e; text-underline-offset: 3px; font-weight: normal; }
.proof-item .g-text b.gr { text-decoration: underline double #2f6fde; text-underline-offset: 3px; font-weight: normal; }
.pill.spell { background: rgba(224, 48, 62, 0.12); color: #c63249; }
.pill.grammar { background: rgba(47, 111, 222, 0.12); color: #2f6fde; }
.review-method { display: flex; align-items: flex-end; gap: 0.6rem; margin-top: 1rem; flex-wrap: wrap; }
.review-method label { flex: 1 1 260px; }
#review-method-note { margin: 0.4rem 0 0; }

/* ---------- Version 0.5: profiles and appearance ---------- */
.top-me { margin-left: 0.2rem; }
.profile-menu { position: fixed; z-index: 90; width: 280px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.profile-menu .pm-head { display: flex; gap: 10px; align-items: center; padding: 8px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.profile-menu button { display: flex; width: 100%; gap: 10px; align-items: center; border: 0; background: none; box-shadow: none !important; border-radius: 10px; padding: 0.5em 0.6em; text-align: left; }
.profile-menu button:hover { background: var(--surface-2); }
.profile-menu button.on { color: var(--accent); font-weight: 600; }
.profile-menu button.on::after { content: "✓"; margin-left: auto; }
.profile-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.profile-menu .pm-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 6px 8px 2px; }

.profile-dialog { max-width: 720px; }
.profile-grid { display: grid; grid-template-columns: 180px 1fr; gap: 1.4rem; align-items: start; }
.avatar-pick { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; text-align: center; }
.avatar-pick .me.lg { width: 112px; height: 112px; font-size: 2rem; border-width: 4px; box-shadow: var(--shadow-sm); }
.avatar-pick .row { justify-content: center; }
.avatar-pick button { font-size: 0.8rem; padding: 0.3em 0.7em; }
.hue-pick { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.hue-pick button { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid var(--surface); background: hsl(var(--h) 65% 52%); box-shadow: 0 0 0 1px var(--line) !important; }
.hue-pick button.on { box-shadow: 0 0 0 2px var(--ink) !important; }
.onboard-head { display: flex; gap: 14px; align-items: center; margin-bottom: 1rem; }
.onboard-head img { width: 46px; height: 46px; }
.onboard-head h2 { margin: 0; font-size: 1.4rem; }
.onboard-head p { margin: 2px 0 0; color: var(--muted); }
.dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.2rem; }
.dialog-actions .left { margin-right: auto; }

.look-dialog { max-width: 860px; }
.look-section { margin-top: 1.2rem; }
.look-section > h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 0.6rem; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.7rem; }
.preset { flex-direction: column; align-items: stretch; padding: 8px; gap: 8px; border-radius: 16px; white-space: normal; text-align: left; }
.preset.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) !important; }
.preset b { font-size: 0.86rem; padding: 0 4px; }
.preset small { font-size: 0.72rem; color: var(--muted); padding: 0 4px 2px; }
.mini { display: grid; grid-template-columns: 28% 1fr; height: 78px; border-radius: 10px; overflow: hidden; background: var(--pbg); border: 1px solid rgba(0, 0, 0, 0.06); }
.mini .ms { background: var(--pside); display: flex; flex-direction: column; gap: 4px; padding: 8px 5px; }
.mini .ms i { height: 5px; border-radius: 3px; background: var(--pside-ink); opacity: 0.55; }
.mini .ms i:first-child { opacity: 1; background: var(--pact); }
.mini .mm { padding: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; align-content: start; }
.mini .mm i { height: 18px; border-radius: 4px; background: var(--pcard); }
.mini .mm i:first-child { grid-column: 1 / -1; height: 8px; width: 60%; background: var(--paccent); }
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button { border: 0; background: none; box-shadow: none !important; border-radius: 9px; padding: 0.4em 0.9em; font-size: 0.86rem; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm) !important; }
.accents { display: flex; gap: 10px; flex-wrap: wrap; }
.accents button { flex-direction: column; gap: 4px; border: 0; background: none; box-shadow: none !important; padding: 2px; font-size: 0.72rem; color: var(--muted); }
.accents .dot { width: 34px; height: 34px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 3px var(--surface), 0 0 0 1px var(--line); }
.accents button.on .dot { box-shadow: inset 0 0 0 3px var(--surface), 0 0 0 2px var(--sw); }
.accents button.on { color: var(--ink); font-weight: 600; }
.look-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.4rem; }
@media (max-width: 700px) { .profile-grid, .look-grid { grid-template-columns: 1fr; } }

/* Account, sync and backups */
.account-dialog { max-width: 620px; }
.acct-section { border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.1rem; margin-top: 1rem; }
.acct-section > h3 { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; margin-bottom: 0.7rem; }
.acct-section p { margin: 0 0 0.7rem; }
.acct-section .cloud-head { margin: 1.1rem 0 0.5rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
.acct-section code { font-size: 0.8em; word-break: break-all; }
.acct-section label.chk { display: flex; flex-direction: row; align-items: center; gap: 0.5em; flex: 1 1 100%; margin-bottom: 0.6rem; }
.acct-section label.chk input { width: auto; margin: 0; }
.cloud-list { display: grid; gap: 0.35rem; max-height: 40vh; overflow: auto; margin-bottom: 0.7rem; }
.cloud-list button { display: flex; justify-content: space-between; gap: 1rem; text-align: left; }
.acct-section form h3 { margin: 0; font-size: 1.05rem; }
.acct-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 0.6rem; }
.acct-head p { margin: 2px 0 0; }
.acct-ok { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--deco-1) 16%, transparent); color: #158a5d; font-weight: 700; flex: none; }
.acct-facts { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; margin: 0 0 0.9rem; font-size: 0.9rem; }
.acct-facts dt { color: var(--muted); }
.acct-facts dd { margin: 0; }
.acct-error { color: var(--danger); margin: 0; }
.cloud-state { font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
.cloud-state::before { content: "☁︎"; margin-right: 5px; color: #22a06b; }
.cloud-state[data-state="pending"]::before { color: #f0a53a; }
.cloud-state[data-state="offline"]::before, .cloud-state[data-state="error"]::before { color: var(--danger); }
.cloud-state:empty::before, .cloud-state[data-state="off"]::before { content: none; }
#pf-signin, .acct-section button.link { color: var(--accent); }
.dash-states { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0 0 !important; }
.dash-states:has(span:empty + span:empty) { display: none; }

/* The sign-in page and the desktop lock (js/gate.js): nothing else shows until it's done. */
#gate { display: none; }
body.gated > :not(#gate) { visibility: hidden !important; }
body.gated #gate { display: flex; position: fixed; inset: 0; z-index: 2147483000; overflow: auto; padding: 4vh 1rem; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 55%), var(--bg); }
.gate-card { width: min(440px, 100%); margin: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 1.8rem 1.8rem 1.5rem; box-shadow: var(--shadow); }
.gate-brand { display: flex; gap: 0.8rem; align-items: center; margin-bottom: 1.3rem; }
.gate-brand img { width: 46px; height: 46px; }
.gate-brand span { display: flex; flex-direction: column; }
.gate-brand b { font-size: 1.25rem; letter-spacing: 0.14em; }
.gate-brand small { color: var(--muted); }
.gate-lead { color: var(--ink-2); margin: 0 0 1rem; }
#gate h3 { margin: 0; }
#gate label { display: flex; flex-direction: column; gap: 0.3em; }
#gate button.link { color: var(--accent); }
#gate .row button.primary { flex: 0 0 auto; }

/* Continue with Google / Microsoft / Apple (js/cloud.js) */
.oauth { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
.oauth-btn { display: flex; align-items: center; justify-content: center; gap: 0.6em; width: 100%; box-sizing: border-box; min-width: 0; white-space: normal; padding: 0.7em 1em; font-weight: 600; background: var(--surface); }
.oauth-ico { width: 18px; height: 18px; flex: 0 0 18px; background: center / contain no-repeat; }
.oauth-google { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23FFC107' d='M43.6 20.5H42V20H24v8h11.3C33.7 32.7 29.2 36 24 36c-6.6 0-12-5.4-12-12s5.4-12 12-12c3.1 0 5.8 1.2 7.9 3.1l5.7-5.7C34 6.1 29.3 4 24 4 13 4 4 13 4 24s9 20 20 20 20-9 20-20c0-1.3-.1-2.4-.4-3.5z'/%3E%3Cpath fill='%23FF3D00' d='m6.3 14.7 6.6 4.8C14.7 15.1 19 12 24 12c3.1 0 5.8 1.2 7.9 3.1l5.7-5.7C34 6.1 29.3 4 24 4 16.3 4 9.7 8.3 6.3 14.7z'/%3E%3Cpath fill='%234CAF50' d='M24 44c5.2 0 9.9-2 13.4-5.2l-6.2-5.2C29.2 35.1 26.7 36 24 36c-5.2 0-9.6-3.3-11.3-8l-6.5 5C9.5 39.6 16.2 44 24 44z'/%3E%3Cpath fill='%231976D2' d='M43.6 20.5H42V20H24v8h11.3c-.8 2.2-2.2 4.2-4.1 5.6l6.2 5.2C37 39.2 44 34 44 24c0-1.3-.1-2.4-.4-3.5z'/%3E%3C/svg%3E"); }
.oauth-azure { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 23 23'%3E%3Cpath fill='%23f35325' d='M1 1h10v10H1z'/%3E%3Cpath fill='%2381bc06' d='M12 1h10v10H12z'/%3E%3Cpath fill='%2305a6f0' d='M1 12h10v10H1z'/%3E%3Cpath fill='%23ffba08' d='M12 12h10v10H12z'/%3E%3C/svg%3E"); }
.oauth-apple { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16.4 12.6c0-2.6 2.1-3.8 2.2-3.9-1.2-1.8-3.1-2-3.7-2-1.6-.2-3.1.9-3.9.9-.8 0-2-.9-3.4-.9-1.7 0-3.3 1-4.2 2.6-1.8 3.1-.5 7.7 1.3 10.2.9 1.2 1.9 2.6 3.2 2.6 1.3-.1 1.8-.8 3.3-.8 1.6 0 2 .8 3.4.8 1.4 0 2.3-1.3 3.1-2.5 1-1.4 1.4-2.8 1.4-2.9 0 0-2.7-1-2.7-4.1zM13.9 5c.7-.9 1.2-2 1-3.2-1 0-2.3.7-3 1.5-.7.8-1.2 2-1.1 3.1 1.2.1 2.4-.6 3.1-1.4z'/%3E%3C/svg%3E"); }
.dark .oauth-apple { filter: invert(1); }
.oauth-or { display: flex; align-items: center; gap: 0.7em; color: var(--muted); font-size: 0.84rem; margin: 0.2rem 0 !important; }
.oauth-or::before, .oauth-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
