/* Colours: "system" (no data-theme) follows the device; the others are chosen in Settings, Display. The text size scales every rem. */
:root {
  --bg: #faf8f4; --surface: #ffffff; --ink: #1c2330; --muted: #6b7280; --line: #e5e1d8;
  --accent: #2f5d8a; --accent-ink: #ffffff; --user: #e6eef7; --warn: #b45309; --bad: #b91c1c; --good: #15803d;
  --bar: #1f2937; --bar-ink: #f5f1e8; --bad-ink: #ffffff; --good-ink: #ffffff; --mark: #0f6b5c;
  color-scheme: light dark; --fscale: 1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --bg: #11151b; --surface: #1a2029; --ink: #e8e6e1; --muted: #98a2b3; --line: #2b3441;
          --accent: #7aa7d6; --accent-ink: #0b1118; --user: #22344a; --warn: #f59e0b; --bad: #f87171; --good: #4ade80; --bad-ink: #1a0a0a; --good-ink: #05180c; --mark: #4cc2ac; }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; --bg: #11151b; --surface: #1a2029; --ink: #e8e6e1; --muted: #98a2b3; --line: #2b3441;
          --accent: #7aa7d6; --accent-ink: #0b1118; --user: #22344a; --warn: #f59e0b; --bad: #f87171; --good: #4ade80; --bad-ink: #1a0a0a; --good-ink: #05180c; --mark: #4cc2ac; }
/* softer than dark: less glare for long evenings */
:root[data-theme="dusk"] { color-scheme: dark; --bg: #1f2227; --surface: #282c33; --ink: #cdc8bd; --muted: #969ca8; --line: #373d47;
          --accent: #93b5d6; --accent-ink: #101820; --user: #2d3a4b; --warn: #e0a040; --bad: #e88a8a; --good: #7fcf95; --bad-ink: #1a0a0a; --good-ink: #05180c; --bar: #2a2e35; --bar-ink: #e2ddd2; --mark: #4cc2ac; }
/* warm paper, easy on the eyes in daylight */
:root[data-theme="sepia"] { color-scheme: light; --bg: #f1e7d0; --surface: #f9f2e0; --ink: #3a2f20; --muted: #75664f; --line: #d9ccaf;
          --accent: #8a4b1c; --accent-ink: #ffffff; --user: #eadbb8; --warn: #a14a00; --bad: #a32020; --good: #2e6b2e; --bar: #4a3b27; --bar-ink: #f8efd9; --mark: #8a4b1c; }
/* a cool grey-green with lower contrast than white */
:root[data-theme="mist"] { color-scheme: light; --bg: #e4e9e6; --surface: #eff3f0; --ink: #26332f; --muted: #5d6c66; --line: #c6d0cb;
          --accent: #2c6a5c; --accent-ink: #ffffff; --user: #d3e3dd; --warn: #99500a; --bad: #a82a2a; --good: #23703a; --bar: #2f403b; --bar-ink: #eef3f0; --mark: #2c6a5c; }
:root[data-theme="contrast-light"] { color-scheme: light; --bg: #ffffff; --surface: #ffffff; --ink: #000000; --muted: #2b2b2b; --line: #000000;
          --accent: #0b3a9e; --accent-ink: #ffffff; --user: #dde8ff; --warn: #7a3200; --bad: #9c0000; --good: #00541a; --bar: #000000; --bar-ink: #ffffff; --mark: #0b3a9e; }
:root[data-theme="contrast-dark"] { color-scheme: dark; --bg: #000000; --surface: #0a0a0a; --ink: #ffffff; --muted: #d6d6d6; --line: #ffffff;
          --accent: #6db3ff; --accent-ink: #000000; --user: #0b2a4d; --warn: #ffb000; --bad: #ff7b7b; --good: #62ff93; --bad-ink: #000; --good-ink: #000; --bar: #000000; --bar-ink: #ffffff; --mark: #62ffd9; }
:root[data-theme^="contrast"] .btn, :root[data-theme^="contrast"] .row, :root[data-theme^="contrast"] .pane-head { border-width: 2px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 1rem/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
html { font-size: calc(16px * var(--fscale)); }
#app { height: 100dvh; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }                       /* the browser's own link blue is unreadable on the dark page */
select, input, textarea { color: var(--ink); }
.hidden { display: none !important; }

/* top bar */
.top { flex: none; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--bar); color: var(--bar-ink); min-height: 52px; }
.top h1 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .icon-btn { color: var(--bar-ink); }
.chip { border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.1); color: var(--bar-ink); border-radius: 999px;
  padding: 6px 12px; min-height: 36px; font-size: .85rem; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; min-width: 44px; min-height: 44px; font-size: 1.3rem; border-radius: 8px; cursor: pointer; }

/* main + tabs */
main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tabs { flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tab { background: none; border: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .72rem; color: var(--muted); cursor: pointer; }
.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tab[aria-current="page"] svg { box-sizing: content-box; padding: 3px 16px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* lists */
.pad { padding: 16px; }
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface); border: 0;
  border-bottom: 1px solid var(--line); padding: 14px 16px; min-height: 64px; cursor: pointer; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: .85rem; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; min-height: 48px; padding: 0 18px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.block + .btn.block { margin-top: 10px; }
/* the ISRD mark: the lab's wordmark (serif, teal R), as on isrd.com */
.isrd-mark { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-weight: 700; letter-spacing: .04em; text-decoration: none; color: inherit; }
.isrd-mark span { color: #4cc2ac; }
.isrd-card { display: flex; align-items: center; gap: 12px; margin-top: 24px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); text-decoration: none; }
.isrd-card .isrd-mark { font-size: 1.25rem; } .isrd-card .isrd-mark span { color: var(--mark); }
.isrd-card .isrd-mark span { color: var(--mark); }
.isrd-card .grow { flex: 1; line-height: 1.35; } .isrd-card small { color: var(--muted); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin: -2px 0 14px; }
.choices .btn { text-align: left; }
input[type=text], input[type=password], input[type=search], input[type=number], textarea, select { width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
label.field { display: block; margin: 12px 0; font-size: .9rem; color: var(--muted); }
label.field > input, label.field > textarea { margin-top: 4px; }

/* chat */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.stream { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 16px; overflow-wrap: anywhere; }
.msg p { margin: 0 0 .6em; } .msg p:last-child { margin-bottom: 0; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.decision { align-self: center; max-width: 96%; font-size: .9rem; background: transparent; border: 1px dashed var(--good); border-left: 4px solid var(--good); border-radius: 10px; padding: 8px 12px; }
.msg.assistant.partial { border-style: dashed; }
.msg pre { white-space: pre-wrap; background: var(--bg); padding: 8px; border-radius: 8px; overflow-x: auto; }
.msg .meta { font-size: .75rem; color: var(--muted); margin-top: 6px; }
.msg .flag { font-size: .8rem; color: var(--warn); margin-top: 6px; }
.status-line { align-self: flex-start; color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: 8px; padding: 2px 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s infinite ease-in-out; }
@keyframes pulse { 0%,100% { opacity: .25; } 50% { opacity: 1; } }
.banner { margin: 8px 12px 0; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--warn); color: var(--ink); font-size: .9rem; }
.composer { position: relative; flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px; background: var(--surface); border-top: 1px solid var(--line); }
.composer textarea { resize: none; max-height: 60vh; min-height: 48px; line-height: 1.35; }
.send { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 1.3rem; cursor: pointer; }
.send.stop { background: var(--bad); color: var(--bad-ink); }
.send:disabled { opacity: .4; }
.send.mic { background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-size: 1.15rem; }
.send.mic.listening, .w-mic.listening, #sa-mic.listening { background: var(--bad); color: var(--bad-ink); border-color: var(--bad); animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse { 50% { opacity: .65; } }

/* sheets */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; z-index: 60; animation: fade .15s; }
.sheet { width: 100%; max-height: 88dvh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); animation: rise .2s ease-out; }
/* The grab strip stays at the top of a long sheet and is a wide target: drag it down to close the sheet. */
.sheet .grab { position: sticky; top: -8px; z-index: 3; height: 30px; margin: -8px -16px 4px; background: var(--surface); border-radius: 20px 20px 0 0; touch-action: none; cursor: grab; }
.sheet .grab::before { content: ""; position: absolute; left: 50%; top: 12px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--line); }
.sheet h2 { margin: 0 0 4px; font-size: 1.15rem; }
.sheet .ctx { color: var(--muted); margin: 0 0 12px; }
.sheet .body { white-space: pre-wrap; margin-bottom: 12px; }
.sheet .actions { display: grid; gap: 10px; margin-top: 14px; }
.sheet .actions .btn { min-height: 54px; font-size: 1.05rem; }
.opt { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.opt input { width: 22px; height: 22px; }
@keyframes rise { from { transform: translateY(40px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }

.phase { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--line); border-radius: 8px; }
.phase .mark { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; flex: none; }
.phase.complete .mark { background: var(--good); border-color: var(--good); color: var(--good-ink); }
.phase.current { background: var(--user); font-weight: 600; }
.phase.current .mark { border-color: var(--accent); color: var(--accent); }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); background: var(--bar); color: var(--bar-ink);
  padding: 12px 16px; border-radius: 12px; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 70; }
#toast.show { opacity: 1; }
#toast.act { pointer-events: auto; } .toast-act { margin-left: 8px; }
.login { max-width: 420px; margin: 0 auto; padding: 48px 20px; }

/* library */
.lib { padding-bottom: 24px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; margin: 12px 16px; padding: 4px; background: var(--line); border-radius: 12px; }
.seg button { border: 0; background: none; min-height: 40px; border-radius: 9px; cursor: pointer; font-weight: 600; color: color-mix(in srgb, var(--ink) 78%, var(--line)); }
.seg button[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.libbar { display: flex; align-items: center; gap: 4px; padding: 4px 8px; position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line); z-index: 2; }
.libtitle { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reader { padding: 16px 18px 32px; max-width: 42rem; margin: 0 auto; font-size: 1.02rem; line-height: 1.65; overflow-wrap: anywhere; }
.reader h1 { font-size: 1.4rem; line-height: 1.25; margin: .2em 0 .3em; }
.reader h2 { font-size: 1.25rem; margin: 1.4em 0 .4em; } .reader h3 { font-size: 1.1rem; margin: 1.2em 0 .3em; } .reader h4, .reader h5 { font-size: 1rem; margin: 1em 0 .3em; }
.reader p { margin: 0 0 1em; } .reader hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.reader blockquote { margin: 0 0 1em; padding: .2em 0 .2em 14px; border-left: 3px solid var(--line); color: var(--muted); }
.reader ul, .reader ol { padding-left: 1.3em; margin: 0 0 1em; } .reader code { background: var(--line); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.reader .meta { margin: 0 0 .8em; font-size: .85rem; }
.help-actions { display: grid; gap: 10px; max-width: 42rem; margin: 0 auto; padding: 0 18px calc(32px + env(safe-area-inset-bottom)); }
.reader .note { background: var(--user); border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.row-actions { margin: 0 0 1.2em; }
.diff { padding: 12px 12px 32px; font-size: .92rem; }
.diff .dl { padding: 3px 8px; border-radius: 4px; margin: 1px 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.diff .dl.add { background: color-mix(in srgb, var(--good) 18%, transparent); }
.diff .dl.del { background: color-mix(in srgb, var(--bad) 18%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.diff .dl.gap { color: var(--muted); text-align: center; font-size: .8rem; }

/* phase detail */
button.phase { width: 100%; text-align: left; background: none; border: 0; cursor: pointer; }
.phase-detail h3 { font-size: .95rem; margin: 1.4em 0 .4em; }
.phase-detail p { margin: .4em 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: .8rem; color: var(--muted); }
.pill.accent { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pill.good { border-color: var(--good); color: var(--good); font-weight: 600; }
.topics { list-style: none; margin: 0; padding: 0; }
.topics li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.topics li.done .grow { color: var(--muted); text-decoration: line-through; }
.topics .mark { width: 1.2em; text-align: center; }
.logentry { border-bottom: 1px solid var(--line); padding: 8px 0; }
.logentry summary { cursor: pointer; list-style: none; line-height: 1.4; }
.logentry summary::-webkit-details-marker { display: none; }
.logbody { padding: 8px 0 4px 4px; font-size: .92rem; overflow-wrap: anywhere; }
.small { font-size: .82rem; }

/* accounts and administration */
.wide { max-width: 760px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; line-height: 1.5; }
.small { font-size: .85rem; }
.pill.bad { border-color: var(--bad); color: var(--bad); font-weight: 600; }
.pill.warn { border-color: var(--warn); color: var(--warn); font-weight: 600; }
.adminlist .row { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 8px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input[type=text], .inline select { width: auto; flex: 1; min-width: 7rem; }
.secret { font-family: ui-monospace, Menlo, monospace; background: var(--bg); border: 1px dashed var(--accent); border-radius: 10px; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }

/* form factor: desktop shows the project as columns (library or the open document | chat | phases), like the old desktop window */
body[data-layout="desktop"] #app > main.page { width: 100%; max-width: 760px; margin: 0 auto; }
.chip.static { cursor: default; }
.colhead { margin: 0 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
/* the left and right columns are resizable (drag the dividers, or focus one and use the arrow keys; double-click resets) */
.cols { --c1: var(--col1, 300px); --c2: var(--col2, 380px); --c3: var(--col3, 260px); --r1: 6px; --r3: 6px; position: relative;
  flex: 1; min-height: 0; display: grid; grid-template-columns: var(--c1) var(--r1) minmax(10%, 1fr) 6px var(--c2) var(--r3) var(--c3); }
.cols.has-doc { --c1: max(var(--col1, 300px), 400px); }
/* the library and tasks columns fold away, for a narrow window: a tab with a triangle stays at the edge to bring them back */
.cols.c1-off { --c1: 0px; --r1: 0px; } .cols.c3-off { --c3: 0px; --r3: 0px; }
.cols.c1-off .col1, .cols.c1-off .resizer[data-col="1"], .cols.c3-off .side, .cols.c3-off .resizer[data-col="3"] { display: none; }
.col-toggle { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 22px; height: 64px; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--surface); color: var(--accent); cursor: pointer; font-size: .8rem; line-height: 1; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.col-toggle:hover, .col-toggle:focus-visible { background: var(--accent); color: var(--accent-ink); outline: none; }
.col-toggle[data-col="1"] { left: calc(var(--c1) + var(--r1) - 11px); } .col-toggle[data-col="3"] { right: calc(var(--c3) + var(--r3) - 11px); }
.col-toggle .lbl { display: none; writing-mode: vertical-rl; font-size: .72rem; font-weight: 600; letter-spacing: .04em; }
.cols.c1-off .col-toggle[data-col="1"], .cols.c3-off .col-toggle[data-col="3"] { height: 96px; width: 26px; }
.cols.c1-off .col-toggle[data-col="1"] { left: 0; border-radius: 0 8px 8px 0; } .cols.c3-off .col-toggle[data-col="3"] { right: 0; border-radius: 8px 0 0 8px; }
.cols.c1-off .col-toggle[data-col="1"] .lbl, .cols.c3-off .col-toggle[data-col="3"] .lbl { display: block; }
.cols .pane { min-height: 0; min-width: 0; overflow-y: auto; background: var(--bg); -webkit-overflow-scrolling: touch; }
.resizer { background: var(--line); cursor: col-resize; touch-action: none; width: 6px; }
.resizer:hover, .resizer:focus-visible, .resizer.drag { background: var(--accent); outline: none; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe { pointer-events: none; }
.cols .seg { margin: 8px; }
.cols .seg button { font-size: .85rem; padding: 0 4px; min-height: 36px; }
.cols.has-doc #pane-library { background: var(--surface); }
.cols .side #pane-more { border-top: 1px solid var(--line); }
.cols .libbar { top: 0; }
.cols .reader { padding-top: 12px; }
@media (max-width: 1099px) { .cols { --c1: var(--col1, 240px); --c2: var(--col2, 300px); --c3: var(--col3, 220px); } .cols.has-doc { --c1: max(var(--col1, 240px), 360px); } }
body[data-layout="desktop"] .scrim { align-items: center; justify-content: center; }
body[data-layout="desktop"] .sheet { max-width: 560px; max-height: 80vh; border-radius: 16px; padding-bottom: 16px; }
body[data-layout="desktop"] .sheet .grab { display: none; }
body[data-layout="desktop"] #toast { max-width: 480px; left: 50%; right: auto; transform: translateX(-50%); bottom: 24px; }

/* the transcript: facts and notices between the bubbles, and the messages still waiting */
.event { align-self: stretch; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--line); font-size: .9rem; }
.event .ico { flex: none; }
.event.phase { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.event.notice { background: transparent; border-style: dashed; color: var(--muted); }
.event.notice.warn { border-color: var(--warn); color: var(--ink); }
.event.notice.error { border-color: var(--bad); color: var(--ink); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .85rem; border-radius: 9px; }
.msg.user.queued { background: transparent; border: 1px dashed var(--line); opacity: .9; }
.msg.user.queued .qbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.composer .send.stop { margin-right: -2px; }

/* a decision that is still waiting, kept in reach while the writer reads what it is about */
#dock { position: fixed; z-index: 15; left: 8px; right: 8px; top: calc(56px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 12px; background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.2); font-size: .9rem; }
#dock .dtxt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body[data-layout="desktop"] #dock { left: 50%; right: auto; transform: translateX(-50%); width: min(560px, calc(100% - 16px)); }
.sheet .cdiff { margin-bottom: 12px; } .sheet .cdiff summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.sheet .cdiff .diff { padding: 4px 0; max-height: 40dvh; overflow-y: auto; }
.reader .review { border: 1px solid var(--accent); border-radius: 12px; padding: 4px 12px 12px; margin: 0 0 1.2em; }
.reader .review h3 { margin: .6em 0 .2em; } .reader .review .diff { padding: 4px 0; max-height: 50dvh; overflow-y: auto; font-size: .9rem; line-height: 1.45; }
/* the per-bubble menu: always visible on touch, shown on hover with a pointer */
/* the options button sits in its own right-aligned row at the top, so the text keeps the bubble's full width */
.msg.has-menu .mrow, .wc-msg.has-menu .mrow { display: flex; justify-content: flex-end; height: 20px; margin: -6px -8px 0 0; }
.mbtn { width: 30px; height: 26px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; opacity: .7; }
.mbtn:hover, .mbtn:focus-visible { background: color-mix(in srgb, var(--ink) 10%, transparent); opacity: 1; }
@media (hover: hover) { .msg.has-menu .mbtn, .wc-msg.has-menu .mbtn { opacity: 0; } .msg.has-menu:hover .mbtn, .msg.has-menu .mbtn:focus-visible, .wc-msg.has-menu:hover .mbtn, .wc-msg.has-menu .mbtn:focus-visible { opacity: 1; } }
#bubble-menu { position: fixed; z-index: 30; min-width: 180px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
#bubble-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 0 12px; min-height: 44px; border-radius: 8px; cursor: pointer; }
#bubble-menu button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }

/* landing */
.landing { max-width: 42rem; margin: 0 auto; padding: 20px 16px 40px; }
.landing h2 { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-size: 1.7rem; margin: .3em 0 .3em; }
.landing .lede { color: var(--muted); margin: 0 0 1.2em; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 14px; min-height: 112px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--surface); cursor: pointer; }
.tile svg { width: 28px; height: 28px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 4px; }
.tile strong { font-size: .95rem; line-height: 1.25; } .tile small { color: var(--muted); }
.tile.soon { opacity: .6; border-style: dashed; }
.landing .colhead { margin: 1.6em 0 .4em; }

/* project data viewer */
.dv { font-size: .88rem; line-height: 1.45; overflow-wrap: anywhere; }
.dv details { margin: 1px 0; } .dv summary { cursor: pointer; padding: 3px 0; } .dv-kids { margin-left: 14px; padding-left: 10px; border-left: 1px solid var(--line); }
.dv-leaf { padding: 2px 0; } .dv-key { font-family: ui-monospace, Menlo, monospace; font-weight: 600; } .dv-val { white-space: pre-wrap; }
.dv-number, .dv-boolean { color: var(--accent); } .dv-null { color: var(--muted); font-style: italic; }

/* ISRD view */
.back-label { background: none; border: 0; color: var(--bar-ink); font-size: 1.05rem; font-weight: 600; min-height: 44px; padding: 0 10px 0 4px; cursor: pointer; }
.top .grow { flex: 1; }
.top a.ext { display: flex; align-items: center; justify-content: center; color: var(--bar-ink); text-decoration: none; }
.frame-wrap { display: flex; padding: 0; overflow: hidden; background: #fff; }
.frame-wrap iframe { flex: 1; width: 100%; border: 0; }

.editor { width: 100%; font: 1rem/1.6 Georgia, "Iowan Old Style", serif; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); resize: vertical; }
.note { background: var(--user); border-radius: 10px; padding: 10px 12px; font-size: .9rem; }

/* project memory */
.memfact { display: flex; align-items: flex-start; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.memfact .opt { flex: 1; align-items: flex-start; } .memfact .grow { flex: 1; overflow-wrap: anywhere; }
.memact { display: flex; flex-direction: column; gap: 6px; }

/* cost and usage */
.cost-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-bottom: 8px; }
.cost-tile { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--surface); display: flex; flex-direction: column; gap: 2px; }
.cost-tile strong { font-size: 1.15rem; } .cost-tile small { color: var(--muted); }
.cost-table { width: 100%; border-collapse: collapse; font-size: .88rem; } .cost-table th { text-align: left; color: var(--muted); font-weight: 600; }
.cost-table td, .cost-table th { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.cost-table td:last-child, .cost-table th:last-child { text-align: right; white-space: nowrap; }
.cost .row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.cost .row-actions .field { display: block !important; margin: 0 !important; }

/* drag and drop overlay */
#dropzone { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 14%, transparent); border: 3px dashed var(--accent); margin: 8px; border-radius: 18px; }
#dropzone div { font-size: 1.2rem; padding: 14px 22px; border-radius: 12px; background: var(--surface); box-shadow: 0 4px 18px rgba(0,0,0,.2); }

/* settings: grouped lists with a right arrow, like a settings screen */
.group-h { margin: 22px 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.list.grouped { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.list.grouped .row { border-bottom: 1px solid var(--line); }
.list.grouped li:last-child .row { border-bottom: 0; }
.chev { color: var(--muted); font-size: 1.5rem; line-height: 1; padding-left: 8px; }
.plain { padding-left: 1.2em; } .plain li { margin: .35em 0; }

/* a new chat per phase */
.phase-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 10px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.phase-divider::before, .phase-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.chat-top { text-align: center; margin: 4px 0 8px; }
.hist-body { padding: 12px 16px 24px; max-width: 46rem; margin: 0 auto; } .hist-stream { overflow: visible; padding: 0; }
.msg.flash { outline: 3px solid var(--accent); outline-offset: 2px; }

/* temporary model banner above the composer */
.model-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 6px 14px; font-size: .85rem;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-top: 1px solid var(--line); }

/* markdown tables and code */
.tablewrap { overflow-x: auto; margin: 0 0 1em; } .tablewrap table { border-collapse: collapse; font-size: .92em; min-width: 100%; }
.tablewrap th, .tablewrap td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; } .tablewrap th { background: var(--user); }
.reader pre, .msg pre { white-space: pre-wrap; background: var(--bg); padding: 10px 12px; border-radius: 8px; overflow-x: auto; border: 1px solid var(--line); }
.reader li, .msg li { margin: .25em 0; } .msg ol, .msg ul { margin: .4em 0 .6em; padding-left: 1.4em; }
.reader del, .msg del { opacity: .7; }

/* The Desk: the writer's own drafting, brief beside the draft */
.write { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; }
.write-bar { flex: none; display: flex; align-items: center; gap: 6px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px; background: var(--bar); color: var(--bar-ink); }
.write-bar .icon-btn { color: var(--bar-ink); }
.write .w-title { flex: 1; min-width: 0; background: transparent; color: var(--bar-ink); border: 0; font-weight: 600; font-size: 1.05rem; padding: 6px 8px; }
.write .w-title:focus { outline: 1px solid rgba(255,255,255,.4); border-radius: 6px; }
.write .w-status { font-size: .8rem; color: var(--bar-ink); opacity: .75; white-space: nowrap; }
.write-tools { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.write-tools .grow { flex: 1; }
.write-tools .w-tabs { margin: 0; display: none; }
.write-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(260px, 34%) 1fr; }
.write-brief { display: flex; flex-direction: column; gap: 8px; padding: 14px 14px 14px 16px; border-right: 1px solid var(--line); overflow-y: auto; background: var(--surface); }
.write-brief textarea { flex: 1; min-height: 180px; resize: none; line-height: 1.5; }
.w-label { font-weight: 600; }
.w-brief-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.write-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.w-fmt { flex: none; display: flex; gap: 4px; padding: 6px 16px; }
.w-fmt button { min-width: 38px; min-height: 34px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; }
.write-main { position: relative; }
.w-text { flex: 1; min-height: 0; width: 100%; max-width: 46rem; margin: 0 auto; border: 0; background: transparent; resize: none; padding: 12px 18px 40px; scrollbar-gutter: stable;
  font: 1.12rem/1.7 Georgia, "Iowan Old Style", "Times New Roman", serif; }
.w-text:focus { outline: none; box-shadow: none; }
.w-preview { flex: 1; min-height: 0; overflow-y: auto; width: 100%; max-width: 46rem; margin: 0 auto; padding: 12px 18px 40px; }
.w-foot { flex: none; padding: 6px 18px calc(8px + env(safe-area-inset-bottom)); text-align: right; }
.write-brief .w-side { margin: 0 0 4px; }
.write-body[data-side="brief"] .w-side-notes, .write-body[data-side="notes"] .w-side-brief,
.write-brief[data-side="brief"] .w-side-notes, .write-brief[data-side="notes"] .w-side-brief { display: none; }
.w-side-brief { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.w-side-notes { display: flex; flex-direction: column; gap: 8px; flex: none; }
.w-refhead { margin: 10px 0 2px; }
.w-refgroup, .w-refitem { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin-bottom: 6px; background: var(--bg); }
.w-refgroup > summary, .w-refitem > summary { cursor: pointer; font-weight: 600; }
.w-refitem { background: var(--surface); }
.w-ref-body { margin-top: 6px; max-height: 50vh; overflow-y: auto; font-size: .95rem; }
.w-refitems { margin-top: 6px; }

.w-note { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; background: var(--bg); }
.w-note summary { cursor: pointer; font-weight: 600; }
.w-note-body { margin: 8px 0; max-height: 40vh; overflow-y: auto; font-size: .95rem; }
@media (max-width: 860px) {
  .write-tools .w-tabs { display: grid; width: 240px; }
  .write-brief .w-side { display: none; }
  .write-body { grid-template-columns: 1fr; }
  .write-body[data-pane="draft"] .write-brief, .write-body[data-pane="side"] .write-main { display: none; }
  .write-brief { border-right: 0; }
}

.login-about { line-height: 1.5; margin: 0 0 14px; }
.login-about.small { font-size: .88rem; }
.login-seg { margin: 12px 0; }

.back-ico { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-btn .back-ico { display: block; margin: 0 auto; }
.back-label .back-ico { width: 20px; height: 20px; margin-right: 2px; }

.notices { border-color: var(--warn); }
.notices .row { min-height: 52px; padding: 8px 4px; border-bottom: 1px solid var(--line); background: transparent; }

.by { font-size: .75rem; font-weight: 600; opacity: .7; margin-bottom: 2px; }
.composer.readonly { padding: 14px 16px; }
.teamrow { align-items: center; }
.teamrow select { width: auto; min-width: 8.5rem; }
.w-banner { flex: none; padding: 10px 14px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border-bottom: 1px solid var(--line); font-size: .92rem; }

.auto-banner { border-color: var(--accent); }

/* actions menu: ⋯ on show, a sheet of rows on a phone, a small menu beside the button on a computer */
.more-btn { border: 1px solid var(--line); background: var(--surface); min-width: 44px; min-height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.more-ico { width: 22px; height: 22px; fill: currentColor; }
.am-ico { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.am-list { display: flex; flex-direction: column; }
.am-item { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: none; border: 0; padding: 14px 6px; min-height: 52px; cursor: pointer; font-size: 1.02rem; border-bottom: 1px solid var(--line); }
.am-item:last-child { border-bottom: 0; }
.am-item.danger { color: var(--bad); }
.am-item:disabled { opacity: .45; cursor: default; }
.am-sep { height: 8px; }
.am-head { font-size: .78rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); padding: 10px 6px 2px; }
#action-menu { position: fixed; z-index: 65; min-width: 240px; max-width: 340px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.28); }
#action-menu .am-item { padding: 10px 10px; min-height: 42px; border: 0; border-radius: 8px; font-size: .95rem; }
#action-menu .am-item:hover, #action-menu .am-item:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); outline: none; }
#action-menu .am-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.listbar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.listbar .grow { flex: 1; min-width: 0; }
.listbar .btn { min-height: 44px; }
.rowlist .row { border-radius: 0; }

.listbar.nopad { padding-left: 0; padding-right: 0; }
.listbar .btn.grow { flex: 1; }
.docbar { padding: 8px 0 12px; }

.morerows { padding-top: 0; }
@media (max-width: 860px) {
  .write-tools { flex-wrap: wrap; row-gap: 6px; }
  .write-tools .w-tabs { width: 100%; flex: 1 1 100%; }
  .write-tools .more-btn { min-width: 40px; min-height: 36px; }
}

.phase .phsub { margin-top: 3px; }
.phase .phsub .pill { display: inline-block; white-space: normal; }

.searchrow { padding: 0 16px 8px; }
.searchrow input { min-height: 44px; }
.excerpt { margin-top: 2px; white-space: normal; }
mark { background: color-mix(in srgb, var(--warn) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.psrow .sub { white-space: normal; }
#psres { padding: 0 16px 16px; }
#w-psq { margin: 4px 0 8px; }
#w-psres .w-refhead { margin: 8px 0 2px; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }

/* structure map */
.sm-sum { font: 14px/1.4 system-ui, sans-serif; color: var(--muted); margin: 4px 0 10px; }
.sm-strip { display: flex; gap: 3px; height: 38px; margin-bottom: 10px; }
.sm-seg { flex: 1 1 0; min-width: 6px; border: 0; border-radius: 6px; background: color-mix(in srgb, var(--accent) 55%, var(--surface)); cursor: pointer; padding: 0; color: var(--accent-ink); font-size: .72rem; overflow: hidden; }
.sm-seg:hover { background: var(--accent); }
.sm-seg span { opacity: .85; }
.sm-notes { margin: 0 0 8px; padding-left: 18px; font-size: .88rem; color: var(--warn); }
.sm-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.sm-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 46px; gap: 8px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); min-height: 40px; cursor: pointer; padding-right: 4px; }
.sm-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.sm-title.scene { color: var(--muted); font-size: .88rem; }
.sm-bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.sm-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.sm-w { text-align: right; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* The Desk's editor: mode tabs, the toolbar, find, and the Page tab */
.w-modebar { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 16px 2px; }
.w-modebar .w-modes { margin: 0; width: 190px; }
.w-modebar .grow { flex: 1; }
.w-pagetools { display: inline-flex; gap: 6px; align-items: center; }
.w-pagetools select { width: auto; min-height: 34px; padding: 0 6px; font-size: .85rem; }
.w-pagetools button { min-height: 34px; min-width: 38px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; }
.w-fmt { display: flex; flex-wrap: nowrap; gap: 4px; overflow-x: auto; padding: 6px 16px; align-items: center; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.w-fmt button { flex: none; min-width: 36px; min-height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; font-size: .95rem; padding: 0 6px; }
.w-fmt button:disabled { opacity: .4; cursor: default; }
.ed-style { flex: none; width: auto; min-height: 36px; padding: 0 6px; font-size: .88rem; max-width: 9.5rem; }
.ed-sep { flex: none; width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.ed-hi { background: color-mix(in srgb, var(--warn) 45%, transparent); padding: 0 3px; border-radius: 3px; }
.w-find { flex: none; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.w-find input[type=search], .w-find input[type=text] { flex: 1 1 9rem; min-width: 7rem; min-height: 36px; }
.w-find button { min-height: 36px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 0 10px; cursor: pointer; }
.w-preview { background: color-mix(in srgb, var(--bg) 92%, #000); }
.page-sheet { --pg-size: 1; --lh: 1.7; margin: 14px auto 40px; background: var(--surface); padding: 2.2rem 2.6rem; border-radius: 6px; box-shadow: 0 1px 8px rgba(0,0,0,.22);
  font: calc(1.08rem * var(--pg-size)) / var(--lh) Georgia, "Iowan Old Style", "Times New Roman", serif; overflow-wrap: anywhere; }
.page-sheet.inline { box-shadow: none; padding: 0; background: transparent; margin: 8px 0 24px; }
.pw-narrow { max-width: 34rem; } .pw-normal { max-width: 46rem; } .pw-wide { max-width: 64rem; }
.pl-tight { --lh: 1.45; } .pl-normal { --lh: 1.7; } .pl-roomy { --lh: 2.05; }
.page-sheet h1, .page-sheet h2, .page-sheet h3, .page-sheet h4, .page-sheet h5, .page-sheet h6 { font-family: -apple-system, system-ui, "Segoe UI", sans-serif; line-height: 1.25; margin: 1.5em 0 .5em; }
.page-sheet h1 { font-size: 1.9em; } .page-sheet h2 { font-size: 1.5em; } .page-sheet h3 { font-size: 1.25em; } .page-sheet h4 { font-size: 1.1em; } .page-sheet h5, .page-sheet h6 { font-size: 1em; text-transform: uppercase; letter-spacing: .03em; }
.page-sheet > :first-child { margin-top: 0; }
.page-sheet p { margin: 0 0 .9em; }
.page-sheet blockquote { margin: 1em 0; padding: .1em 1em; border-left: 4px solid var(--accent); color: var(--muted); }
.page-sheet table { border-collapse: collapse; margin: 1em 0; width: 100%; font-size: .95em; display: block; overflow-x: auto; }
.page-sheet th, .page-sheet td { border: 1px solid var(--line); padding: .4em .7em; text-align: left; vertical-align: top; }
.page-sheet th { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.page-sheet code { font-family: ui-monospace, Menlo, monospace; font-size: .88em; background: color-mix(in srgb, var(--line) 60%, transparent); padding: .1em .35em; border-radius: 4px; }
.page-sheet pre { background: color-mix(in srgb, var(--line) 50%, transparent); padding: .8em 1em; border-radius: 8px; overflow-x: auto; }
.page-sheet pre code { background: none; padding: 0; }
.page-sheet mark { background: color-mix(in srgb, var(--warn) 38%, transparent); color: inherit; padding: 0 .1em; }
.page-sheet abbr[title] { text-decoration: underline dotted; cursor: help; }
.page-sheet dt { font-weight: 700; margin-top: .6em; } .page-sheet dd { margin: .1em 0 .3em 1.6em; }
.page-sheet hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em auto; max-width: 40%; }
.page-sheet ul.contains-task-list, .page-sheet li.task-list-item { list-style: none; } .page-sheet ul.contains-task-list { padding-left: .4em; }
.page-sheet li.task-list-item input { margin-right: .5em; }
.page-sheet .footnotes { font-size: .85em; border-top: 1px solid var(--line); margin-top: 2em; padding-top: .6em; }
.page-sheet .footnote-ref a, .page-sheet .footnote-backref { text-decoration: none; }
@media (max-width: 860px) { .page-sheet { padding: 1.2rem 1.1rem; margin: 8px 0 24px; border-radius: 0; box-shadow: none; } .w-modebar { flex-wrap: wrap; } }
.w-focus .write-bar, .w-focus .write-tools, .w-focus .write-brief, .w-focus .w-modebar, .w-focus .w-fmt, .w-focus .w-foot { display: none !important; }
.w-focus .write-body { grid-template-columns: 1fr; }
.w-focus-exit { display: none; position: fixed; top: calc(8px + env(safe-area-inset-top)); right: 10px; z-index: 5; min-height: 34px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 0 14px; font-size: .82rem; opacity: .75; cursor: pointer; }
.w-focus .w-focus-exit { display: inline-block; }
@media print {
  body.print-page { visibility: hidden; background: #fff; }
  body.print-page .write.in-pane, body.print-page .write.in-pane * { visibility: visible; }
  body.print-page .write.in-pane { position: absolute; inset: 0 auto auto 0; width: 100%; height: auto; display: block; overflow: visible; background: #fff; }
  body.print-page .write-bar, body.print-page .write-tools, body.print-page .write-brief, body.print-page .w-modebar, body.print-page .w-fmt, body.print-page .w-find, body.print-page .w-foot, body.print-page .w-banner, body.print-page .w-focus-exit { display: none !important; }
  body.print-page .write-body { display: block; } body.print-page .w-preview { overflow: visible; background: #fff; }
  body.print-page .page-sheet { box-shadow: none; max-width: none; padding: 0; margin: 0; background: #fff; color: #000; }
}
.page-sheet a { color: var(--accent); }
.page-sheet .footnote-ref a, .page-sheet .footnote-backref { color: var(--accent); font-weight: 600; }

/* tasks: the five tasks as a tree, each opening to its steps */
.task { border-bottom: 1px solid var(--line); }
.taskhead { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 8px; background: none; border: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; border-radius: 8px; }
.taskhead .chev { width: 1ch; color: var(--muted); flex: none; }
.taskhead .mark { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; flex: none; }
.task.done .taskhead .mark { background: var(--good); border-color: var(--good); color: var(--good-ink); }
.task.current .taskhead .mark { border-color: var(--accent); color: var(--accent); }
.task.current .taskhead .phname { font-weight: 700; }
.taskbar { height: 4px; margin: 0 8px 4px 46px; background: var(--line); border-radius: 2px; overflow: hidden; }
.taskbar span { display: block; height: 100%; background: var(--good); }
.steps { margin: 0 0 8px 28px; border-left: 2px solid var(--line); }
.steps[hidden] { display: none; }
.phase.step { padding: 9px 8px; border-bottom: 0; }
.phase.step .mark { width: 22px; height: 22px; font-size: .72rem; }
.phase.step .phname { font-size: .95rem; }

/* The Desk first: the card that takes the writer back to it, and, on a wide screen, the assistant docked beside the open Desk */
.deskcard { display: flex; align-items: center; gap: 10px; padding: 12px; margin: 4px 0 10px; border: 1px solid var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.deskcard .grow { min-width: 0; } .deskcard .phsub { overflow-wrap: anywhere; }

/* step owner and due date, notes and ripples */
.stepmeta { display: grid; gap: 8px; }
.stepmeta .field { margin: 0; }
.tnotes { margin-top: 18px; }
.tnote { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: var(--surface); overflow-wrap: anywhere; }
.tnote.ripple { border-color: var(--warn); }
.tnote .listbar { margin-top: 8px; gap: 6px; flex-wrap: wrap; }
.ripple-list { margin: 8px 0; } .ripple-list ol, .ripple-list ul { margin: 4px 0; padding-left: 20px; }

/* The Desk: suggestions for the selected text */
.w-sel { flex: none; display: flex; align-items: center; gap: 6px; padding: 4px 16px; flex-wrap: wrap; }
.w-sel button, .w-sug .btn { min-height: 34px; }
.w-sel button { border: 1px solid var(--accent); background: var(--surface); color: var(--accent); border-radius: 8px; padding: 0 12px; cursor: pointer; font-weight: 600; }
.w-sug { flex: none; margin: 4px 16px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 10px; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); max-height: 40vh; overflow-y: auto; }
.w-sug-text { margin: 8px 0; white-space: pre-wrap; line-height: 1.55; }

/* The Desk first, part 2: navigator beside it (wide screens), the assistant as a drawer over it (phones) */
.write-bar .btn { background: transparent; color: var(--bar-ink); border-color: rgba(255,255,255,.55); }

/* the process map */
.pmap { display: block; margin: 4px auto; }
.pm-node { fill: var(--surface); stroke: var(--line); stroke-width: 2; }
.pm-done { fill: var(--good); stroke: var(--good); }
.pm-working { stroke: var(--accent); stroke-width: 3; }
.pm-look { fill: var(--warn); stroke: var(--warn); }
.pm-task.pm-todo { stroke: var(--line); }
.pm-edge { stroke: var(--line); stroke-width: 2; fill: none; } .pm-edge.pm-done { stroke: var(--good); }
.pm-arrowhead { fill: var(--line); }
.pm-dep { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 4; fill: none; opacity: .6; }
.pm-num { font: 700 12px system-ui, sans-serif; fill: var(--ink); } .pm-task.pm-done + .pm-num, .pm-hit .pm-task.pm-done ~ .pm-num { fill: #fff; }
.pm-name { font: 700 14px system-ui, sans-serif; fill: var(--ink); }
.pm-sub { font: 11px system-ui, sans-serif; fill: var(--muted); }
.pm-label { font: 13px system-ui, sans-serif; fill: var(--ink); } .pm-label.pm-cur { font-weight: 700; }
.pm-hit { cursor: pointer; } .pm-hit:hover .pm-label, .pm-hit:focus .pm-label, .pm-hit:hover .pm-name { text-decoration: underline; }
.pm-hit:focus { outline: none; } .pm-hit:focus-visible .pm-node { stroke: var(--accent); stroke-width: 4; }
.pm-legend { text-align: center; } .pm-legend .pm-key { display: inline-block; min-width: 1.2em; text-align: center; margin-left: 8px; fill: none; stroke: none; }
.pm-legend .pm-key.pm-done { color: var(--good); background: none; } .pm-legend .pm-key.pm-working { color: var(--accent); } .pm-legend .pm-key.pm-look { color: var(--warn); } .pm-legend .pm-key.pm-todo { color: var(--line); }
.mapbar { display: flex; gap: 8px; margin: 4px 0 8px; align-items: center; } .mapbar .seg { margin: 0; flex: 1; } .mapbar .btn { flex: none; }
body[data-layout="desktop"] .sheet:has(.pm-big), .sheet:has(.pm-big) { max-width: min(1040px, 96vw); }
/* the large maps can be resized by dragging the corner (a computer) */
body[data-layout="desktop"] .sheet:has(.pm-big), body[data-layout="desktop"] .sheet:has(.cm-big) { resize: both; overflow: auto; width: min(960px, 96vw); min-width: 340px; min-height: 260px; max-width: 98vw; max-height: 94vh; }

/* the content map */
.cmap { display: block; margin: 6px auto; }
.cm-node { cursor: pointer; } .cm-node rect { fill: var(--surface); stroke: var(--line); stroke-width: 2; }
.cm-L0 rect { stroke: var(--accent); } .cm-L1 rect { stroke: var(--good); } .cm-L2 rect { stroke: var(--warn); } .cm-L3 rect { stroke: var(--muted); }
.cm-node.sel rect { stroke-width: 4; fill: color-mix(in srgb, var(--accent) 12%, var(--surface)); } .cm-node.near rect { stroke-width: 3.5; }
.cm-type { font: 700 8px system-ui, sans-serif; letter-spacing: .06em; fill: var(--muted); } .cm-label { font: 600 11px system-ui, sans-serif; fill: var(--ink); } .cm-doc { font: 10px system-ui, sans-serif; fill: var(--muted); }
.cm-node:focus { outline: none; } .cm-node:focus-visible rect { stroke-width: 4.5; }
.cm-edge { fill: none; stroke: var(--line); stroke-width: 1.6; } .cm-edge.hot { stroke: var(--accent); stroke-width: 2.8; } .cm-edge.dim { opacity: .3; }
.cmdetail { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: var(--surface); overflow-wrap: anywhere; }
.cmdetail .listbar { margin-top: 8px; gap: 6px; flex-wrap: wrap; }
.sheet:has(.cm-big) { max-width: min(900px, 96vw); }
.cm-node.lit rect { fill: color-mix(in srgb, var(--warn) 20%, var(--surface)); stroke: var(--warn); stroke-width: 3.5; }
.cm-bang { fill: var(--warn); } .cm-bangtxt { font: 800 12px system-ui, sans-serif; fill: #fff; }
.banner.small .btn { margin: 6px 6px 0 0; }

/* Write: the writing page, a column on a computer and a tab on a phone */
.write.in-pane { position: relative; inset: auto; z-index: auto; height: 100%; min-height: 0; overflow: hidden; background: var(--bg); }
.write.in-pane.w-focus { position: fixed; inset: 0; z-index: 40; }
.write.in-pane .write-bar { padding: 6px 10px; }
.write.in-pane .w-tabs, .write.in-pane .write-tools .w-tabs { display: none; }
.write.in-pane .write-tools { flex-wrap: nowrap; padding: 6px 10px; }
.write.in-pane .write-body, .write.in-pane .write-body[data-pane] { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
.write.in-pane .write-body[data-pane] .write-main { display: flex; grid-row: 1; grid-column: 1; }
.write.in-pane .write-brief { display: none; }
/* the brief and guidance shelf: below the page (open), beside it on a wide window, filling the column, or minimized to a tab */
.write.in-pane.sh-open .write-body, .write.in-pane.sh-open .write-body[data-pane] { grid-template-rows: minmax(120px, 1fr) minmax(170px, 46%); }
.write.in-pane.sh-open .write-brief { display: flex; grid-row: 2; grid-column: 1; border-right: 0; border-top: 1px solid var(--line); padding-top: 8px; }
.write.in-pane.sh-open.sh-full .write-body, .write.in-pane.sh-open.sh-full .write-body[data-pane] { grid-template-rows: minmax(0, 1fr); }
.write.in-pane.sh-open.sh-full .write-main, .write.in-pane.sh-open.sh-full .write-body[data-pane] .write-main { display: none; }
.write.in-pane.sh-open.sh-full .write-brief { grid-row: 1; border-top: 0; }
@media (min-width: 861px) {
  .write.in-pane.sh-open.sh-side .write-body, .write.in-pane.sh-open.sh-side .write-body[data-pane] { grid-template-columns: minmax(250px, 38%) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .write.in-pane.sh-open.sh-side .write-brief { grid-row: 1; grid-column: 1; border-top: 0; border-right: 1px solid var(--line); }
  .write.in-pane.sh-open.sh-side .write-body[data-pane] .write-main { grid-row: 1; grid-column: 2; }
}
.write.in-pane .write-brief .w-side { display: grid; }
.shelf-head { flex: none; display: flex; align-items: center; gap: 4px; }
.shelf-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.shelf-btn { min-width: 36px; min-height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font-size: 1rem; cursor: pointer; }
.shelf-btn:hover, .shelf-btn:focus-visible { background: color-mix(in srgb, var(--accent) 20%, transparent); outline: none; }
.w-shelftab { display: none; flex: none; width: 100%; min-height: 44px; padding: 0 14px; border: 0; border-top: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.write.in-pane.sh-min .w-shelftab { display: block; }
.write.in-pane.sh-min.w-focus .w-shelftab, .write.in-pane.has-prop .w-shelftab { display: none; }
.write.in-pane .w-fmt { overflow-x: auto; }
.cols #pane-library .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.cols #pane-library .seg button { font-size: .74rem; padding: 0 2px; }
.lib .seg button { padding: 0 8px; font-size: .88rem; }
/* each column keeps its own track even while a neighbour is folded away */
.cols > .col1 { grid-column: 1; } .cols > .resizer[data-col="1"] { grid-column: 2; } .cols > #col-write { grid-column: 3; }
.cols > .resizer[data-col="2"] { grid-column: 4; } .cols > #pane-chat { grid-column: 5; } .cols > .resizer[data-col="3"] { grid-column: 6; } .cols > .side { grid-column: 7; }
.cols > .col1, .cols > #col-write, .cols > #pane-chat, .cols > .side, .cols > .resizer { grid-row: 1; }
/* the ⋯ and Mark done sit at the right of the title row, not on a row of their own */
.write.in-pane .write-tools { display: none; }
.write.in-pane .write-bar .more-btn { flex: none; min-width: 36px; min-height: 36px; background: transparent; color: var(--bar-ink); border-color: rgba(255,255,255,.55); }
.write.in-pane .write-bar #w-done { flex: none; }

/* Write: the chat about this document, a drawer under the page */
.w-chat { flex: none; height: 46%; min-height: 0; display: flex; flex-direction: column; border-top: 2px solid var(--accent); background: var(--surface); }
.w-chat.hidden { display: none; }
.w-chat-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; flex-wrap: wrap; }
.w-chat-head .grow { flex: 1; }
.w-chat-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 8px; }
.wc-msg { margin: 6px 0; padding: 8px 10px; border-radius: 10px; overflow-wrap: anywhere; }
.wc-msg.me { background: var(--user); margin-left: 24px; white-space: pre-wrap; }
.wc-msg.ai { background: var(--bg); border: 1px solid var(--line); margin-right: 12px; }
.wc-msg blockquote { margin: 0 0 6px; padding-left: 8px; border-left: 3px solid var(--accent); color: var(--muted); font-size: .85rem; }
.wc-msg .reader { padding: 0; }
.wc-edits { margin-top: 8px; }
.wc-edit { margin: 4px 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: .88rem; white-space: pre-wrap; }
.wc-edit del { display: block; background: color-mix(in srgb, #c0392b 16%, transparent); }
.wc-edit ins { display: block; text-decoration: none; background: color-mix(in srgb, #2e8b57 20%, transparent); }
.w-chat-form { display: flex; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.w-chat-form textarea { flex: 1; resize: none; min-height: 44px; }
.write.in-pane .w-chat-head .muted { display: none; }
@media (min-width: 900px) { .write.in-pane .w-chat-head .muted { display: inline; } }
@media (max-width: 600px) { .write.in-pane .write-bar .w-status { display: none; } .write.in-pane .write-bar .btn.small { padding: 0 10px; } }

/* the detail slider: Simple, Medium, Detailed */
.detail-pick { margin: 10px 0 14px; }
.detail-pick input[type=range] { width: 100%; min-height: 36px; accent-color: var(--accent); }
.dl-ticks { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); padding: 0 2px; }
.dl-ticks .on { color: var(--accent); font-weight: 700; }
.dl-text { margin: 10px 0 0; line-height: 1.5; }

/* Project settings: a panel beside the page on a computer */
.setup-scrim { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.35); display: flex; justify-content: flex-end; }
.setup-panel { width: min(640px, 100%); height: 100%; background: var(--bg); border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0,0,0,.3); }
.setup-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bar); color: var(--bar-ink); }
.setup-head .grow { flex: 1; }
.setup-head .btn { background: transparent; color: var(--bar-ink); border-color: rgba(255,255,255,.55); }
.setup-head .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#setup-body { flex: 1; min-height: 0; overflow-y: auto; }
.role-card { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.role-card h4 { margin: 0 0 2px; }

/* Activity: the log at the foot of the Library column */
.col1 { display: flex; flex-direction: column; min-height: 0; min-width: 0; --act-h: 160px; background: var(--bg); }
.col1 > #pane-library { flex: 1; min-height: 0; }
.act { flex: none; display: flex; flex-direction: column; height: var(--act-h); min-height: 0; border-top: 1px solid var(--line); background: var(--surface); }
.act.folded { height: auto; }
.act.folded .act-list, .act.folded .act-live, .act.folded .act-grip { display: none; }
.act-grip { flex: none; height: 6px; margin-top: -3px; cursor: row-resize; touch-action: none; background: transparent; }
.act-grip:hover, .act-grip:focus-visible, .act-grip.drag { background: var(--accent); outline: none; }
body.resizing-row { cursor: row-resize; user-select: none; }
.act-head { flex: none; display: flex; align-items: center; gap: 6px; padding: 2px 8px; }
.act-head .grow { flex: 1; }
.act-fold, .act-clear { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; font-size: .78rem; padding: 4px 4px; }
.act-fold { font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.act-clear { color: var(--muted); } .act-fold:hover, .act-clear:hover { color: var(--accent); }
.act-count { font-weight: 400; }
.act-live { flex: none; padding: 3px 10px; font-size: .78rem; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.act-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 6px; font-size: .78rem; line-height: 1.35; }
.act-row { display: grid; grid-template-columns: auto 1em 1fr; gap: 6px; padding: 1px 0; }
.act-t { color: var(--muted); font-variant-numeric: tabular-nums; } .act-x { overflow-wrap: anywhere; }
.act-row.warn .act-i, .act-row.warn .act-x { color: #c58a00; } .act-row.error .act-i, .act-row.error .act-x { color: #c0392b; }
.act-row.save .act-i { color: #2e8b57; } .act-row.ai .act-i, .act-row.model .act-i { color: var(--accent); } .act-row.model .act-x { color: var(--muted); }
.act-x a { color: var(--accent); text-decoration: underline; }

/* Activity on a phone: a panel across the lower part of the screen */
.act-phone { position: fixed; left: 0; right: 0; bottom: 0; z-index: 55; border-top: 2px solid var(--accent); box-shadow: 0 -8px 30px rgba(0,0,0,.3); padding-bottom: env(safe-area-inset-bottom); }
.act-phone .act-grip { height: 14px; margin-top: -7px; } .act-phone .act-list { font-size: .85rem; }
.act-phone .act-close { color: var(--accent); font-weight: 700; padding: 8px 10px; }
body.act-open .tabs { visibility: hidden; }
.act-link { margin-left: 8px; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; font-size: .85rem; padding: 4px 2px; }

/* suggested replies under a question: whole sentences, so they wrap */
.choices.replies { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.choices .btn.reply { text-align: left; white-space: normal; height: auto; min-height: 36px; line-height: 1.35; padding: 8px 12px; }

/* Library section dropdown */
.libsel { margin: 8px; } .libsel select { width: 100%; min-height: 40px; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* a map in Write */
.map-pane { display: flex; flex-direction: column; }
.map-pane .map-body { flex: 1; min-height: 0; overflow-y: auto; }
.map-card { flex: none; max-height: 40%; overflow-y: auto; padding: 10px 14px; border-top: 2px solid var(--accent); background: var(--surface); }
.cm-band { fill: color-mix(in srgb, var(--ink) 4%, transparent); stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 4; }
.cm-bandlabel { font-size: 10px; fill: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cm-node { touch-action: none; } .cm-node.dragging { opacity: .85; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); cursor: grabbing; }
.cm-node.target rect { stroke: var(--accent); stroke-width: 5; } svg.cmap.dragging { cursor: grabbing; }

/* moving a part of a document on the structure map */
.sm-grip { display: inline-block; width: 18px; margin-right: 4px; color: var(--muted); text-align: center; user-select: none; }
.sm-row.dragging { opacity: .8; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); position: relative; z-index: 3; box-shadow: 0 4px 10px rgba(0,0,0,.3); }
.sm-drop { position: fixed; height: 3px; background: var(--accent); z-index: 70; pointer-events: none; border-radius: 2px; }

/* the two side columns each have a heading that stays put while what is under it scrolls */
.cols > .side { display: flex; flex-direction: column; overflow: hidden; }
.cols > .side #pane-phases { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.cols .pane-head { flex: none; margin: 0; padding: 12px 16px 8px; background: color-mix(in srgb, var(--bg) 90%, #000); border-bottom: 1px solid var(--line); }
.chat > .pane-head { flex: none; }
/* a map on a phone: a drawer over the Library */
.map-layer { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; animation: fade .15s; }
.map-drawer { width: 100%; height: 94dvh; background: var(--bg); border-radius: 20px 20px 0 0; overflow: hidden; display: flex; flex-direction: column; animation: rise .2s ease-out; }
.map-drawer.write { height: 94dvh; }
.write-bar #mp-back { margin-right: 4px; color: var(--bar-ink); }
.map-drawer .write-bar { padding-top: 8px; border-radius: 20px 20px 0 0; }

.colwrap { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; background: var(--bg); }
.colwrap > #pane-write { flex: 1; min-height: 0; }
.mapsub { margin: -2px 0 8px; } .mapsub .btn { width: 100%; }
.cols > .side #pane-phases { overflow-x: hidden; }
.cols > .side .pad { min-width: 0; padding: 12px; }

/* Settings, Display: pick a colour scheme and a text size */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 6px 0 14px; }
.swatch { border: 2px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; text-align: left; min-height: 64px; }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.swatch b { display: block; font-size: 1.1rem; } .swatch span { font-size: .8rem; opacity: .85; }
.sizes { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; } .sizes .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.stepchat { cursor: pointer; font-size: .75rem; padding: 2px 10px; margin-left: auto; }
.stepchat:hover, .stepchat:focus-visible { border-color: var(--accent); color: var(--accent); }

/* One navigator column: a single project tree. A step's detail, or the library drilled into, takes the column in its place. */
.cols.nav, .cols.nav.c3-off { --c3: 0px; --r3: 0px; }
.col1 > .navtree { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.col1 > #pane-phases { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.col1[data-nav="tree"] > #pane-phases, .col1[data-nav="tree"] > #pane-library, .col1[data-nav="step"] > .navtree, .col1[data-nav="step"] > #pane-library, .col1[data-nav="lib"] > .navtree, .col1[data-nav="lib"] > #pane-phases { display: none; }
.col1[data-nav="step"] > #pane-phases .pad { min-width: 0; padding: 12px; }
.nv-search { display: flex; align-items: center; gap: 8px; padding: 8px 10px 4px; } .nv-search input { flex: 1; min-width: 0; }
.nv-plus { flex: none; min-width: 42px; min-height: 42px; padding: 0; border-radius: 50%; font-size: 1.4rem; line-height: 1; }
.nv-goal { padding: 2px 14px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nv-head { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 12px; border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.nv-head:hover, .nv-head:focus-visible, .nv-leaf:hover, .nv-leaf:focus-visible, .nv-stepname:hover, .nv-stepname:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); outline: none; }
.nv-head .chev { width: 1em; color: var(--muted); flex: none; }
.nv-group > .nv-head { text-transform: uppercase; letter-spacing: .05em; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--line); }
.nv-kids { padding-left: 10px; }
.nv-group > .nv-kids { padding-left: 4px; }
.nv-taskhead .mark { flex: none; }
.nv-steprow { display: flex; align-items: center; gap: 2px; padding-right: 8px; }
.nv-steprow.current .nv-t { font-weight: 700; }
.nv-steprow.complete .nv-t { color: var(--muted); }
.nv-chev { flex: none; width: 24px; height: 28px; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.nv-stepname { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 6px 6px; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; border-radius: 6px; }
.nv-leaf { display: flex; align-items: center; gap: 6px; width: 100%; padding: 5px 10px 5px 14px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: .92rem; text-align: left; cursor: pointer; border-radius: 6px; }
.nv-leaf.current { background: color-mix(in srgb, var(--accent) 22%, transparent); font-weight: 600; }
.nv-add { color: var(--muted); }
.nv-ic { flex: none; width: 1.2em; text-align: center; color: var(--muted); }
.nv-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv-none { padding: 2px 14px; }
.nv-docs { padding-left: 26px; }
.col1 .navtree .tnotes { padding: 8px 12px; }
.col1 .libbar.navback { display: flex; align-items: center; gap: 8px; }

/* the assistant's text in the Write column: light gray until the writer accepts it */
.w-prop { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.w-prop-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.w-prop-why { margin: 6px 18px 0; }
.w-prop-text { opacity: .55; color: var(--muted); }
.w-prop-text * { color: inherit; }
.nv-leaf.building { animation: nvpulse 1.4s ease-in-out infinite; }
@keyframes nvpulse { 0%, 100% { background: color-mix(in srgb, var(--accent) 10%, transparent); } 50% { background: color-mix(in srgb, var(--accent) 34%, transparent); } }
@media (prefers-reduced-motion: reduce) { .nv-leaf.building { animation: none; background: color-mix(in srgb, var(--accent) 24%, transparent); } }
.write.has-prop .w-banner, .write.has-prop .write-tools { display: none; }
.write.has-prop .write-main > :not(.w-prop):not(.w-foot) { display: none !important; }
.w-prop-text { flex: 1; padding: 8px 4px 24px; }
.w-prop-text.page-sheet { box-shadow: none; background: transparent; }
.w-prop-text, .w-prop-text.page-sheet { display: block; max-width: 46rem; margin: 0 auto; padding: 8px 18px 24px; }

/* writing goals */
.nv-goalbtn { display: block; width: 100%; padding: 8px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.nv-goalbtn:hover, .nv-goalbtn:focus-visible { background: color-mix(in srgb, var(--accent) 12%, transparent); outline: none; }
.gbar { height: 5px; margin: 4px 0 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.gbar > span { display: block; height: 100%; background: var(--accent); }
.linkbtn { border: 0; background: transparent; color: var(--muted); font: inherit; padding: 0; cursor: pointer; text-decoration: underline dotted; }

/* the read-aloud player */
#readbar { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 6px; width: min(94vw, 560px); padding: 8px 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 6px 24px rgba(0,0,0,.35); }
#readbar button { min-width: 36px; min-height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--ink); font-size: 1rem; cursor: pointer; }
#readbar button:hover, #readbar button:focus-visible { background: color-mix(in srgb, var(--accent) 24%, transparent); outline: none; }
#readbar select { max-width: 9rem; min-height: 32px; }
.rd-now { flex: 1 0 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: var(--muted); font-size: .82rem; }

/* line-edit checks, in the Write column */
.w-ckpanel { flex: none; max-height: 42%; overflow-y: auto; border-top: 1px solid var(--line); background: var(--surface); }
.ck-bar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.ck-body { padding: 4px 14px 12px; }
.ck-sec { border-bottom: 1px solid var(--line); padding: 6px 0; } .ck-sec summary { cursor: pointer; padding: 4px 0; }
.ck-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font: inherit; font-size: .9rem; text-align: left; cursor: pointer; }
.ck-item:hover, .ck-item:focus-visible { background: color-mix(in srgb, var(--accent) 16%, transparent); outline: none; }
.ck-note { margin: 4px 0; }
.write.has-prop .w-ckpanel { display: none; }

/* the board: a document's parts as cards */
.w-board { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.write.has-board .write-main > :not(.w-board):not(.w-foot):not(.w-modebar) { display: none !important; }
.write.has-board .write-main > .w-modebar .w-modes, .write.has-board .write-main > .w-modebar .w-pagetools { display: none; }
.write.has-board .w-ckpanel { display: none; }
.bd-bar { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.bd-lanes { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 12px; overflow: auto; align-items: flex-start; }
.bd-lane { flex: 0 0 min(260px, 78vw); max-height: 100%; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.bd-lane h4 { margin: 0; padding: 10px 12px 6px; font-size: .9rem; }
.bd-cards { padding: 4px 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.bd-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); cursor: grab; }
.bd-card:focus-visible { outline: 2px solid var(--accent); }
.bd-card.dragging { opacity: .45; } .bd-card.over { border-color: var(--accent); box-shadow: 0 -3px 0 var(--accent); }
.bd-t { font-weight: 600; } .bd-s { margin-top: 4px; color: var(--muted); }
.bd-btns { display: flex; gap: 4px; margin-top: 6px; }
.bd-btns button { min-width: 32px; min-height: 28px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--ink); cursor: pointer; }
.bd-btns button:disabled { opacity: .35; cursor: default; }
.bd-btns button:not(:disabled):hover, .bd-btns button:not(:disabled):focus-visible { background: color-mix(in srgb, var(--accent) 20%, transparent); outline: none; }
.bd-empty { padding: 8px; text-align: center; }

/* the grey continuation after the end of the page */
.w-ghost { position: absolute; z-index: 1; display: none; margin: 0; border: 0; padding: 12px 18px 40px; box-sizing: border-box; overflow: hidden; scrollbar-gutter: stable; pointer-events: none;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; font: 1.12rem/1.7 Georgia, "Iowan Old Style", "Times New Roman", serif; }
.w-ghost .gh-hide { color: transparent; } .w-ghost .gh-text { color: var(--muted); opacity: .75; }

/* the project home page, in the Write column */
.write.in-pane.home-pane .home-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.home-title { font-size: 1rem; }
.hm-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 12px 14px; }
.hm-card h3 { margin: 0 0 8px; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.hm-name { margin: 0 0 2px; font-size: 1.35rem; } .hm-aim { margin: 6px 0 0; }
.hm-stats { display: flex; gap: 18px; flex-wrap: wrap; } .hm-stats > div { display: flex; flex-direction: column; } .hm-stats strong { font-size: 1.3rem; }
.hm-next { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); } .hm-next:first-of-type { border-top: 0; }
.hm-nt { font-weight: 600; }
.hm-ev { padding: 4px 0; font-size: .92rem; }
.home-btn { flex: none; }

/* the two level sliders and the project feed, on the project home */
.lv-set + .lv-set { margin-top: 14px; }
.lv-set .group-h { margin: 0 0 2px; }
.fd-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fd-row { display: flex; gap: 8px; align-items: center; }
.fd-row input { flex: 1; min-width: 0; }
.fd-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 10px 0 4px; }
.fd-filters input[type=search] { flex: 1; min-width: 90px; max-width: 200px; }
.fd-list { list-style: none; margin: 8px 0; padding: 0; }
.fd-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.fd-title { font-weight: 600; text-decoration: none; color: var(--ink); overflow-wrap: anywhere; }
.fd-title:hover { text-decoration: underline; }
.fd-chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: .85rem; cursor: pointer; }
.fd-chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.fd-snip { margin-top: 2px; font-size: .9rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.hm-h { display: flex; align-items: center; gap: 6px; }
.hm-move { margin-left: auto; display: inline-flex; gap: 2px; }
.hm-move .icon-btn { min-width: 32px; min-height: 32px; width: 32px; height: 32px; font-size: .7rem; opacity: .6; }
.hm-move .icon-btn:hover:not(:disabled) { opacity: 1; }
.hm-move .icon-btn:disabled { opacity: .2; }
.fd-plan span { white-space: nowrap; }

/* captive browser */
.browser-view { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; background: var(--bg); }
.bv-bar { display: flex; align-items: center; gap: 10px; padding: calc(6px + env(safe-area-inset-top)) 12px 6px; background: var(--surface); border-bottom: 1px solid var(--line); }
.bv-back { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: inherit; font: inherit; font-weight: 600; cursor: pointer; }
.bv-back .back-ico { width: 20px; height: 20px; }
.bv-host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .9rem; }
.bv-out { font-size: .85rem; white-space: nowrap; }
.bv-frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* navigator branch arrows: larger, in a tinted chip, so they can be seen and hit */
.nv-head .chev, .nv-chev { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 26px; height: 26px; padding: 0; border-radius: 6px; font-size: 1.15rem; line-height: 1; color: var(--ink); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.nv-chev { width: 30px; height: 30px; border: 0; cursor: pointer; }
.nv-head:hover .chev, .nv-chev:hover, .nv-chev:focus-visible { background: color-mix(in srgb, var(--accent) 34%, transparent); outline: none; }
.bv-note { padding: 8px 14px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-bottom: 1px solid var(--line); font-size: .88rem; }
.bv-reader { flex: 1; overflow-y: auto; background: var(--bg); }
.bv-doc { max-width: 46rem; margin: 0 auto; padding: 14px 18px 40px; line-height: 1.6; }
.bv-doc h2 { margin: .2em 0 .5em; font-size: 1.25rem; }
.bv-summary { padding: 10px 14px; margin: 0 0 14px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 6px; }
.bv-leave { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); overflow-y: auto; }
.bv-leave-card { width: 100%; max-width: 30rem; padding: 32px 26px; text-align: center; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.bv-leave-mark { font-size: 2rem; margin-bottom: 14px; } .bv-leave-mark span { color: var(--mark, #4cc2ac); }
.bv-leave-card h2 { margin: 0 0 10px; font-size: 1.4rem; }
.bv-leave-card p { margin: 0 0 12px; line-height: 1.5; color: var(--muted); }
.bv-leave-why:empty { display: none; }
.bv-leave-card .btn { display: block; width: 100%; box-sizing: border-box; margin-top: 10px; text-align: center; text-decoration: none; }
.bv-go { padding: 16px 18px; font-size: 1.1rem; font-weight: 700; overflow-wrap: anywhere; }
.bv-textlink { margin-top: 16px; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.bv-frame[hidden], .bv-reader[hidden], .bv-note[hidden], .bv-leave[hidden] { display: none; }

/* delete control on navigator rows: shown on hover or focus on a computer, always faintly on a touch screen */
.nv-del { margin-left: auto; flex: none; padding: 2px 8px; border-radius: 6px; font-size: .8rem; color: var(--muted); opacity: .4; cursor: pointer; }
.nv-leaf:hover .nv-del, .nv-leaf:focus-within .nv-del, .nv-del:focus-visible { opacity: 1; }
.nv-del:hover, .nv-del:focus-visible { color: var(--bad); outline: none; }
@media (hover: none) { .nv-del { opacity: .55; } }

/* the project home is the root of the navigator; everything else hangs under it */
.nv-head.nv-home.current { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.nv-home .nv-ic { font-size: 1.05rem; }
.dchat .w-chat-head { border-bottom: 1px solid var(--line); flex: none; }
.dchat .w-chat-msgs { padding: 8px 12px; }
.dchat .dc-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dchat .w-chat-form { flex: none; }

/* a library page shown in the Write column */
.write.in-pane.lib-pane { overflow-y: auto; }
.lib-pane .lib { width: 100%; max-width: 52rem; margin: 0 auto; box-sizing: border-box; }

.build-stamp { text-align: center; margin-top: 18px; opacity: .6; }

.wc-sum { margin: 6px 0; } .hist-arch { margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.chat-top .btn + .btn { margin-left: 6px; }

/* navigator branches: one hue per kind of branch, all at the same brightness; a parent is the stronger tint, what is under it the fainter one */
.nv-group { --h: 215; --bc: hsl(var(--h) 52% 60%); }
.nv-group.g-home { --h: 215; } .nv-group.g-tasks { --h: 212; } .nv-group.g-docs { --h: 150; } .nv-group.g-notes { --h: 42; }
.nv-group.g-sources { --h: 275; } .nv-group.g-maps { --h: 185; } .nv-group.g-linked { --h: 335; } .nv-group.g-ref { --h: 22; } .nv-group.g-mylib { --h: 95; }
.nv-group > .nv-head { background: color-mix(in srgb, var(--bc) 22%, transparent); box-shadow: inset 3px 0 0 var(--bc); }
.nv-group > .nv-head:hover, .nv-group > .nv-head:focus-visible { background: color-mix(in srgb, var(--bc) 32%, transparent); }
.nv-group > .nv-head.current { background: color-mix(in srgb, var(--bc) 40%, transparent); }
.nv-group > .nv-head .chev { background: color-mix(in srgb, var(--bc) 30%, transparent); }
.nv-group > .nv-kids { background: color-mix(in srgb, var(--bc) 8%, transparent); box-shadow: inset 3px 0 0 color-mix(in srgb, var(--bc) 38%, transparent); }
.nv-group > .nv-kids .nv-kids { background: color-mix(in srgb, var(--bc) 5%, transparent); }
.nv-group > .nv-kids .nv-leaf:hover, .nv-group > .nv-kids .nv-leaf:focus-visible { background: color-mix(in srgb, var(--bc) 20%, transparent); }
.nv-group > .nv-kids .nv-leaf.current { background: color-mix(in srgb, var(--bc) 30%, transparent); }

.dl-ticks span.capped { opacity: .35; text-decoration: line-through; }

/* the brief and guidance shelf, shown as a pop-up over Write */
.shelf-sheet .write-brief { display: flex !important; max-height: 68dvh; border: 0; padding: 4px 4px 8px; background: transparent; }
.shelf-sheet .write-brief .w-side { display: grid !important; }
.shelf-sheet .write-brief textarea { min-height: 150px; }

/* ---------- the Write editor: formatted text you type into (CodeMirror), styled like the Review page ---------- */
.cm-host { --pg-size: 1; --lh: 1.7; flex: 1; min-height: 0; width: 100%; max-width: 46rem; margin: 0 auto; display: flex; flex-direction: column; }
.cm-host[hidden] { display: none; }
.cm-host.pw-narrow { max-width: 34rem; } .cm-host.pw-normal { max-width: 46rem; } .cm-host.pw-wide { max-width: 64rem; }
.cm-host.pl-tight { --lh: 1.45; } .cm-host.pl-normal { --lh: 1.7; } .cm-host.pl-roomy { --lh: 2.05; }
.cm-host .cm-editor { flex: 1; min-height: 0; background: transparent; color: var(--ink); font: calc(1.12rem * var(--pg-size)) / var(--lh) Georgia, "Iowan Old Style", "Times New Roman", serif; }
.cm-host .cm-editor.cm-focused { outline: none; }
.cm-host .cm-scroller { overflow: auto; font: inherit; scrollbar-gutter: stable; }
.cm-host .cm-content { padding: 12px 18px 40px; caret-color: var(--ink); }
.cm-host .cm-line { padding: 0; overflow-wrap: anywhere; }
.cm-host .cm-placeholder { color: var(--muted); }
.cm-host .cm-cursor { border-left-color: var(--ink); }
.cm-host .cm-selectionBackground, .cm-host .cm-editor.cm-focused .cm-selectionBackground { background: color-mix(in srgb, var(--accent) 35%, transparent) !important; }
.cm-host.cm-readonly .cm-content { cursor: default; }
.cm-host.cm-source .cm-editor { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: calc(1rem * var(--pg-size)); }
/* formatting, only while the live view is on */
.cm-live .cm-blank { line-height: .75; }
.cm-live .cm-h { font-family: -apple-system, system-ui, "Segoe UI", sans-serif; font-weight: 700; line-height: 1.25; padding-top: .55em; }
.cm-live .cm-h1 { font-size: 1.6em; } .cm-live .cm-h2 { font-size: 1.35em; } .cm-live .cm-h3 { font-size: 1.15em; } .cm-live .cm-h4 { font-size: 1.05em; }
.cm-live .cm-h5, .cm-live .cm-h6 { font-size: .95em; text-transform: uppercase; letter-spacing: .04em; }
.cm-live .cm-strong { font-weight: 700; } .cm-live .cm-em { font-style: italic; } .cm-live .cm-strike { text-decoration: line-through; }
.cm-live .cm-icode { font-family: ui-monospace, Menlo, monospace; font-size: .88em; background: color-mix(in srgb, var(--line) 60%, transparent); border-radius: 4px; padding: 0 .2em; }
.cm-live .cm-link { color: var(--accent); text-decoration: underline; }
.cm-live .cm-image { color: var(--muted); }
.cm-live .cm-quote { border-left: 4px solid var(--accent); padding-left: 1em; color: var(--muted); }
.cm-live .cm-fence { font-family: ui-monospace, Menlo, monospace; font-size: .88em; background: color-mix(in srgb, var(--line) 45%, transparent); padding: 0 .6em; }
.cm-live .cm-tablesrc { font-family: ui-monospace, Menlo, monospace; font-size: .88em; }
.cm-live .cm-hr { color: var(--muted); }
.cm-bullet { display: inline-block; width: 1.1em; text-align: center; color: var(--muted); }
.cm-rule { display: block; border-top: 1px solid var(--line); margin: .6em auto; width: 40%; height: 0; }
.cm-check { cursor: pointer; margin-right: .2em; user-select: none; }
.cm-listmark { color: var(--muted); }
.cm-block { margin: .4em 0; } .cm-block.page-sheet { background: transparent; padding: 0; box-shadow: none; font-size: inherit; line-height: inherit; }
.cm-ghost { color: var(--muted); opacity: .75; }
.cm-block table { margin: .3em 0; } .cm-svg svg { max-width: 100%; height: auto; }

/* ---------- immersive writing: the page fills the screen; advice on the left follows the cursor; the document's own chat on the right ---------- */
.imm-bar, .imm-advice, .imm-chat { display: none; }
.write.in-pane.w-imm { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-columns: minmax(250px, 22rem) minmax(0, 1fr) minmax(260px, 24rem); grid-template-rows: auto minmax(0, 1fr); background: var(--bg); }
.w-imm .write-bar, .w-imm .write-tools, .w-imm .w-modebar, .w-imm .w-fmt, .w-imm .w-find, .w-imm .w-foot, .w-imm .w-focus-exit { display: none !important; }
.w-imm .imm-bar { display: flex; grid-column: 1 / -1; grid-row: 1; align-items: center; gap: 10px; padding: calc(6px + env(safe-area-inset-top)) 12px 6px; background: var(--surface); border-bottom: 1px solid var(--line); }
.w-imm .imm-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.w-imm .write-body { grid-column: 2; grid-row: 2; min-height: 0; display: flex; flex-direction: column; }
.w-imm .write-main { flex: 1; min-height: 0; }
.w-imm .imm-advice { display: block; grid-column: 1; grid-row: 2; overflow-y: auto; padding: 12px 14px 40px; border-right: 1px solid var(--line); background: var(--surface); }
.w-imm .imm-chat { display: block; grid-column: 3; grid-row: 2; min-height: 0; overflow: hidden; border-left: 1px solid var(--line); background: var(--surface); }
.w-imm .imm-chat .chat { height: 100%; }
.imm-tabs { display: none; }
.imm-sec { margin-bottom: 14px; } .imm-path { font-size: 1.15rem; font-weight: 700; line-height: 1.3; margin: 2px 0 4px; }
.imm-block { margin: 0 0 16px; } .imm-block h4, .imm-block > summary { margin: 0 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); cursor: pointer; }
.imm-block ul { margin: 0; padding-left: 1.1em; } .imm-block li { margin: .3em 0; }
.imm-brief { white-space: normal; font-size: .92rem; line-height: 1.5; }
.imm-ai { margin-top: 10px; padding: 8px 10px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 6px; font-size: .92rem; }
.imm-note { margin: 6px 0; } .imm-note > summary { cursor: pointer; font-size: .92rem; }
.imm-outline { list-style: none; margin: 0; padding: 0; } .imm-outline button { border: 0; background: none; color: inherit; font: inherit; font-size: .9rem; text-align: left; padding: 3px 0; cursor: pointer; }
.imm-outline li.here button { font-weight: 700; color: var(--accent); }
@media (max-width: 899px) {
  .write.in-pane.w-imm { grid-template-columns: minmax(0, 1fr); }
  .w-imm .imm-tabs { display: grid; grid-auto-flow: column; }
  .w-imm .imm-title { display: none; }
  .w-imm .imm-advice, .w-imm .imm-chat, .w-imm .write-body { grid-column: 1; grid-row: 2; }
  .write.in-pane.w-imm[data-imm="write"] .imm-advice, .write.in-pane.w-imm[data-imm="write"] .imm-chat { display: none; }
  .write.in-pane.w-imm[data-imm="advice"] .write-body, .write.in-pane.w-imm[data-imm="advice"] .imm-chat { display: none; }
  .write.in-pane.w-imm[data-imm="chat"] .write-body, .write.in-pane.w-imm[data-imm="chat"] .imm-advice { display: none; }
}

/* inline marks the page draws: highlight, sub and superscript, footnotes */
.cm-live .cm-hl { background: color-mix(in srgb, var(--warn) 38%, transparent); padding: 0 .1em; }
.cm-live .cm-sub { vertical-align: sub; font-size: .75em; } .cm-live .cm-sup { vertical-align: super; font-size: .75em; }
.cm-live .cm-fnref { color: var(--accent); vertical-align: super; font-size: .75em; } .cm-live .cm-fndef { font-size: .88em; color: var(--muted); }
.imm-method { margin: 8px 0 0; padding: 6px 9px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 6px; font-size: .9rem; line-height: 1.45; }
/* a phone: the page tools wait in the menu, and the bars above the page are one scrolling row each */
@media (max-width: 860px) {
  .write.in-pane .w-pagetools { display: none; }
  .write.in-pane .w-modebar { flex-wrap: nowrap; overflow-x: auto; padding-top: 4px; padding-bottom: 4px; }
  .write.in-pane .w-modebar .btn { flex: none; white-space: nowrap; }
  .write.in-pane .w-fmt { padding-top: 4px; padding-bottom: 4px; }
}

/* the navigator's levels step in, so a task sits under Tasks, its steps under the task, and a step's documents under the step */
.nv-group > .nv-kids { padding-left: 14px; }
.nv-task > .nv-kids { padding-left: 14px; margin-left: 14px; border-left: 1px solid color-mix(in srgb, var(--bc) 40%, transparent); }
.nv-step > .nv-kids.nv-docs { padding-left: 12px; margin-left: 44px; border-left: 1px solid color-mix(in srgb, var(--bc) 30%, transparent); }
.nv-group > .nv-kids > .nv-task > .nv-head { padding-left: 8px; }
.nv-group > .nv-kids > .nv-leaf { padding-left: 8px; }

/* About and Advisor */
.about .about-lede { font-size: 1.1rem; line-height: 1.5; margin: 0 0 14px; }
.about-ask { margin: 0 0 18px; }
.about-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.about-thread { max-height: 46dvh; overflow-y: auto; margin: 4px 0 8px; }
.about-form { display: flex; gap: 8px; align-items: flex-end; } .about-form textarea { flex: 1; resize: none; min-height: 48px; }
.about-why { margin-top: 8px; }

.am-item .am-more { margin-left: auto; color: var(--muted); font-size: 1.1em; }

/* project settings: folds that show what is set while they are closed */
.set-fold { margin: 0 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.set-fold > summary { display: flex; align-items: baseline; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; }
.set-fold > summary::-webkit-details-marker { display: none; }
.set-fold > summary::after { content: "\203a"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.set-fold[open] > summary::after { transform: rotate(90deg); }
.set-fold .fold-sum { flex: 1; text-align: right; margin-right: 6px; }
.set-fold > :not(summary) { margin-left: 14px; margin-right: 14px; } .set-fold > :last-child { margin-bottom: 12px; }

/* Project home: the parent row, its progress bar, and the pages under it */
.nv-homerow .nv-home { font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: .78rem; color: var(--muted); }
.nv-homerow .nv-home.current { background: color-mix(in srgb, var(--bc) 30%, transparent); color: var(--ink); }
.nv-group.g-home > .nv-steprow { background: color-mix(in srgb, var(--bc) 22%, transparent); box-shadow: inset 3px 0 0 var(--bc); border-top: 1px solid var(--line); }
.nv-pbar { height: 3px; margin: 0 8px 2px 36px; border-radius: 2px; background: color-mix(in srgb, var(--bc) 20%, transparent); overflow: hidden; }
.nv-pbar i { display: block; height: 100%; background: var(--bc); }
.nv-group.g-home > .nv-kids { margin-left: 14px; }
.hm-pages { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.hpage .hp-body { padding-bottom: 40px; }
.pg-days { display: flex; align-items: flex-end; gap: 6px; height: 90px; margin: 6px 0; }
.pg-day { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.pg-day i { display: block; width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--accent); opacity: .85; }
.pg-day span { font-size: .7rem; color: var(--muted); }
.pg-task { margin: 0 0 12px; } .pg-step { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: .92rem; text-align: left; cursor: pointer; border-radius: 6px; }
.pg-step:hover, .pg-step:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); outline: none; }
.fd-item { display: flex; gap: 10px; align-items: flex-start; } .fd-acts { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex: none; }
.fd-title { font: inherit; font-weight: 600; text-align: left; padding: 0; } .fd-snip { color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fd-opts { margin: 12px 0; } .fd-opts > summary { cursor: pointer; color: var(--muted); }

/* the microphone: a drawn icon, so it reads the same on Windows, macOS and Linux */
.mic-ico { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.send.mic .mic-ico { width: 22px; height: 22px; }
button.unsupported { opacity: .55; }

/* a bar along the top of the message box: drag it to make the box taller or shorter (double-click resets) */
.comp-grip { position: absolute; left: 0; right: 0; top: -7px; height: 14px; cursor: ns-resize; touch-action: none; z-index: 2; }
.comp-grip::after { content: ""; position: absolute; left: 50%; top: 5px; width: 44px; height: 4px; margin-left: -22px; border-radius: 2px; background: var(--line); }
.comp-grip:hover::after { background: var(--muted, #888); }

/* the document chat: a microphone beside Send, and a box that can be dragged taller */
.w-chat-form textarea { resize: vertical; max-height: 50vh; }
.dc-mic { flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.dc-mic .mic-ico { width: 22px; height: 22px; }
.dc-mic.listening { background: var(--bad); color: var(--bad-ink); border-color: var(--bad); animation: micpulse 1.2s ease-in-out infinite; }

/* the menu: shortcut hints on the right of a row */
.am-item .am-kbd { margin-left: auto; font: inherit; font-size: .8em; color: var(--muted); background: none; border: 0; padding: 0; white-space: nowrap; }

/* a ⋯ at the top right of a chat */
.pane-head-row { display: flex; align-items: center; gap: 8px; }
.chat-more { font-size: 1.3rem; line-height: 1; min-width: 36px; min-height: 36px; margin-left: auto; }
.pane-head-row .chat-more { min-height: 28px; }

/* the model test */
.mt-run { margin: 10px 0; }
.mt-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mt-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .92rem; }
.mt-table td { padding: 4px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.mt-pts { white-space: nowrap; font-weight: 600; }
.mt-fail { color: var(--bad); font-weight: 600; }

/* the model test's progress */
.mt-prog { margin: 10px 0; }
.mt-prog progress { width: 100%; height: 14px; accent-color: var(--accent); }

/* the badge a tested model has earned */
.mbadge { white-space: nowrap; cursor: help; }

/* folders in the navigator: one level, in the same indent and guide lines as the other nested rows */
.nv-folder { margin: 1px 0; }
.nv-frow { display: flex; align-items: center; gap: 2px; border-radius: 6px; }
.nv-fhead { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 8px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: .92rem; font-weight: 600; text-align: left; cursor: pointer; border-radius: 6px; }
.nv-fhead:hover, .nv-fhead:focus-visible, .nv-fmore:hover, .nv-fmore:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); outline: none; }
.nv-fhead .chev { width: 1em; flex: none; color: var(--muted); }
.nv-fmore { flex: none; width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; opacity: 0; }
.nv-folder:hover .nv-fmore, .nv-fmore:focus-visible, .nv-fmore:focus { opacity: 1; }
@media (hover: none) { .nv-fmore { opacity: 1; } }
.nv-fkids { padding-left: 10px; margin-left: 12px; border-left: 1px solid var(--line); }
.nv-nudge { display: block; width: calc(100% - 16px); margin: 4px 8px; padding: 6px 8px; border: 1px dashed var(--line); border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: .85rem; text-align: left; cursor: pointer; }
.nv-nudge:hover, .nv-nudge:focus-visible { color: var(--ink); border-color: var(--accent); outline: none; }
.nv-drop, .nv-frow.nv-drop { background: color-mix(in srgb, var(--accent) 28%, transparent) !important; outline: 2px dashed var(--accent); outline-offset: -2px; }

/* a row's own menu button, and the item being dragged with the mouse */
.nv-more { flex: none; margin-left: auto; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--muted); opacity: 0; cursor: pointer; font-size: 1.05rem; }
.nv-leaf:hover .nv-more, .nv-leaf:focus-within .nv-more, .nv-more:focus-visible { opacity: 1; }
.nv-more:hover, .nv-more:focus-visible { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--ink); outline: none; }
@media (hover: none) { .nv-more { opacity: 1; } }
.nv-leaf[data-fk] { user-select: none; -webkit-user-select: none; }
.nv-ghost { position: fixed; z-index: 1000; pointer-events: none; max-width: 240px; padding: 5px 10px; border-radius: 8px; background: var(--surface); color: var(--ink); border: 1px solid var(--accent); box-shadow: 0 6px 18px rgba(0,0,0,.35); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.nv-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }

/* where a dragged row would land among the others: a line above or below the row under the pointer */
.nv-leaf.nv-ins-before { box-shadow: 0 -2px 0 0 var(--accent); }
.nv-leaf.nv-ins-after { box-shadow: 0 2px 0 0 var(--accent); }

/* the writer's mark on a step: Exploring (open), In progress (half), Settled (filled, with a tick) */
.mark[data-mark] { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: inline-grid; place-items: center; font-size: .72rem; flex: none; background: transparent; }
.mark[data-mark="exploring"] { border-style: dashed; border-color: var(--accent); }
.mark[data-mark="in_progress"] { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.mark[data-mark="settled"] { background: var(--good); border-color: var(--good); color: var(--good-ink); }
.markbar { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.markbtn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.markbtn[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600; }
.markhelp { margin: 0 0 6px; }

/* Project home lines up with the other groups: the same left edge for the triangle and the label */
.nv-group.g-home > .nv-steprow { gap: 6px; padding: 0 8px 0 12px; }
.nv-group.g-home > .nv-steprow .nv-chev { width: 26px; height: 26px; }
.nv-group.g-home > .nv-steprow .nv-stepname { padding: 8px 6px 8px 0; border-radius: 0; }

/* The rich-text editor (web/pmeditor.js) */
.pm-host { overflow: auto; }
.pm-host .pm-doc { flex: 1; min-height: 100%; outline: none; padding: 12px 18px 40px; color: var(--ink); caret-color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; font: calc(1.12rem * var(--pg-size)) / var(--lh) Georgia, "Iowan Old Style", "Times New Roman", serif; }
.pm-host .pm-doc > :first-child { margin-top: 0; }
.pm-host .pm-doc p { margin: 0 0 .9em; }
.pm-host .pm-doc h1, .pm-host .pm-doc h2, .pm-host .pm-doc h3, .pm-host .pm-doc h4, .pm-host .pm-doc h5, .pm-host .pm-doc h6 { font-family: -apple-system, system-ui, "Segoe UI", sans-serif; font-weight: 700; line-height: 1.25; margin: .9em 0 .4em; }
.pm-host .pm-doc h1 { font-size: 1.6em; } .pm-host .pm-doc h2 { font-size: 1.35em; } .pm-host .pm-doc h3 { font-size: 1.15em; } .pm-host .pm-doc h4 { font-size: 1.05em; }
.pm-host .pm-doc h5, .pm-host .pm-doc h6 { font-size: .95em; text-transform: uppercase; letter-spacing: .04em; }
.pm-host .pm-doc strong { font-weight: 700; } .pm-host .pm-doc em { font-style: italic; }
.pm-host .pm-doc code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88em; background: color-mix(in srgb, var(--line) 60%, transparent); border-radius: 4px; padding: 0 .2em; }
.pm-host .pm-doc a { color: var(--accent); text-decoration: underline; }
.pm-host .pm-doc blockquote { border-left: 4px solid var(--accent); margin: 0 0 .9em; padding-left: 1em; color: var(--muted); }
.pm-host .pm-doc ul, .pm-host .pm-doc ol { margin: 0 0 .9em; padding-left: 1.6em; } .pm-host .pm-doc li > p { margin: 0 0 .3em; }
.pm-host .pm-doc hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.pm-host .pm-doc pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88em; background: color-mix(in srgb, var(--line) 45%, transparent); padding: .5em .8em; border-radius: 6px; margin: 0 0 .9em; white-space: pre-wrap; }
.pm-host .pm-doc pre.raw-block { border-left: 3px solid var(--muted); }
.pm-host .pm-doc pre.raw-block::before { content: "Kept as written"; display: block; font: 600 .7rem -apple-system, system-ui, sans-serif; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .3em; }
.pm-host .pm-ghost { color: var(--muted); opacity: .7; }
.pm-host .ProseMirror-selectednode { outline: 2px solid var(--accent); }
textarea.pm-source { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; }
.pm-on [data-ed="strike"], .pm-on [data-ed="mark"], .pm-on [data-ed="sub"], .pm-on [data-ed="sup"], .pm-on [data-ed="task"], .pm-on [data-ed="footnote"] { display: none; }

/* The formatting row: plain buttons like a word processor's, wrapping onto a second row; it scrolls only when even two rows do not fit */
.w-fmt, .write.in-pane .w-fmt { flex-wrap: wrap; overflow-x: hidden; overflow-y: auto; max-height: 5.9rem; row-gap: 2px; align-content: flex-start; }
.w-fmt button { background: transparent; border-color: transparent; border-radius: 6px; }
.w-fmt button:hover:not(:disabled), .w-fmt button:focus-visible { background: color-mix(in srgb, var(--line) 70%, transparent); }
.w-fmt button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.w-fmt .ed-style { background: transparent; border-color: transparent; }
.w-fmt .ed-style:hover { background: color-mix(in srgb, var(--line) 70%, transparent); }
.w-fmt .ed-sep { background: color-mix(in srgb, var(--line) 80%, transparent); }

.pfolder > details > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; }
.pfolder > details > summary::-webkit-details-marker { display: none; }
.pfolder > details > ul { margin: 0 0 0 14px; }

/* The editor's heading: a shade apart from the page it holds, in every colour scheme */
.write-bar, .write-tools, .w-modebar, .w-fmt { background: color-mix(in srgb, var(--ink) 7%, var(--bg)); }
.write-bar { border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.write-bar .w-mic { flex: none; margin-left: auto; }
.write-bar .w-title { min-width: 0; }
.w-modebar #w-srcbtn, .w-modebar .w-pagetools { display: none !important; }      /* these are in the View menu */
.write-bar, .write-bar .icon-btn, .write .w-title, .write-bar #mp-back, .write.in-pane .write-bar .more-btn { color: var(--ink); }
.write-bar .btn, .write.in-pane .write-bar .more-btn { color: var(--ink); border-color: var(--line); }
.write-bar .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.write .w-title:focus { outline: 1px solid var(--line); }

/* Where this stands: the AI's review of a page, as a small feed under the editor on a computer */
.w-stand { flex: none; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--ink) 4%, var(--bg)); padding: 4px 14px; }
.w-stand .ws-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.w-stand .ws-body { max-height: 38vh; overflow: auto; padding: 4px 0 8px; }
.stand-msg p { margin: .3em 0; } .stand-msg ul { margin: .3em 0; padding-left: 1.2em; }
.stand-opts { list-style: none; padding-left: 0 !important; } .stand-opts li { margin: .35em 0; }
.stand-sep { border: 0; border-top: 1px solid var(--line); margin: .8em 0; }
body[data-layout="mobile"] .w-stand { display: none; }
