/* ============================================================
   WRITER/PERFORMER — "1B" SKIN  (sidebar + cast panel)
   ============================================================
   An override layer that goes on top of skin.css. Add it as the
   LAST stylesheet in <head>:

     <link rel="stylesheet" href="skin.css">
     <link rel="stylesheet" href="wp-1b-skin.css">

   What it does:
     1. Tokens move to the Modernist palette, with Archivo for the
        interface and the script.
     2. Chrome drops the tracked all-caps: sentence case, 13–15px.
     3. On desktop (≥801px) the header becomes a 232px left rail:
        wordmark, script switcher, nav with icons, and utility icons
        along the bottom.
     4. In the Play Room the transport moves into a right-hand panel,
        and the Cast & Voices drawer docks under it, always open.
     5. The Library becomes a card grid and the Scene Board a ruled
        list of rows (stack view only; compact view is unchanged).
     6. The script switches to a stage-play layout: the character
        name sits in a left column beside its dialogue. Delete
        section 7 to keep the standard screenplay layout.
   Mobile (≤800px) keeps the app's own layout; only tokens and
   type apply there.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700&display=swap');

/* ---------- 1. TOKENS ---------- */

html[data-theme="light"], html[data-theme="paper"], :root {
  --bg:      #f3f2f2;
  --panel:   #f3f2f2;
  --panel-2: #eae9e9;
  --panel-3: #d7d3d3;
  --panel2:  #eae9e9;
  --panel3:  #d7d3d3;
  --ink:     #201e1d;
  --muted:   #605d5d;
  --line:    #d7d3d3;
  --wp-rule: color-mix(in srgb, #201e1d 40%, transparent);
  --wp-tint: #f8f4f4;
  --wp-hover: #eae7e7;

  --accent:      #ec3013;
  --accent-deep: #ae1800;
  --accent-dim:  #fff2ef;
  --accent-glow: #ffc4b8;
  --accent-ink:  #ffffff;
  --amber:       #ec3013;
  --amber-dim:   #fff2ef;
  --amber-glow:  #ffc4b8;

  --font-body:    "Archivo", system-ui, sans-serif;
  --font-mono:    "Archivo", system-ui, sans-serif;
  --font-display: "Archivo", system-ui, sans-serif;
  --font-light:   "Archivo", system-ui, sans-serif;
  --script-font:  "Archivo", system-ui, sans-serif;
  --ui-size: 15px;
  --wp-rail-w: 232px;
  --wp-panel-w: 312px;
  --wp-transport-h: 248px;
}

html[data-theme="dark"], html[data-theme="noir"] {
  --bg:      #201e1d;
  --panel:   #201e1d;
  --panel-2: #2d2b2b;
  --panel-3: #444141;
  --panel2:  #2d2b2b;
  --panel3:  #444141;
  --ink:     #f8f4f4;
  --muted:   #bab6b6;
  --line:    #444141;
  --wp-rule: color-mix(in srgb, #f8f4f4 28%, transparent);
  --wp-tint: #2d2b2b;
  --wp-hover: #2d2b2b;
  --accent:      #ec3013;
  --accent-deep: #ff9783;
  --accent-dim:  color-mix(in srgb, #ec3013 18%, transparent);
  --accent-ink:  #ffffff;
  --amber:       #ec3013;
  --amber-dim:   color-mix(in srgb, #ec3013 18%, transparent);
}

body { font-family: var(--font-body); font-size: 15px; -webkit-font-smoothing: antialiased; }
::selection { background: color-mix(in srgb, #ec3013 28%, transparent); }

/* ---------- 2. TYPE: NO MORE TRACKED CAPS ----------
   skin.css sets labels, tabs, buttons and headings in heavy uppercase.
   Everything in the chrome goes back to sentence case. */

.section-title, label, .eyebrow, .disp, .details-label,
nav.tabs button, .tab-btn, button, .btn, .pill, .view-mode-btn,
.header-project .project-status, .sb-card-num, .sb-card-heading,
.sb-act-header, .sb-act-edit-input, .sb-act-divider-label,
.cast-list .cast-card .char-role, .cast-list .cast-card .cast-role,
.cast-list .cast-card .cast-meta, .cast-list .cast-card .cast-name .name-display,
.gender-tag-btn, .gender-tag-name, .theme-swatch, .take-row button.small,
.note-box-head .note-label, .mv-name, #license-email-display .acct-label,
#settings-tab .key-card:has(.appearance-row) label:has(> input[type="checkbox"]),
.lib-open-btn, header h1, .tool-header h1 {
  font-family: var(--font-body) !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}
.cue-counter, .status-line, #header-credits, .ns-text .sub,
.cast-card .voice-meta, .mv-meta, .take-count, #my-voices-slot-counter,
.header-project .breadcrumb-project, #license-email-display .acct-value {
  font-family: var(--font-body) !important;
  font-variant-numeric: tabular-nums;
}

.section-title { font-size: 13px; font-weight: 500; color: var(--muted); }
label, .details-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.disp { font-size: 15px; font-weight: 600; }
h2, h3, .display-lg { font-family: var(--font-body); font-weight: 600; letter-spacing: -0.01em; }
.help-text, .settings-desc, .field-hint, .empty-state p, .modal-body p {
  font-size: 15px !important; line-height: 1.6; color: var(--muted);
}

/* ---------- 3. CONTROLS ---------- */

button, .btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  border-color: var(--wp-rule);
  border-radius: 0;
}
button:hover:not(:disabled), .btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-color: var(--wp-rule);
}
button:active:not(:disabled), .btn:active:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 14%, transparent);
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled), .btn.primary:hover:not(:disabled) { background: #dd2b0f; border-color: #dd2b0f; }
button.primary:active:not(:disabled) { background: #ae1800; border-color: #ae1800; }
input, select, textarea {
  font-family: var(--font-body);
  font-size: 15px;
  border-radius: 0;
  border-color: var(--wp-rule);
  background: var(--wp-tint);
}
input[type="range"] { background: transparent; }
:focus-visible, button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.setting-toggle-input:focus-visible + .setting-toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }
/* A quiet text action, so the skin's boxed-button defaults are undone. */
#cast-edit-merge-link {
  background: none !important; border: none !important; box-shadow: none !important;
  padding: 0 !important; margin: 0; min-height: 0 !important; height: auto !important;
  color: var(--muted); font-size: var(--ui-size); font-weight: 400; letter-spacing: 0;
  text-transform: none; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
#cast-edit-merge-link:hover { color: var(--ink); }
/* Remove from Cast and the merge link share one row; the row carries the spacing. */
.cast-edit-footer-actions { margin-top: 20px; }
.cast-edit-footer-actions #cast-edit-delete-btn { margin: 0; }
.pill.accent { color: var(--accent-deep); }

/* ---------- 4. LEFT RAIL (desktop) ---------- */

@media (min-width: 801px) {
  html, body { height: 100%; }
  body { flex-direction: row !important; overflow: hidden; }
  main { flex: 1 1 auto; min-width: 0; height: 100vh; }

  header.tool-header {
    width: var(--wp-rail-w);
    flex: 0 0 var(--wp-rail-w);
    height: 100vh;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: auto auto auto 1fr auto;
    align-content: stretch;
    gap: 0;
    padding: 24px 16px 16px;
    background: var(--wp-tint);
    border: none !important;
    border-right: 2px solid var(--wp-rule) !important;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .header-tab-divider, #mobile-nav-btn { display: none !important; }

  /* Wordmark: always the full mark in the rail, never the icon. */
  .header-brand {
    grid-column: 1 / -1; grid-row: 1;
    padding: 0 0 28px !important;
    border: none !important;
    align-self: start;
  }
  header h1, .tool-header h1 { margin: 0; padding: 0; gap: 0; }
  .brand-icon-wrap { display: none !important; }
  /* Cancel the base rule's negative margin on every brand image... */
  header h1 .brand-mark, .tool-header h1 .brand-mark { margin: 0 !important; top: 0 !important; }
  /* ...but size only the WORDMARK. .brand-icon also carries .brand-mark, so
     an unscoped `width: 168px !important` here stretched the square icon in
     the collapsed rail — and beat both the element's inline width:auto and
     any plain override further down the file. */
  header h1 .brand-mark.brand-wordmark, .tool-header h1 .brand-mark.brand-wordmark {
    width: 100% !important; max-width: 100%; height: auto !important; /* as wide as the Script box below */
  }
  header h1 .brand-mark.brand-icon, .tool-header h1 .brand-mark.brand-icon {
    width: auto !important; max-width: none !important;
  }
  html[data-theme="light"] .brand-mark-light.brand-wordmark,
  html[data-theme="paper"] .brand-mark-light.brand-wordmark,
  html[data-theme="grey"]  .brand-mark-light.brand-wordmark,
  html[data-theme="taos"]  .brand-mark-light.brand-wordmark,
  html[data-theme="cape"]  .brand-mark-light.brand-wordmark,
  html[data-theme="dark"]  .brand-mark-dark.brand-wordmark,
  html[data-theme="noir"]  .brand-mark-dark.brand-wordmark,
  html[data-theme="mono"]  .brand-mark-dark.brand-wordmark,
  html[data-theme="script-blue"] .brand-mark-dark.brand-wordmark,
  html[data-theme="steel"] .brand-mark-dark.brand-wordmark { display: block !important; }

  /* The right cluster dissolves so its pieces can sit in the rail grid. */
  .header-right { display: contents !important; }

  /* Script switcher. */
  .header-project {
    grid-column: 1 / -1; grid-row: 2;
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    gap: 2px !important;
    padding: 10px 12px !important;
    margin: 0 0 24px !important;
    background: var(--bg);
    border: 1px solid var(--line) !important;
    overflow: visible !important;
    position: relative;
    min-width: 0;
  }
  .header-project::before {
    content: "Script";
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    line-height: 1.3;
  }
  .header-project .breadcrumb-project,
  .header-project span.breadcrumb-project {
    font-family: var(--font-body) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    color: var(--ink) !important;
  }
  .header-project .project-status {
    font-size: 12px !important;
    font-weight: 400 !important;
    color: var(--muted) !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* Nav: a vertical list with icons and labels. */
  nav.tabs {
    grid-column: 1 / -1; grid-row: 3;
    display: flex !important;
    flex-direction: column;
    gap: 2px;
    align-self: start;
    border: none;
    margin-top: 24px;
  }
  nav.tabs button, nav.tabs .tab-btn {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 12px !important;
    width: 100%;
    height: 40px !important;
    min-height: 40px;
    padding: 0 8px !important;
    border: none !important;
    background: transparent !important;
    color: var(--muted) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    animation: none;
  }
  nav.tabs .tab-icon { display: block !important; width: 18px; height: 18px; flex: none; }
  nav.tabs .tab-label { display: inline !important; }
  nav.tabs button:hover:not(.active) { background: var(--wp-hover) !important; color: var(--ink) !important; }
  nav.tabs button.active, nav.tabs .tab-btn.active {
    background: #eae7e7 !important;
    color: var(--ink) !important;
  }
  html[data-theme="dark"] nav.tabs button.active,
  html[data-theme="noir"] nav.tabs button.active { background: #444141 !important; }
  nav.tabs button.active .tab-icon { color: var(--accent); }
  nav.tabs button[data-tab="settings"] { display: none !important; }
  nav.tabs.no-project button[data-tab="library"] { animation: none; color: var(--ink) !important; }

  /* Utility icons sit in one row at the foot of the rail. */
  .header-right > .icon-btn,
  .header-right > .download-menu-wrap {
    grid-row: 5;
    align-self: end;
    justify-self: stretch;
    border-top: 1px solid var(--line) !important;
    padding-top: 12px !important;
  }
  .header-right .icon-btn,
  .header-right button.icon-btn,
  .header-right .download-menu-wrap > .icon-btn {
    width: 100% !important;
    height: 52px !important;
    min-height: 0 !important;
    border: none !important;
    background: transparent;
    color: var(--muted);
    justify-content: center !important;
  }
  .header-right .download-menu-wrap { display: flex; border: none !important; }
  .header-right .download-menu-wrap > .icon-btn { padding: 0 !important; height: 40px !important; }
  .header-right > .icon-btn { height: 52px !important; }
  .header-right .icon-btn svg { width: 18px; height: 18px; stroke-width: 1.75; }
  .header-right .icon-btn:hover:not(:disabled) { background: var(--wp-hover) !important; color: var(--ink) !important; }
  .header-right .icon-btn:active:not(:disabled) { background: #d7d3d3 !important; color: var(--ink) !important; }
  .header-right .icon-btn.active { background: var(--wp-hover) !important; color: var(--accent) !important; }
  /* ---- Download: a modal, not a dropdown ----
     The app anchors this menu to its button with inline top/right computed
     from getBoundingClientRect. That was written for a button in a top bar;
     with the button at the foot of a left rail it pins the panel to the
     bottom-left corner, half of it below the fold. Rather than fight the
     anchor, ignore it: !important beats the inline styles, and the panel
     becomes a centred dialog. The app's existing document-click handler
     still closes it, and the backdrop is a pseudo-element with no listeners
     of its own, so a click on it bubbles up and closes too. */
  .header-right .download-menu-wrap .download-menu.open {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100vw - 48px));
    max-height: min(560px, calc(100vh - 96px));
    overflow-y: auto;
    padding: 0;
    background: var(--bg);
    border: 1px solid var(--line);
    border-top: 2px solid var(--ink);
    box-shadow: 0 24px 64px rgba(45, 43, 43, .28);
    z-index: 10400;
  }
  .header-right .download-menu-wrap .download-menu.open::before {
    content: "Export script";
    display: block;
    padding: 16px 20px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
  }
  .header-right .download-menu-wrap:has(.download-menu.open)::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(32, 30, 29, .42);
    z-index: 10399;
  }
  .header-right .download-menu-wrap .download-menu button {
    font-size: 15px;
    font-weight: 500;
    border-bottom: 1px solid var(--line);
    height: 48px;
    padding: 0 20px !important;
    justify-content: flex-start !important;
  }
  /* Inside a dialog the export list expands in place — a flyout anchored to
     the old menu's edge would fly off into the middle of the page. */
  .header-right .download-menu-wrap .download-menu.open .download-submenu {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: auto !important;
    min-width: 0 !important;
    border: none;
    box-shadow: none;
    background: var(--wp-tint);
  }
  .header-right .download-menu-wrap .download-menu.open .download-submenu button {
    padding-left: 36px !important;
    height: 44px;
  }
}

/* Narrow desktop: the rail collapses to icons so the script keeps its measure. */
@media (min-width: 801px) and (max-width: 1199px) {
  html[data-theme], :root { --wp-rail-w: 72px; --wp-panel-w: 288px; }
  header.tool-header {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr repeat(5, auto);
    padding: 20px 12px 12px;
  }
  .header-brand { padding: 0 0 20px !important; justify-content: center; }
  html .brand-mark.brand-wordmark.brand-wordmark.brand-wordmark { display: none !important; }
  .brand-icon-wrap { display: flex !important; justify-content: center; padding: 0; height: auto; }
  /* width:auto is load-bearing here. The wide-rail block above sets
     `header h1 .brand-mark { width: 168px !important }` for the wordmark,
     and .brand-icon carries .brand-mark too — so overriding only the height
     left the icon 28px tall and still 168px wide. */
  html[data-theme="light"] .brand-icon-light, html[data-theme="paper"] .brand-icon-light,
  html[data-theme="dark"] .brand-icon-dark, html[data-theme="noir"] .brand-icon-dark {
    display: block !important;
    height: 28px !important;
    width: auto !important;
    max-width: none !important;
  }
  .header-project { display: none !important; }
  nav.tabs { grid-row: 2; margin-top: 0; }
  nav.tabs button, nav.tabs .tab-btn { justify-content: center !important; padding: 0 !important; height: 44px !important; }
  nav.tabs .tab-label { display: none !important; }
  .header-right > .icon-btn,
  .header-right > .download-menu-wrap { grid-row: auto; border-top: none !important; padding-top: 0 !important; }
  .header-right > :nth-child(2) { grid-row: 4 !important; }
  .header-right > :nth-child(3) { grid-row: 5 !important; }
  .header-right > :nth-child(4) { grid-row: 6 !important; }
  .header-right > :nth-child(5) { grid-row: 7 !important; }
  .header-right > :nth-child(6) { grid-row: 8 !important; }
  .header-right > .icon-btn:first-of-type { border-top: 1px solid var(--line) !important; }
  .header-right > .icon-btn, .header-right .download-menu-wrap > .icon-btn { height: 44px !important; }
  html[data-theme], :root { --wp-gutter-col: 92px; }
  .script-page { padding: 0 32px 0 var(--wp-gutter-col) !important; }
  .script-toolbars { padding: 16px 24px 0 24px !important; }
  #perf-tab > .status-line { padding: 10px 32px 10px var(--wp-gutter-col) !important; }
}

/* ---------- 5. LIBRARY: A CARD GRID ---------- */

#library-tab-inner {
  max-width: 1120px !important;
  margin: 0 !important;
  padding: 48px 48px 56px !important;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 24px;
}
#library-tab-inner > .section-title {
  grid-column: 1;
  margin: 0 0 32px !important;
  padding: 0;
  border: none !important;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em !important;
  line-height: 1.1;
  color: var(--ink);
}
#library-tab-actions {
  grid-column: 2;
  margin: 0 0 32px !important;
  align-items: center;
  gap: 8px !important;
  flex-wrap: nowrap !important;
}
#library-tab-inner > #library-welcome-banner,
#library-tab-inner > .library-list,
#library-tab-inner > :not(.section-title):not(#library-tab-actions) { grid-column: 1 / -1; }
#library-welcome-banner { text-align: left !important; color: var(--muted); font-size: 15px; }
#library-welcome-banner * { font-family: var(--font-body) !important; font-style: normal !important; font-size: 15px !important; }

#new-workspace-btn-tab, #library-import-script-btn-tab {
  height: 40px !important; min-height: 40px; padding: 0 14px !important;
  font-size: 14px !important; letter-spacing: 0 !important;
}
#new-workspace-btn-tab { order: 9; }
/* One row, one height: sort, then the secondary actions, then New Script. */
#library-tab-actions > .library-sort-wrap { order: 1; margin: 0 8px 0 0 !important; }
#library-open-shared-btn-tab { order: 2; }
#library-import-script-btn-tab { order: 3; }
#library-open-shared-btn-tab {
  width: auto !important; height: 40px !important; min-height: 40px;
  padding: 0 14px !important; font-size: 14px !important; letter-spacing: 0 !important;
}
#library-tab-inner > .library-foot { margin-top: 32px; }
.library-foot-link {
  background: none !important; border: none !important; padding: 0 !important;
  height: auto !important; min-height: 0 !important;
  font-family: var(--font-body) !important; font-size: 13px !important; letter-spacing: 0 !important;
  text-transform: none !important; color: var(--muted) !important;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
  white-space: normal; text-align: left;
}
.library-foot-link:hover { color: var(--ink) !important; }
#library-sort-select-tab {
  height: 40px !important; font-size: 14px !important;
  background: var(--wp-tint) !important; border-color: var(--line) !important;
  font-family: var(--font-body) !important;
}
#library-tab-actions span { font-size: 13px !important; letter-spacing: 0 !important; text-transform: none !important; color: var(--muted); }

#library-list-tab {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px !important;
  overflow: visible;
}
#library-list-tab > :not(.lib-folder) {
  grid-column: 1 / -1;
  font-size: 13px !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  border-top: 2px solid var(--wp-rule) !important;
  padding: 16px 0 0 !important;
  margin-top: 16px !important;
}
#library-list-tab .lib-folder {
  margin: 0;
  background: var(--wp-tint);
  border: 1px solid var(--line);
  position: relative;
  transition: border-color .12s;
}
#library-list-tab .lib-folder[style*="accent"] { background: var(--wp-tint) !important; border-color: var(--ink); }
#library-list-tab .lib-folder:hover { border-color: var(--ink); }
#library-list-tab .lib-folder-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 168px;
  height: 100%;
  padding: 22px;
  background: transparent !important;
}
#library-list-tab .lib-file-icon { display: none; }
#library-list-tab .lib-folder-name {
  order: 2;
  flex: 1 1 auto;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
  text-wrap: pretty;
  color: var(--ink);
}
#library-list-tab .lib-folder-head > span[style*="color:var(--muted)"] {
  order: 1;
  font-size: 13px !important;
}
#library-list-tab .lib-folder-head > span[style*="color:var(--muted)"]::before { content: "Edited "; }
/* Shared with me: the date is when it was shared or opened, and the card says who shared it. */
#library-list-tab .lib-folder-head > span.lib-shared-date::before { content: "Shared "; }
#library-list-tab .lib-shared-by { order: 3; font-size: 13px; color: var(--muted); white-space: normal; overflow: visible; overflow-wrap: anywhere; max-width: 100%; }
#library-list-tab .lib-shared-name { color: var(--ink); font-weight: 600; }
#library-list-tab .lib-shared-email { display: block; }
.lib-shared-email { margin-left: .35em; }
#library-list-tab .lib-shared-email { margin-left: 0; }
.lib-shared-by { font-size: 1rem; color: var(--muted); flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#library-list-tab .lib-folder-head > span[style*="border:1px solid"] {
  order: 3;
  font-size: 12px !important;
  font-weight: 600;
  border: none !important;
  background: var(--panel-2);
  color: var(--ink) !important;
  opacity: 1 !important;
  padding: 3px 8px !important;
  border-radius: 0 !important;
}
#library-list-tab .lib-rename-btn,
#library-list-tab .lib-delete-btn,
#library-list-tab .lib-shared-remove-btn {
  position: absolute;
  top: 12px;
  width: 32px; height: 32px; min-height: 0;
  padding: 0;
  justify-content: center !important;
  border: 1px solid transparent;
  background: var(--wp-tint);
}
#library-list-tab .lib-rename-btn { right: 48px; }
#library-list-tab .lib-delete-btn, #library-list-tab .lib-shared-remove-btn { right: 12px; }
#library-list-tab .lib-rename-btn svg, #library-list-tab .lib-delete-btn svg { width: 14px; height: 14px; }
#library-list-tab .lib-open-btn { order: 4; }

/* ---------- 5b. CAST & VOICES: same frame and header as Library ---------- */

#cast-tab > .cast-page, #project-tab > .project-page { padding: 48px 48px 56px !important; }
.cast-head { display: flex; align-items: center; gap: 24px; margin: 0 0 32px; }
.cast-head .section-title {
  margin: 0 auto 0 0 !important;
  padding: 0;
  border: none !important;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em !important;
  line-height: 1.1;
  color: var(--ink);
}
.cast-head-actions { display: flex; align-items: center; gap: 8px; }
.cast-sort-label { font-size: 13px; color: var(--muted); }
#cast-tab #cast-sort-select {
  width: auto; height: 40px !important; font-size: 14px !important;
  background: var(--wp-tint) !important; border-color: var(--line) !important;
  font-family: var(--font-body) !important;
}
#char-report-btn {
  height: 40px !important; min-height: 40px; padding: 0 14px !important;
  font-size: 14px !important; letter-spacing: 0 !important;
}
#cast-tab .cast-toolbar, #cast-tab .cast-list { max-width: none; margin-left: 0; margin-right: 0; }
#cast-tab .cast-toolbar { margin-bottom: 24px; }
#cast-tab .cast-toolbar button {
  height: 40px !important; min-height: 40px; padding: 0 14px !important;
  font-size: 14px !important; letter-spacing: 0 !important;
}
@media (max-width: 800px) {
  #cast-tab > .cast-page, #project-tab > .project-page { padding: 24px 16px 48px !important; }
  .cast-head { flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
  .cast-head .section-title { font-size: 26px !important; }
}

/* ---------- 6. SCENE BOARD: RULED ROWS (stack view) ---------- */

.sb-toolbar {
  padding: 48px 48px 28px !important;
  border-bottom: none !important;
  gap: 8px !important;
}
.sb-toolbar .section-title {
  font-size: 36px !important;
  font-weight: 700;
  letter-spacing: -0.02em !important;
  line-height: 1.1;
  color: var(--ink);
  border: none !important;
  padding: 0;
  margin: 0 auto 0 0 !important;
  order: -1;
}
.sb-toolbar-right { margin-left: 16px !important; order: 9; }
.sb-size-label { font-size: 13px; color: var(--muted); }
.sb-view-btn { width: 40px; padding: 0 !important; justify-content: center !important; }
.sb-view-btn.active, .sb-rhythm-btn.active { background: var(--ink) !important; color: var(--bg) !important; border-color: var(--ink) !important; }
.sb-scroll { padding: 0 48px 56px !important; }

.sb-act-header {
  font-size: 20px !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em !important;
  color: var(--ink) !important;
  padding: 0 0 12px !important;
  margin: 0 !important;
  border-bottom: 2px solid var(--ink) !important;
}
.sb-act-header:not(:first-child) { margin-top: 40px !important; }
.sb-act-del-btn { font-size: 13px !important; height: 32px; min-height: 0; }
.sb-act-time { font-size: 14px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.sb-total-time { font-size: 13px; color: var(--muted); margin-left: 8px; }

#scene-board-tab:not(:has(.sb-view-compact)) .sb-cards,
#scene-board-tab:not(:has(.sb-view-compact)) .sb-cards-row {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0 !important;
  margin: 0;
}
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card {
  width: 100% !important;
  min-height: 0;
  display: grid;
  grid-template-columns: 88px minmax(0, 1.3fr) minmax(0, 1fr) 96px minmax(120px, 160px) 36px auto;
  align-items: center;
  column-gap: 16px;
  padding: 14px 8px;
  margin: 0;
  background: transparent;
  border: none !important;
  border-bottom: 1px solid var(--line) !important;
  box-shadow: none;
}
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card:hover { background: var(--wp-tint); box-shadow: none; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card.sb-drop-before { box-shadow: inset 0 2px 0 var(--accent); }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card.sb-drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card-meta,
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card-footer { display: contents; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card-num { grid-column: 1; grid-row: 1; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card-heading { grid-column: 2; grid-row: 1; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card-summary,
#scene-board-tab:not(:has(.sb-view-compact)) .sb-summary-input { grid-column: 3; grid-row: 1; min-height: 0; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card-time { grid-column: 4; grid-row: 1; margin: 0; }
/* The list's time column is narrow: page range above the run time. */
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card-page { display: block; margin-bottom: 4px; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-card-sep { display: none; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-status-badge { grid-column: 5; grid-row: 1; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-dir-btn { grid-column: 6; grid-row: 1; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-go-btn { grid-column: 7; grid-row: 1; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-size-label,
#scene-board-tab:not(:has(.sb-view-compact)) .sb-size-slider { display: none; }

/* The leading drop zone is a thin vertical sliver in the app's own wrapped-row
   layout, where its 140px minimum just matches card height. Stacked into a
   single column it becomes a 140px empty block between the act rule and the
   first scene — so here it turns into a horizontal band instead. Geometry is
   class-driven in the app now, so the hover state follows along. */
#scene-board-tab:not(:has(.sb-view-compact)) .sb-leading-drop-zone {
  width: 100% !important;
  min-height: 0 !important;
  height: 6px;
}
#scene-board-tab:not(:has(.sb-view-compact)) .sb-leading-drop-zone.sb-dz-over {
  width: 100% !important;
  height: 22px;
}
/* Renaming a scene in place: the input carries .sb-card-heading, so it already
   sits in the heading's grid column — it just needs the row's own type. */
#scene-board-tab:not(:has(.sb-view-compact)) .sb-heading-edit-input {
  font-size: 16px !important;
  font-weight: 600 !important;
  border-radius: 0;
}

/* Phones: the list's seven columns squeezed the title to one letter wide.
   Each row stacks instead: number, title and buttons; the summary at full
   width; then page, run time and status. */
@media (max-width: 760px) {
  .sb-scroll { padding: 0 16px 56px !important; }
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-card {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    row-gap: 6px;
    column-gap: 10px;
    padding: 12px 4px;
  }
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-card-num { grid-column: 1; grid-row: 1; }
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-card-heading { grid-column: 2; grid-row: 1; }
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-dir-btn { grid-column: 3; grid-row: 1; }
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-go-btn { grid-column: 4; grid-row: 1; }
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-card-summary,
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-summary-input { grid-column: 1 / -1; grid-row: 2; }
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-card-time { grid-column: 1 / 3; grid-row: 3; }
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-card-page { display: inline; margin: 0; }
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-card-sep { display: inline; }
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-status-badge { grid-column: 3 / -1; grid-row: 3; justify-self: end; }
  /* Compact view: acts stack top to bottom, each with a level label and its
     cards at full width. One column leaves nothing for the size slider. */
  #sb-cards.sb-view-compact { flex-direction: column !important; align-items: stretch !important; }
  .sb-view-compact .sb-act-divider { flex-direction: row !important; align-items: center !important; padding: 18px 0 10px !important; }
  .sb-view-compact .sb-act-divider-label { writing-mode: horizontal-tb !important; transform: none !important; padding: 0 !important; }
  .sb-view-compact .sb-act-divider-line { flex: 1 !important; height: 1px !important; width: auto !important; min-height: 0 !important; }
  .sb-view-compact .sb-act-col-cards { flex-direction: column !important; flex-wrap: nowrap !important; gap: 10px !important; }
  .sb-view-compact .sb-card { width: 100% !important; }
  #scene-board-tab:has(.sb-view-compact) .sb-size-label,
  #scene-board-tab:has(.sb-view-compact) .sb-size-slider { display: none !important; }
}

.sb-card-num { font-size: 14px !important; color: var(--muted); }
.sb-card-heading { font-size: 16px !important; font-weight: 600 !important; line-height: 1.35; }
.sb-card-summary { font-size: 14px !important; color: var(--muted); line-height: 1.45; }
.sb-card-summary.empty { color: #9b9797; font-style: normal !important; }
.sb-card-time { font-size: 14px !important; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Rhythm strip: one bar per speech, width = time to say it, colour = speaker
   (cast order, eight hues cycling). Gaps are stage directions. */
.sb-rh-legend {
  --rh-0: #c0504d; --rh-1: #3d7ab8; --rh-2: #d29a2c; --rh-3: #4f9a6a;
  --rh-4: #8a5fb0; --rh-5: #2f9fa6; --rh-6: #c46a96; --rh-7: #7a7a3a;
}
.sb-rhythm {
  --rh-0: #c0504d; --rh-1: #3d7ab8; --rh-2: #d29a2c; --rh-3: #4f9a6a;
  --rh-4: #8a5fb0; --rh-5: #2f9fa6; --rh-6: #c46a96; --rh-7: #7a7a3a;
  --rh-gap: var(--line);
  display: flex; align-items: stretch;
  height: 12px; margin: 6px 0 2px; min-width: 0; overflow: hidden;
  border-radius: 3px; cursor: pointer;
}
html[data-theme="dark"], html[data-theme="noir"], html[data-theme="mono"] { --rl-ok: #6cc488; --rl-wrong: #ef7a6e; }
html[data-theme="dark"] :is(.sb-rhythm, .sb-rh-legend), html[data-theme="noir"] :is(.sb-rhythm, .sb-rh-legend), html[data-theme="mono"] :is(.sb-rhythm, .sb-rh-legend) {
  --rh-0: #e07a76; --rh-1: #6fa6dc; --rh-2: #e8b95a; --rh-3: #78c091;
  --rh-4: #b08ad4; --rh-5: #5cc4ca; --rh-6: #e090b8; --rh-7: #b5b56a;
}
.sb-rh-bar, .sb-rh-gap { flex-basis: 0; min-width: 0; }
/* A hairline between pieces, drawn inside the bar so it costs no width.
   Dense scenes drop it: at a pixel or two per speech it would be all line. */
.sb-rhythm:not(.dense) > span { box-shadow: inset -1px 0 0 var(--panel); }
.sb-rh-gap { background: var(--rh-gap); opacity: .55; }
.sb-rh-bar[data-hue="0"] { background: var(--rh-0); }
.sb-rh-bar[data-hue="1"] { background: var(--rh-1); }
.sb-rh-bar[data-hue="2"] { background: var(--rh-2); }
.sb-rh-bar[data-hue="3"] { background: var(--rh-3); }
.sb-rh-bar[data-hue="4"] { background: var(--rh-4); }
.sb-rh-bar[data-hue="5"] { background: var(--rh-5); }
.sb-rh-bar[data-hue="6"] { background: var(--rh-6); }
.sb-rh-bar[data-hue="7"] { background: var(--rh-7); }
.sb-rh-bar.muted { opacity: .25; }
.sb-rh-bar:hover, .sb-rh-gap:hover { filter: brightness(1.15); outline: 1px solid var(--ink); outline-offset: -1px; }
#scene-board-tab:not(:has(.sb-view-compact)) .sb-rhythm { grid-column: 2 / 5; grid-row: 2; margin: 2px 0 0; }
.sb-rhythm-btn { height: 32px; padding: 0 10px !important; }
.sb-rhythm-btn:not(.active) { color: var(--muted); }
@media (max-width: 760px) {
  #scene-board-tab:not(:has(.sb-view-compact)) .sb-rhythm { grid-column: 1 / -1; grid-row: 4; }
}
.sb-status-badge {
  height: 32px !important;
  font-size: 13px !important;
  font-weight: 600;
  letter-spacing: 0 !important;
  border: none !important;
  background: var(--panel-2);
  color: var(--ink);
}
.sb-status-badge[data-color] { border-left: 3px solid !important; }
.sb-dir-btn { width: 36px; height: 32px !important; border-color: transparent !important; color: var(--muted); }
.sb-go-btn { height: 32px !important; font-size: 13px !important; border-color: transparent !important; }
.sb-card:hover .sb-go-btn, .sb-card:hover .sb-dir-btn { border-color: var(--wp-rule) !important; color: var(--ink); }
.sb-status-menu { border: 1px solid var(--line); border-top: 2px solid var(--ink); box-shadow: 0 12px 32px rgba(45,43,43,.22); }
.sb-status-option { font-size: 14px; height: 36px; }

/* ---------- 7. THE SCRIPT: STAGE-PLAY LAYOUT ----------
   The character name floats into a 120px left column so the dialogue
   starts beside it. Action and headings clear the column. Delete this
   section to go back to the centred screenplay layout. */

:root { --wp-name-col: 120px; --wp-gutter-col: 104px; }
.script-scroll { padding: 56px 0 280px !important; }
/* The left padding is the margin the per-line controls live in — play button,
   insert/delete, drag handle. 104px clears both the rail and the name column. */
.script-page { max-width: 760px !important; margin: 0 !important; padding: 0 56px 0 var(--wp-gutter-col) !important; }
.p-line { padding: 8px 16px; margin: 0 -16px 2px; }
.p-line .p-text { font-family: var(--script-font); font-size: 18px; line-height: 1.6; }

.p-line[data-type="Scene Heading"] {
  clear: both;
  border-top: none !important;
  margin-top: 32px;
  padding-top: 8px;
}
.p-line[data-type="Scene Heading"] .p-text {
  font-size: 24px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  letter-spacing: -0.01em !important;
  text-transform: none !important;
  line-height: 1.3;
}
.p-line[data-type="Act"] { clear: both; border-color: var(--ink); }
.p-line[data-type="Act"] .p-text { font-family: var(--script-font) !important; text-align: left; font-size: 15px; font-weight: 700; }

.p-line[data-type="Character"] {
  clear: both;
  float: left;
  width: var(--wp-name-col);
  margin: 0;
  padding-right: 8px;
  background: transparent !important;
  box-shadow: none !important;
}
.p-line[data-type="Character"] .p-text {
  text-align: left !important;
  margin: 0 !important;
  padding-top: 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em !important;
  line-height: 1.5;
  color: var(--ink);
}
.p-line[data-type="Dialogue"],
.p-line[data-type="Lyrics"],
.p-line[data-type="Parenthetical"] { margin-left: calc(var(--wp-name-col) - 16px); }
.p-line[data-type="Dialogue"] .p-text { max-width: none !important; margin: 0 !important; }
/* Lyrics: sung lines, in capitals and one indent (5 characters) in, as the
   submission guide prints them. The stored text keeps the writer's case. */
.p-line[data-type="Lyrics"] .p-text {
  max-width: none !important; margin: 0 !important;
  padding-left: 5ch; text-transform: uppercase;
}
.p-line[data-type="Parenthetical"] .p-text {
  max-width: none !important; margin: 0 !important;
  font-size: 16px !important; color: var(--muted);
}
/* Stage directions start at the name column, not the dialogue column — set
   flush with CHUCK rather than with what Chuck says, so the eye reads them
   as a separate channel instead of as another speech. */
.p-line[data-type="Action"], .p-line[data-type="General"], .p-line[data-type="Transition"] {
  clear: both;
  margin-top: 12px; margin-bottom: 12px;
  margin-left: 0;
  padding-left: 16px;
}
.p-line[data-type="Action"] .p-text, .p-line[data-type="General"] .p-text {
  font-size: 16px; color: var(--muted); opacity: 1 !important; line-height: 1.55;
  font-style: italic;
  max-width: 44em;
}
/* A line turned off by Do Not Synthesize, whatever its type. */
#script-page .p-line.line-nosynth .p-text { opacity: .35 !important; }
/* Act sits right above its scene: keep its icon clear of the scene's. */
#script-page .p-line[data-type="Act"] .line-skip-btn { margin-top: -12px; }
.p-line[data-type="Cue"], .p-line[data-type="Music"] { clear: both; }

/* ---- Per-line margin controls: one gutter column for every line type ----
   Character, Action and the headings sit at the page's content edge, while
   Dialogue and Parenthetical are pushed right by the name column — so their
   absolutely-positioned controls need that offset subtracted to land on the
   same x as everyone else's. */
.line-play-gutter { left: -44px !important; top: 2px; }
.line-toolbar     { left: -44px !important; }
.line-drag-handle { left: -74px !important; }
.p-line[data-type="Dialogue"] .line-play-gutter,
.p-line[data-type="Lyrics"] .line-play-gutter,
.p-line[data-type="Parenthetical"] .line-play-gutter,
.p-line[data-type="Dialogue"] .line-toolbar,
.p-line[data-type="Lyrics"] .line-toolbar,
.p-line[data-type="Parenthetical"] .line-toolbar {
  left: calc(-44px - var(--wp-name-col) + 16px) !important;
}
.p-line[data-type="Dialogue"] .line-drag-handle,
.p-line[data-type="Lyrics"] .line-drag-handle,
.p-line[data-type="Parenthetical"] .line-drag-handle {
  left: calc(-74px - var(--wp-name-col) + 16px) !important;
}

.p-line:hover { background: var(--wp-tint); }
/* :not(.line-loading) because !important beats animations, which would hide the loading pulse. */
.p-line.active-line:not(.line-loading) { background: var(--panel-2) !important; }
.p-line.active-line { box-shadow: none !important; }
.p-line.active-line[data-type="Character"] .p-text,
.p-line.active-line + .p-line[data-type="Dialogue"] ~ .p-line[data-type="Character"] .p-text { color: var(--ink); }
.p-line.active-line[data-type="Character"] .p-text { color: var(--accent-deep) !important; }
/* Light the speaker's name while their dialogue is the active line. */
.p-line[data-type="Character"]:has(+ .p-line.active-line[data-type="Dialogue"]) .p-text,
.p-line[data-type="Character"]:has(+ .p-line[data-type="Parenthetical"] + .p-line.active-line[data-type="Dialogue"]) .p-text,
.p-line[data-type="Character"]:has(+ .p-line.active-line[data-type="Parenthetical"]) .p-text,
.p-line[data-type="Character"]:has(+ .p-line.active-line[data-type="Lyrics"]) .p-text {
  color: var(--accent-deep) !important;
}
.p-line .p-text:focus { background: transparent; }

/* The toolbars get their own left edge rather than the script's. That gutter
   exists to hold the per-line margin controls — play, insert, delete — and
   the toolbars have none, so inheriting it stranded the Play button a
   hundred-odd pixels in and took room the type bar needed. */
.script-toolbars { padding: 16px 32px 0 32px !important; gap: 8px !important; }
.view-mode-toggle { padding: 0 !important; gap: 8px !important; }
.ptype-toolbar { padding: 0 !important; }
.script-toolbars:not(.labels-on) .ptype-toolbar { border-color: var(--wp-rule) !important; }
.ptype-toolbar .ptype-label { font-family: var(--font-body) !important; letter-spacing: 0 !important; text-transform: none !important; font-size: 13px !important; }
.ptype-btn { border-color: var(--wp-rule) !important; }
.ptype-btn.active { background: var(--ink) !important; color: var(--bg) !important; border-color: var(--ink) !important; }
.ptype-btn.active .ptype-key { color: var(--bg) !important; }
.ptype-toolbar.show-labels .ptype-btn .ptype-name {
  font-family: var(--font-body) !important; font-size: 13px !important;
  font-weight: 600; letter-spacing: 0 !important;
}
#ptype-size-btn, #panel-dock-btn, #panel-collapse-btn { border-color: var(--wp-rule) !important; }
.view-mode-btn { font-size: 14px !important; font-weight: 600; }
.view-mode-btn.active { background: var(--ink) !important; color: var(--bg) !important; }
/* The switch carries the on state, so the button itself stays unfilled. */
#edit-toggle-btn.active { background: none !important; color: var(--ink) !important; }
#undo-btn, #redo-btn, #outline-toggle-btn {
  width: 40px; padding: 0 !important; justify-content: center !important; border-color: transparent;
}

/* One height for every control in the script toolbars, one hairline, one
   gap. The height is a single token so the two rows can't drift apart again:
   app.css alone sets these to 30, 34 and 40px, and Listen As to nothing. */
.script-toolbars { --wp-bar-h: 36px; --wp-bar-gap: 6px; gap: var(--wp-bar-gap) !important; }
@media (max-width: 800px) { .script-toolbars { --wp-bar-h: 32px; } }
.view-mode-toggle, .ptype-toolbar { gap: var(--wp-bar-gap) !important; }
.script-toolbars .view-mode-btn, #listen-as-btn, #mute-lines-btn, #cuts-chip, #undo-btn, #redo-btn, #outline-toggle-btn,
#panel-dock-btn, #panel-collapse-btn, #ptype-size-btn,
.ptype-btn, .ptype-toolbar.show-labels .ptype-btn {
  box-sizing: border-box; height: var(--wp-bar-h) !important; min-height: 0 !important;
}
.ptype-toolbar:not(.show-labels) .ptype-btn,
#panel-dock-btn, #panel-collapse-btn, #ptype-size-btn { width: var(--wp-bar-h) !important; }
.script-toolbars .view-mode-btn, #listen-as-btn, #mute-lines-btn, #cuts-chip {
  display: inline-flex; align-items: center;
  padding: 0 12px !important; font-size: 13px !important; font-weight: 600;
  border-color: var(--wp-rule) !important;
}
#listen-as-btn.listen-active { border-color: var(--ink) !important; }
.panel-ctl-group { gap: var(--wp-bar-gap); }
#ptype-size-btn { border-style: solid; }

/* ---------- 7b. PAGE VIEW ----------
   Settings → General → Script layout: Page. The script becomes a Letter
   page in 12pt Courier Prime, laid out by the same ScriptLayout margin
   tables as the PDF: JS writes each element's columns onto #script-page as
   --pv-<kind>-l (left column from the page edge), -box (line box width in em),
   -align, -b (blank rows before) and -a (blank rows after). Everything is in
   em so one --pv-z scales the page to the space available: 1em = one row =
   1/6in, 0.6em = one column = 1/10in, 51em = 8.5in.
   The paper stays white in dark mode. Colours are set on the text, not as
   tokens on the page, so the per-line controls out in the margin keep the
   theme's colours. Phones keep the Reading layout. */
@media (min-width: 801px) {
  html.wp-page-view .script-scroll { position: relative; background: var(--panel-3); padding: 40px 96px 280px !important; }
  html.wp-page-view #script-page {
    position: relative; z-index: 1;
    font-size: calc(16px * var(--pv-z, 1));
    width: 51em; max-width: none !important; box-sizing: border-box;
    min-height: 66em;
    margin: 0 auto !important;
    padding: 6em 0 6em !important;
    background: transparent;
  }
  /* Until the sheets are drawn, the page itself is the paper, so opening
     Play Room never shows bare text on the grey. */
  html.wp-page-view .script-scroll:not(.pv-sheeted) #script-page { background: #fff; }
  /* The sheets sit behind the text: one white Letter page per PDF page,
     with its number and the (MORE) / (CONT'D) the PDF will print. */
  html.wp-page-view #pv-sheets {
    position: absolute; top: 40px; left: 0; right: 0; margin: 0 auto;
    width: 51em; font-size: calc(16px * var(--pv-z, 1));
    z-index: 0; pointer-events: none;
  }
  html.wp-page-view .pv-sheet {
    position: absolute; left: 0; width: 51em; height: 66em; background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.10), 0 10px 30px rgba(0,0,0,.10);
  }
  html.wp-page-view .pv-mark {
    position: absolute; white-space: pre;
    font-family: 'Courier Prime', 'Courier New', monospace; font-size: 1em; line-height: 1em;
    letter-spacing: calc(7em / 12 - 1ch);
    color: #8f8a8a;
  }
  html.wp-page-view .pv-split { display: block; user-select: none; pointer-events: none; }
  html.wp-page-view #script-page .p-text:empty { min-height: 1em; }
  html.wp-page-view #script-page .p-line {
    float: none !important; clear: none !important; width: auto !important;
    margin: 0 !important; padding: 0 !important;
    border: none !important; box-shadow: none !important;
    background: transparent;
    margin-top: calc(var(--pv-b, 0) * 1em) !important;
    margin-bottom: calc(var(--pv-a, 0) * 1em) !important;
  }
  html.wp-page-view #script-page .p-line.first-line { margin-top: 0 !important; }
  html.wp-page-view #script-page .p-line:hover { background: #f7f5f5; }
  html.wp-page-view #script-page .p-line.active-line:not(.line-loading) { background: #efecec !important; }
  /* A line split across two sheets: the highlight skips the gap between them
     (--pv-cut-a/b are set by paginatePageView). */
  html.wp-page-view #script-page .p-line.pv-split-line:hover {
    background: linear-gradient(to bottom, #f7f5f5 var(--pv-cut-a), transparent var(--pv-cut-a), transparent var(--pv-cut-b), #f7f5f5 var(--pv-cut-b));
  }
  html.wp-page-view #script-page .p-line.pv-split-line.active-line:not(.line-loading) {
    background: linear-gradient(to bottom, #efecec var(--pv-cut-a), transparent var(--pv-cut-a), transparent var(--pv-cut-b), #efecec var(--pv-cut-b)) !important;
  }
  html.wp-page-view #script-page .p-line .p-text {
    font-family: 'Courier Prime', 'Courier New', monospace !important;
    font-size: 1em !important; line-height: 1em !important;
    font-weight: 400 !important; font-style: normal !important;
    /* Final Draft's 7pt pitch: each character advances 7/12em, not 1ch. */
    letter-spacing: calc(7em / 12 - 1ch) !important; text-transform: none !important;
    color: #201e1d !important; caret-color: #201e1d;
    margin: 0 0 0 calc(var(--pv-l, 15) * 0.6em) !important;
    padding: 0 !important;
    width: calc(var(--pv-box, 35) * 1em); max-width: none !important;
    text-align: var(--pv-align, left) !important;
    overflow-wrap: anywhere;
  }
  html.wp-page-view #script-page .p-line .p-text::before,
  html.wp-page-view #script-page .p-line .p-text::after { color: #201e1d !important; }

  /* Which margin row each line type reads from. */
  html.wp-page-view #script-page .p-line[data-type="Act"]           { --pv-l: var(--pv-act-l); --pv-box: var(--pv-act-box); --pv-align: var(--pv-act-align); --pv-b: var(--pv-act-b); --pv-a: var(--pv-act-a); }
  html.wp-page-view #script-page .p-line[data-type="Scene Heading"] { --pv-l: var(--pv-scene-l); --pv-box: var(--pv-scene-box); --pv-align: var(--pv-scene-align); --pv-b: var(--pv-scene-b); --pv-a: var(--pv-scene-a); }
  html.wp-page-view #script-page .p-line[data-type="Action"]        { --pv-l: var(--pv-action-l); --pv-box: var(--pv-action-box); --pv-align: var(--pv-action-align); --pv-b: var(--pv-action-b); --pv-a: var(--pv-action-a); }
  html.wp-page-view #script-page .p-line[data-type="General"]       { --pv-l: var(--pv-general-l); --pv-box: var(--pv-general-box); --pv-align: var(--pv-general-align); --pv-b: var(--pv-general-b); --pv-a: var(--pv-general-a); }
  html.wp-page-view #script-page .p-line[data-type="Character"]     { --pv-l: var(--pv-char-l); --pv-box: var(--pv-char-box); --pv-align: var(--pv-char-align); --pv-b: var(--pv-char-b); --pv-a: var(--pv-char-a); }
  html.wp-page-view #script-page .p-line[data-type="Parenthetical"] { --pv-l: var(--pv-paren-l); --pv-box: var(--pv-paren-box); --pv-align: var(--pv-paren-align); --pv-b: var(--pv-paren-b); --pv-a: var(--pv-paren-a); }
  html.wp-page-view #script-page .p-line[data-type="Dialogue"]      { --pv-l: var(--pv-dial-l); --pv-box: var(--pv-dial-box); --pv-align: var(--pv-dial-align); --pv-b: var(--pv-dial-b); --pv-a: var(--pv-dial-a); }
  html.wp-page-view #script-page .p-line[data-type="Transition"]    { --pv-l: var(--pv-trans-l); --pv-box: var(--pv-trans-box); --pv-align: var(--pv-trans-align); --pv-b: var(--pv-trans-b); --pv-a: var(--pv-trans-a); }
  html.wp-page-view #script-page .p-line[data-type="Cue"]           { --pv-l: var(--pv-cue-l); --pv-box: var(--pv-cue-box); --pv-align: var(--pv-cue-align); --pv-b: var(--pv-cue-b); --pv-a: var(--pv-cue-a); }
  html.wp-page-view #script-page .p-line[data-type="Music"]         { --pv-l: var(--pv-music-l); --pv-box: var(--pv-music-box); --pv-align: var(--pv-music-align); --pv-b: var(--pv-music-b); --pv-a: var(--pv-music-a); }
  html.wp-page-view #script-page .p-line[data-type="Lyrics"]        { --pv-l: var(--pv-lyric-l); --pv-box: var(--pv-lyric-box); --pv-align: var(--pv-lyric-align); --pv-b: var(--pv-lyric-b); --pv-a: var(--pv-lyric-a); }
  /* Lyrics as the PDF sets them: the indent comes from the page format, so no
     padding; capitals in a stage play, italics in a screenplay. */
  html.wp-page-view #script-page .p-line[data-type="Lyrics"] .p-text { padding-left: 0 !important; }
  html.wp-page-view #script-page[data-page-format="screenplay"] .p-line[data-type="Lyrics"] .p-text { text-transform: none !important; font-style: italic !important; }

  /* Type styles, as in the PDF. */
  html.wp-page-view #script-page .p-line:is([data-type="Act"], [data-type="Scene Heading"], [data-type="Character"], [data-type="Transition"], [data-type="Lyrics"]) .p-text { text-transform: uppercase !important; }
  html.wp-page-view #script-page .p-line:is([data-type="Act"], [data-type="Cue"]) .p-text { font-weight: 700 !important; text-decoration: underline; text-underline-offset: 0.15em; }
  html.wp-page-view #script-page .p-line[data-type="Music"] .p-text { font-style: italic !important; }
  /* A parenthetical's second line sits inside its opening bracket. */
  html.wp-page-view #script-page .p-line[data-type="Parenthetical"] .p-text {
    /* border-box: the hanging-indent padding sits inside the line's box */
    box-sizing: border-box;
    padding-left: calc(7em / 12) !important; text-indent: calc(-7em / 12);
    width: calc(var(--pv-box, 15) * 1em);
  }
  /* Act headings: bold and underlined in a screenplay, plain in a stage play. */
  html.wp-page-view #script-page[data-page-format="stage"] .p-line[data-type="Act"] .p-text { font-weight: 400 !important; }
  /* Submission format: acts and scenes plain and underlined, scenes as
     written ("SCENE 6" reads "Scene 6", via the .pv-scene-word lead-in), and
     "Setting:" / "At Rise:" hung in the margin, 1.5in left of the text
     (.pv-label, set by decorateScriptText). An inline-block takes no
     underline from its line, so the scene word draws its own. */
  html.wp-page-view #script-page[data-page-format="submission"] .p-line[data-type="Act"] .p-text { font-weight: 400 !important; }
  html.wp-page-view #script-page[data-page-format="submission"] .p-line[data-type="Scene Heading"] .p-text {
    text-transform: none !important; text-decoration: underline !important; text-underline-offset: 0.15em;
  }
  html.wp-page-view #script-page[data-page-format="submission"] .pv-scene-word {
    display: inline-block; text-transform: lowercase; text-decoration: underline; text-underline-offset: 0.15em;
  }
  html.wp-page-view #script-page[data-page-format="submission"] .pv-scene-word::first-letter { text-transform: uppercase; }
  html.wp-page-view #script-page[data-page-format="submission"] .pv-label {
    display: inline-block; width: 9em; margin-left: -9em; white-space: pre; overflow: visible;
  }
  /* Speech with no name above it (the FDX left it out) still gets air. */
  html.wp-page-view #script-page .p-line:not([data-type="Character"]):not([data-type="Parenthetical"]):not([data-type="Dialogue"]):not([data-type="Lyrics"]) + .p-line:is([data-type="Dialogue"], [data-type="Lyrics"]) { margin-top: 1em !important; --pv-b: 1; }

  /* Cue and music badges move out into the margin instead of over the text. */
  html.wp-page-view #script-page .p-line[data-type="Cue"]::before { top: 0; left: -40px; }
  html.wp-page-view #script-page .p-line[data-type="Music"]::before { top: 0; left: -28px; }
  html.wp-page-view #script-page .p-line[data-in-music] { background: transparent; }
  /* A song on the sheet: the rail in the left margin, the end bar across to
     the right margin, its handle out there where no text is. */
  html.wp-page-view #script-page .song-rail { left: 3.4em; width: 2px; }
  html.wp-page-view #script-page .song-end { left: 3.4em; right: 0.3em; border-top-width: 1.5px; }
  html.wp-page-view #script-page .song-end-label { right: 0; left: auto; top: -0.8em; font-size: 10px; }

  /* One margin column for every line's controls, out on the desk. */
  html.wp-page-view #script-page .p-line .line-play-gutter,
  html.wp-page-view #script-page .p-line .line-toolbar { left: -44px !important; }
  html.wp-page-view #script-page .p-line .line-drag-handle { left: -74px !important; }

  /* Dual dialogue: the same two columns the PDF prints (ScriptLayout.dualColumns).
     The left column runs from the page edge, so its lines keep their usual left
     offset; the right column starts where its text does. */
  html.wp-page-view #script-page .dual-dialogue-pair { display: flex; align-items: flex-start; gap: 0; margin: 0; padding: 0; border: none; }
  html.wp-page-view #script-page .dual-dialogue-pair .dual-col { display: block; }
  html.wp-page-view #script-page .dual-dialogue-pair .dual-col-left { flex: 0 0 calc(var(--pv-dual-right-l) * 0.6em); min-width: 0; }
  html.wp-page-view #script-page .dual-dialogue-pair .dual-col-right { flex: 1 1 0; min-width: 0; position: relative; z-index: 1; }
  html.wp-page-view #script-page .dual-dialogue-pair.pv-page-top .p-line { margin-top: 0 !important; }
  html.wp-page-view #script-page .dual-badge { display: none; }
  html.wp-page-view #script-page .dual-col-left .p-line[data-type="Character"] { --pv-l: var(--pv-dual-left-l); --pv-box: var(--pv-dual-name-box); --pv-align: center; }
  html.wp-page-view #script-page .dual-col-left .p-line[data-type="Dialogue"] { --pv-l: var(--pv-dual-left-l); --pv-box: var(--pv-dual-dial-box); --pv-align: left; }
  html.wp-page-view #script-page .dual-col-left .p-line[data-type="Parenthetical"] { --pv-l: calc(var(--pv-dual-left-l) + var(--pv-dual-paren-inset)); --pv-box: var(--pv-dual-paren-box); --pv-align: left; }
  html.wp-page-view #script-page .dual-col-right .p-line[data-type="Character"] { --pv-l: 0; --pv-box: var(--pv-dual-name-box); --pv-align: center; }
  html.wp-page-view #script-page .dual-col-right .p-line[data-type="Dialogue"] { --pv-l: 0; --pv-box: var(--pv-dual-dial-box); --pv-align: left; }
  html.wp-page-view #script-page .dual-col-right .p-line[data-type="Parenthetical"] { --pv-l: var(--pv-dual-paren-inset); --pv-box: var(--pv-dual-paren-box); --pv-align: left; }
  /* Controls stay in the page margins: left ones reach back past the left
     column, and left-column lines are as wide as the page so their right-hand
     pins land in the margin, not on the speech beside them. */
  html.wp-page-view #script-page .dual-col-left .p-line { width: 51em !important; }
  html.wp-page-view #script-page .dual-col-left .p-line:hover { background: transparent; }
  html.wp-page-view #script-page .dual-col-right .p-line .line-play-gutter,
  html.wp-page-view #script-page .dual-col-right .p-line .line-toolbar { left: calc(-44px - var(--pv-dual-right-l) * 0.6em) !important; }
  html.wp-page-view #script-page .dual-col-right .p-line .line-drag-handle { left: calc(-74px - var(--pv-dual-right-l) * 0.6em) !important; }

  html.wp-page-view #script-page .add-line-btn { margin: 2em 0 0 calc(var(--pv-action-l, 15) * 0.6em); }
}

/* ---------- 8. PLAY ROOM: TRANSPORT + CAST PANEL (desktop) ----------
   Everything here is the SIDE arrangement, so every selector carries an
   html:not(.wp-panel-bottom) prefix. Flip .wp-panel-bottom on <html> and
   none of it applies: the app falls back to its own layout, transport as a
   bar under the script and the cast list as an overlay drawer. Section 8b
   handles the hidden state.
   The prefix is spelled out on each rule rather than written once as a
   nested block, so this section asks nothing of the browser that the rest
   of the file doesn't already ask. */

@media (min-width: 801px) {

 html:not(.wp-panel-bottom) #perf-tab.active{
   display: grid !important;
   grid-template-columns: minmax(0, 1fr) var(--wp-panel-w);
   grid-template-rows: minmax(0, 1fr) auto;
   height: 100vh;
 }
 html:not(.wp-panel-bottom) #perf-tab > .perf-body{ grid-column: 1; grid-row: 1; min-height: 0; }
 html:not(.wp-panel-bottom) #perf-tab > .status-line{
   grid-column: 1; grid-row: 2;
   font-size: 13px !important;
   color: var(--muted);
   background: var(--bg) !important;
   border-top: 1px solid var(--line) !important;
   padding: 10px 56px 10px var(--wp-gutter-col) !important;
   min-height: 40px;
 }
 html:not(.wp-panel-bottom) #perf-tab > .status-line.warn{ color: var(--accent-deep); }

 html:not(.wp-panel-bottom) /* The transport becomes the head of the right panel. */
 #perf-tab > .perf-top.perf-bottom{
   grid-column: 2; grid-row: 1 / span 2;
   align-self: start;
   height: var(--wp-transport-h);
   display: flex !important;
   flex-direction: column;
   align-items: stretch;
   gap: 0;
   padding: 28px 24px 20px !important;
   background: var(--bg) !important;
   border: none !important;
   border-left: 2px solid var(--wp-rule) !important;
   border-bottom: 1px solid var(--line) !important;
   position: relative;
   z-index: 2;
 }
 html:not(.wp-panel-bottom) /* Fill the column under the transport so the rule runs full height. */
 #perf-tab.active::after{
   content: "";
   grid-column: 2; grid-row: 1 / span 2;
   border-left: 2px solid var(--wp-rule);
   background: var(--bg);
 }
 html:not(.wp-panel-bottom) #perf-tab > .perf-top.perf-bottom{ grid-row: 1 / span 2; }

 html:not(.wp-panel-bottom) .perf-bottom .now-speaking{ min-width: 0; gap: 12px; order: 1; }
 html:not(.wp-panel-bottom) .perf-bottom .ns-photo{
   width: 44px !important; height: 44px !important;
   background: var(--accent) !important; border: none !important; outline: none !important;
   box-shadow: none !important;
 }
 html:not(.wp-panel-bottom) .perf-bottom .ns-photo svg{ width: 22px; height: 22px; color: #fff !important; }
 html:not(.wp-panel-bottom) .perf-bottom .ns-photo.stage{ background: var(--ink) !important; }
 html:not(.wp-panel-bottom) .perf-bottom .ns-text{ min-width: 0; line-height: 1.35; }
 html:not(.wp-panel-bottom) .perf-bottom .ns-text .disp{
   color: var(--ink) !important;
   font-size: 17px !important;
   font-weight: 600 !important;
   white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
 }
 html:not(.wp-panel-bottom) .perf-bottom .ns-text .sub{
   color: var(--muted) !important;
   font-size: 13px !important;
   letter-spacing: 0 !important;
   white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
 }

 html:not(.wp-panel-bottom) .perf-bottom .transport-cluster{
   order: 2;
   display: flex !important;
   flex-direction: column;
   align-items: stretch;
   gap: 16px;
   margin-top: 22px;
   justify-self: stretch;
 }
 html:not(.wp-panel-bottom) .perf-bottom .cue-counter{
   order: 1;
   color: var(--muted) !important;
   font-size: 13px !important;
   padding-top: 8px;
   border-top: 2px solid var(--line);
   min-width: 0;
 }
 html:not(.wp-panel-bottom) .perf-bottom .transport{ order: 2; display: flex; gap: 8px; }
 html:not(.wp-panel-bottom) .perf-bottom .transport button{
   width: 44px !important; height: 44px !important;
   border-radius: 0 !important;
   border: 1px solid var(--wp-rule) !important;
   background: transparent !important;
   color: var(--ink) !important;
   flex: none;
 }
 html:not(.wp-panel-bottom) .perf-bottom .transport button svg{ width: 16px; height: 16px; }
 html:not(.wp-panel-bottom) .perf-bottom .transport button:hover:not(:disabled){ background: color-mix(in srgb, var(--ink) 7%, transparent) !important; }
 html:not(.wp-panel-bottom) .perf-bottom .transport button.play-btn{
   order: -1;
   flex: 1 1 auto;
   width: auto !important;
   background: var(--ink) !important;
   border-color: var(--ink) !important;
   color: var(--bg) !important;
 }
 html:not(.wp-panel-bottom) .perf-bottom .transport button.play-btn:hover:not(:disabled){ background: #444141 !important; }
 html:not(.wp-panel-bottom) .perf-bottom .transport button.play-btn:active:not(:disabled){ background: var(--accent) !important; border-color: var(--accent) !important; }
 html:not(.wp-panel-bottom) .perf-bottom .transport button.play-btn svg{ width: 18px; height: 18px; }

 html:not(.wp-panel-bottom) .perf-bottom .perf-actions{ order: 3; margin-top: auto; justify-self: stretch; }
 html:not(.wp-panel-bottom) .perf-bottom .perf-actions button,
 html:not(.wp-panel-bottom) #drawer-toggle-btn{
   width: 100%;
   height: 36px !important; min-height: 0 !important;
   padding: 0 !important;
   border: none !important;
   background: transparent !important;
   color: var(--ink) !important;
   font-size: 13px !important;
   font-weight: 600;
   justify-content: space-between !important;
 }
 html:not(.wp-panel-bottom) #drawer-toggle-btn::after{ content: "Voice explorer \2192"; color: var(--muted); font-weight: 500; }
 html:not(.wp-panel-bottom) #drawer-toggle-btn{ font-size: 0 !important; display: flex !important; align-items: center; }
 html:not(.wp-panel-bottom) #drawer-toggle-btn::before{ content: "Cast"; font-size: 13px; color: var(--muted); font-weight: 500; }
 html:not(.wp-panel-bottom) #drawer-toggle-btn::after{ font-size: 13px; }
 html:not(.wp-panel-bottom) #drawer-toggle-btn:hover::after{ color: var(--ink); }

 html:not(.wp-panel-bottom) /* The cast drawer docks under the transport whenever the Play Room is open. */
/* Classes the app sets (body.perf-tab-active, .script-scroll.pv-sheeted), not :has():
   a :has() anchored on body or the script re-checks on every edit and made
   Chrome restyle all ~75,000 elements of a full play per keystroke. */
 body.perf-tab-active .cast-drawer{
   top: var(--wp-transport-h);
   right: 0 !important;
   bottom: 0;
   height: auto;
   width: var(--wp-panel-w);
   max-width: none;
   padding: 8px 0 24px;
   background: var(--bg);
   border-left: 2px solid var(--wp-rule);
   transition: none;
   z-index: 3;
 }
 html:not(.wp-panel-bottom) body.perf-tab-active #drawer-overlay{ display: none !important; }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .drawer-head{ display: none; }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-toolbar{
   display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 24px 12px; margin: 0;
 }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-toolbar > *{ height: 32px; min-height: 0; font-size: 13px; padding: 0 10px; }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-toolbar select{ flex: 1 1 100%; }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-list{ gap: 0; }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-card{
   grid-template-columns: 32px minmax(0, 1fr);
   grid-template-areas: "photo name" "photo provider" "photo voice" "photo test";
   gap: 6px 12px;
   padding: 12px 24px;
   border: none;
   border-bottom: 1px solid var(--line);
   background: transparent;
 }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-card:hover{ background: var(--wp-tint); }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-card .photo-wrap{ width: 32px; height: 32px; }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-card .cast-name{ font-size: 14px; font-weight: 600; }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-card select,
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-card .test-btn{ height: 32px !important; min-height: 0; font-size: 13px; }
 html:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer .cast-card.highlight-pulse{ background: var(--accent-dim); }
}

/* ---------- 8b. PLAY PANEL: HIDDEN ----------
   In side mode, collapse the column to nothing and take the panel, its
   backing fill and the docked cast list out of the flow, so the script runs
   the full width. In bottom mode there's just the one bar to drop. */

@media (min-width: 801px) {
  html.wp-panel-hidden:not(.wp-panel-bottom) { --wp-panel-w: 0px; }
  html.wp-panel-hidden:not(.wp-panel-bottom) #perf-tab > .perf-top.perf-bottom,
  html.wp-panel-hidden:not(.wp-panel-bottom) #perf-tab.active::after,
  html.wp-panel-hidden:not(.wp-panel-bottom) body.perf-tab-active .cast-drawer { display: none !important; }
}
html.wp-panel-hidden.wp-panel-bottom #perf-tab > .perf-top.perf-bottom { display: none !important; }

/* ---------- 9. CAST & VOICES TAB + SETTINGS: QUIETER ---------- */

.cast-list .cast-card { background: var(--wp-tint); border-color: var(--line); }
.cast-list .cast-card:hover { border-color: var(--ink); }
.cast-list .cast-card .cast-name .name-display { font-size: 18px !important; font-weight: 600; line-height: 1.25 !important; }
.cast-list .cast-card .char-role, .cast-list .cast-card .cast-role,
.cast-list .cast-card .cast-meta { font-size: 13px !important; font-weight: 400 !important; }
.cast-btn-row .test-btn, .cast-btn-row .cast-clear-voice-btn { font-size: 13px; }
.section-title, .settings-section-title { border-bottom: 2px solid var(--wp-rule) !important; }
.modal, .dialog, .modal-content, .cast-edit-panel {
  border: 1px solid var(--line) !important;
  border-top: 2px solid var(--ink) !important;
  box-shadow: 0 12px 32px rgba(45,43,43,.22) !important;
}
#settings-tab .settings-nav-item { font-size: 14px; font-weight: 600; text-transform: none; letter-spacing: 0; }
#settings-tab .key-card .appearance-row > label { font-size: 14px; color: var(--ink); }

/* ---------- 10. MOBILE TRIAGE (≤800px) ----------
   This skin is a desktop layout; below 800px the app uses its own, and the
   only job here is to stop the desktop-shaped rules above from bleeding in.
   Not a mobile design — the Library grid in section 5 puts the heading and
   the action row in two columns, which at phone width stack on top of each
   other instead of beside each other. */

@media (max-width: 800px) {
  #library-tab-inner {
    display: block !important;
    max-width: none !important;
    padding: 24px 16px 48px !important;
  }
  #library-tab-inner > .section-title {
    font-size: 26px !important;
    margin: 0 0 16px !important;
  }
  #library-tab-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin: 0 0 24px !important;
  }
  #new-workspace-btn-tab { order: 0; flex: 1 1 100%; }
  #library-open-shared-btn-tab, #library-import-script-btn-tab { flex: 1 1 0; min-width: 0; }
  #library-tab-actions > .library-sort-wrap { order: 4; flex: 1 1 100%; margin: 0 !important; }
  #library-sort-select-tab { width: 100%; }
  #library-list-tab { grid-template-columns: minmax(0, 1fr) !important; }
  #library-list-tab .lib-folder-head { min-height: 0; padding: 16px; }

  /* Section 7's name column assumes room the phone doesn't have: the script
     goes back to one column, with the speaker above the line. */
  .script-page { padding: 0 16px !important; max-width: none !important; }
  .p-line[data-type="Character"] { float: none; width: auto; }
  .p-line[data-type="Dialogue"],
  .p-line[data-type="Lyrics"],
  .p-line[data-type="Parenthetical"] { margin-left: 0; }
  .p-line[data-type="Action"],
  .p-line[data-type="General"],
  .p-line[data-type="Transition"] { padding-left: 16px; }
}

/* ============================================================
   Rounded refresh (2026-11-12). The Voice Wheel brought circles
   into the app; corners soften to meet it. Four sizes only:
   controls 10px, cards 16px, dialogs 20px, chips and choices round.
   Kept last so it wins over the square defaults above it.
   ============================================================ */
:root { --r-ctl: 10px; --r-card: 16px; --r-dlg: 20px; --r-pill: 999px; --radius: 10px; --radius-sm: 6px; }

/* :is() takes its strongest member's weight, so this beats single-class field rules like .cast-desc. */
html :is(button, .btn, select, textarea, input:not([type="checkbox"]):not([type="radio"]):not([type="range"])) { border-radius: var(--r-ctl); }
input[type="checkbox"] { border-radius: 5px; }
.icon-btn, .test-btn.icon-only, .close-btn, .modal-close { border-radius: var(--r-ctl) !important; }
html:not(.wp-panel-bottom) .perf-bottom .transport button { border-radius: var(--r-ctl) !important; }
#library-list-tab .lib-rename-btn, #library-list-tab .lib-delete-btn { border-radius: var(--r-ctl) !important; }
#library-sort-select, #library-sort-select-tab { border-radius: var(--r-ctl) !important; }
.photo-wrap, .photo-clip, .cast-edit-headshot-img, .cast-edit-headshot-placeholder { border-radius: var(--r-ctl) !important; }
.photo-clip { overflow: hidden; }

/* Menus: rounded box, items stay flush inside it. */
.download-menu, .download-submenu { border-radius: var(--r-ctl); overflow: hidden; }
.download-menu button, .download-submenu button { border-radius: 0 !important; }

/* Cards */
.cast-card, .key-card, .vw-card, .ve-card, .vm-card, .vm-assigned-card, .vw-maprow,
.vw-cc-row, .vw-design, .vw-spread-card, .sb-card { border-radius: var(--r-card); }
.cast-list .cast-card { overflow: hidden; }

/* Dialogs and panels */
.cast-edit-panel, .voice-needed-panel, #vw-panel, #ve-panel, #upgrade-modal-panel, #app-dialog-panel,
#settings-overlay > div, #synth-all-modal, #import-confirm-modal, #sb-manage-modal,
#cloud-restore-modal, #library-overlay > div { border-radius: var(--r-dlg); }

/* Choices and chips: round, with the selected option a filled pill inside. */
.vw-seg { border: 0; background: var(--panel-2); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.vw-seg button { border-radius: var(--r-pill) !important; }
.vw-badge, .voice-archetype-bubble, .vw-suggest { border-radius: var(--r-pill); }
.vw-suggest { padding-left: 12px; padding-right: 12px; }
.header-project { border-radius: var(--r-ctl); }
/* Settings: the selected section is a tinted pill, not a side bar; close is a plain rounded icon button. */
.settings-nav { padding-left: 8px; padding-right: 8px; }
.settings-nav-item { border-radius: var(--r-ctl) !important; }
.settings-nav-item.active { border-right: 0; margin-right: 0; background: var(--panel-2); }
#settings-modal-close { border-left: 0; width: 40px; height: 40px; margin-right: 8px; border-radius: var(--r-ctl) !important; }
.upgrade-tier-row { border-radius: var(--r-card); }

/* Dialog frames: hairline and a soft shadow instead of the heavy ink top rule. */
.modal, .dialog, .modal-content, .cast-edit-panel { border: 1px solid var(--wp-rule) !important; box-shadow: 0 24px 60px rgba(0,0,0,.28) !important; }

/* ── Edit Character (2026-11-12): header of facts, then who they are | voice ── */
.cast-edit-panel.ec-panel { width: 1040px; max-width: 96vw; max-height: 92vh; padding: 0; gap: 0; }
.ec-head { display: flex; gap: 22px; align-items: flex-start; padding: 24px 28px 20px; border-bottom: 1px solid var(--wp-rule); }
.ec-photo { flex: none; width: 104px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.ec-photo #cast-edit-headshot-preview { width: 96px; height: 96px; }
.ec-panel .cast-edit-headshot-img, .ec-panel .cast-edit-headshot-placeholder { border-radius: 999px !important; width: 96px; height: 96px; }
.ec-photo-btns { display: flex; gap: 4px; }
.ec-photo-btns button { min-height: 30px; height: 30px; padding: 0 10px; font-size: 13px; }
.ec-photo-btns .icon-btn { width: 30px; justify-content: center; padding: 0; }
.ec-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ec-id .cast-edit-head { margin: 0; }
.ec-id .cast-edit-head .disp { font-size: 13px; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.ec-name { font-family: var(--font-display); font-size: 34px !important; font-weight: 800; text-transform: uppercase; letter-spacing: .01em;
  height: auto !important; min-height: 0 !important; padding: 2px 8px !important; margin-left: -8px; border: 1px solid transparent !important; background: transparent !important; width: 100%; }
.ec-name:hover { border-color: var(--wp-rule) !important; }
.ec-name:focus { border-color: var(--ink) !important; background: var(--panel) !important; outline: none; }
.ec-facts { display: flex; gap: 8px; flex-wrap: wrap; }
html .ec-facts .ec-fact { border-radius: 999px; height: 34px; min-height: 34px; padding: 0 14px; font-size: 14px; font-weight: 600; width: auto; background: var(--bg); }
.ec-facts input.ec-fact { width: 150px; }
.ec-stats { font-size: 15px; color: var(--ink); }
.ec-stats:empty, .ec-partners:empty { display: none; }
.ec-partners { font-size: 14px; color: var(--muted); }
.ec-partners b { color: var(--ink); font-weight: 600; }
.ec-close { width: 40px !important; height: 40px; justify-content: center; padding: 0 !important; border-color: transparent !important; }
.ec-close svg { width: 20px; height: 20px; }
.ec-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 28px; padding: 22px 28px; }
.ec-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ec-h { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.ec-hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.ec-voice { padding: 0 !important; display: flex; flex-direction: column; gap: 12px; }
.ec-card { background: var(--bg); border: 1px solid var(--wp-rule); border-radius: var(--r-card); padding: 18px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.ec-card-top { display: flex; gap: 18px; align-items: center; }
.ec-glyph-btn { all: unset; cursor: pointer; flex: none; border-radius: 999px; line-height: 0; }
.ec-glyph-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ec-glyph { width: 112px; height: 112px; display: block; }
.ec-glyph .ec-g-inner { fill: var(--panel-2); stroke: var(--bg); stroke-width: 1.5; }
.ec-glyph .ec-g-outer { fill: var(--panel-3); stroke: var(--bg); stroke-width: 1.5; }
.ec-glyph .ec-g-voice { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; }
.ec-glyph .ec-g-placed { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 3 2.5; }
.ec-glyph .ec-g-axis { stroke: var(--muted); stroke-width: .6; stroke-dasharray: 1.5 3; }
.ec-glyph .ec-g-hub { fill: var(--bg); }
.ec-glyph-btn:hover .ec-g-inner, .ec-glyph-btn:hover .ec-g-outer { fill: color-mix(in srgb, var(--accent) 10%, var(--panel-2)); }
.ec-card-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ec-card-name { font-size: 22px; font-weight: 700; color: var(--ink); }
.ec-card-accent { font-size: 15px; font-weight: 400; color: var(--muted); }
.ec-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.ec-tag { font-size: 13px; font-weight: 600; border-radius: 999px; padding: 3px 10px; background: var(--panel-2); color: var(--ink); }
.ec-tag-red { background: color-mix(in srgb, var(--accent) 14%, var(--bg)); color: color-mix(in srgb, var(--accent) 70%, #000); }
.ec-key { font-size: 13px; color: var(--muted); line-height: 1.45; }
.ec-card-desc { font-size: 16px; font-style: italic; color: var(--ink); line-height: 1.45; }
.ec-card-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.ec-card-btns .ve-play-btn { font-family: inherit; }
.ec-voice-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
html .ec-red { background: #d42a10; border-color: #d42a10; color: #fff; }
html .ec-red:hover:not(:disabled) { background: #b8230c; border-color: #b8230c; color: #fff; }
html .ec-quiet { border-color: transparent; color: var(--muted); }
html .ec-quiet:hover:not(:disabled) { border-color: transparent; color: var(--ink); }
.ec-match-status { font-size: 14px; color: var(--muted); }
.ec-match-status:empty { display: none; }
.ec-speak { border: 1px solid var(--wp-rule); border-radius: var(--r-card); background: var(--bg); }
html .ec-speak-toggle { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; border-radius: var(--r-card); color: var(--ink); }
.ec-speak-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ec-speak-text { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.ec-speak-text span { font-size: 13px; color: var(--muted); }
.ec-speak-toggle svg { width: 18px; height: 18px; transition: transform .15s; flex: none; }
.ec-speak-toggle.open svg { transform: rotate(90deg); }
.ec-speak-body { display: flex; flex-direction: column; gap: 14px; padding: 0 18px 18px; }
.ec-speak-body[hidden] { display: none; }
.ec-speak-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ec-foot { padding: 14px 28px 18px; border-top: 1px solid var(--wp-rule); margin: 0 !important; justify-content: space-between; }
.ec-foot .cast-edit-delete-btn { background: transparent; border-color: transparent; margin: 0; }
.ec-foot .cast-edit-delete-btn:hover { border-color: var(--danger); }
@media (max-width: 760px){
  .ec-head { flex-wrap: wrap; padding: 16px; gap: 14px; }
  .ec-body { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .ec-speak-row { grid-template-columns: minmax(0, 1fr); }
  .ec-name { font-size: 26px !important; }
  .ec-foot { padding: 12px 16px; }
}
@media (max-width: 760px){ .cast-edit-panel.ec-panel { padding: 0 !important; } }
/* The sections keep their height and the panel scrolls. dvh is the visible
   screen; 92vh on iOS runs under the browser bars and pushed the close
   button off the top. */
.cast-edit-panel.ec-panel > * { flex-shrink: 0; }
.cast-edit-panel.ec-panel { overflow-y: auto; overscroll-behavior: contain; }
@supports (height: 1dvh){
  .cast-edit-panel.ec-panel { max-height: 92dvh; }
  @media (max-width: 760px){ .cast-edit-panel.ec-panel { max-height: 92dvh !important; } }
}
/* Phones: the backdrop covers exactly the visible area (--vv-* set from
   visualViewport), so a keyboard opening and closing can't leave a gap. */
@media (max-width: 760px){
  .cast-edit-overlay { top: var(--vv-top, 0px) !important; bottom: auto !important; height: var(--vv-h, 100dvh) !important; }
  .cast-edit-panel.ec-panel { max-height: calc(var(--vv-h, 100dvh) * .92) !important; }
}
html .ec-facts .ec-fact { border: 1px solid var(--wp-rule) !important; border-radius: 999px !important; background: var(--bg) !important; height: 34px !important; min-height: 34px !important; }
html .ec-facts .ec-fact:focus { border-color: var(--ink) !important; outline: none; }

/* ── Voice Wheel: characters as faces (2026-11-12) ── */
.vw-av { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; border-radius: 999px; overflow: hidden;
  background: var(--panel-3); color: var(--ink); font-style: normal; font-weight: 700; font-size: 13px; }
.vw-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vw-ribbon { position: sticky; top: -16px; z-index: 2; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin;
  margin: -16px -18px 14px; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--wp-rule); }
html .vw-rib-chip { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 40px; min-height: 40px; padding: 0 14px 0 6px;
  border-radius: 999px; border: 1px solid var(--wp-rule); background: var(--bg); color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 600; }
html .vw-rib-chip.vw-rib-all { padding: 0 16px; color: var(--muted); }
html .vw-rib-chip.on { background: var(--ink); border-color: var(--ink); color: var(--panel); }
html .vw-rib-chip.on .vw-av { box-shadow: 0 0 0 2px var(--panel); }
.vw-rib-ok { color: var(--accent); font-size: 12px; }
html .vw-rib-chip.on .vw-rib-ok { color: inherit; }
.vw-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
html .vw-tile { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 14px 10px 12px; border: 1px solid var(--wp-rule); border-radius: var(--r-card); background: var(--bg); min-width: 0; }
html .vw-tile:hover { border-color: var(--ink); }
html .vw-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vw-tile .vw-av { width: 56px; height: 56px; font-size: 22px; margin-bottom: 4px; }
.vw-tile-name { font-weight: 700; font-size: 15px; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-tile-voice { font-size: 13px; color: var(--ink); }
.vw-tile-where { font-size: 12px; color: var(--muted); }
@media (max-width: 760px){ .vw-ribbon { top: 0; margin: -10px -12px 12px; padding: 10px 12px; } }

/* ── Cast & Voices on phones: a grid of small cards, two or three across ── */
@media (max-width: 600px){
  #cast-tab .cast-list { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  #cast-tab .cast-list .cast-card .cast-card-main { padding: 10px; gap: 6px; }
  #cast-tab .cast-list .cast-card .cast-name .name-display { font-size: 15px !important; }
  #cast-tab .cast-list .cast-card .char-role, #cast-tab .cast-list .cast-card .cast-role, #cast-tab .cast-list .cast-card .role-display { font-size: 11px !important; }
  #cast-tab .cast-list .cast-card select.voice-pack-sel { height: 34px; min-height: 34px; font-size: 13px; padding: 0 8px; }
  #cast-tab .cast-list .cast-card .cast-btn-row button { height: 34px; min-height: 34px; font-size: 13px; padding: 0 8px; }
  #cast-tab .cast-list .cast-card .cast-btn-row .cast-no-synth-btn { width: 34px; }
}
/* Your voices: slim rows, name and play. */
.vw-cv-list { display: flex; flex-direction: column; gap: 4px; }
.vw-cv-row { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: var(--r-ctl); background: color-mix(in srgb, var(--bg) 70%, transparent); }
.vw-cv-row.mine { box-shadow: inset 0 0 0 1px var(--accent); }
html .vw-cv-row button { height: 32px; min-height: 32px; font-size: 13px; padding: 0 10px; }
html .vw-cv-row .vw-cv-preview { width: 32px; padding: 0; justify-content: center; border-radius: 999px; }
.vw-cv-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Designed voices on the wheel: an accent ring marks them. */
.vw-dot.custom .vw-pip { stroke: var(--accent); stroke-width: 2.5; }
.vw-dot.custom.taken .vw-pip { stroke: var(--accent); }
.vw-badge-mine { border-color: var(--accent); color: var(--accent); }
.vw-cv-row { flex-wrap: wrap; }
.vw-cv-where { font-size: 12px; color: var(--muted); }
.vw-cv-place { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
html .vw-cv-row .vw-cv-gender { height: 32px; min-height: 32px; font-size: 13px; padding: 0 8px; width: auto; }
.vw-cv-name { flex: 1 1 110px; }
.vw-cv-row .vw-hear { order: 2; } .vw-cv-row .vw-cv-cast { order: 3; }
.vw-cv-place { order: 4; flex-basis: 100%; margin-left: 42px; justify-content: flex-start; flex-wrap: wrap; }
/* Settings › My Voices: name is editable in place; where it sits on the wheel and its gender beside it. */
html .mv-name-input { font-weight: 700; font-size: 16px; border-color: transparent; background: transparent; padding: 0 8px; margin-left: -8px; height: 34px; min-height: 34px; width: 100%; max-width: 360px; }
html .mv-name-input:hover { border-color: var(--wp-rule); }
html .mv-name-input:focus { border-color: var(--ink); background: var(--bg); outline: none; }
.mv-place { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
html .mv-place select { height: 34px; min-height: 34px; font-size: 14px; width: auto; max-width: 100%; }
/* My Voices: a small wheel to place each designed voice. */
.mv-place { align-items: center; gap: 16px; }
.mv-wheel { width: 132px; height: 132px; flex: none; display: block; }
.mvw-cell { cursor: pointer; stroke: var(--panel); stroke-width: 1.5; outline: none; transition: fill .12s; }
.mvw-cell.inner { fill: var(--panel-2); } .mvw-cell.outer { fill: var(--panel-3); }
.mvw-cell:hover, .mvw-cell:focus-visible { fill: color-mix(in srgb, var(--accent) 30%, var(--panel-2)); }
.mvw-cell.on { fill: var(--accent); }
.mvw-axis { stroke: var(--muted); stroke-width: .6; stroke-dasharray: 1.5 3; pointer-events: none; }
.mvw-hub { fill: var(--panel); pointer-events: none; }
.mv-place-side { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.mv-place-now { font-size: 14px; font-weight: 600; color: var(--ink); }
html .mv-unplace { height: 30px; min-height: 30px; font-size: 13px; padding: 0 10px; }
.mv-wheel { width: 170px; height: 148px; }
.mvw-lbl { font-size: 10px; font-weight: 600; fill: var(--muted); pointer-events: none; }
.mv-wheel { width: 200px; height: 174px; }
.mv-btns { display: flex; flex-direction: column; gap: 6px; align-items: stretch; flex-shrink: 0; }

/* ---------- Play Room toolbar, one row (2026-11-21) ----------
   Ten type buttons became one menu naming the current line's type; B / I / U
   appear over selected text; Outline and the play-panel switches sit in the
   ⋯ menu. One row that wraps if it must. */
.script-toolbars { flex-direction: row !important; }
.view-mode-toggle { flex-wrap: wrap; row-gap: var(--wp-bar-gap); flex-shrink: 1 !important; min-width: 0; }
.view-mode-toggle .ptype-toolbar { display: inline-flex; flex-wrap: nowrap; border: none !important; padding: 0 !important; margin: 0; }
body.mode-rehearsal .ptype-toolbar { display: none !important; }
#dict-btn { box-sizing: border-box; height: var(--wp-bar-h) !important; min-height: 0 !important; padding: 0 12px !important; font-size: 13px !important; font-weight: 600; border: 1px solid var(--wp-rule) !important; }
#dict-btn.active { border-color: var(--accent) !important; }
#ptype-menu-btn, #tb-more-btn {
  box-sizing: border-box; height: var(--wp-bar-h) !important; min-height: 0 !important;
  display: inline-flex !important; align-items: center; gap: 8px;
  padding: 0 10px 0 12px !important; font-size: 13px !important; font-weight: 600;
  background: transparent; border: 1px solid var(--wp-rule) !important; color: var(--ink); cursor: pointer;
}
#ptype-menu-btn { min-width: 150px; justify-content: flex-start !important; }
#ptype-menu-btn .ptype-cur-icon { width: 15px; height: 15px; flex: none; }
#ptype-menu-btn .ptype-caret { width: 14px; height: 14px; margin-left: auto; color: var(--muted); flex: none; }
#ptype-menu-btn[aria-expanded="true"], #tb-more-btn[aria-expanded="true"] { border-color: var(--ink) !important; }
#tb-more-btn { width: var(--wp-bar-h) !important; padding: 0 !important; justify-content: center !important; color: var(--muted); }
#ptype-menu, #tb-more-menu {
  position: fixed; z-index: 70; min-width: 220px; padding: 6px;
  background: var(--panel); border: 1px solid var(--wp-rule, var(--line)); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
}
#ptype-menu[hidden], #tb-more-menu[hidden], #fmt-bar[hidden] { display: none !important; }
#ptype-menu .ptype-btn {
  display: flex !important; width: 100% !important; height: 34px !important; gap: 10px;
  padding: 0 10px !important; justify-content: flex-start !important;
  border: none !important; border-radius: 6px; color: var(--ink); background: transparent;
}
#ptype-menu .ptype-btn:hover { background: var(--wp-tint, var(--panel2)) !important; }
#ptype-menu .ptype-btn.active { background: var(--ink) !important; color: var(--bg) !important; }
#ptype-menu .ptype-btn .ptype-name { display: inline !important; font-size: 14px; font-weight: 500; white-space: nowrap; }
#ptype-menu .ptype-btn .ptype-key { position: static !important; margin-left: auto; font-family: var(--font-body); font-size: 12px !important; opacity: .6; color: inherit !important; }
.tb-more-row { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--ink); white-space: nowrap; }
.tb-more-row:hover { background: var(--wp-tint, var(--panel2)); }
.tb-more-slot { display: inline-flex; }
#tb-more-menu .panel-ctl-group { margin: 0 !important; padding: 0 !important; }
#tb-more-menu #outline-toggle-btn { width: var(--wp-bar-h) !important; border-color: transparent; }
@media (max-width: 800px) { #tb-more-menu .tb-more-panel { display: none !important; } }
#fmt-bar {
  position: fixed; z-index: 75; display: flex; gap: 2px; padding: 4px;
  background: var(--panel); border: 1px solid var(--wp-rule, var(--line)); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
#fmt-bar .pstyle-btn {
  width: 34px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: none; border-radius: 6px; background: transparent; color: var(--ink); cursor: pointer;
}
#fmt-bar .pstyle-btn:hover { background: var(--wp-tint, var(--panel2)); }
#fmt-bar .pstyle-btn.active { background: var(--ink); color: var(--bg); }

/* ---------- Toolbar frame and margin pins (2026-11-21, round 2) ----------
   An even frame around the toolbar row: it used to sit 16px down with
   nothing under it, so the buttons rested on the grey page well. */
html .script-toolbars { padding: 8px 16px !important; }
@media (max-width: 800px) { html .script-toolbars { padding: 6px 12px !important; } }
#mute-lines-btn[hidden] { display: none !important; }
/* The right-hand pins share one shape: re-voice had picked up the 10px
   control radius while the others were forced square. */
#script-page .line-take-btn, #script-page .line-skip-btn, #script-page .line-note-btn,
#script-page .line-revoice-btn, #script-page .line-scene-dir-btn { border-radius: 7px !important; }

/* ---------- Song meter in the status line (2026-11-21) ----------
   While a Music cue plays the status line is its scrubber: a light fill and
   a 3px bar for how far in it is, a hairline with the time under the
   pointer. JS: renderMusicMeter / wireMusicMeter. */
html:root .status-line.music-meter {
  position: relative; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none;
  gap: 12px; color: var(--ink) !important;
  background-image:
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(to right, color-mix(in srgb, var(--accent) 12%, transparent), color-mix(in srgb, var(--accent) 12%, transparent)) !important;
  background-repeat: no-repeat !important;
  background-position: left bottom, left top !important;
  background-size: calc(var(--mm, 0) * 100%) 3px, calc(var(--mm, 0) * 100%) 100% !important;
}
.status-line.music-meter .mm-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.status-line.music-meter .mm-time { flex: none; font-variant-numeric: tabular-nums; color: var(--muted); }
.status-line.music-meter .mm-time:hover { color: var(--ink); }
.status-line.music-meter .mm-hover {
  position: absolute; top: 0; bottom: 0; left: calc(var(--mh, 0) * 100%);
  display: flex; align-items: center; padding-left: 6px;
  border-left: 1px solid var(--ink); font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--ink); white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s;
}
.status-line.music-meter:hover .mm-hover { opacity: .6; }

/* ---------- Stage map (2026-11-21) ----------
   The stage as the audience sees it: upstage at the top, the house below,
   stage right on the left. Chips are centred on their spot. */
.stage-panel { max-width: 640px; width: 92vw; }
.stage-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 4px 0 8px; }
.stage-controls .setting-toggle { flex: 1 1 260px; }
.stage-controls select { width: auto; max-width: 100%; flex: 0 1 260px; }
.stage-map {
  position: relative; margin: 8px 0 4px; padding: 30px 26px;
  border: 1px solid var(--wp-rule, var(--line)); border-radius: var(--r-card, 16px);
  background:
    repeating-linear-gradient(0deg, transparent 0 39px, color-mix(in srgb, var(--ink) 5%, transparent) 39px 40px),
    var(--panel-2, var(--panel2));
  user-select: none; -webkit-user-select: none;
}
.stage-map::after {
  content: ''; position: absolute; left: 12%; right: 12%; bottom: 0; height: 4px;
  border-radius: 4px 4px 0 0; background: var(--accent); opacity: .5;
}
.stage-floor { position: relative; aspect-ratio: 2 / 1; min-height: 150px; }
.stage-lbl { position: absolute; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); pointer-events: none; }
.stage-lbl-up { top: 8px; left: 50%; transform: translateX(-50%); }
.stage-lbl-down { bottom: 8px; left: 50%; transform: translateX(-50%); }
.stage-lbl-sr { left: 6px; top: 50%; transform: translateY(-50%) rotate(-90deg); transform-origin: center; left: -14px; }
.stage-lbl-sl { right: -10px; top: 50%; transform: translateY(-50%) rotate(90deg); }
html .stage-chip {
  height: 30px !important; min-height: 0 !important; padding: 0 12px !important;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: 999px !important; border: 1px solid var(--ink) !important;
  background: var(--bg) !important; color: var(--ink) !important;
  font-size: 13px !important; font-weight: 600; cursor: grab; touch-action: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.12); justify-content: center !important;
}
.stage-floor .stage-chip { position: absolute; transform: translate(-50%, -50%); z-index: 1; }
html .stage-chip.inherited { border-style: dashed !important; color: var(--muted) !important; box-shadow: none; }
html .stage-chip.dragging { cursor: grabbing; z-index: 3; background: var(--ink) !important; color: var(--bg) !important; }
.stage-tray-wrap { margin-top: 10px; }
.stage-tray-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stage-tray { display: flex; flex-wrap: wrap; gap: 6px; }
.sd-blocking-btn { margin-top: 10px; }

/* ---------- Rhythm legend (2026-11-21) ----------
   Who each colour is, with their share of the play's speaking time. The
   eight biggest talkers get a hue each; the rest share grey. A name dims
   everyone else's bars across the board. */
.sb-rhythm, .sb-rh-legend { --rh-other: #9a9590; }
.sb-rh-legend { display: flex; flex-wrap: wrap; gap: 6px 8px; padding: 0 48px 20px; margin-top: -8px; flex-shrink: 0; }
.sb-rh-legend[hidden] { display: none !important; }
html .sb-rh-key {
  display: inline-flex !important; align-items: center; gap: 7px;
  height: 30px !important; min-height: 0 !important; padding: 0 10px 0 8px !important;
  border: 1px solid var(--wp-rule, var(--line)) !important; border-radius: 999px !important;
  background: var(--bg) !important; color: var(--ink) !important;
  font-size: 13px !important; font-weight: 600; cursor: pointer; white-space: nowrap;
}
html .sb-rh-key:hover { border-color: var(--ink) !important; }
html .sb-rh-key.on { background: var(--ink) !important; color: var(--bg) !important; border-color: var(--ink) !important; }
html .sb-rh-key-static { cursor: default; border-style: dashed !important; color: var(--muted) !important; }
html .sb-rh-key-static:hover { border-color: var(--wp-rule, var(--line)) !important; }
.sb-rh-pct { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.sb-rh-key.on .sb-rh-pct { color: inherit; opacity: .75; }
.sb-rh-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.sb-rh-swatch[data-hue="0"] { background: var(--rh-0); } .sb-rh-swatch[data-hue="1"] { background: var(--rh-1); }
.sb-rh-swatch[data-hue="2"] { background: var(--rh-2); } .sb-rh-swatch[data-hue="3"] { background: var(--rh-3); }
.sb-rh-swatch[data-hue="4"] { background: var(--rh-4); } .sb-rh-swatch[data-hue="5"] { background: var(--rh-5); }
.sb-rh-swatch[data-hue="6"] { background: var(--rh-6); } .sb-rh-swatch[data-hue="7"] { background: var(--rh-7); }
.sb-rh-swatch[data-hue="other"], .sb-rh-bar[data-hue="other"] { background: var(--rh-other); }
.sb-rh-swatch-gap { background: var(--line); opacity: .8; }
.sb-cards.rh-focus .sb-rh-bar:not(.rh-on) { opacity: .12; }
.sb-cards.rh-focus .sb-rh-gap { opacity: .25; }
@media (max-width: 760px) { .sb-rh-legend { padding: 0 16px 12px; margin-top: 0; } }

/* ---------- Out-of-date lines (2026-11-21) ----------
   A line voiced before the speech above it changed: its re-voice pin stays
   up in a warm yellow until the line plays and is voiced again. */
:root { --stale: #a86a12; --stale-dim: #f6e7c8; }
html[data-theme="dark"], html[data-theme="noir"], html[data-theme="mono"] { --stale: #e3ad55; --stale-dim: #3d3220; }
#script-page .p-line.line-ctx-stale > .line-revoice-btn {
  opacity: 1 !important; pointer-events: auto;
  background: var(--stale-dim); border-color: var(--stale); color: var(--stale);
}
#script-page .p-line.line-ctx-stale > .line-revoice-btn:hover:not(:disabled) { background: var(--stale); border-color: var(--stale); color: var(--bg); }

/* Delivery tags ([whispering]) in the Play Room and Run Lines: tinted so they
   read as direction, struck through where the plan strips them. Set by
   refreshTagMarks(); the Editor shows them as plain text. */
body.mode-playroom #script-page .p-text::highlight(wp-tag),
body.mode-rehearsal #script-page .p-text::highlight(wp-tag) { color: var(--accent-deep); background-color: var(--accent-dim); }
body.mode-playroom #script-page .p-text::highlight(wp-tag-off),
body.mode-rehearsal #script-page .p-text::highlight(wp-tag-off) { color: var(--muted); text-decoration: line-through; }
