/* ============================================================================
   VeritasScriptor — the design system.

   Ground: sage-slate in light, deep ink in dark. Frosted panels over soft
   colour. One accent, brass. Fraunces for display, DM Sans for the interface,
   Spectral for anything the author actually reads as prose.

   Every colour is a token declared on bare :root first. A colour whose only
   definition sits inside a media query or a [data-theme] block does not exist
   in the un-stamped state, which is what most viewers are in.
   ============================================================================ */

:root {
  --ground:        #99AB9E;
  --wash-a:        rgba(169,194,164,0.50);
  --wash-b:        rgba(198,179,134,0.42);
  --wash-c:        rgba(111,142,151,0.38);

  /* Held well below opaque on purpose. At 0.58 these read as solid white cards
     sitting on a pale field; letting the sage through tints them, and the bright
     hairline plus the shadow is what then reads as glass rather than as paper. */
  --panel:         rgba(255,255,255,0.40);
  --panel-solid:   rgba(255,255,255,0.60);
  --panel-sunk:    rgba(255,255,255,0.22);
  --hairline:      rgba(255,255,255,0.66);
  --edge:          rgba(26,38,30,0.16);

  /* Darkened a step with the panels. Secondary text that cleared 4.5:1 against
     near-white does not clear it against a sage-tinted panel. */
  --ink:           #141B17;
  --ink-2:         #2B3832;
  --muted:         #41504A;
  --faint:         #5A6961;

  --accent:        #E8A33D;
  --accent-soft:   rgba(232,163,61,0.18);
  --accent-ink:    #7A520D;
  --on-accent:     #2A1D06;

  --good:          #2F7D5B;
  --warn:          #B7791F;
  --crit:          #B04A3C;

  --shadow-lift:   0 18px 40px -18px rgba(18,28,22,0.45);
  --shadow-panel:  0 28px 64px -28px rgba(18,28,22,0.55);

  --r-panel: 26px;
  --r-card:  16px;
  --r-chip:  999px;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-ui: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --font-prose: "Spectral", Georgia, "Times New Roman", serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:      #101820;
    --wash-a:      rgba(27,48,64,0.90);
    --wash-b:      rgba(44,34,52,0.85);
    --wash-c:      rgba(20,50,58,0.80);

    --panel:       rgba(255,255,255,0.055);
    --panel-solid: rgba(255,255,255,0.085);
    --panel-sunk:  rgba(0,0,0,0.20);
    --hairline:    rgba(255,255,255,0.10);
    --edge:        rgba(255,255,255,0.09);

    --ink:         #E9EEF0;
    --ink-2:       #C6D1D5;
    --muted:       #93A1AA;
    --faint:       #74838C;

    --accent-soft: rgba(232,163,61,0.16);
    --accent-ink:  #F2BE63;
    --on-accent:   #241802;

    --good:        #58C295;
    --warn:        #E0B057;
    --crit:        #E3796A;

    --shadow-lift:  0 18px 40px -18px rgba(0,0,0,0.70);
    --shadow-panel: 0 30px 70px -30px rgba(0,0,0,0.85);

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground:      #101820;
  --wash-a:      rgba(27,48,64,0.90);
  --wash-b:      rgba(44,34,52,0.85);
  --wash-c:      rgba(20,50,58,0.80);

  --panel:       rgba(255,255,255,0.055);
  --panel-solid: rgba(255,255,255,0.085);
  --panel-sunk:  rgba(0,0,0,0.20);
  --hairline:    rgba(255,255,255,0.10);
  --edge:        rgba(255,255,255,0.09);

  --ink:         #E9EEF0;
  --ink-2:       #C6D1D5;
  --muted:       #93A1AA;
  --faint:       #74838C;

  --accent-soft: rgba(232,163,61,0.16);
  --accent-ink:  #F2BE63;
  --on-accent:   #241802;

  --good:        #58C295;
  --warn:        #E0B057;
  --crit:        #E3796A;

  --shadow-lift:  0 18px 40px -18px rgba(0,0,0,0.70);
  --shadow-panel: 0 30px 70px -30px rgba(0,0,0,0.85);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;

  /*
    The wash is painted here rather than by a separate layer of blurred elements.
    Three 46vw divs under a 90px blur is a lot of compositing for something a
    radial gradient does natively, more softly, and without a stacking context to
    reason about.
  */
  background:
    radial-gradient(62vw 62vw at 6% -8%,  var(--wash-a), transparent 62%),
    radial-gradient(52vw 52vw at 98% 14%, var(--wash-b), transparent 62%),
    radial-gradient(58vw 58vw at 46% 112%, var(--wash-c), transparent 62%),
    var(--ground);
  background-attachment: fixed, fixed, fixed, fixed;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Soft colour behind the glass. Without something to refract, frosted panels
   read as flat grey rectangles. */

/* The working area is the window, not a column down the middle of it. There is no max-width
   here on purpose: an author on a wide screen bought that screen to see their book on it, and a
   1240px band with half the monitor empty either side is a website's instinct rather than an
   application's. What a wide window buys is a longer chapter list, a bigger bible and room for
   the panels - not longer lines of prose, which have their own measure further down. */

.shell {
  position: relative; z-index: 1;
  width: 100%; margin: 0 auto;
  padding: 22px clamp(22px, 2.2vw, 60px) 60px;
  display: flex; flex-direction: column; gap: 18px;
}

/* ------------------------------------------------------------------ glass */

.glass {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--r-panel);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  box-shadow: var(--shadow-panel);
}

/* ------------------------------------------------------------------ type */

h1, h2, h3 {
  font-family: var(--font-display); font-weight: 500; margin: 0;
  text-wrap: balance; letter-spacing: -0.015em;
}
h1 { font-size: 34px; font-variation-settings: "SOFT" 24, "WONK" 1, "opsz" 72; line-height: 1.12; }
h2 { font-size: 22px; font-variation-settings: "SOFT" 20, "opsz" 36; }
h3 { font-size: 16px; font-variation-settings: "opsz" 20; }

.eyebrow {
  font-size: 11px; font-weight: 500; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint); margin: 0;
}
.lede { color: var(--muted); max-width: 62ch; margin: 6px 0 0; }
.note { font-size: 12.5px; color: var(--faint); }

/* ------------------------------------------------------------------ topbar */

.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 16px; flex-wrap: wrap; }

.wordmark {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 600; font-size: 19px;
  font-variation-settings: "SOFT" 30, "WONK" 1, "opsz" 24;
  letter-spacing: -.01em; padding-right: 6px;
  color: inherit; text-decoration: none;
}
/* The monogram, where a letter in an accent tile used to be.

   No tile behind it and no shadow under it: the mark is navy and purple on nothing, and the
   accent green it used to sit on fought both. Its own silhouette is the shape now, which is
   what a logo is for. */
.mark {
  width: 30px; height: 30px; flex: none;
  object-fit: contain;
}

/* Dark mode would otherwise leave the navy half of the mark sitting on near-black. A little
   lift is enough - inverting or recolouring somebody's logo is not ours to do. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mark { filter: brightness(1.35) saturate(1.1); }
}
:root[data-theme="dark"] .mark { filter: brightness(1.35) saturate(1.1); }

/* The full lock-up, for the two places with room to read it. */
.wordmark-full {
  display: block;
  width: 190px; height: auto;
  margin: 0 auto 4px;
}

.segmented {
  display: flex; gap: 2px; padding: 4px; margin-right: auto;
  background: var(--panel-sunk); border: 1px solid var(--edge); border-radius: var(--r-chip);
}
.segmented a, .segmented button {
  font: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--muted); background: transparent; border: 0;
  padding: 7px 16px; border-radius: var(--r-chip);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .18s, color .18s;
}
.segmented a:hover, .segmented button:hover { color: var(--ink); }
.segmented .active {
  background: var(--panel-solid); color: var(--ink); box-shadow: var(--shadow-lift);
}

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--edge); background: var(--panel-sunk);
  color: var(--ink-2); cursor: pointer;
  transition: background .18s, color .18s;
}
.icon-btn:hover { background: var(--panel-solid); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

.me {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 12px 4px 4px; border-radius: var(--r-chip);
  background: var(--panel-sunk); border: 1px solid var(--edge);
  color: inherit; text-decoration: none;
}
.me .av {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #FFF6E8; font-size: 12px; font-weight: 600;
}
.me .nm { font-size: 13px; font-weight: 500; }
.me .pl { font-size: 11px; color: var(--faint); }

/* ------------------------------------------------------------------ controls */

.btn {
  font: inherit; font-size: 13px; font-weight: 500;
  border-radius: var(--r-chip); padding: 9px 17px;
  border: 1px solid var(--edge); background: var(--panel-sunk); color: var(--ink);
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--panel-solid); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

.btn-ai {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: 0 6px 18px -8px var(--accent);
}
.btn-ai:hover { background: var(--accent); filter: brightness(1.06); }

.btn-lg { font-size: 14.5px; padding: 12px 24px; }

/* The destructive one. Named by what it does rather than coloured like everything else,
   because a button that removes a paragraph should not look like a button that saves one. */
.btn-bad {
  background: var(--bad); border-color: var(--bad); color: #fff;
  box-shadow: 0 6px 18px -8px var(--bad);
}
.btn-bad:hover { background: var(--bad); filter: brightness(1.06); }

/* Asking before something cannot be undone. */
.scrim {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(10, 14, 12, .45);
  backdrop-filter: blur(2px);
}

.sheet {
  width: min(420px, 100%);
  background: var(--panel-solid, #fff);
  background-color: var(--panel-raised, var(--panel-solid));
  border: 1px solid var(--edge); border-radius: 16px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .45);
  padding: 20px 22px 18px;
}
.sheet h3 { margin: 0 0 8px; font-size: 16px; }
.sheet .note { margin: 0 0 16px; }
.sheet .actions { display: flex; gap: 9px; justify-content: flex-end; }


/* The destructive one. Named by what it does rather than coloured like everything else,
   because a button that removes a paragraph should not look like a button that saves one. */
.btn-bad {
  background: var(--bad); border-color: var(--bad); color: #fff;
  box-shadow: 0 6px 18px -8px var(--bad);
}
.btn-bad:hover { background: var(--bad); filter: brightness(1.06); }

/* Asking before something cannot be undone. */
.scrim {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(10, 14, 12, .45);
  backdrop-filter: blur(2px);
}

.sheet {
  width: min(420px, 100%);
  background: var(--panel-solid, #fff);
  background-color: var(--panel-raised, var(--panel-solid));
  border: 1px solid var(--edge); border-radius: 16px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .45);
  padding: 20px 22px 18px;
}
.sheet h3 { margin: 0 0 8px; font-size: 16px; }
.sheet .note { margin: 0 0 16px; }
.sheet .actions { display: flex; gap: 9px; justify-content: flex-end; }


:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }

.input, .textbox {
  font: inherit; color: var(--ink);
  background: var(--panel-sunk); border: 1px solid var(--edge);
  border-radius: 11px; padding: 10px 13px; width: 100%;
}
.input::placeholder, .textbox::placeholder { color: var(--faint); }

/* Every long-form box in the application: a character's details, the setting, a book overview,
   a section of the idea, a blurb. They hold sentences, so they keep a measure for the same
   reason the manuscript editor does - the window got wider, the eye did not. Left aligned
   rather than centred, so the box still starts under its own label. */
.textbox {
  font-family: var(--font-prose); font-size: 15.5px; line-height: 1.65;
  color: var(--ink-2); border-radius: var(--r-card); padding: 16px 18px;
  min-height: 160px; resize: vertical; max-width: 82ch;
}

.pill {
  font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--r-chip); white-space: nowrap;
  border: 1px solid transparent;
}
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.pill-quiet  { background: var(--panel-solid); color: var(--faint); border-color: var(--edge); }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* The AI actions where they repeat - once per chapter down an outline, once per cover face.
   Quieter and tighter than a section's own buttons, because thirty of them at full size would
   read as the point of the screen rather than something available on each row. */
.actions-tight { gap: 6px; margin-top: 2px; }

.btn-sm {
  font-size: 12px; padding: 4px 10px; border-radius: 9px;
}

/* A proposal sits under the box it would replace, indented and marked, so it is never mistaken
   for the thing itself. */
.proposal {
  margin-top: 10px;
  border-left: 3px solid var(--accent);
}
.proposal .prose p { font-size: 14px; }

.banner {
  border-radius: var(--r-card); padding: 11px 15px; font-size: 13.5px;
  border: 1px solid var(--edge); background: var(--panel-sunk);
}
.banner-bad { border-color: var(--crit); color: var(--crit); }

/* ------------------------------------------------------------------ library */

.hero {
  padding: 26px 28px; display: flex; align-items: flex-end;
  justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.stats { display: flex; gap: 26px; }
.stat .n {
  font-family: var(--font-display); font-size: 30px;
  font-variation-settings: "opsz" 48, "SOFT" 18;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.stat .l { font-size: 12px; color: var(--faint); margin-top: 5px; }

.shelf {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px; padding: 22px;
}

.work {
  text-align: left; background: none; border: 0; padding: 0; font: inherit;
  color: inherit; cursor: pointer; text-decoration: none;
  display: flex; flex-direction: column; gap: 11px;
}
.work:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--r-card); }

.cover {
  aspect-ratio: 2 / 3; border-radius: 10px 4px 4px 10px;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 16px 14px 14px 20px; box-shadow: var(--shadow-lift);
  transition: transform .25s cubic-bezier(.2,.8,.3,1), box-shadow .25s;
}
.work:hover .cover { transform: translateY(-5px) rotate(-.6deg); box-shadow: 0 26px 48px -20px rgba(10,16,13,.6); }

/* The binding edge: the one detail that makes a rectangle read as a book. */
.cover::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 9px;
  background: linear-gradient(90deg, rgba(0,0,0,.34), rgba(0,0,0,0));
}
.cover .ct {
  font-family: var(--font-display); font-size: 19px; line-height: 1.1;
  font-variation-settings: "SOFT" 10, "WONK" 1, "opsz" 36;
  color: #FFF8EC; text-shadow: 0 2px 10px rgba(0,0,0,.45);
}
.cover .cb {
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: rgba(255,248,236,.72);
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.work .wt { font-weight: 600; font-size: 14.5px; line-height: 1.25; }
.work .wm {
  font-size: 12px; color: var(--faint);
  display: flex; align-items: center; gap: 7px; margin-top: 2px; flex-wrap: wrap;
}
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; flex: none; }

.new-work {
  display: grid; place-items: center; aspect-ratio: 2/3; border-radius: 10px;
  border: 1.5px dashed var(--edge); background: var(--panel-sunk);
  color: var(--muted); font-size: 13px; gap: 8px; text-align: center; padding: 16px;
}

.empty {
  padding: 60px 28px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}

/* ------------------------------------------------------------------ sign-in */

.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; position: relative; z-index: 1; }
.auth { width: 100%; max-width: 420px; padding: 32px 30px; display: flex; flex-direction: column; gap: 18px; }
.auth .wordmark { font-size: 22px; }

.channel {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
  background: var(--panel-sunk); border: 1px solid var(--edge);
  border-radius: var(--r-card); padding: 14px 16px;
}
.channel:hover { background: var(--panel-solid); }
.channel .ic {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink);
}
.channel .ic svg { width: 17px; height: 17px; }
.channel .t { font-size: 14px; font-weight: 500; }
.channel .s { font-size: 12px; color: var(--faint); }

.code-input {
  font-family: var(--font-ui); font-size: 30px; font-weight: 500;
  letter-spacing: .42em; text-align: center; text-indent: .42em;
  font-variant-numeric: tabular-nums;
  padding: 16px 12px; border-radius: var(--r-card);
  background: var(--panel-sunk); border: 1px solid var(--edge); color: var(--ink); width: 100%;
}

/* ------------------------------------------------------------------ misc */

.spinner {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block;
  border: 2px solid var(--edge); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/*
  A locked chapter's button, so the state reads at a glance rather than from the word alone.
  Muted rather than loud: a lock is a quiet, settled thing, and a red button would say "problem"
  about a chapter the author deliberately finished.
*/
.btn-locked { border-color: var(--accent); color: var(--accent); }

/* A locked chapter's text, still readable and plainly not editable. */
.prose-edit[contenteditable="false"] { opacity: .88; cursor: default; }

/*
  The one indicator that says a model is working, anywhere in the app.

  Fixed and out of the flow, so appearing does not shove the page down under somebody who is
  mid-sentence. Bottom-right rather than top: the top bar already carries four things, and on a
  phone the bottom corner is the half of the screen not under a thumb holding the device.
*/
.ai-working {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;

  /*
    Nothing in it is clickable, so it must not swallow clicks.

    Centred means it sits over whatever the author was using - including Stop, which is the one
    control somebody watching a generation is most likely to want. An overlay that blocked it
    would make the wait feel like a hang, which is the exact opposite of why it is here.
  */
  pointer-events: none;
}

.ai-working > span {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 22px 14px 18px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--edge);

  /* Deeper than the resting shadow: it has to read as floating above the page, not as part of
     whatever it happens to be centred over. */
  box-shadow: 0 10px 40px rgba(0,0,0,.28);
  font-size: 14px; color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 680px) {
  .shell { padding: 14px 14px 40px; }
  .stats { gap: 18px; }
  h1 { font-size: 27px; }
}

[hidden] { display: none !important; }

/* ------------------------------------------------------------------ story bible */

.work-head {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 24px; border-bottom: 1px solid var(--edge); flex-wrap: wrap;
}
.back {
  font: inherit; font-size: 13px; color: var(--muted); text-decoration: none;
  background: var(--panel-sunk); border: 1px solid var(--edge);
  padding: 7px 14px; border-radius: var(--r-chip); cursor: pointer;
}
.back:hover { color: var(--ink); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.tabs button {
  font: inherit; font-size: 13px; color: var(--muted);
  background: transparent; border: 1px solid transparent;
  padding: 7px 14px; border-radius: var(--r-chip); cursor: pointer;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] {
  background: var(--accent-soft); color: var(--accent-ink);
  border-color: var(--accent-soft); font-weight: 500;
}

/* The character pane is a grid so the rail can run full height beside it; the other
   two panes are plain columns. Both share the body padding. */
.bible { display: grid; grid-template-columns: 1fr 86px; min-height: 520px; }
.bible-body { padding: 24px 26px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.stack { display: flex; flex-direction: column; gap: 11px; min-width: 0; }


.section-card {
  background: var(--panel-sunk); border: 1px solid var(--edge);
  border-radius: var(--r-card); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 9px;
}
.section-card .sh { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.heading-input {
  font-family: var(--font-display); font-size: 16px; font-weight: 500;
  font-variation-settings: "opsz" 20; letter-spacing: -.015em;
  color: var(--ink); background: transparent; border: 0;
  border-bottom: 1px dashed transparent; padding: 2px 0; min-width: 0; flex: 1;
}
.heading-input:hover { border-bottom-color: var(--edge); }
.heading-input:focus { outline: none; border-bottom-color: var(--accent); }

.ref-list { display: flex; flex-direction: column; gap: 9px; }
.ref {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--panel-sunk); border: 1px solid var(--edge);
  border-radius: 13px; padding: 11px 13px;
}
.ref .ic {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-size: 15px;
  background: var(--accent-soft); color: var(--accent-ink);
}
.ref .rt { font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.ref .rm { font-size: 11.5px; color: var(--faint); margin-top: 2px; }

button.pill { cursor: pointer; font-family: inherit; }

.char-head { display: flex; align-items: center; gap: 16px; }
.char-av {
  width: 66px; height: 66px; border-radius: 20px; flex: none;
  display: grid; place-items: center; font-size: 22px; font-weight: 600; color: #FFF6E8;

  /* The picture is stored square, but overflow still has to be clipped or a browser that
     rounds differently leaves corners outside the radius. */
  overflow: hidden; position: relative;
}
.char-av img, .rail-btn .ini img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* The face is the control, so it has to look like one on hover - and carry a hint, because a
   picture that happens to be clickable is not discoverable on its own. */
.av-pick { cursor: pointer; }
.av-pick::after {
  content: "Change";
  position: absolute; inset: auto 0 0 0;
  padding: 3px 0; text-align: center;
  font-family: var(--font-ui); font-size: 9.5px; letter-spacing: .09em; text-transform: uppercase;
  background: rgba(0,0,0,.55); color: #FFF6E8;
  opacity: 0; transition: opacity .12s ease;
}
.av-pick:hover::after, .av-pick:focus-within::after { opacity: 1; }
.av-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* A name, an age and a gender. Three boxes six hundred pixels wide would be a wide window spent
   on nothing - the row stops growing and the space goes to the panel around it. */
.fields { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; max-width: 920px; }

.rail {
  border-left: 1px solid var(--edge); padding: 20px 0;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--panel-sunk);
  border-radius: 0 var(--r-panel) var(--r-panel) 0;

  /* Its own scrollbar, and overscroll-behavior so reaching the end of it does not hand the
     scroll on to the page underneath - running out of chapters should not move the screen. */
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
}
.rail-btn {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  border: 2px solid transparent; padding: 0; cursor: pointer;
  background: none; display: grid; place-items: center;
  transition: border-color .18s, transform .18s;
}
.rail-btn:hover { transform: scale(1.06); }
.rail-btn[aria-selected="true"] { border-color: var(--accent); }
.rail-btn .ini {
  width: 100%; height: 100%; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  font-weight: 600; font-size: 14px; color: #FFF6E8; letter-spacing: .02em;
}
.rail-add {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  border: 1.5px dashed var(--edge); background: transparent; color: var(--muted);
  font-size: 20px; cursor: pointer; display: grid; place-items: center;
}
.rail-sep { width: 26px; height: 1px; background: var(--edge); flex: none; }

@media (max-width: 980px) {
}
@media (max-width: 680px) {
  .fields { grid-template-columns: 1fr; }
  .bible { grid-template-columns: 1fr; }
  .rail {
    flex-direction: row; overflow-x: auto; border-left: 0;
    border-top: 1px solid var(--edge); padding: 14px;
    border-radius: 0 0 var(--r-panel) var(--r-panel);
  }
}

/* ------------------------------------------------------------------ book workspace */

.book { display: grid; grid-template-columns: 228px 1fr; min-height: 560px; }
.book-rail {
  padding: 22px 18px; display: flex; flex-direction: column; gap: 18px;
  border-right: 1px solid var(--edge); background: var(--panel-sunk);
  border-radius: var(--r-panel) 0 0 var(--r-panel);
}
.book-rail .cover { aspect-ratio: 2/3; width: 100%; }
.book-body { padding: 22px 26px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.sections { display: flex; flex-direction: column; gap: 2px; }
.sections button {
  font: inherit; font-size: 13.5px; text-align: left;
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; color: var(--muted);
  padding: 9px 11px; border-radius: 11px; cursor: pointer; width: 100%;
}
.sections button:hover { color: var(--ink); background: var(--panel-solid); }
.sections button[aria-selected="true"] { background: var(--panel-solid); color: var(--ink); font-weight: 500; }
.sections .num {
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 600;
  background: var(--panel-sunk); color: var(--faint); font-variant-numeric: tabular-nums;
}
.sections button[aria-selected="true"] .num { background: var(--accent); color: var(--on-accent); }

/* progress ring */
.ring { display: flex; align-items: center; gap: 11px; }
.ring svg { width: 46px; height: 46px; flex: none; transform: rotate(-90deg); }
.ring .trk { fill: none; stroke: var(--edge); stroke-width: 5; }
.ring .bar { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; }
.ring .pct {
  font-family: var(--font-display); font-size: 17px;
  font-variation-settings: "opsz" 24; font-variant-numeric: tabular-nums; line-height: 1;
}
.ring .lb { font-size: 11px; color: var(--faint); margin-top: 3px; }

/* ------------------------------------------------------------------ books + chapters */

.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px;
}
.book-card {
  display: grid; grid-template-columns: 76px 1fr; gap: 14px;
  background: var(--panel-sunk); border: 1px solid var(--edge);
  border-radius: var(--r-card); padding: 14px;
  color: inherit; text-decoration: none; align-items: start;
}
.book-card:hover { background: var(--panel-solid); }
.book-card .cover { aspect-ratio: 2/3; width: 76px; }
.book-card .cover .ct { font-size: 12px; }
.book-card .cover .cb { font-size: 8px; }
.book-card .bo {
  font-family: var(--font-prose); font-size: 13px; line-height: 1.5;
  color: var(--muted); margin: 5px 0 7px;
}

/* ------------------------------------------------------------------ outline

   Section 5 reuses the bible grid, so the chapter rail behaves exactly as the cast rail does
   and there is one set of rules for both. Only two things differ: this pane is taller, and its
   boxes take the whole width.

   The reading measure is deliberately dropped here. Everywhere else a max-width keeps prose at
   a comfortable line length, but a chapter summary is written against the shape of the book
   rather than read as prose, and the author asked for the width. */
/* Fits the window instead of growing with the book.

   The rail is one 46px circle per chapter, so a twenty-four chapter book made the pane fourteen
   hundred pixels tall and pushed the boxes an author actually types in off the bottom of the
   screen. The pane is now bounded by the viewport and the parts inside it scroll on their own:
   the rail for choosing a chapter, the beats for reading one.

   The subtraction is the page chrome above it - the top bar, the workspace heading and the
   shell's padding. A little generous, so a short window loses a little height rather than
   gaining a second scrollbar. */
.outline-pane {
  min-height: 420px;
  height: calc(100vh - 230px);
}

/* auto rather than hidden: on a window too short to hold everything the body scrolls, which
   is a worse day than usual but never clips a control off the bottom. */
.outline-pane .bible-body { gap: 14px; overflow-y: auto; min-height: 0; }
.outline-pane .textbox { max-width: none; }

/* Which part gives way, said once.

   Flex will shrink a child below the height of its own contents unless told otherwise, and
   these are label-plus-box-plus-note stacks - so squeezing one does not make it smaller, it
   makes its note overlap whatever comes next. That is what was happening: the Expand buttons
   sat on top of the summary and the checklist's note sat on the Beats heading.

   The summary takes the slack. The checklist never shrinks, because seeing it next to the
   summary is the point of the screen. The beats give way, and scroll. */
.outline-pane .field-grow { flex: 1 1 auto; min-height: 150px; }
.outline-pane .field-fixed { flex: 0 0 auto; }
.outline-pane .field-scroll { flex: 1 1 auto; min-height: 0; }

/* Takes whatever height the pane has left, so the summary is the thing that grows when the
   window does rather than a short box with empty space under it. */
/* The summary takes what is spare; the checklist keeps a fixed share and never gets squeezed
   out of sight, because being able to see both at once is the point. */
.outline-summary { flex: 1 1 auto; min-height: 0; resize: vertical; }
.included-details { flex: 0 0 auto; height: 96px; min-height: 96px; resize: vertical; }

/* Beats are the long part and the part being read rather than written, so they are what gives
   way: the list scrolls inside itself instead of pushing the boxes above it off the screen. */
.outline-pane .beats {
  overflow-y: auto; overscroll-behavior: contain;
  max-height: 190px; padding-right: 6px;
}

.ch-head-solo { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1 1 auto; }
.ch-head-solo .heading-input { flex: 1 1 auto; min-width: 0; }

.ch-num {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: var(--panel-solid); color: var(--muted); font-variant-numeric: tabular-nums;
}

/* The rail's number is the chapter's avatar: it says which chapter, and its tint says how far
   that chapter has got, so the rail answers "where am I" and "what is left" at once. */
.rail-num {
  width: 100%; height: 100%; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-ui); font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--panel-solid); color: var(--muted);
  border: 1px solid var(--edge);
}
/* A ring rather than a fill. Filling the circle with --warn or --good means guessing a text
   colour that stays legible on both of them in both themes, and the number is the thing that
   has to be readable. The ring carries the state and the number keeps its own contrast.

   st-empty is overridden because the shared rule fades it to 45% - right for a 7px dot beside a
   title, wrong for a number somebody has to read at a glance. */
.rail-num.st-empty,
.rail-num.st-draft,
.rail-num.st-final { background: var(--panel-solid); opacity: 1; }

.rail-num.st-draft { border-width: 2px; border-color: var(--warn); color: var(--ink-2); }
.rail-num.st-final { border-width: 2px; border-color: var(--good); color: var(--ink-2); }

/* The selected chapter has to be obvious, and the rail-btn's accent border sits OUTSIDE the
   circle - so a filled circle hides it. That is what the backgrounds above are overriding:
   .st-draft fills with --warn, which is right for a 7px dot beside a title and wrong here,
   and with every number filled gold all six looked identical and the selection vanished. */
.rail-btn[aria-selected="true"] .rail-num { border-color: var(--accent); }

.status-tick { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.st-final { background: var(--good); }
.st-draft { background: var(--warn); }
.st-empty { background: var(--faint); opacity: .45; }

/* Beats are sentences too, and a chapter's worth of them set the full width of a wide window
   is a wall. Same measure rule as the editor and the long-form boxes. */
.beats {
  margin: 0; padding: 0 0 0 20px; max-width: 88ch;
  display: flex; flex-direction: column; gap: 5px;
  font-family: var(--font-prose); font-size: 14px; line-height: 1.55; color: var(--ink-2);
}
.beats li::marker { color: var(--accent-ink); font-family: var(--font-ui); font-size: 11px; }

@media (max-width: 980px) {
  .book { grid-template-columns: 1fr; }
  .book-rail {
    flex-direction: row; align-items: flex-start; border-right: 0;
    border-bottom: 1px solid var(--edge);
    border-radius: var(--r-panel) var(--r-panel) 0 0;
  }
  .book-rail .cover { width: 120px; flex: none; }
  .sections { flex: 1; }
}

/* ------------------------------------------------------------------ manuscript */

/* Fractions with floors rather than two fixed rails. The shares are set so that at the width
   this layout used to be fixed at it still comes out 186 / 735 / 248 - the proportions were
   right, it was only the ceiling that was wrong - and everything past that is shared out
   instead of landing in the margins. */
.ms-layout {
  display: grid;
  grid-template-columns: minmax(186px, 0.6fr) minmax(0, 2.4fr) minmax(248px, 0.8fr);
  gap: 16px; align-items: start;
}

/* Scrolls at a share of the window rather than at 520px, so a tall screen shows more of a long
   book's chapters before it has to scroll. */
.chapter-list {
  display: flex; flex-direction: column; gap: 3px;
  max-height: clamp(320px, 62vh, 1000px); overflow-y: auto;
}
.chapter-list button {
  font: inherit; text-align: left; background: transparent; border: 0;
  padding: 8px 10px; border-radius: 10px; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; gap: 2px;
}
.chapter-list button:hover { background: var(--panel-sunk); color: var(--ink); }
.chapter-list button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.chapter-list .cn { font-size: 13px; font-weight: 500; line-height: 1.25; }
.chapter-list .cw {
  font-size: 11px; opacity: .85; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 6px;
}

/* The one thing on this screen that must NOT follow the window.

   Prose at 130 characters a line is unreadable and unwritable - the eye loses its place on the
   way back - so the writing column keeps a measure and the room a wide window gives goes to the
   panels either side instead. A touch wider than the 65ch a printed page would use, because a
   draft is not a printed page. The toolbar and the word count are inside this so the three
   line up as one object.

   In rem rather than ch deliberately: ch would resolve against this element's font, which is the
   interface face, while the text being measured is set in the prose face below it. 48rem is
   about 85 characters of that face - a little more room than the fixed layout used to give. */
.ms-write {
  display: flex; flex-direction: column; gap: 11px;
  width: 100%; max-width: 48rem; margin-inline: auto; min-width: 0;
}

/* The editor is a contenteditable set in the reading face. */
.prose-edit {
  width: 100%; resize: vertical;
  background: var(--panel-sunk); border: 1px solid var(--edge);
  border-radius: var(--r-card); padding: 26px 30px;
  font-family: var(--font-prose); font-size: 16.5px; line-height: 1.75; color: var(--ink-2);
  min-height: 420px;
}
.prose-edit:focus { outline: none; border-color: var(--accent); }

/* A contenteditable has no placeholder of its own, so one is drawn when it is genuinely empty.
   :empty alone is not enough - the browser leaves a <br> or an empty <p> behind the moment the
   caret has been in there, and the hint would sit underneath the author's cursor forever. */
.prose-edit:empty::before,
.prose-edit > p:only-child:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

/* Paragraph spacing rather than indents: this is a manuscript being written, not typeset.
   The exporters decide what a printed page looks like. */
.prose-edit p { margin: 0 0 1.05em; }

/* A run of paragraphs written together. The box is the chapter; the rows under it are the
   citations on individual paragraphs, and only appear where there is one or where the caret is,
   so a page of plain prose stays a page of plain prose. */
.blk-run { padding-bottom: .25rem; }
.blk-run .blk-notes { border: 0; padding: .1rem 0 0; margin: 0; background: none; }
.blk-run .blk-notes .blk-cite { padding-top: 0; }

/* Which paragraph a row belongs to. Quiet - it is a label, not a heading. */
/* The run's bar stays put while the author is in the box, unlike a block's, which appears on
   hover. It carries the buttons that act on one paragraph, and a control somebody has to
   discover by hovering is a control they will conclude does not exist. */
.blk-bar-run { opacity: 0; }
.blk-run:hover > .blk-bar-run,
.blk-run:focus-within > .blk-bar-run,
.blk-bar-run.on { opacity: 1; }

/* Which paragraph those buttons mean. Marked in the margin rather than behind the words, so it
   points without making the sentence harder to read. */
.prose-edit p.here {
  position: relative;
}
.prose-edit p.here::before {
  content: "";
  position: absolute;
  left: -14px; top: .15em; bottom: .15em;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.blk-para {
  font-size: .72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-right: .4rem;
}

.prose-edit p:last-child { margin-bottom: 0; }
.prose-edit em { font-style: italic; }
.prose-edit strong { font-weight: 650; }

/* A scene break, drawn the way it reads in a finished book. */
.prose-edit hr {
  border: 0; margin: 1.6em auto; width: 40%;
  text-align: center; overflow: visible; height: 0;
}
.prose-edit hr::after {
  content: "# # #";
  display: block; text-align: center;
  color: var(--muted); font-family: var(--font-ui); font-size: 12px; letter-spacing: .5em;
}

.prose-tools { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.tool {
  min-width: 34px; height: 30px; padding: 0 9px;
  background: var(--panel-sunk); border: 1px solid var(--edge); border-radius: var(--r-chip);
  color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer;
}
.tool:hover { background: var(--panel-solid); color: var(--ink); }

.prose {
  background: var(--panel-sunk); border: 1px solid var(--edge);
  border-radius: var(--r-card); padding: 22px 24px;
  font-family: var(--font-prose); font-size: 15.5px; line-height: 1.72; color: var(--ink-2);
  max-height: 440px; overflow-y: auto;
}
.prose h4 {
  font-family: var(--font-display); font-weight: 500; font-size: 15px;
  font-variation-settings: "opsz" 20; letter-spacing: -.015em;
  margin: 0 0 12px; color: var(--faint); text-transform: uppercase; font-size: 11px;
  letter-spacing: .1em;
}
.prose p { margin: 0 0 1em; max-width: 62ch; }
.prose p:last-child { margin-bottom: 0; }

.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.aside { display: flex; flex-direction: column; gap: 12px; }
.aside-card {
  background: var(--panel-sunk); border: 1px solid var(--edge);
  border-radius: var(--r-card); padding: 14px;
  display: flex; flex-direction: column; gap: 9px;
}

.ctx-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.ctx-line .tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 6px; border-radius: 5px; flex: none;
  background: var(--accent-soft); color: var(--accent-ink);
}
.ctx-line .tag.r { background: var(--panel-solid); color: var(--faint); }
.ctx-line .tk { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 11px; color: var(--faint); flex: none; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.budget { height: 5px; border-radius: 3px; background: var(--panel-solid); overflow: hidden; }
.budget i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.issue { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; line-height: 1.45; }
.issue .sev { width: 3px; border-radius: 2px; align-self: stretch; flex: none; }
.sev-crit { background: var(--crit); }
.sev-warn { background: var(--warn); }
.sev-note { background: var(--faint); }
.issue em { font-style: normal; color: var(--faint); display: block; font-size: 11.5px; margin-top: 2px; }

@media (max-width: 1100px) {
  .ms-layout { grid-template-columns: 1fr; }
  .chapter-list { flex-direction: row; overflow-x: auto; max-height: none; }
  .chapter-list button { flex: none; min-width: 150px; }
  .diff { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ covers */

.faces { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.face {
  background: var(--panel-sunk); border: 1px solid var(--edge);
  border-radius: var(--r-card); padding: 14px;
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.face-art {
  aspect-ratio: 2/3; border-radius: 10px; overflow: hidden;
  background: var(--panel-solid); border: 1px solid var(--edge);
  display: grid; place-items: center;
}
.face-art.wide { aspect-ratio: 3/2; }
.face-art img { width: 100%; height: 100%; object-fit: cover; display: block; }

.versions { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.version {
  flex: none; width: 46px; padding: 0; border-radius: 7px; cursor: pointer;
  border: 2px solid transparent; background: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.version.on { border-color: var(--accent); }
.version img { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 5px; display: block; }
.version span { font-size: 9.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ export */

.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.profile {
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--panel-sunk); border: 1px solid var(--edge);
  border-radius: var(--r-card); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.profile:hover { background: var(--panel-solid); }
.profile.on { border-color: var(--accent); background: var(--accent-soft); }
.profile .pn { font-size: 13.5px; font-weight: 600; }
.profile .pd { font-size: 12px; color: var(--faint); line-height: 1.4; }

.check {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--muted); cursor: pointer;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ------------------------------------------------------------------ kdp */

.steps { margin: 0; padding: 0 0 0 4px; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.steps li { display: block; }
.steps .check { align-items: flex-start; }
.steps .check input { margin-top: 3px; flex: none; }
.steps strong { font-size: 13.5px; color: var(--ink); }

/* ------------------------------------------------------------------ import */

.import { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.import .section-card { align-items: stretch; }

/* ------------------------------------------------------------------ settings */

.val-readonly {
  background: var(--panel-solid); border: 1px solid var(--edge);
  border-radius: 11px; padding: 10px 13px; font-size: 14px; color: var(--muted);
}

.enrol { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
.qr {
  background: #FFFFFF; padding: 10px; border-radius: 12px;
  border: 1px solid var(--edge); line-height: 0; flex: none;
}
.qr svg { width: 168px; height: 168px; display: block; }

@media (max-width: 680px) {
  .enrol { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ credits */

.credit-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin: 4px 0 12px;
}
.credit-balance { font-size: 34px; font-weight: 600; letter-spacing: -.02em; }
.credit-unit { font-size: 13px; color: var(--muted); margin-left: 6px; }
.credit-meta { text-align: right; font-size: 13.5px; }

/* A track rather than a number alone: "1,240" means nothing without the ceiling beside it. */
.credit-bar {
  height: 7px; border-radius: 99px; background: var(--panel-sunk);
  border: 1px solid var(--edge); overflow: hidden;
}
.credit-bar > span { display: block; height: 100%; background: var(--accent); }

.credit-plan { margin-top: 10px; }

.credit-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 13.5px; }
.credit-table th {
  text-align: left; font-weight: 500; font-size: 11.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); padding: 0 0 7px;
  border-bottom: 1px solid var(--edge);
}
.credit-table td { padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.credit-table .num { text-align: right; font-variant-numeric: tabular-nums; }
/* The balance is the loud thing on this card. A grant in full accent out-shouts it, and the
   accent is already spent on the bar - so these stay quiet and only the sign distinguishes them. */
.credit-table .spend { color: var(--ink-2); }
.credit-table .grant { color: var(--good); }

/* ------------------------------------------------------------------ plans */

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 12px; }
.plan {
  border: 1px solid var(--edge); border-radius: var(--r-card);
  background: var(--panel-sunk); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 7px; align-items: flex-start;
}
.plan-current { border-color: var(--accent); }
.plan .btn { margin-top: auto; }

/* A button that reads as part of the sentence it sits in, because it is. */
.linklike {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  cursor: pointer; text-decoration: underline;
}

/* ------------------------------------------------------------------ read-through */

/* A reading column, not a layout. Everything here serves one measurement: about 66 characters
   a line, which is where the eye stops having to hunt for the start of the next one. */
.reading {
  --read-size: 19px;
  max-width: 34rem; margin: 0 auto; padding: 86px 24px 120px;
  font-family: var(--font-prose);
  font-size: var(--read-size);
  line-height: 1.68;
  color: var(--ink-2);
}

.read-head { margin-bottom: 54px; }
.read-head h1 { font-family: var(--font-display); font-size: 1.9em; font-weight: 500; margin: 0 0 8px; }

.read-chapter { margin: 0 0 58px; scroll-margin-top: 80px; }
.read-chapter h2 {
  font-family: var(--font-display); font-weight: 500;
  font-size: 1.25em; margin: 0 0 22px;
  display: flex; align-items: baseline; gap: 12px;
}
.read-chapter h2 .rm { font-size: .72em; }

.read-prose p { margin: 0 0 1.05em; }
.read-prose p:last-child { margin-bottom: 0; }
.read-prose em { font-style: italic; }
.read-prose strong { font-weight: 650; }

/* The same scene break the editor draws, so the two never disagree about what a divider is. */
.read-prose hr { border: 0; margin: 1.7em auto; height: 0; overflow: visible; }
.read-prose hr::after {
  content: "# # #"; display: block; text-align: center;
  color: var(--muted); font-family: var(--font-ui); font-size: .6em; letter-spacing: .5em;
}

/* A hole in the book, drawn as a hole. */
.read-gap {
  color: var(--muted); font-style: italic;
  border-left: 2px solid var(--edge); padding-left: 14px; margin: 0;
}

.read-empty, .read-end { text-align: center; padding: 60px 0 0; }
.read-empty { padding-top: 120px; }
.read-end { border-top: 1px solid var(--edge); margin-top: 20px; }
.read-end .btn { margin-top: 14px; }

/* The chrome. Fixed, slight, and quiet until it is wanted - an author reading through is trying
   not to be an author editing, and every visible control is an invitation to stop reading. */
.read-bar {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 11px 20px;
  background: var(--panel); backdrop-filter: blur(14px) saturate(130%);
  border-bottom: 1px solid var(--edge);
  font-family: var(--font-ui); font-size: 13px;
  opacity: .32; transition: opacity .18s ease;
}
.read-bar:hover, .read-bar:focus-within { opacity: 1; }

.read-out { color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.read-out:hover { color: var(--ink); }
.read-where { flex: 1; text-align: center; color: var(--ink-2); }
.read-tools { display: flex; gap: 6px; }

.read-progress {
  position: fixed; inset: 0 0 auto 0; z-index: 6;
  height: 2px; background: transparent;
}
.read-progress > span { display: block; height: 100%; background: var(--accent); transition: width .1s linear; }

@media (max-width: 640px) {
  .reading { padding-top: 74px; }
  .read-where { display: none; }
}

/* ------------------------------------------------------------------ manuscript health */

.health-figures {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px;
}
.health-figures > div {
  background: var(--panel-sunk); border: 1px solid var(--edge); border-radius: var(--r-card);
  padding: 13px 15px; display: flex; flex-direction: column; gap: 2px;
}
.health-figures strong { font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.health-figures span { font-size: 12px; color: var(--muted); }

.health-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }

/* The chapter bars. Deliberately a shape rather than a chart: an author reads the silhouette of
   their book here, and axes and gridlines would be answering a question nobody asked. */
.shape {
  display: flex; align-items: flex-end; gap: 4px;
  height: 118px; margin: 14px 0 10px; padding-bottom: 16px;
  border-bottom: 1px solid var(--edge);
}
/* The median, drawn. The caption said "the middle line is the median" before there was one,
   which is the sort of sentence that quietly makes a reader distrust the rest of a page. */
.shape { position: relative; }
.shape.has-median::before {
  content: ""; position: absolute; left: 0; right: 0;

  /* 16px is the chart's own bottom padding, where the bars stand; the rest of the box is the
     area a bar's own height is a percentage of. Multiplying that by the fraction puts the line
     exactly where a median-length bar would reach. */
  bottom: calc(16px + (100% - 16px) * var(--median, 0));
  border-top: 1px dashed var(--edge); pointer-events: none;
}

.shape-bar { flex: 1 1 0; min-width: 7px; height: 100%; position: relative; display: flex; align-items: flex-end; }
.shape-bar > span { display: block; width: 100%; border-radius: 3px 3px 0 0; background: var(--accent-soft); }
.shape-bar > small {
  position: absolute; bottom: -15px; left: 0; right: 0;
  text-align: center; font-size: 9px; color: var(--muted);
}

/* One colour for "stands out", not two.
   The palette's warn and accent are both amber and differ only in darkness, so short and long
   were nearly indistinguishable - and that is the most important distinction on the chart. The
   bar's HEIGHT already says which direction it stands out in, perfectly and in a channel that
   does not depend on telling two ambers apart. So the colour says only that it is worth a look. */
.shape-bar.k-short > span,
.shape-bar.k-long > span { background: var(--accent); }
.shape-bar.k-none > span { height: 3px !important; background: var(--edge); }

.shape-key { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; }
.shape-key i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.shape-key .k-normal { background: var(--accent-soft); }
.shape-key .k-flagged { background: var(--accent); }
.shape-key .k-none { background: var(--edge); }

.finding { padding: 12px 0; border-top: 1px solid var(--hairline); }
.finding:first-of-type { border-top: 0; }
.finding p { margin: 4px 0 0; }
.finding-eg { margin: 7px 0 0; padding-left: 17px; font-size: 13px; color: var(--ink-2); }
.finding-eg li { margin: 2px 0; }

.habit { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13.5px; }
.habit td { padding: 5px 0; border-bottom: 1px solid var(--hairline); }
.habit .num { text-align: right; font-variant-numeric: tabular-nums; }

/* The quoted passage that triggered a finding. Set in the prose face, because it is prose. */
.finding-quote {
  font-family: var(--font-prose); font-size: 14px; color: var(--ink-2);
  border-left: 2px solid var(--edge); padding-left: 12px; margin: 7px 0 0;
}

/* ------------------------------------------------------------------ connection */

/* Blazor shows this by adding a class to the element; it is hidden otherwise. The default
   stylesheet does not ship with the app, so without these rules the modal would simply never
   appear - which is indistinguishable from not having added it. */
#components-reconnect-modal { display: none; }

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
  display: grid; place-items: center;
  position: fixed; inset: 0; z-index: 1000;
  background: color-mix(in srgb, var(--ground) 72%, transparent);
  backdrop-filter: blur(3px);
}

.reconnect-card {
  background: var(--panel-solid); border: 1px solid var(--edge);
  border-radius: var(--r-card); box-shadow: var(--shadow-lift);
  padding: 20px 24px; max-width: 420px;
  font-family: var(--font-ui); font-size: 14px; color: var(--ink-2);
}
.reconnect-card p { margin: 0; display: none; align-items: center; gap: 10px; }
.reconnect-card button, .reconnect-card a {
  font: inherit; color: var(--accent); background: none; border: 0;
  padding: 0 0 0 4px; cursor: pointer; text-decoration: underline;
}

/* One line at a time, chosen by whichever state Blazor has put on the modal. */
.components-reconnect-show .reconnect-trying,
.components-reconnect-failed .reconnect-failed,
.components-reconnect-rejected .reconnect-rejected { display: flex; }

#blazor-error-ui {
  display: none;
  position: fixed; inset: auto 0 0 0; z-index: 1001;
  padding: 11px 20px;
  background: var(--crit); color: #FFF6E8;
  font-family: var(--font-ui); font-size: 13.5px;
  box-shadow: 0 -2px 14px rgba(0,0,0,.2);
}
#blazor-error-ui .reload, #blazor-error-ui .dismiss {
  color: #FFF6E8; margin-left: 12px; cursor: pointer; text-decoration: underline;
}
#blazor-error-ui .dismiss { float: right; text-decoration: none; }

/* The foldable "what went wrong" under the error screen. Quiet by default: the reassurance
   above it is what matters to somebody mid-chapter, and this is for when they want to report it. */
.why { margin-top: 18px; border-top: 1px solid var(--hairline); padding-top: 12px; }
.why summary {
  cursor: pointer; font-size: 12.5px; color: var(--faint);
  font-family: var(--font-ui); list-style: none;
}
.why summary::-webkit-details-marker { display: none; }
.why summary::before { content: "▸ "; }
.why[open] summary::before { content: "▾ "; }
.why p { margin: 9px 0 0; }
.why code { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; }

/* Only the desktop writes a log, so only the desktop's bar carries this line. */
#blazor-error-ui .where { opacity: .82; margin-left: 10px; }
#blazor-error-ui .where code {
  font-family: var(--font-mono, ui-monospace, monospace); font-size: 12.5px;
  background: rgba(255,255,255,.16); padding: 1px 5px; border-radius: 5px;
}

/* ============================================================================================
   PARTS AND BLOCKS

   A chapter is an optional introduction and then a run of parts, each with an optional heading
   and each holding typed blocks. The visual job is to make the structure legible without making
   it loud: an author is reading their own prose through this, so the chrome stays quiet until
   it is hovered and the text keeps the measure and the face it has everywhere else.
   ============================================================================================ */

.part {
  border: 1px solid var(--edge);
  border-radius: var(--r-card);
  background: var(--panel-sunk);
  padding: 14px 16px 10px;
  margin-bottom: 16px;
}

.part-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.part-head .actions { margin-left: auto; }

.part-intro {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-ink); font-weight: 600;
}

.part-summary {
  margin: 8px 0 12px;
  font-size: 12.5px;
  background: transparent;
  border-style: dashed;
}

.part-foot {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--edge);
}

.add-part, .add-block {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-top: 10px;
}

/* The add-block row is the only place the eight kinds are all visible at once, so it is quiet
   rather than hidden: an author who cannot see that a table is available will write one as a
   paragraph of tab-separated text, which is what the content model exists to prevent. */
.add-block { padding-top: 9px; border-top: 1px dashed var(--edge); opacity: .72; }
.add-block:hover, .add-block:focus-within { opacity: 1; }
.add-block .btn, .add-part .btn { font-size: 11.5px; padding: 4px 9px; }

/* ---------------------------------------------------------------------------- one block */

.blk {
  position: relative;
  padding: 2px 0 10px;

  /* Room for the marker that appears on hover, reserved always - so arriving at a block does
     not nudge the text sideways. */
  padding-left: 14px;
  margin-left: -14px;
  border-radius: var(--r-chip);
  transition: background .12s ease;
}

/* The block the bar above belongs to, while it is being worked on. */
.blk::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background .12s ease;
}

.blk:hover, .blk:focus-within { background: var(--hover, rgba(127, 127, 127, .055)); }
.blk:hover::before, .blk:focus-within::before { background: var(--edge); }

.blk-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 5px;
  /* Hidden until wanted. Eight of these stacked down a chapter would be a wall of
     labels and buttons between the author and their own sentences. */
  opacity: 0; transition: opacity .12s ease;
}
.blk:hover > .blk-bar, .blk:focus-within > .blk-bar { opacity: 1; }

.blk-kind {
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--faint);
}

.blk-acts { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.blk-sel {
  font: inherit; font-size: 11.5px;
  padding: 3px 7px;
  border: 1px solid var(--edge); border-radius: var(--r-chip);
  background: var(--panel-solid); color: var(--ink);
}

.blk-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 7px; }

/* A caption, an attribution, an alt text. Underlined rather than boxed, so they read as
   belonging to the thing above them rather than as a form beside it. */
.blk-attr {
  margin-top: 6px;
  font-size: 12.5px;
  background: transparent;
  border: 0; border-bottom: 1px dashed var(--edge);
  border-radius: 0;
  padding: 4px 2px;
}
.blk-attr:focus { outline: none; border-bottom-color: var(--accent); }

.blk-rule { border: 0; border-top: 2px solid var(--edge); margin: 14px 0; }

/* A quotation and an aside are drawn differently from prose, because that is what they are. */
.blk-quote .prose-edit {
  border-left: 3px solid var(--accent-soft);
  font-style: italic;
}

.blk-callout .prose-edit {
  background: var(--panel-solid);
  border-left: 3px solid var(--accent);
}

/* ---------------------------------------------------------------------------- citations */

/* An aside's own heading, beside the kind it is. Uppercase on the page, so uppercase here -
   an author typing lower case would otherwise be surprised by the export. */
.blk-caption {
  flex: 1; min-width: 0; max-width: 32ch;
  font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 7px;
}

.blk-cite { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 7px; }

/* A note reads differently from a citation, because it is a different thing: a citation names
   something the author gathered, a note is something they wrote. Marked rather than coloured in
   alarm - a note is ordinary, and twelve of them down a chapter must not look like twelve
   problems. */
.pill-note {
  background: var(--panel-solid); color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--edge));
}

.pill-note-text {
  color: var(--faint); font-style: italic; margin-left: 6px;
  max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: bottom; display: inline-block;
}

.blk-note-edit {
  margin-top: 8px; padding: 10px 12px;
  background: var(--panel-sunk); border-radius: var(--r-card);
  display: flex; flex-direction: column; gap: 8px;
}

.blk-note-edit textarea { resize: vertical; min-height: 56px; }

/* The chapter's notes, where a reader meets them: smaller than the prose, and clearly after it.
   The rule above is the thing that says "the chapter has ended" - without it the notes read as a
   last numbered list that the author forgot to introduce. */
.read-notes {
  margin-top: 2.4em; padding-top: 1.2em;
  border-top: 1px solid var(--edge);
}

.read-notes h3 {
  font-size: .95em; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 .7em;
}

.read-notelist {
  margin: 0; padding-left: 1.6em;
  font-size: .88em; line-height: 1.5; color: var(--muted);
}

.read-notelist li { margin-bottom: .45em; }

.pill-x {
  border: 0; background: transparent; cursor: pointer;
  color: inherit; font: inherit; opacity: .6;
  margin-left: 4px; padding: 0 2px;
}
.pill-x:hover { opacity: 1; }

/* ---------------------------------------------------------------------------- table */

.tbl-wrap { overflow-x: auto; margin-bottom: 7px; }

.tbl-edit { border-collapse: collapse; width: 100%; min-width: 320px; }
.tbl-edit th, .tbl-edit td { padding: 0; border: 1px solid var(--edge); }
.tbl-edit thead th { background: var(--panel-solid); }
.tbl-edit .tbl-gutter { border: 0; width: 30px; text-align: center; }

/* A cell, a list item, a point: a box with no box. Borderless so a grid of twenty of them is
   a table rather than twenty form fields. */
.cell {
  font: inherit; font-size: 13px;
  width: 100%; min-width: 60px;
  padding: 6px 7px;
  border: 0; background: transparent; color: var(--ink);
}
.cell:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------------------------------------------------------------------------- list */

.list-edit { margin: 0 0 7px; padding: 0; list-style: none; }
.list-edit li { display: flex; align-items: center; gap: 6px; }

.li-mark {
  flex: 0 0 auto; min-width: 20px;
  font-size: 12px; color: var(--accent-ink); font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------- figure */

.fig-edit { margin: 0 0 7px; }
.fig-edit img {
  display: block; max-width: 100%;
  border-radius: var(--r-card);
  border: 1px solid var(--edge);
}

.fig-none {
  border: 1px dashed var(--edge); border-radius: var(--r-card);
  padding: 18px; text-align: center; margin-bottom: 7px;
}

/* ---------------------------------------------------------------------------- code */

.code-edit {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px; line-height: 1.45;
  width: 100%; resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--edge); border-radius: var(--r-card);
  background: var(--panel-sunk); color: var(--ink);
  /* Never wrapped away. The spacing is the content in a listing, so a soft wrap that hides
     where a line actually ends is worse than a scrollbar. */
  white-space: pre; overflow-x: auto;
}
.code-edit:focus { outline: none; border-color: var(--accent); }

/* ---------------------------------------------------------------------------- streaming */

/* What a generation looks like while it is arriving: the dialect, as text. It cannot be
   parsed per chunk - a half-written table is not a table - so it is shown as what it is. */
.streaming, .streamed {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  margin: 0;
}
.streaming pre { margin: 6px 0 0; white-space: pre-wrap; }

/* ---------------------------------------------------------------------------- the shelf */

.group-head {
  font-size: 12px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint); font-weight: 600;
  margin: 14px 0 2px;
}
.group-head .note { text-transform: none; letter-spacing: 0; margin-left: 6px; }

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }

@media (max-width: 720px) {
  .field-row { grid-template-columns: 1fr; }
}

/* ============================================================================================
   READING

   The read-through and the side-by-side both render a chapter through ChapterView, so these are
   the styles for a finished page rather than an editor. Everything is sized in the prose face
   and nothing is interactive.
   ============================================================================================ */

.read-part { margin-bottom: 1.6em; }
.read-part > h3 {
  font-family: var(--font-display);
  font-size: 1.15em; margin: 1.6em 0 .6em;
}

.read-quote {
  margin: 1.3em 0 1.3em 1.4em;
  font-style: italic;
  border-left: 2px solid var(--accent-soft);
  padding-left: 1em;
}
.read-quote footer { font-style: normal; font-size: .9em; color: var(--faint); margin-top: .4em; }

.read-aside {
  margin: 1.3em 0; padding: .9em 1.1em;
  border-left: 3px solid var(--accent);
  background: var(--panel-sunk);
  border-radius: 0 var(--r-card) var(--r-card) 0;
}
.read-aside .label {
  display: block; margin-bottom: .35em;
  font-family: var(--font-ui);
  font-size: .72em; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent-ink); font-weight: 600;
}

/* The tone is carried by the stripe rather than by a background wash, which keeps a page with
   four asides on it from reading as a set of warnings. */
.read-aside.tone-warning { border-left-color: var(--crit); }
.read-aside.tone-warning .label { color: var(--crit); }
.read-aside.tone-tip { border-left-color: var(--good); }
.read-aside.tone-tip .label { color: var(--good); }
.read-aside.tone-exercise { border-left-color: var(--wash-c); }

.read-list { margin: 1.1em 0 1.1em 1.4em; }
.read-list li { margin: .35em 0; }

.read-table-wrap { overflow-x: auto; margin: 1.4em 0; }
.read-table { border-collapse: collapse; width: 100%; font-size: .92em; }
.read-table caption {
  caption-side: bottom; text-align: left;
  font-size: .85em; font-style: italic; color: var(--faint);
  padding-top: .5em;
}
.read-table th, .read-table td {
  padding: .45em .6em; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--edge);
}
.read-table thead th { border-bottom: 1.5px solid var(--muted); font-weight: 600; }

.read-figure { margin: 1.6em 0; text-align: center; }
.read-figure img {
  max-width: 100%; border-radius: var(--r-card); border: 1px solid var(--edge);
}
.read-figure figcaption {
  font-size: .85em; font-style: italic; color: var(--faint);
  margin-top: .5em; text-align: left;
}

.read-code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: .82em; line-height: 1.45;
  padding: .9em 1.1em; margin: 1.4em 0;
  background: var(--panel-sunk); border-radius: var(--r-card);
  overflow-x: auto;
}

.read-rule {
  border: 0; height: 0; margin: 1.8em 0; text-align: center;
}
.read-rule::after { content: "* * *"; letter-spacing: .4em; color: var(--faint); }
