/* Offbook — minimal theatrical theme */
:root {
  --bg: #faf7f2;
  --paper: #ffffff;
  --ink: #2b2422;
  --muted: #8a7f78;
  --line: #e6ddd3;
  --accent: #a4343a;        /* curtain red */
  --accent-dark: #7e272c;
  --gold: #b98a2f;
  --shadow: 0 1px 3px rgba(43, 36, 34, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, .brand, .titlepage { font-family: Georgia, "Times New Roman", serif; }
h1 { font-size: 1.9rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.25rem; margin: 2rem 0 .6rem; border-bottom: 2px solid var(--line); padding-bottom: .3rem; }
h3 { font-size: 1.05rem; margin: .2rem 0 .4rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f1e9dd; padding: .1rem .4rem; border-radius: 4px; letter-spacing: .08em; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
  background: linear-gradient(180deg, #2d2421 0%, #241d1b 55%, #1e1817 100%);
  color: #f3ece2;
  padding: .55rem 1.2rem;
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 6px 18px -8px rgba(20, 15, 14, .55);
}
/* three-slot bar: actions flank a centered wordmark (playbill masthead) */
.bar-side { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.bar-left { justify-content: flex-start; }
.bar-right { justify-content: flex-end; }
/* a thin gold "proscenium" line riding just above the curtain-red edge */
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(185, 138, 47, .6), transparent);
}
.topbar nav { display: flex; align-items: center; gap: .9rem; }
.topbar a { color: #f3ece2; }
.topbar .btn { margin-top: 0; }

/* wordmark */
.brand { display: inline-flex; align-items: center; gap: .5rem; font-size: 1.35rem; font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mask { font-size: 1.1em; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45)); transition: transform .25s ease; }
.brand:hover .brand-mask { transform: rotate(-9deg) scale(1.08); }
.brand-word { font-family: Georgia, "Times New Roman", serif; letter-spacing: .01em; }
.brand-a { color: var(--gold); }

/* signed-in identity */
.userchip { display: inline-flex; align-items: center; gap: .5rem; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 1.95rem; height: 1.95rem; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #d0a24a, #9c7222);
  color: #241d1b; font-family: Georgia, serif; font-weight: 700; font-size: .95rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 1px 3px rgba(0, 0, 0, .35);
}
.who { color: #e7ddd0; font-size: .92rem; }
.logout-form { border-left: 1px solid rgba(243, 236, 226, .18); padding-left: .9rem; }
.logout { color: #c4b7ab; text-decoration: none; font-size: .88rem; }
.logout:hover { color: #f3ece2; text-decoration: underline; }

/* signed-out actions */
.navlink { color: #e7ddd0; font-weight: 500; }
.navlink:hover { color: #fff; text-decoration: none; }
.topbar .btn.signup { box-shadow: 0 1px 10px rgba(164, 52, 58, .5); }

/* whole-page zoom control */
.zoom { display: inline-flex; align-items: center; border: 1px solid rgba(243, 236, 226, .28); border-radius: 7px; overflow: hidden; }
.zoom button { background: none; border: none; color: #f3ece2; cursor: pointer; font: inherit; padding: .12rem 0; line-height: 1.2; }
.zoom button:hover { background: rgba(243, 236, 226, .14); }
.zoom-btn { width: 1.9rem; font-size: 1.05rem; }
.zoom-level { min-width: 3.2rem; font-size: .8rem; border-left: 1px solid rgba(243, 236, 226, .2); border-right: 1px solid rgba(243, 236, 226, .2); }

main { max-width: 760px; margin: 1.6rem auto 3rem; padding: 0 1.2rem; zoom: var(--zoom, 1); }
main.wide { max-width: 980px; }
footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.5rem 0 2.5rem; }

/* landing */
.lede { color: #5d534d; font-size: 1.05rem; max-width: 34rem; }
/* a centered lede (compiled script logline) must center its own 34rem box too,
   not just the text inside it */
.lede.center { margin-inline: auto; }

.stage-hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 2.5rem; align-items: center;
  background: radial-gradient(ellipse 90% 120% at 25% -20%, #55403a 0%, #372b28 40%, #241d1b 75%);
  color: #f3ece2; border-radius: 18px; border-bottom: 4px solid var(--accent);
  padding: 3rem 3.2rem; margin-top: .8rem;
  box-shadow: 0 24px 60px rgba(36, 29, 27, .28);
}
.stage-hero h1 { font-size: 3rem; line-height: 1.12; margin: .4rem 0 .8rem; color: #faf5ec; }
.stage-hero .lede { color: #cfc2b4; }
.kicker {
  margin: 0; font-size: .78rem; font-weight: 600; letter-spacing: .18em;
  text-transform: uppercase; color: var(--gold);
}
.cta-row { display: flex; align-items: center; gap: 1.1rem; margin-top: 1.4rem; flex-wrap: wrap; }
.hero-alt { color: #cfc2b4; text-decoration: underline; text-underline-offset: 3px; }
.hero-alt:hover { color: #faf5ec; }
.hero-note { color: #8f8177; font-size: .85rem; margin-top: 1.2rem; }

/* the script mock in the hero */
.mock {
  background: #fffdf9; color: var(--ink); border-radius: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .4);
  transform: rotate(1.2deg); overflow: hidden;
}
.mock-bar {
  display: flex; align-items: center; gap: .4rem;
  background: #efe7db; padding: .55rem .8rem; border-bottom: 1px solid var(--line);
}
.mock-bar span { width: 10px; height: 10px; border-radius: 50%; background: #d8cbbc; }
.mock-bar em { font-style: normal; font-size: .78rem; color: var(--muted); margin-left: .4rem; }
.mock-body { padding: 1.1rem 1.2rem 1.3rem; font: 13px/1.65 "SF Mono", ui-monospace, Menlo, monospace; }
.mock-body p { margin: .55rem 0; }
.mock-cue { display: inline-block; border-radius: 4px; padding: .05rem .45rem; font-weight: 600; }
.mock-lx { color: #7a5410; background: #f9efd9; }
.mock-sfx { color: #3f5c78; background: #e7eef4; }
.mock-dir { text-decoration: underline dashed rgba(110, 98, 89, .45); text-underline-offset: 3px; }
.mock-mention { font-weight: 700; color: #6e6259; text-transform: uppercase; font-size: .92em; }
.mock-name { font-weight: 700; margin-bottom: 0 !important; }
.mock-name + p { margin-top: 0; }

/* plan → write → stage */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 2.2rem; }
.step {
  position: relative; background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 1.2rem 1.3rem 1.1rem; box-shadow: var(--shadow);
}
.step em {
  font-style: normal; font-family: Georgia, serif; font-size: 2.4rem; line-height: 1;
  color: var(--gold); display: block;
}
.step h3 { margin: .3rem 0 .35rem; }
.step p { margin: 0; color: #5d534d; font-size: .93rem; }
.step code { font-size: .85em; }

.landing-h2 { text-align: center; margin-top: 2.8rem; border: none; font-size: 1.4rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.features > div { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.features p { margin: .3rem 0 0; color: #5d534d; font-size: .93rem; }

.band {
  text-align: center; background: #241d1b; color: #f3ece2;
  border-radius: 18px; padding: 2.6rem 2rem 2.8rem; margin-top: 2.8rem;
  border-bottom: 4px solid var(--accent);
}
.band h2 { border: none; color: #faf5ec; font-size: 1.9rem; margin: 0 0 .4rem; }
.band p { color: #cfc2b4; margin: 0 0 1.4rem; }

@media (max-width: 860px) {
  .stage-hero { grid-template-columns: 1fr; padding: 2.2rem 1.6rem; }
  .stage-hero h1 { font-size: 2.3rem; }
  .mock { transform: none; }
  .steps { grid-template-columns: 1fr; }
}

/* cards, forms, tables */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.3rem; margin: 1rem 0; box-shadow: var(--shadow); }
.narrow { max-width: 26rem; margin-inline: auto; }
.center { text-align: center; }
.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.cards .card { margin: 0; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .twocol { grid-template-columns: 1fr; } }

label { display: block; margin: .6rem 0; font-size: .9rem; color: #5d534d; }
input, textarea, select {
  display: block; width: 100%; margin-top: .25rem;
  padding: .5rem .6rem; font: inherit; color: var(--ink);
  background: #fffdf9; border: 1px solid var(--line); border-radius: 6px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }

.btn {
  display: inline-block; background: var(--accent); color: #fff !important;
  border: none; border-radius: 6px; padding: .55rem 1.1rem;
  font: inherit; font-weight: 600; cursor: pointer; margin-top: .4rem;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn-sm { padding: .3rem .7rem; font-size: .85rem; }
.btn-lg { padding: .7rem 1.5rem; font-size: 1.1rem; }
.btn-danger { background: #6e6259; }
.btn-danger:hover { background: #4e443d; }
.btn.ghost { background: none; color: var(--ink) !important; border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { background: #f6f0e7; }
.link { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.danger-link {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; font-size: .85rem; color: var(--accent); opacity: .75;
  text-decoration: underline dotted; text-underline-offset: 3px;
}
.danger-link:hover { opacity: 1; }

/* confirmation dialog */
#confirm {
  border: none; border-radius: 12px; padding: 1.2rem 1.4rem; max-width: 24rem;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 20px 60px rgba(36, 29, 27, .3);
}
#confirm::backdrop { background: rgba(36, 29, 27, .45); }
#confirm p { margin: 0 0 1rem; line-height: 1.5; }
.confirm-actions { display: flex; gap: .6rem; justify-content: flex-end; }

table { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
/* wide tables scroll inside their own box on narrow screens, not the whole page */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
.tablewrap table { min-width: 34rem; }
th, td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #f6f0e7; }
tr:last-child td { border-bottom: none; }
tr.acthead td { background: #f1e9dd; font-family: Georgia, serif; font-weight: 700; letter-spacing: .05em; }

.badge { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: .15rem .5rem; border-radius: 999px; white-space: nowrap; }
.badge-planning   { background: #e8e2f5; color: #4a3d7a; }
.badge-drafting   { background: #fdeacc; color: #7a5410; }
.badge-rehearsal  { background: #d9ecdc; color: #23662f; }
.badge-production { background: #f6d7d9; color: #7e272c; }
.badge-archived, .badge-locked { background: #e7e2dc; color: #6e6259; }
.badge-outline { background: #e8e2f5; color: #4a3d7a; }
.badge-draft   { background: #fdeacc; color: #7a5410; }

/* page head */
.pagehead { display: flex; justify-content: space-between; align-items: start; gap: 1rem; flex-wrap: wrap; }
/* the compiled-script header has no big title, so center the row */
.script-head { align-items: center; margin-bottom: 1rem; }
.script-head .crumbs { font-size: .95rem; }
.crumbs { color: var(--muted); font-size: .85rem; margin: 0; }
.headactions { display: flex; align-items: center; gap: .6rem; position: relative; }
.invite { color: var(--muted); font-size: .9rem; }
.tabs { display: flex; align-items: baseline; gap: 1.4rem; border-bottom: 2px solid var(--line); margin-top: .8rem; flex-wrap: wrap; }
.tabs a { padding: .1rem .1rem .45rem; margin-bottom: -2px; border-bottom: 2px solid transparent; color: #7a6f67; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { color: var(--muted); font-size: .78em; font-weight: 400; }
/* primary tabs (Characters, Scenes) — the working surfaces, given more weight */
.tabs .tab-primary { font-size: 1.05rem; font-weight: 600; color: #4a423d; }
.tabs .tab-primary.active { color: var(--ink); }
/* secondary tabs (Plot, Rehearsals, Credits) — reference; pushed to the right */
.tabs .tab-secondary { font-size: .9rem; }
.tabs .tab-split { margin-left: auto; }
@media (max-width: 560px) { .tabs .tab-split { margin-left: 0; } }
/* with JS on, panels swap in place; h2 repeats the tab name, so hide it */
nav.tabs[role="tablist"] ~ section > h2 { display: none; }
nav.tabs[role="tablist"] ~ section { margin-top: 1.4rem; }

/* beats */
.beats { list-style: none; padding: 0; counter-reset: beat; }
.beat { display: flex; justify-content: space-between; gap: .8rem; background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 8px; padding: .6rem .9rem; margin: .5rem 0; box-shadow: var(--shadow); }
.beat p { margin: .2rem 0 0; color: #5d534d; font-size: .92rem; }

/* characters */
.chars .card { border-top: 4px solid var(--accent); }
.char .notes { background: #fbf6ee; border-radius: 6px; padding: .5rem .6rem; font-size: .9rem; }

/* row actions, inline forms, popovers */
.inline { display: inline; }
.rowactions { display: flex; gap: .25rem; align-items: start; position: relative; flex-shrink: 0; }
.icon { background: none; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font-size: .95rem; color: var(--muted); padding: .1rem .35rem; list-style: none; display: inline-block; }
.icon:hover { border-color: var(--line); color: var(--ink); background: #f6f0e7; }
.icon:disabled { opacity: .3; cursor: default; }
.icon.danger:hover { color: var(--accent); }
details > summary { cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.popform {
  position: absolute; right: 0; z-index: 10; width: 21rem; max-width: 82vw;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: .8rem 1rem 1rem; box-shadow: 0 8px 24px rgba(43, 36, 34, .18); text-align: left;
}
.popform .sep { margin: .9rem 0 .7rem; border-top: 1px solid var(--line); }

/* kebab "more actions" menu */
.menu { position: relative; }
.menu-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--paper); color: #5d534d;
  font-size: 1.2rem; line-height: 1; list-style: none;
}
.menu-btn:hover { background: #f6f0e7; color: var(--ink); }
.menu-btn::-webkit-details-marker { display: none; }
.menu-label { margin: 0 0 .5rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.menu-link {
  display: block; padding: .4rem .5rem; margin: 0 -.5rem; border-radius: 6px;
  color: var(--ink); font-size: .92rem;
}
.menu-link:hover { background: #f6f0e7; text-decoration: none; }
.menu-pop .danger-link { padding: .3rem .5rem; margin: 0 -.5rem; display: inline-block; }
.noteswrap details { display: inline-block; margin-left: .3rem; }

/* the "add new …" row: a tinted card with a gold + badge leading it.
   stretch makes the button match the input height; inline-flex centers its label */
.addform {
  display: flex; gap: .6rem; margin-top: 1.1rem; flex-wrap: wrap; align-items: stretch;
  background: #faf5ec; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem;
}
.addform::before {
  content: '+'; flex: 0 0 auto; align-self: center;
  display: flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--gold); color: #fff; font-size: 1.15rem; line-height: 1;
}
.addform input { margin-top: 0; width: auto; flex: 1 1 10rem; background: #fff; }
.addform input[type=number] { flex: 0 0 4.5rem; }
.addform input[type=date], .addform input[type=time] { flex: 0 0 auto; width: auto; }
.addform .btn { margin-top: 0; flex: 0 0 auto; display: inline-flex; align-items: center; }
.inlinefield { margin: 0; flex: 0 0 auto; display: inline-flex; align-items: center; gap: .35rem; color: #5d534d; }

/* scene editor */
.editor { display: grid; grid-template-columns: 1fr 300px; gap: 1.2rem; align-items: start; margin-top: .5rem; }
@media (max-width: 760px) { .editor { grid-template-columns: 1fr; } }
.editmeta { display: flex; gap: .8rem; }
.editmeta .grow { flex: 1; }
textarea.script { font: 15px/1.6 "SF Mono", ui-monospace, Menlo, monospace; background: #fffdf9; tab-size: 8; }

/* highlight overlay: the backdrop renders the same characters as the textarea,
   visibly styled; the textarea's own text goes transparent (caret/selection
   still show). ".enhanced" is added by editor.js so no-JS keeps plain text. */
.scriptwrap { position: relative; margin-top: .25rem; }
.scriptwrap textarea.script { position: relative; z-index: 1; margin-top: 0; background: transparent; caret-color: var(--ink); }
.scriptwrap.enhanced textarea.script { color: transparent; }
.scriptwrap.enhanced textarea.script::placeholder { color: var(--muted); }
.script-backdrop { position: absolute; inset: 0; overflow: hidden; border-radius: 6px; background: #fffdf9; pointer-events: none; }
.script-render {
  padding: .5rem .6rem; border: 1px solid transparent;
  font: 15px/1.6 "SF Mono", ui-monospace, Menlo, monospace;
  white-space: pre-wrap; overflow-wrap: break-word; color: var(--ink); tab-size: 8;
}
.script-render .hl-mention { font-weight: 700; color: #6e6259; }
.script-render .hl-direction { text-decoration: underline dashed rgba(110, 98, 89, .45); text-underline-offset: 3px; }
.script-render .hl-cue { border-radius: 4px; font-weight: 600; }
.script-render .hl-cue-lx { color: #7a5410; background: rgba(253, 234, 204, .55); }
.script-render .hl-cue-sfx { color: #3f5c78; background: rgba(217, 231, 240, .65); }

.mention-menu[hidden] { display: none; }
.mention-menu {
  position: absolute; z-index: 6; min-width: 170px; max-width: 260px;
  display: flex; flex-direction: column; padding: .25rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(43, 36, 34, .18);
}
.mention-menu button {
  text-align: left; background: none; border: none; font: inherit;
  padding: .3rem .6rem; border-radius: 5px; cursor: pointer; color: var(--ink);
}
.mention-menu button.active, .mention-menu button:hover { background: #f6f0e7; }

/* rendered script styling (compiled view): mentions read like traditional
   script character names — bold caps in a softer ink, no @ */
.mention { font-weight: 700; text-transform: uppercase; color: #6e6259; letter-spacing: .02em; }
/* in the script body the name sits a touch larger than the dialogue */
.scripttext .mention { font-size: 1.06em; }
.scripttext .direction { text-decoration: underline dashed rgba(110, 98, 89, .4); text-underline-offset: 3px; }
.scripttext .cue { display: inline-block; border-radius: 4px; padding: 0 .4rem 0 .3rem; font-weight: 600; }
.scripttext .cue-lx { color: #7a5410; background: #f9efd9; }
.scripttext .cue-sfx { color: #3f5c78; background: #e7eef4; }
.scripttext .cue-lx::before { content: '💡 '; }
.scripttext .cue-sfx::before { content: '🔊 '; }

/* ---- comments ---------------------------------------------------------- */
.commented { background: #fdeeb8; border-radius: 2px; box-shadow: 0 1px 0 #e2bd47; cursor: pointer; }
.commented.mention { background: #fbe6a6; }
.commented.flash { background: #ffd97a; }

/* editor: right column holds the notes rail then the cast list (see .editor
   grid above; it collapses to one column at ≤760px) */
.editor-side { display: flex; flex-direction: column; gap: 1rem; }
.comments-rail .composer { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; margin-bottom: .8rem; background: #fffdf9; }
.composer-quote { margin: 0 0 .4rem; font-size: .85rem; }
.composer-quote q { color: #5d534d; }
.composer textarea { margin: 0; }
.composer-actions { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; }

.ccard { border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 8px; padding: .55rem .7rem; margin: .5rem 0; background: var(--paper); box-shadow: var(--shadow); font-size: .9rem; }
.ccard.resolved { opacity: .6; border-left-color: #b7ad9f; }
.ccard.orphaned { border-left-color: #b7ad9f; border-left-style: dashed; }
.ccard-quote { color: #6e6259; font-size: .8rem; margin-bottom: .25rem; border-left: 2px solid var(--line); padding-left: .4rem; }
.ccard-quote q { quotes: '“' '”'; }
.ccard-body { line-height: 1.45; white-space: normal; }
.ccard-meta { color: var(--muted); font-size: .75rem; margin-top: .3rem; }
.ccard-actions { display: flex; gap: .7rem; margin-top: .4rem; }
.ccard-actions .link { font-size: .8rem; }
.ccard-actions .link.danger { color: var(--accent); }
.ccard-edit { width: 100%; margin: .3rem 0; }

/* read view: script on the left, notes pinned in the right margin */
.reading { position: relative; max-width: 760px; margin: 0 auto; }
.reading.has-comments { max-width: none; padding-right: 300px; }
.reading.has-comments .promptbook { max-width: 700px; }
.comments-gutter { display: none; }
.ccard-abs { position: absolute; right: 0; width: 280px; margin: 0; }
.reading .comments-extras { position: static; width: 280px; margin-left: auto; margin-top: 1.5rem; }
.comments-extras h3 { border: none; margin: 0 0 .4rem; }
/* on phones there is no room for a side margin: drop the gutter and let the
   note cards flow below the script (their inline top offsets are ignored once
   they are position:static) */
@media (max-width: 760px) {
  .reading.has-comments { padding-right: 0; }
  .reading .ccard-abs { position: static; width: auto; margin: .6rem 0; }
  .reading .comments-extras { width: auto; margin-left: 0; }
}

/* character page */
.charpage { display: grid; grid-template-columns: 1fr 260px; gap: 1.2rem; align-items: start; }
@media (max-width: 760px) { .charpage { grid-template-columns: 1fr; } }
.mentionlist { list-style: none; padding: 0; margin: .3rem 0; }
.mentionlist li { margin: .4rem 0; }
.mentionlist .small { display: block; }

/* settings */
.fieldhint { margin: -.2rem 0 .6rem; }
.radio { display: flex; align-items: flex-start; gap: .5rem; margin: .5rem 0; cursor: pointer; }
.radio input { width: auto; margin: .2rem 0 0; flex: 0 0 auto; }
.radio span { color: var(--ink); }
.menu-links { display: flex; gap: .5rem; flex-wrap: wrap; }
.nomargin { margin: 0; }

/* settings page: a centered column of labelled setting rows */
.settings { max-width: 660px; margin: 0 auto; }
.settings-group { padding: 1.1rem 1.4rem 1.3rem; }
.settings-group h2 { margin-top: .2rem; }
.settings-note { margin: -.3rem 0 .2rem; }
.setting { display: grid; grid-template-columns: 8.5rem 1fr; gap: .3rem 1.4rem; padding: .95rem 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: none; padding-top: .4rem; }
.setting-name { font-weight: 600; font-size: .95rem; display: flex; flex-direction: column; gap: .25rem; }
.setting-hint { font-weight: 400; }
.setting-control { min-width: 0; }
.setting-control label { margin: 0; }
.setting-control .radio { margin: .1rem 0 .35rem; }
.setting-control input:not([type]) { max-width: 20rem; }
.setting-control p { margin: .3rem 0 0; }
.settings-actions { display: flex; align-items: center; gap: 1.2rem; margin: 1.1rem 0 .5rem; }
.settings-foot { text-align: center; margin: .6rem 0 0; }
@media (max-width: 560px) { .setting { grid-template-columns: 1fr; gap: .5rem; } }

/* credits */
.creditlist { list-style: none; padding: 0; }
.creditlist li { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .8rem; margin: .4rem 0; box-shadow: var(--shadow); display: flex; align-items: center; gap: .4rem; }
.creditlist form { margin-left: auto; }
.credits-block { margin: 1rem 0; }
.credit { margin: .15rem 0; }
.editactions { display: flex; align-items: center; gap: 1rem; }
.editactions .back { margin-left: auto; }

/* locked scene (read-only) */
.lockbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: #f1e9dd; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .9rem; margin-bottom: 1rem; }
.lockbar > span { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; }
.locked-script { background: #fffdf9; border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1.1rem; }
.locked-script .scripttext { margin: 0; }

/* autosave status pill */
.autosave { font-size: .82rem; color: var(--muted); transition: color .2s; }
.autosave.saving { color: var(--gold); }
.autosave.ok::before { content: '✓ '; color: #23662f; }
.autosave.ok { color: #4e7a58; }
.autosave.dirty { color: #8a7f78; }
.autosave.err { color: var(--accent); }
.castlist ul { padding-left: 1.1rem; margin: .3rem 0; }
.castlist li { margin: .3rem 0; font-size: .92rem; }

/* compiled script */
.promptbook { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 3rem 3.5rem; box-shadow: var(--shadow); }
@media (max-width: 760px) { .promptbook { padding: 1.5rem 1.2rem; } }
.titlepage { text-align: center; font-size: 2.2rem; margin-top: 1rem; }
.act { text-align: center; letter-spacing: .2em; margin-top: 2.5rem; border: none; }
.scenehead { margin-top: 1.8rem; }
.scripttext { font: 15px/1.7 Georgia, serif; margin: .5rem 0 0; }
.sline { white-space: pre-wrap; overflow-wrap: break-word; min-height: 1.7em; }
/* first-line indent for a continued paragraph; wrapped lines stay flush */
.sline.indent { text-indent: 2.8em; }
.pb-line.indent { text-indent: 2.8em; }
hr { border: none; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* print / page-break preview */
.printhint { text-align: center; margin: .2rem 0 1rem; }
.pageframe {
  background: #e6e0d6; border: 1px solid var(--line); border-radius: 10px;
  padding: 1.6rem; display: flex; flex-direction: column; align-items: center; gap: 1.5rem;
  overflow-x: auto;
}
.sheet {
  position: relative; box-sizing: border-box;
  width: 210mm; height: 297mm; padding: 18mm;
  background: #fff; box-shadow: 0 3px 16px rgba(36, 29, 27, .24);
}
.sheet-body { height: calc(297mm - 36mm); overflow: hidden; margin: 0; }
.sheet-num {
  position: absolute; bottom: 9mm; left: 0; right: 0;
  text-align: center; font: 9pt Georgia, serif; color: var(--muted);
}
.pb-block { break-inside: avoid; }
.pb-titleblock { padding-top: 1.4in; text-align: center; }
.pb-titleblock .titlepage { font-size: 2rem; margin: 0 0 .18in; }
.pb-titleblock .credits-block { margin: .2in 0; }
.pb-act { text-align: center; letter-spacing: .2em; font-weight: 700; font-family: Georgia, serif; margin: .28in 0 .16in; }
.pb-scene-head { font-weight: 700; font-family: Georgia, serif; margin: .16in 0 .03in; }
.pb-synopsis { color: var(--muted); margin: 0 0 .05in; }
.pb-line { min-height: 1.7em; }
/* print view: reserve a right margin on each sheet for note cards */
.pageframe.has-comments .sheet { padding-right: 58mm; }
.pageframe .sheet .ccard-abs { position: absolute; right: 6mm; width: 46mm; margin: 0; font-size: 8.5pt; box-shadow: none; }
.pageframe .sheet .ccard-abs .ccard-quote { font-size: 7.5pt; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { background: #f6d7d9; color: #7e272c; padding: .5rem .8rem; border-radius: 6px; }

@media print {
  .topbar, footer, .noprint { display: none; }
  .promptbook { border: none; box-shadow: none; padding: 0; }
  body { background: #fff; }
  /* stage directions carry no extra style on paper; cues stay marked for the tech team */
  .scripttext .direction { text-decoration: none; }
  .scripttext .cue { background: none; padding: 0; }
  /* print the play page with every tab section visible and titled */
  nav.tabs { display: none; }
  section[role="tabpanel"][hidden] { display: block !important; }
  nav.tabs[role="tablist"] ~ section > h2 { display: block; }
  /* screen zoom must not scale the printed output; main's own margins would
     otherwise spill past the last sheet and print a blank trailing page */
  main { zoom: 1; margin: 0; padding: 0; max-width: none; }
  /* print-view sheets become physical pages. break-before (not break-after)
     avoids a blank page after the final sheet */
  .pageframe { background: none; border: none; padding: 0; gap: 0; display: block; overflow: visible; }
  .sheet { box-shadow: none; margin: 0; }
  .sheet + .sheet { break-before: page; }
  .sheet-num { color: #000; }
  /* comment highlights: underline instead of a filled block, to save ink */
  .commented { background: none !important; box-shadow: none !important; text-decoration: underline; text-decoration-color: #b58900; }
  .ccard-abs { border: 1px solid #ccc; box-shadow: none; }
}

/* ---- small-screen polish (phones) -------------------------------------- */
@media (max-width: 640px) {
  /* header: drop the whole-page zoom (you pinch to zoom on a phone) and keep
     the name / log-out on one line */
  .zoom { display: none; }
  /* the centered-masthead grid is a desktop nicety; on phones fall back to a
     plain left wordmark / right actions so nothing collides or wraps */
  .topbar { display: flex; justify-content: space-between; padding: .5rem .9rem; }
  .bar-left { display: none; }
  .topbar nav { gap: .7rem; }
  .brand { font-size: 1.15rem; }
  .who, .navlink, .topbar nav .link { white-space: nowrap; }
  .logout-form { border-left: none; padding-left: 0; }
  /* print preview: scale the A4 sheets down so a whole page fits the screen */
  .pageframe { padding: .8rem; }
  .pageframe .sheet { zoom: 0.55; }
}
@media (max-width: 430px) {
  /* the gold avatar still says who you are, so drop the name text when tight */
  .who { display: none; }
  .pageframe .sheet { zoom: 0.43; }
}

/* ---- landing: fleshed-out marketing page -------------------------------- */
/* keep anchored sections clear of the sticky topbar */
[id="how"], [id="features"], [id="faq"] { scroll-margin-top: 74px; }
.landing-sub { text-align: center; color: #5d534d; max-width: 40rem; margin: -.2rem auto 0; }

/* quick trust row under the hero */
.trustbar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .55rem 1.5rem;
  margin: 1.8rem 0 .4rem; padding: .9rem 1rem;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  color: #6a5f58; font-size: .92rem;
}
.trustbar span { display: inline-flex; align-items: center; gap: .4rem; }

/* who it's for */
.audience { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.2rem; }
.aud-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1.4rem 1.3rem; box-shadow: var(--shadow); }
.aud-ic { font-size: 1.8rem; display: block; margin-bottom: .5rem; }
.aud-card h3 { margin: 0 0 .35rem; }
.aud-card p { margin: 0; color: #5d534d; font-size: .93rem; }

/* two-column showcase */
.showcase {
  display: grid; grid-template-columns: 1.05fr .95fr; gap: 2.4rem; align-items: center;
  margin-top: 2.6rem; background: var(--paper); border: 1px solid var(--line);
  border-radius: 16px; padding: 2.2rem 2.3rem; box-shadow: var(--shadow);
}
.showcase h2 { border: none; margin: .25rem 0 .6rem; font-size: 1.55rem; }
.showcase-copy p { color: #5d534d; }
.ticks { list-style: none; padding: 0; margin: 1.1rem 0 0; display: grid; gap: .6rem; }
.ticks li { position: relative; padding-left: 1.7rem; color: #40382f; font-size: .95rem; }
.ticks li::before { content: "✓"; position: absolute; left: 0; top: -1px; color: var(--gold); font-weight: 700; }

/* showcase art: an anchored-note demo */
.note-demo {
  background: #fffdf9; border: 1px solid var(--line); border-radius: 12px;
  padding: 1.3rem 1.4rem; box-shadow: 0 16px 36px rgba(43, 36, 34, .14);
  font: 14px/1.7 "SF Mono", ui-monospace, Menlo, monospace;
}
.note-demo p { margin: .2rem 0; }
.note-demo .mock-name { font-weight: 700; margin: 0; }
.note-demo .dim { color: var(--muted); }
.anchor-word { background: #f9efd9; box-shadow: inset 0 -2px 0 #e7c877; border-radius: 2px; padding: 0 .1rem; }
.note-card {
  margin-top: 1rem; background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 8px; padding: .6rem .8rem; font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: .88rem; box-shadow: var(--shadow);
}
.note-meta { display: flex; align-items: center; gap: .4rem; font-weight: 600; margin-bottom: .25rem; color: #40382f; }
.note-ava {
  display: inline-flex; align-items: center; justify-content: center; width: 1.35rem; height: 1.35rem;
  border-radius: 50%; background: radial-gradient(circle at 30% 30%, #d0a24a, #9c7222);
  color: #241d1b; font-size: .72rem; font-weight: 700;
}
.note-card p { margin: 0; color: #5d534d; }

/* FAQ */
.faq { max-width: 46rem; margin: 1.1rem auto 0; }
.faq details { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; margin-bottom: .6rem; box-shadow: var(--shadow); }
.faq summary { cursor: pointer; padding: .85rem 1.1rem; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--gold); font-size: 1.35rem; line-height: 1; flex: 0 0 auto; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0 1.1rem 1rem; color: #5d534d; }

/* rich site footer (public pages) */
.site-footer { background: #241d1b; color: #cfc2b4; border-top: 3px solid var(--accent); margin-top: 3.2rem; }
.foot-inner { max-width: 980px; margin: 0 auto; padding: 2.6rem 1.2rem 1.8rem; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1.6rem; }
.foot-brand .brand { color: #f3ece2; font-size: 1.3rem; }
.foot-brand p { margin: .7rem 0 0; max-width: 24rem; font-size: .9rem; color: #a99d90; }
.foot-col h4 { margin: 0 0 .7rem; color: #f3ece2; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.foot-col a { display: block; color: #cfc2b4; padding: .22rem 0; font-size: .92rem; }
.foot-col a:hover { color: #fff; text-decoration: none; }
.foot-bar {
  border-top: 1px solid rgba(243, 236, 226, .12); max-width: 980px; margin: 0 auto;
  padding: 1rem 1.2rem; display: flex; justify-content: space-between; color: #8f8177; font-size: .82rem;
}

@media (max-width: 760px) {
  .audience { grid-template-columns: 1fr; }
  .showcase { grid-template-columns: 1fr; padding: 1.6rem; gap: 1.4rem; }
  .foot-inner { grid-template-columns: 1fr 1fr; }
  .foot-brand { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .foot-bar { flex-direction: column; gap: .3rem; text-align: center; }
}

/* ---- admin dashboard ---------------------------------------------------- */
.adminlink { color: #d9b25a !important; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.adminlink:hover { color: #f0cf86 !important; text-decoration: none; }

.admin-head { margin-bottom: 1.2rem; }
.admin-head h1 { margin-bottom: .2rem; }
.admin-h2 { margin-top: 2rem; border: none; font-size: 1.2rem; }

.kpis-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1.1rem; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.kpi-val { font-family: Georgia, serif; font-size: 1.9rem; line-height: 1; color: var(--ink); }
.kpi-label { margin-top: .35rem; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.kpi-sub { margin-top: .25rem; font-size: .82rem; color: var(--gold); }

.admin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem 1.3rem; box-shadow: var(--shadow); min-width: 0; }
.panel h2 { margin: 0; border: none; font-size: 1.15rem; }
.panel-sub { margin: 1rem 0 .5rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* bar chart */
.barchart { display: flex; align-items: flex-end; gap: .5rem; height: 120px; margin-top: .8rem; }
.barcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .25rem; }
.bartrack { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.bar { width: 100%; background: linear-gradient(180deg, #c1893a, #9c7222); border-radius: 4px 4px 0 0; min-height: 2px; }
.barval { font-size: .72rem; color: var(--muted); height: .9rem; line-height: .9rem; }
.barlab { font-size: .68rem; color: var(--muted); height: .8rem; }
.growth-mini { margin-top: 1.1rem; display: grid; gap: .6rem; }
.growth-mini > div { display: flex; align-items: center; gap: .6rem; }
.growth-mini .gm-k { flex: 0 0 3.5rem; font-size: .8rem; color: var(--muted); }
.growth-mini .barchart { height: 30px; flex: 1; margin: 0; gap: .2rem; }
.growth-mini .barval, .growth-mini .barlab { display: none; }

/* status distribution */
.distro { display: grid; gap: .4rem; }
.distro-row { display: grid; grid-template-columns: 5rem 1fr 2.5rem; align-items: center; gap: .6rem; font-size: .9rem; }
.distro-k { text-transform: capitalize; color: #5d534d; }
.distro-bar { background: #efe7db; border-radius: 5px; height: .55rem; overflow: hidden; }
.distro-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.distro-v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

.factrow { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; margin-top: 1rem; color: #5d534d; font-size: .92rem; }
.factrow.tall { flex-direction: column; gap: .7rem; }
.factrow b { color: var(--ink); font-size: 1.05em; }

.admin-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.admin-table th { text-align: left; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: .4rem .6rem; border-bottom: 2px solid var(--line); }
.admin-table td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table th:not(:first-child), .admin-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

.feeds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.feed { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; box-shadow: var(--shadow); min-width: 0; }
.feed h3 { margin: 0 0 .6rem; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.feed ul { list-style: none; margin: 0; padding: 0; }
.feed li { padding: .45rem 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr); gap: .12rem; }
.feed li:last-child { border-bottom: none; }
.feed li b { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed li span { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed li time { font-size: .74rem; color: var(--gold); }

.sysbar { display: flex; flex-wrap: wrap; gap: .6rem 1.6rem; margin-top: 1.6rem; padding: .9rem 1.1rem; background: #241d1b; color: #cfc2b4; border-radius: 10px; font-size: .85rem; }
.sysbar span { display: inline-flex; align-items: center; gap: .4rem; }

@media (max-width: 900px) {
  .kpis-grid { grid-template-columns: repeat(2, 1fr); }
  .feeds { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .admin-cols { grid-template-columns: 1fr; }
  .feeds { grid-template-columns: 1fr; }
}
