/* Carriage — a sheet of paper coming out of a typewriter on a wooden desk.
   Tokens first: paper and ink, the desk's wood, the typewriter's paint, the lamp. */
:root {
  --page: #FFFEFA;
  --ink: #1D1B18;
  --muted: #76706A;
  --rule: #DCD5CA;
  --accent: #A3362B;              /* ribbon red: cursor, focus, the type guide */
  --accent-soft: rgba(163, 54, 43, 0.12);
  --pen: #27396A;                 /* fountain-pen blue, for the notebooks */
  --note: #8A5D0E;
  --note-bg: rgba(214, 160, 40, 0.2);
  --card: #FBF8F1;                /* menus and sheets are cards of paper */
  --raised: #FBF8F1;
  --card-edge: rgba(70, 48, 26, 0.16);
  --shadow: 0 1px 2px rgba(30, 18, 8, 0.2), 0 12px 32px rgba(30, 18, 8, 0.26);
  --paper-shadow: 0 1px 1px rgba(0, 0, 0, 0.14), 0 8px 22px rgba(25, 14, 5, 0.3);

  /* Revision colors, in industry order: Blue, Pink, Yellow, Green, Goldenrod, Buff, Salmon, Cherry */
  --rv-0: #2F62C9; --rv-1: #C8357F; --rv-2: #9A7B00; --rv-3: #23874C;
  --rv-4: #B06F0C; --rv-5: #8C6F48; --rv-6: #CC5A42; --rv-7: #B0122F;

  --font-script: "Courier Prime", "Courier New", Courier, monospace;
  --font-type: "Courier Prime", "Courier New", Courier, monospace;
  --font-ui: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-hand: "Kalam", "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
  --sidebar-w: 268px;
  --strip-h: 30px;

  /* Walnut desk: a photograph of the wood (textures/, from Poly Haven, with an oiled finish
     baked in), and its colours for the parts that are drawn rather than photographed. */
  --wood-tex: url("textures/wood-walnut.jpg");
  --wood-1: #6B4529; --wood-2: #4D311E; --wood-3: #3A2315;
  /* Seafoam typewriter: body, top cover, keys */
  --m-b1: #C2DED1; --m-b2: #A5CAB9; --m-b3: #7AA591;
  --m-h1: #D3E9DE; --m-h2: #B1D3C3; --m-h3: #94BCAA;
  --m-k1: #6E998A; --m-k2: #4E7A6B; --m-kskirt: #3A6052; --m-legend: #F4F7F2;
  --m-rim: rgba(255, 255, 255, 0.6);
  --m-ink: #20302A;
  /* The wall behind the desk */
  --wall-base: #E6DDCC; --frame: #F2EEE5;

  /* Lamp: daylight */
  --glow: radial-gradient(ellipse 80% 70% at 18% -10%, rgba(255, 248, 230, 0.16), transparent 60%),
          radial-gradient(ellipse 120% 90% at 50% 45%, transparent 55%, rgba(15, 8, 3, 0.28));
  color-scheme: light;
}
:root[data-paper="ivory"] { --page: #FBF5E6; }

:root[data-wood="oak"] { --wood-tex: url("textures/wood-oak.jpg"); --wood-1: #BC8E58; --wood-2: #9C703F; --wood-3: #7D5730; }
:root[data-wood="ash"] { --wood-tex: url("textures/wood-ash.jpg"); --wood-1: #E2D4BA; --wood-2: #CDB997; --wood-3: #B29C78; }
:root[data-wood="ebony"] { --wood-tex: url("textures/wood-ebony.jpg"); --wood-1: #3B312B; --wood-2: #26201C; --wood-3: #171310; }

:root[data-machine="cream"] { --m-b1: #F7F0E1; --m-b2: #E9DEC6; --m-b3: #CDBD9B; --m-h1: #FBF6EC; --m-h2: #EDE3CE; --m-h3: #D9CBAE; --m-k1: #5C4E40; --m-k2: #3F342A; --m-kskirt: #2E261E; --m-legend: #F3EAD7; --m-ink: #2D261C; }
:root[data-machine="charcoal"] { --m-b1: #55595E; --m-b2: #36393D; --m-b3: #1D1F22; --m-h1: #62666C; --m-h2: #43474C; --m-h3: #2E3034; --m-k1: #2D2F33; --m-k2: #17181B; --m-kskirt: #0D0E10; --m-legend: #ECEAE4; --m-rim: rgba(255, 255, 255, 0.22); --m-ink: #E9E6DD; }
:root[data-machine="cherry"] { --m-b1: #D2564B; --m-b2: #B23A31; --m-b3: #82261F; --m-h1: #DE6A5E; --m-h2: #BE443A; --m-h3: #9A3129; --m-k1: #F5ECDD; --m-k2: #DDD0B9; --m-kskirt: #BCAC92; --m-legend: #7E241E; --m-rim: rgba(255, 255, 255, 0.35); --m-ink: #FFF5EE; }
:root[data-machine="navy"] { --m-b1: #4F6790; --m-b2: #344A6E; --m-b3: #1F2F4A; --m-h1: #5C77A2; --m-h2: #3D5680; --m-h3: #2C4163; --m-k1: #EEF1F5; --m-k2: #D4D9E2; --m-kskirt: #B4BCC9; --m-legend: #22345A; --m-rim: rgba(255, 255, 255, 0.28); --m-ink: #EEF2FA; }
:root[data-wall="sage"] { --wall-base: #C6D0BB; }
:root[data-wall="slate"] { --wall-base: #A9B4BF; }
:root[data-wall="clay"] { --wall-base: #D5B29B; }
@property --fy { syntax: "<number>"; inherits: true; initial-value: 1; }

/* Lamplight: the room goes dark and a warm pool of light falls on the page. */
@media (prefers-color-scheme: dark) {
  :root:not([data-lamp="day"]) {
    --glow: radial-gradient(ellipse 55% 60% at 50% 50%, rgba(255, 190, 110, 0.07), rgba(255, 190, 110, 0) 35%, rgba(14, 8, 3, 0.55) 70%, rgba(6, 4, 2, 0.86));
    --page: #F8F1E2;
  }
  :root:not([data-lamp="day"])[data-paper="ivory"] { --page: #F3EAD3; }
}
:root[data-lamp="night"] {
  --glow: radial-gradient(ellipse 55% 60% at 50% 50%, rgba(255, 190, 110, 0.07), rgba(255, 190, 110, 0) 35%, rgba(14, 8, 3, 0.55) 70%, rgba(6, 4, 2, 0.86));
  --page: #F8F1E2;
}
:root[data-lamp="night"][data-paper="ivory"] { --page: #F3EAD3; }

/* Courier Prime ships with the app, so the page's typeface works offline. */
@font-face { font-family: "Courier Prime"; src: local("Courier Prime"), url("fonts/CourierPrime-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: local("Courier Prime Bold"), url("fonts/CourierPrime-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: local("Courier Prime Italic"), url("fonts/CourierPrime-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: local("Courier Prime Bold Italic"), url("fonts/CourierPrime-BoldItalic.ttf") format("truetype"); font-weight: 700; font-style: italic; font-display: swap; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--wood-2);
  color: var(--ink);
  font: 14px/1.4 var(--font-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- The desk ---------- */
:root {
  /* The desk top: the wood, with the light falling off a little toward you. */
  --wood-bg:
    linear-gradient(176deg, rgba(255, 240, 220, 0.07), rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.16)),
    var(--wood-tex) 0 0 / 1400px auto,
    var(--wood-2);
}
.desk-surface { position: fixed; inset: 0; z-index: 0; background: var(--wood-bg); background-attachment: fixed; }
.lamp-glow { position: fixed; inset: 0; z-index: 1; pointer-events: none; background: var(--glow); }

.app {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  height: 100%;
  padding-bottom: calc(var(--strip-h) + env(safe-area-inset-bottom, 0px));
}

/* ---------- Desk bar: what's floating at the top of the desk ---------- */
.deskbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: calc(56px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px));
  pointer-events: none;
  transition: opacity 0.25s;
}
.deskbar > * { pointer-events: auto; }
.deskbar-left, .deskbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.deskbar-left { flex: 1 1 0; }
.deskbar-right { flex: 1 1 0; justify-content: flex-end; }
.desk-btn {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  color: #F4EBDC;
  background: rgba(24, 14, 7, 0.46);
  box-shadow: inset 0 1px 0 rgba(255, 240, 220, 0.12), 0 1px 2px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s;
}
.desk-btn:hover, .desk-btn[aria-pressed="true"], .desk-btn[aria-expanded="true"] { background: rgba(24, 14, 7, 0.72); }
.desk-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.desk-btn svg .fill { fill: currentColor; stroke: none; }

/* The script's title is the tab of its folder. */
.folder-tab {
  display: flex; align-items: center; gap: 9px; min-width: 0; max-width: min(46vw, 520px);
  height: 36px; padding: 0 12px 0 6px;
  background: linear-gradient(180deg, #F0DBA4, #DCBF7C);
  border-radius: 8px 8px 3px 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 1px 1px rgba(0, 0, 0, 0.2), 0 4px 10px rgba(0, 0, 0, 0.28);
  color: #2D2414;
}
.folder-tab:hover { background: linear-gradient(180deg, #F4E1AF, #E1C584); }
.ft-kind {
  flex: none; padding: 3px 7px; border-radius: 3px;
  background: #FFFDF6; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  font: 700 10px/1.2 var(--font-type); letter-spacing: 0.12em; text-transform: uppercase; color: #6B5833;
}
.doc-title { font: 700 14.5px/1.2 var(--font-type); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-caret { width: 12px; height: 12px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; }
.save-state, .page-count {
  color: rgba(255, 244, 228, 0.78); font-size: 12px; white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); font-variant-numeric: tabular-nums;
}
.save-state.warn { color: #FFD38A; }
.page-count { margin-right: 4px; }

/* ---------- Menus and popovers: cards of paper ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 45;
  min-width: 240px; padding: 6px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--card-edge); border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.menu button { display: flex; justify-content: space-between; align-items: center; gap: 16px; text-align: left; padding: 8px 10px; border-radius: 7px; }
.menu button:hover { background: var(--accent-soft); }
.menu kbd { font: 12px var(--font-ui); color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--rule); margin: 5px 4px; width: auto; }
/* The ⋯ menu is six submenus (File, Export, Document, Tools, Mode, Set up). Each flies out to the
   left of its name, its first item level with it; on a narrow screen it opens underneath instead. */
.menu-group { position: relative; display: flex; flex-direction: column; }
.menu-head .chev { color: var(--muted); margin-left: auto; width: 7px; height: 7px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); margin-right: 3px; }
.menu-head[aria-expanded="true"] { background: var(--accent-soft); }
.submenu { position: absolute; right: calc(100% + 16px); top: -6px; }
@media (max-width: 640px) {
  #menu { max-height: calc(100vh - 80px); overflow-y: auto; }
  .submenu { position: static; border: 0; border-radius: 0; box-shadow: none; background: transparent; padding: 0 0 4px 14px; }
  .menu-head[aria-expanded="true"] .chev { transform: rotate(135deg); }
}

.menu.appearance { width: 344px; max-width: calc(100vw - 24px); padding: 12px 14px 10px; gap: 6px; max-height: calc(100vh - 110px); overflow-y: auto; }
.ap-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 6px 2px 2px; }
.swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.swatches.machines { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.menu .skin { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 5px; border-radius: 9px; border: 1px solid transparent; }
.menu .skin:hover { background: var(--accent-soft); }
.menu .skin[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.sw { display: block; height: 36px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14); }
.sw-wood { background: repeating-linear-gradient(176deg, var(--c1) 0 5px, var(--c2) 5px 9px, var(--c1) 9px 12px); }
.sw-machine { background: radial-gradient(circle at 50% 120%, var(--c2) 40%, transparent 41%), linear-gradient(var(--c1), var(--c2)); border-radius: 18px 18px 6px 6px; }
.sw-wall { background: linear-gradient(var(--c1), var(--c2)); }
.scenes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.menu .scene-opt { display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 4px; border-radius: 8px; border: 1px solid transparent; }
.menu .scene-opt:hover { background: var(--accent-soft); }
.menu .scene-opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.scene-thumb { display: block; height: 38px; border-radius: 5px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); background: #9BB7CC; }
.scene-thumb svg { display: block; width: 100%; height: 100%; }
.scene-thumb { position: relative; }
.scene-opt.locked .scene-thumb svg { filter: grayscale(0.6) brightness(0.75); }
.scene-lock { position: absolute; inset: auto 3px 3px auto; padding: 1px 5px; border-radius: 6px; background: rgba(20, 12, 6, 0.72); color: #F5D58E; font: 600 9.5px/14px var(--font-ui); }
/* A view's name gets two lines (the chips are narrow and most names are two words). */
.scene-opt .sw-name { font-size: 10.5px; line-height: 1.2; min-height: 2.4em; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.sw-name { font-size: 11.5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-fonts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.menu .font-opt { justify-content: center; padding: 8px 6px; border: 1px solid var(--rule); border-radius: 8px; font-size: 13.5px; white-space: nowrap; }
.menu .font-opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.ap-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 2px; font-size: 13px; border-top: 1px solid var(--rule); }
.ap-row:first-of-type { margin-top: 6px; }
.ap-wide { display: flex; }
.ap-wide button { flex: 1; }
.stepper { display: flex; align-items: center; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.menu .stepper button { padding: 4px 11px; border-radius: 0; font-size: 15px; }
.stepper output { min-width: 3.4em; text-align: center; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: rgba(90, 60, 30, 0.1); gap: 2px; }
.menu .seg button, .seg button { padding: 4px 10px; border-radius: 6px; font-size: 12.5px; color: var(--muted); justify-content: center; }
.seg button[aria-pressed="true"] { background: #FFFFFF; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14); }
.switch { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--rule); position: relative; cursor: pointer; transition: background 0.15s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }
.ap-note { margin: 4px 2px 2px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }

/* ---------- The notepad (scenes and revisions), lying left of the typewriter ---------- */
.sidebar {
  grid-column: 1; position: relative; z-index: 6;
  width: var(--sidebar-w);
  margin: calc(66px + env(safe-area-inset-top, 0px)) 0 18px 18px;
  margin-left: calc(-1 * var(--sidebar-w) - 40px);
  display: flex; flex-direction: column; min-height: 0;
  background:
    repeating-linear-gradient(180deg, transparent 0 25px, rgba(70, 110, 180, 0.16) 25px 26px) 0 74px / 100% calc(100% - 74px) no-repeat,
    #FCFAF4;
  border-radius: 2px 2px 4px 4px;
  box-shadow: 0 1px 0 #EDE6D8, 0 2px 0 #E2DACA, 0 3px 0 #D6CDBC, var(--paper-shadow);
  transform: rotate(-0.7deg);
  transition: margin-left 0.24s ease, transform 0.24s ease;
}
/* It lies over the desk rather than pushing it along, so opening it moves nothing else: the
   typewriter, the window and everything on the desk and the wall stay where they are. (Modern's
   sidebar is a column of the page, in spec.css.) */
:root:not([data-ui="spec"]) .sidebar {
  position: fixed; z-index: 31; left: 18px; top: calc(66px + env(safe-area-inset-top, 0px)); bottom: calc(var(--strip-h) + 18px); margin: 0;
  transform: translateX(calc(-100% - 40px)) rotate(-0.7deg);
  transition: transform 0.24s ease;
}
:root:not([data-ui="spec"]).sidebar-open .sidebar { margin: 0; transform: rotate(-0.7deg); }
.np-binding {
  height: 26px; flex: none; border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, #3B3734, #23201E);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  position: relative;
}
.np-binding::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 6px; height: 2px; background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 10px, transparent 10px 22px); }
.tabs { display: flex; gap: 2px; padding: 12px 14px 6px; }
.tabs button {
  flex: 1; padding: 5px 0 6px; border-bottom: 2px solid transparent;
  font: 700 12px/1.2 var(--font-type); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.panel { flex: 1; overflow-y: auto; padding: 4px 10px 14px; -webkit-overflow-scrolling: touch; }
.sidebar-foot {
  padding: 9px 16px 11px; border-top: 1px solid rgba(0, 0, 0, 0.08);
  font: 12px var(--font-type); color: var(--muted); font-variant-numeric: tabular-nums;
}

.scene-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.scene-list button {
  display: grid; grid-template-columns: 2.2em minmax(0, 1fr); column-gap: 4px;
  width: 100%; text-align: left; padding: 5px 6px; border-radius: 4px;
  font-family: var(--font-type);
}
.scene-list button:hover { background: rgba(163, 54, 43, 0.07); }
.scene-list button.current { background: rgba(255, 214, 90, 0.38); box-shadow: inset 3px 0 0 var(--accent); }
.scene-list .num { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.scene-list .heading { font-size: 12.5px; font-weight: 700; letter-spacing: 0.01em; line-height: 1.35; overflow-wrap: anywhere; }
.scene-list .syn { grid-column: 2; color: var(--muted); font: 15px/1.25 var(--font-hand); margin-top: 1px; }
.scene-list .section button {
  display: block; margin-top: 10px;
  font: 700 11px var(--font-ui); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent);
}
.scene-list .section.depth-2 button { padding-left: 16px; }
.scene-list .section.depth-3 button { padding-left: 24px; }
.scene-list .empty { color: var(--muted); font: 16px/1.4 var(--font-hand); padding: 8px; }
.new-script {
  width: 100%; padding: 7px; border-radius: 4px;
  border: 1px dashed rgba(0, 0, 0, 0.22); color: var(--muted); font: 700 12.5px var(--font-type);
}
.new-scene { margin: 10px 0 0; }
.new-script:hover { color: var(--ink); border-color: var(--accent); }
.scrim { display: none; }

/* ---------- The typewriter and its paper ---------- */
.desk { grid-column: 2; position: relative; min-width: 0; min-height: 0; z-index: 2; overflow: hidden; overflow: clip; }
.machine-back, .machine-top, .machine-front { position: absolute; pointer-events: none; }
.machine-back { z-index: 1; }
.editor-host { position: absolute; inset: 0; z-index: 2; container-type: inline-size; }
.machine-top { z-index: 3; }
.machine-front { z-index: 4; container-type: inline-size; }
.tw { display: block; width: 100%; height: auto; overflow: visible; }
.tw-anim .machine-front, .tw-anim .machine-back, .tw-anim .machine-top { transition: top 0.7s cubic-bezier(0.3, 0.7, 0.2, 1), height 0.7s cubic-bezier(0.3, 0.7, 0.2, 1), transform 0.45s cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.45s; }
.tw-anim .desk { transition: --fy 0.7s cubic-bezier(0.3, 0.7, 0.2, 1); }
.machine-front, .machine-back, .machine-top, .editor-host { transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.45s; }
.nb-out .machine-front, .nb-out .machine-back, .nb-out .machine-top, .nb-out .editor-host { transform: translateY(60px); opacity: 0.3; }

.tw .b1 { stop-color: var(--m-b1); } .tw .b2 { stop-color: var(--m-b2); } .tw .b3 { stop-color: var(--m-b3); }
.tw .h1 { stop-color: var(--m-h1); } .tw .h2 { stop-color: var(--m-h2); } .tw .h3 { stop-color: var(--m-h3); }
.tw .k1 { stop-color: var(--m-k1); } .tw .k2 { stop-color: var(--m-k2); }
/* Looking up, the machine is seen low and foreshortened. */
.tw-front { transform: scaleY(var(--fy, 1)); transform-origin: 50% 0; }
.tw-body { filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.42)); }
.tw-rim { stroke: var(--m-rim); stroke-width: 1.6; }
.tw-lip { fill: rgba(0, 0, 0, 0.1); }
.tw-tabkey { fill: var(--m-b3); }
.tw-brand { font: 700 11px var(--font-type); letter-spacing: 2.6px; text-anchor: middle; fill: #DCD8CD; }
.tw-well-lip { stroke: rgba(255, 255, 255, 0.1); stroke-width: 1; }
.tw-arm { stroke: #1A1A1A; stroke-width: 6; stroke-linecap: round; }
.key { pointer-events: auto; cursor: pointer; }
.key .cap { transition: transform 0.06s ease-out; }
.key.down .cap, .key.held .cap { transform: translateY(3px); }
.key-shadow { fill: rgba(0, 0, 0, 0.6); transition: opacity 0.06s; }
.key.down .key-shadow, .key.held .key-shadow { opacity: 0.35; }
.key-skirt { fill: var(--m-kskirt); }
.kl { font: 600 13px var(--font-ui); fill: var(--m-legend); text-anchor: middle; pointer-events: none; }
.kl-t { font-size: 8.5px; opacity: 0.85; }
.kl-b { font-size: 11.5px; }
.kl-s { font-size: 8px; letter-spacing: 0.6px; }
.tw-lever { pointer-events: auto; cursor: pointer; transform-box: view-box; transform-origin: 50px 84px; }
.tw-lever.pull { animation: lever-pull 0.42s cubic-bezier(0.3, 0.7, 0.3, 1); }
@keyframes lever-pull { 0% { transform: none; } 35% { transform: translateX(26px) rotate(-6deg); } 100% { transform: none; } }

/* The scale under the typed line: ticks on the page's character columns, a pointer at the cursor. */
.scale { position: absolute; top: 0; height: calc(var(--ms, 1) * 14px); pointer-events: none; --chw: 10px; }
.scale-ticks {
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(90deg, rgba(30, 30, 30, 0.7) 0 1px, transparent 1px calc(var(--chw) * 5)),
    repeating-linear-gradient(90deg, rgba(30, 30, 30, 0.42) 0 1px, transparent 1px var(--chw));
  background-size: 100% 52%, 100% 30%;
  background-position: 0 100%, 0 100%;
  background-repeat: no-repeat;
}
.scale-tabs { position: absolute; inset: 0; }
/* An analog page's tab stops: a red rule through the scale at each one (click the scale to set or clear). */
.scale-tabs i { position: absolute; top: -1px; bottom: 0; width: 2px; margin-left: -1px; background: #A3362B; border-radius: 1px; }
.scale-tabs i::before { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-top: 5px solid #A3362B; }
.scale.settable { pointer-events: auto; cursor: pointer; }
.scale-ticks span {
  position: absolute; top: 0; transform: translateX(-50%);
  font: 700 calc(var(--ms, 1) * 7px) / 1 var(--font-ui); color: rgba(30, 30, 30, 0.75);
}
.type-guide {
  position: absolute; left: 0; bottom: 0; width: var(--chw); height: 100%;
  /* No easing: the carriage steps with each key, in the same frame as the letter. */
}
.type-guide::before {
  content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  border-left: calc(var(--ms, 1) * 6px) solid transparent; border-right: calc(var(--ms, 1) * 6px) solid transparent;
  border-bottom: calc(var(--ms, 1) * 9px) solid var(--accent);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35));
}

/* The element plate on the ribbon cover. */
.element-wrap { position: absolute; left: 37.5cqw; width: 25cqw; top: calc(4.8cqw * var(--fy, 1)); height: calc(4.8cqw * var(--fy, 1)); min-height: 26px; pointer-events: auto; }
.element-chip {
  display: flex; align-items: stretch; height: 100%;
  border-radius: max(5px, 0.7cqw);
  background: linear-gradient(180deg, #FAF8F2, #DAD8D1 55%, #C9C7C0);
  box-shadow: inset 0 1px 0 #FFFFFF, inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.32), 0 2px 3px rgba(0, 0, 0, 0.3);
  touch-action: manipulation; color: #232120;
}
.chip-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15cqw; padding: 0 0.8cqw; }
.chip-label { font: 700 max(9.5px, 1.35cqw) / 1.1 var(--font-type); letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chip-hint { font: 500 max(8.5px, 1.05cqw) / 1.1 var(--font-ui); color: #6A665F; white-space: nowrap; }
.chip-caret { display: grid; place-items: center; width: max(22px, 2.8cqw); border-left: 1px solid rgba(0, 0, 0, 0.18); color: #55514A; }
.chip-caret:hover, .chip-caret[aria-expanded="true"] { color: #000; background: rgba(0, 0, 0, 0.05); }
.chip-caret svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.element-menu { left: 50%; right: auto; top: auto; bottom: calc(100% + 8px); transform: translateX(-50%); min-width: 220px; }
.menu.element-menu button { justify-content: flex-start; gap: 10px; white-space: nowrap; }
.element-menu .check { width: 14px; height: 14px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.element-menu [aria-checked="true"] { font-weight: 600; }
.element-menu [aria-checked="true"] .check { visibility: visible; }
.element-menu button:disabled { color: var(--muted); cursor: default; background: none; }
.element-menu hr { margin: 5px 4px; }

/* A mechanical page counter on the right of the ribbon cover. */
.counter { position: absolute; left: 66cqw; top: calc(5.9cqw * var(--fy, 1)); height: calc(2.8cqw * var(--fy, 1)); min-height: 16px; display: flex; align-items: center; gap: 0.6cqw; color: var(--m-ink); }
.counter-label { font: 700 max(7px, 0.9cqw) / 1 var(--font-ui); letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.7; }
.counter-digits {
  height: 100%; display: grid; place-items: center; padding: 0 0.5cqw;
  font: 700 max(9px, 1.6cqw) / 1 var(--font-type); letter-spacing: 0.32em; text-indent: 0.32em;
  color: #F6F2E7; border-radius: 3px;
  background: #151515;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.8), 0 0 0 2px rgba(255, 255, 255, 0.28), 0 0 0 3px rgba(0, 0, 0, 0.25);
}

/* TT2020 (fonts/TT2020-LICENSE.txt): bundled, since Google Fonts hasn't a monospaced typewriter face
   with a worn look. Its nine variants of each letter come through OpenType's rand and calt features. */
@font-face { font-family: "TT2020 Style B"; src: url("fonts/TT2020StyleB-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "TT2020 Style D"; src: url("fonts/TT2020StyleD-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
[data-font^="tt2020"] .CodeMirror pre.CodeMirror-line, [data-font^="tt2020"] .CodeMirror pre.CodeMirror-line-like, [data-font^="tt2020"] .title-paper, .font-opt[data-font^="tt2020"] { font-variant-ligatures: contextual; font-feature-settings: "calt" 1, "rand" 1; }

/* ---------- The page ---------- */
/* On a touch screen the page takes its typing through a contenteditable, and iPadOS draws a caret of
   its own for it; CodeMirror draws the red one, so the system's is kept invisible. */
@media (pointer: coarse) { :root:not([data-ui="spec"]) .CodeMirror { caret-color: transparent; } }
.CodeMirror {
  height: 100%;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-script);
  font-size: min(calc(17.5px * var(--zoom, 1)), max(var(--fs-min, 12px), calc((100cqw - 40px) / 61.5)));
  line-height: var(--lh, 1.5);
  --pad-l: 5.4em; --pad-r: 3.6em; --cols: 60ch;
}
/* An analog page: 65 columns between 1" margins, exactly as typed (no element indents). */
[data-format="analog"] .CodeMirror {
  --pad-l: 3.6em; --pad-r: 3.6em; --cols: 65ch;
  font-family: var(--font-analog, var(--font-script)); font-kerning: none; letter-spacing: 0; /* 65 columns, so a monospaced face (app.js picks it) */
  font-size: min(calc(17.5px * var(--zoom, 1)), max(var(--fs-min, 12px), calc((100cqw - 40px) / 63)));
}
[data-format="novel"] .CodeMirror {
  --pad-l: 3.6em; --pad-r: 3.6em; --cols: 65ch;
  font-size: min(calc(17.5px * var(--zoom, 1)), max(var(--fs-min, 12px), calc((100cqw - 40px) / 63)));
  line-height: calc(var(--lh, 1.5) * 1.3);
}
/* CodeMirror hides the scroller's native scrollbars by making it 50px taller and wider than its box
   and clipping them off; the paper's roll relies on the scroller ending where its box ends, so the
   bottom bar isn't clipped here. On a Mac that's an invisible overlay; on Windows, where scrollbars
   are solid, it showed as a bar across the bottom of the paper. So the native bars are simply hidden
   (the paper scrolls by wheel, finger and the roll, never by a bar). */
.CodeMirror-scroll { padding-bottom: 0; scrollbar-width: none; }
.CodeMirror-scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }
.CodeMirror-sizer {
  box-sizing: content-box; /* CodeMirror adds a 50px transparent border on the right */
  max-width: calc(var(--cols) + var(--pad-l) + var(--pad-r));
  margin: var(--sizer-top, 2.2rem) auto var(--sizer-bottom, 40vh) !important;
}
.CodeMirror-sizer > div { background: var(--page); box-shadow: var(--paper-shadow); border-radius: 1px; }
/* No bottom padding: the foot of the page is the paper hanging below the text (see below), so a
   page that runs a line or two long fills its bottom margin instead of growing. */
.CodeMirror-lines { padding: 4.5em var(--pad-r) 0 var(--pad-l); }
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like { padding: 0; font-variant-ligatures: none; }
.CodeMirror-cursor { border-left: 2px solid var(--accent); }
.CodeMirror-selected { background: rgba(255, 205, 70, 0.35); }
.CodeMirror-focused .CodeMirror-selected, .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: rgba(255, 205, 70, 0.42); }
.CodeMirror-gutters { display: none; }
.spec-selection { clip-path: inset(-100000px -2px -100000px -2px); }
.CodeMirror-code > .fx-dual::before {
  content: ""; position: absolute; top: 0; bottom: 0;
  left: calc(var(--pad-l) * -0.45); width: 2px; border-radius: 1px;
  background: var(--accent); opacity: 0.35;
}
.CodeMirror-code:focus, .CodeMirror-code:focus-visible { outline: none; }

/* The sheet is always a true 8½ × 11 (desk.js makes it 11/8.5 as tall as it is wide), and the
   machine's pitch is fixed: ten characters and six lines to the inch, whatever the typeface, as on a
   typewriter. --em is the machine's em (12 points at the sheet's scale, which is also the line
   pitch, with the margins and columns measured in it), and --pitch (app.js measures each face) scales
   the type so its characters land at ten to the inch: a face with narrow letters is set a little
   larger, and the sheet and the typewriter stay the same size. 1½" and 1" side margins and 1" top
   for a script, 1" all round for a manuscript, which is double-spaced. Line spacing is the lever:
   Single rules the sheet at six lines to the inch; 1¼, 1½ and Double set the lines that much
   further apart, so a page holds that many fewer, and the page breaks and the PDF follow (pdf.js).
   --lh is the lever's setting. (Modern is laid out in spec.css.) */
[data-spacing="single"][data-format="novel"] .CodeMirror { line-height: 2; }
@container (min-width: 641px) {
  :root:not([data-ui="spec"]) .CodeMirror {
    --em: min(calc(17.5px * var(--zoom, 1)), max(var(--fs-min, 12px), calc((100cqw - 40px) / 70)));
    --pad-l: calc(9 * var(--em)); --pad-r: calc(6 * var(--em));
    font-size: calc(var(--em) * var(--pitch, 1));
    line-height: calc(var(--em) * var(--lh, 1));
  }
  :root:not([data-ui="spec"])[data-format="novel"] .CodeMirror, :root:not([data-ui="spec"])[data-format="analog"] .CodeMirror { --pad-l: calc(6 * var(--em)); --pad-r: calc(6 * var(--em)); }
  :root:not([data-ui="spec"])[data-format="novel"] .CodeMirror { line-height: calc(2 * var(--em) * var(--lh, 1)); }
  :root:not([data-ui="spec"]) .CodeMirror-lines { padding-top: calc(6 * var(--em)); }
  :root:not([data-ui="spec"]) .CodeMirror-sizer > div::before { top: calc(3 * var(--em)); }
  :root:not([data-ui="spec"]) .rv-star { line-height: inherit; }
}

/* Phones: the page fills the screen and text wraps to fit. */
@container (max-width: 640px) {
  .CodeMirror, [data-format="novel"] .CodeMirror, [data-format="analog"] .CodeMirror { --pad-l: 16px; --pad-r: 16px; font-size: calc(15px * var(--zoom, 1)); }
  .CodeMirror-sizer { max-width: none; margin: var(--sizer-top, 1rem) 0 var(--sizer-bottom, 40vh) !important; }
  .CodeMirror-sizer > div { border-radius: 0; }
  .CodeMirror-lines { padding-top: 1.5em; }
}

/* Screenplay elements. Widths follow the standard US Letter layout: 60-character
   action, dialogue 10 in from the margin for 35, cue at 22, parentheticals at 16. */
.CodeMirror pre.fx-scene { font-weight: 700; }
.CodeMirror pre.fx-character { padding-left: 22ch; }
.CodeMirror pre.fx-dialogue { padding-left: 10ch; padding-right: 15ch; }
.CodeMirror pre.fx-paren { padding-left: 16ch; padding-right: 19ch; }
.CodeMirror pre.fx-lyric { padding-left: 10ch; padding-right: 15ch; font-style: italic; }
.CodeMirror pre.fx-transition { text-align: right; }
.CodeMirror pre.fx-centered { text-align: center; }
.CodeMirror pre.fx-act, .CodeMirror pre.fx-actend { text-align: center; }
.CodeMirror pre.fx-act .cm-centered-text, .CodeMirror pre.fx-actend .cm-centered-text { text-decoration: underline; text-underline-offset: 0.18em; }
.CodeMirror pre.fx-act { border-top: 1px dashed var(--rule); padding-top: 0.75em; }
.CodeMirror pre.fx-actend { border-bottom: 1px dashed var(--rule); padding-bottom: 0.75em; }
.CodeMirror pre.fx-pagebreak { color: var(--muted); text-align: center; letter-spacing: 0.4em; }
.CodeMirror pre.fx-section { font-family: var(--font-ui); font-weight: 600; color: var(--accent); letter-spacing: 0.02em; }
.CodeMirror pre.fx-synopsis { font-style: italic; color: var(--muted); }
.CodeMirror pre.fx-title-key { color: var(--muted); }
.CodeMirror pre.fx-title-val { padding-left: 4ch; }

@container (max-width: 640px) {
  .CodeMirror pre.fx-character { padding-left: 14ch; }
  .CodeMirror pre.fx-dialogue { padding-left: 5ch; padding-right: 5ch; }
  .CodeMirror pre.fx-paren { padding-left: 9ch; padding-right: 9ch; }
}

/* Stage play manuscript: names centered, speeches margin to margin, stage directions set in 2". */
[data-format="play"] .CodeMirror pre.fx-scene { font-weight: 400; text-align: center; text-decoration: underline; text-underline-offset: 0.18em; }
[data-format="play"] .CodeMirror pre.fx-act { text-decoration: underline; text-underline-offset: 0.18em; }
[data-format="play"] .CodeMirror pre.fx-character { padding-left: 0; text-align: center; }
[data-format="play"] .CodeMirror pre.fx-dialogue { padding-left: 0; padding-right: 0; }
[data-format="play"] .CodeMirror pre.fx-paren { padding-left: 10ch; padding-right: 10ch; }
[data-format="play"] .CodeMirror pre.fx-action { padding-left: 20ch; font-style: italic; }
[data-format="play"] .CodeMirror pre.fx-lyric { padding-left: 5ch; padding-right: 5ch; }
@container (max-width: 640px) {
  [data-format="play"] .CodeMirror pre.fx-action { padding-left: 8ch; }
  [data-format="play"] .CodeMirror pre.fx-paren { padding-left: 4ch; padding-right: 4ch; }
}

/* Novel manuscript: indented paragraphs, chapters a third of the way down a fresh page. */
/* The indent is an inline spacer rather than text-indent, which CodeMirror can't measure on wrapped lines. */
[data-format="novel"] .CodeMirror pre.fx-para > span::before { content: ""; display: inline-block; width: 5ch; }
[data-format="novel"] .CodeMirror pre.fx-chapter { text-align: center; padding-top: 3.5em; padding-bottom: 0.6em; }
[data-format="novel"] .CodeMirror pre.fx-break { text-align: center; color: var(--muted); }
[data-format="novel"] .CodeMirror pre.fx-centered { text-align: center; }

/* Inline syntax */
.cm-strong { font-weight: 700; }
.cm-em { font-style: italic; }
.cm-underline { text-decoration: underline; text-underline-offset: 0.15em; }
.cm-note { color: var(--note); background: var(--note-bg); border-radius: 3px; }
.cm-boneyard { color: var(--muted); text-decoration: line-through; opacity: 0.7; }
.cm-marker { color: var(--muted); opacity: 0.6; }

/* Empty line waiting for a name or a transition */
.CodeMirror pre.fx-character:has(> span > span[cm-text]:only-child)::after,
.CodeMirror pre.fx-transition:has(> span > span[cm-text]:only-child)::after {
  position: absolute; top: 0; color: var(--muted); opacity: 0.45; pointer-events: none;
}
.CodeMirror pre.fx-character:has(> span > span[cm-text]:only-child)::after { content: "CHARACTER"; left: 22ch; }
.CodeMirror pre.fx-transition:has(> span > span[cm-text]:only-child)::after { content: "TRANSITION:"; right: 0; }
[data-format="play"] .CodeMirror pre.fx-character:has(> span > span[cm-text]:only-child)::after { left: 0; right: 0; text-align: center; }
@container (max-width: 640px) {
  .CodeMirror pre.fx-character:has(> span > span[cm-text]:only-child)::after { left: 14ch; }
}

/* ---------- One sheet in the typewriter at a time ---------- */
/* Every sheet is a whole page long, numbered at the top right like the printed page. The paper
   below the last line hangs down past the text (rather than adding to it), so any line, the last
   one included, can still be rolled up to the typing line. */
.CodeMirror-sizer > div::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%;
  height: max(0px, calc(var(--sheet-min, 0px) - 100%));
  background: var(--page); box-shadow: var(--paper-shadow); clip-path: inset(0 -40px -40px -40px);
  pointer-events: none;
}
.CodeMirror-sizer > div::before {
  content: var(--page-label, "");
  position: absolute; top: 2.2em; right: var(--pad-r);
  color: var(--ink); opacity: 0.8; pointer-events: none;
}
@container (max-width: 640px) {
  .CodeMirror-lines { padding-top: 2.4em; }
  .CodeMirror-sizer > div::before { top: 0.6em; right: 16px; font-size: 0.85em; }
}
/* (MORE) and NAME (CONT'D) where a page breaks in a speech, set where the printed page puts them. */
.CodeMirror .sheet-cont { padding-left: 22ch; white-space: pre; color: var(--ink); opacity: 0.55; user-select: none; }
[data-format="play"] .CodeMirror .sheet-cont { padding-left: 0; text-align: center; }
@container (max-width: 640px) { .CodeMirror .sheet-cont { padding-left: 14ch; } }

/* While the title page is in, the script's sheet is out (and there's no element to type). */
.CodeMirror.sheet-out { opacity: 0; pointer-events: none; }
.title-in .element-wrap { opacity: 0.35; pointer-events: none; transition: opacity 0.2s; }

/* ---------- Title page: a sheet of its own, put in before page 1 ---------- */
.title-paper {
  position: absolute; z-index: 3;
  font-family: var(--font-script); color: var(--ink);
  line-height: 1.5;
}
.title-paper[hidden] { display: none; }
.tp-sheet {
  position: relative;
  display: flex; flex-direction: column;
  height: 100%;
  padding: 0 var(--pad-r) 3.6em var(--pad-l);
  background: var(--page);
  box-shadow: var(--paper-shadow);
  border-radius: 1px;
  cursor: pointer;
}
.tp-sheet:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.tp-center { margin-top: 36%; display: flex; flex-direction: column; align-items: center; gap: 1.5em; text-align: center; }
.tp-title { white-space: pre-line; text-transform: uppercase; font-weight: 700; letter-spacing: 0.02em; text-wrap: balance; }
.tp-credit, .tp-author, .tp-source { white-space: pre-line; }
.tp-credit { margin-top: 1.5em; }
.tp-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; gap: 2em; white-space: pre-line; }
.tp-date { text-align: right; }
.tp-novel { padding-top: 4.5em; }
.tp-novel .tp-head { display: flex; justify-content: space-between; gap: 2em; white-space: pre-line; line-height: 1.25; }
.tp-novel .tp-words { text-align: right; white-space: nowrap; }
.tp-novel .tp-center { margin-top: 30%; gap: 2em; }
.tp-novel .tp-title { font-weight: 400; }
.tp-edit {
  position: absolute; top: 14px; right: 14px;
  font: 500 12px var(--font-ui); color: var(--muted);
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--rule); background: var(--card);
  opacity: 0; transition: opacity 0.15s;
}
.tp-sheet:hover .tp-edit, .tp-sheet:focus-visible .tp-edit { opacity: 1; }
@media (hover: none) { .tp-edit { opacity: 0.85; } }


/* ---------- Looking up: the wall behind the desk, the window, the far side of the desk ---------- */
:root {
  --rain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='160'%3E%3Cg stroke='%23E6EEF5' stroke-opacity='.42' stroke-width='1.2' stroke-linecap='round'%3E%3Cpath d='M12 4 l-3 24'/%3E%3Cpath d='M62 44 l-3 28'/%3E%3Cpath d='M104 92 l-3 22'/%3E%3Cpath d='M36 112 l-3 26'/%3E%3Cpath d='M86 12 l-2 16'/%3E%3C/g%3E%3C/svg%3E");
  --snow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cg fill='white' fill-opacity='.85'%3E%3Ccircle cx='20' cy='30' r='2.2'/%3E%3Ccircle cx='92' cy='12' r='1.6'/%3E%3Ccircle cx='150' cy='60' r='2.6'/%3E%3Ccircle cx='60' cy='96' r='1.8'/%3E%3Ccircle cx='182' cy='132' r='2'/%3E%3Ccircle cx='118' cy='160' r='1.4'/%3E%3Ccircle cx='30' cy='176' r='2.4'/%3E%3C/g%3E%3C/svg%3E");
  --wall-c: var(--wall-base);
}
:root[data-sky="night"] { --wall-c: color-mix(in srgb, var(--wall-base) 34%, #0B0D18); --frame: #8D8A84; }
.room { --win-w: min(1500px, 94vw); position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; transition: transform 0.75s cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.6s; }
[data-look="desk"] .room { transform: translateY(-34vh); opacity: 0; visibility: hidden; transition: transform 0.75s cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.6s, visibility 0s 0.75s; }
[data-look="desk"] .room * { animation-play-state: paused !important; }
.desk-surface { transition: transform 0.75s cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.6s; }
[data-look="window"] .desk-surface { transform: translateY(30vh); opacity: 0; }

.wall {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 55% at var(--room-cx, 50%) 30%, rgba(255, 252, 240, 0.28), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.1)),
    url("textures/wall-stucco.jpg") 0 0 / 640px auto,
    var(--wall-c);
  /* The plaster is a photograph in neutral grey; multiplied over the wall's colour, it's painted that colour. */
  background-blend-mode: normal, normal, multiply;
}
/* At night a lamp on the desk lights the wall behind its shade (decor.js sets where, and whether one's out). */
[data-sky="night"] .wall {
  background: radial-gradient(ellipse 34% 40% at var(--lamp-x, 50%) var(--lamp-y, var(--wall-y, 70%)), rgba(255, 196, 120, var(--lamp-on, 0)), transparent 70%),
    url("textures/wall-stucco.jpg") 0 0 / 640px auto, var(--wall-c);
  background-blend-mode: normal, multiply;
}

.window {
  position: absolute; left: calc(var(--room-cx, 50vw) - var(--win-w) / 2); width: var(--win-w);
  top: max(80px, 10vh); height: calc(var(--wall-y, 60vh) - max(80px, 10vh) - 44px);
  background: #9BB7CC;
}
.win-view, .win-weather, .win-glass { position: absolute; inset: 0; overflow: hidden; }
.win-view svg { display: block; width: 100%; height: 100%; }
.win-glass { background: linear-gradient(115deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.06) 55%, rgba(255, 255, 255, 0) 70%); box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.14); }
.win-frame {
  position: absolute; inset: -16px; border: 16px solid var(--frame); border-radius: 3px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 8px 16px -4px rgba(0, 0, 0, 0.28);
}
.mullion { position: absolute; top: 0; bottom: 0; width: 12px; background: var(--frame); box-shadow: 2px 0 3px rgba(0, 0, 0, 0.18); }
.mullion.m1 { left: calc(33.33% - 6px); } .mullion.m2 { left: calc(66.66% - 6px); }
.rail { position: absolute; left: 0; right: 0; top: 38%; height: 12px; background: var(--frame); box-shadow: 0 2px 3px rgba(0, 0, 0, 0.18); }
.win-sill { position: absolute; left: -38px; right: -38px; bottom: -40px; height: 22px; border-radius: 2px; background: linear-gradient(180deg, var(--frame), color-mix(in srgb, var(--frame) 80%, #000)); box-shadow: 0 10px 16px rgba(0, 0, 0, 0.22); }
/* Rain and snow: tall strips of pattern that slide down and loop seamlessly. */
.wx-rain::before, .wx-rain::after, .wx-snow::before, .wx-snow::after { content: ""; position: absolute; left: 0; right: 0; will-change: transform; }
.wx-rain::before { top: -160px; bottom: 0; background: var(--rain) 0 0 / 120px 160px; animation: wx-a 0.75s linear infinite; }
.wx-rain::after { top: -250px; bottom: 0; background: var(--rain) 40px 0 / 190px 250px; opacity: 0.7; animation: wx-b 1.1s linear infinite; }
.wx-snow::before { top: -200px; bottom: 0; background: var(--snow) 0 0 / 200px 200px; animation: wx-c 14s linear infinite; }
.wx-snow::after { top: -330px; bottom: 0; background: var(--snow) 70px 0 / 330px 330px; opacity: 0.8; animation: wx-d 19s linear infinite; }
@keyframes wx-a { to { transform: translateY(160px); } }
@keyframes wx-b { to { transform: translateY(250px); } }
@keyframes wx-c { to { transform: translateY(200px); } }
@keyframes wx-d { to { transform: translateY(330px); } }

.far-desk {
  position: absolute; left: 0; right: 0; top: var(--wall-y, 70vh); bottom: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0, rgba(0, 0, 0, 0.12) 12px, rgba(0, 0, 0, 0) 40%, rgba(255, 236, 205, 0.05)),
    var(--wood-tex) 0 0 / 1100px 380px, /* squashed: the far side of the desk recedes */
    var(--wood-2);
  box-shadow: 0 -1px 0 rgba(255, 240, 220, 0.18);
}
.far-desk::before { content: ""; position: absolute; left: 0; right: 0; top: -22px; height: 22px; background: linear-gradient(to top, rgba(0, 0, 0, 0.2), transparent); }
[data-sky="night"] .far-desk { filter: brightness(0.6); }
.rl-pool, .rl-glow { opacity: 0; transition: opacity 0.6s; }
[data-sky="night"] .rl-pool { opacity: 1; }
[data-sky="night"] .rl-glow { opacity: 1; filter: drop-shadow(0 0 6px #FFD38A); }
/* A lava lamp's wax rises and falls, each blob on its own time. */
.df-lava { transform-box: fill-box; transform-origin: center; animation: df-lava 9s ease-in-out infinite; }
.df-lava:nth-child(2n) { animation-duration: 12s; animation-delay: -4s; }
.df-lava:nth-child(3n) { animation-duration: 15s; animation-delay: -7s; }
@keyframes df-lava { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-46px) scale(0.86, 1.18); } }

/* The views move a little: each moving part is its own layer, slid or faded by the compositor. */
.win-layer { position: absolute; inset: 0; }
/* A layer's drawing may spill past its own box: the window clips it, not the layer. (A layer that
   drifts sideways would otherwise cut its clouds off along its own edge, a hard line inside the window.) */
.win-view svg, .win-layer svg { display: block; width: 100%; height: 100%; overflow: visible; }
/* Clouds that drift past the top or bottom of the window dissolve there rather than ending in a hard
   line (a blurred cloud cut by the window's edge looks like a mistake). */
.lx-drift { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 90%, transparent 100%); mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 90%, transparent 100%); }
.lx-drift svg { will-change: transform; animation: lx-drift 180s ease-in-out infinite alternate; } /* (the drawing drifts; its box, and the fade, stay put) */
@keyframes lx-drift { from { transform: translateX(-5%); } to { transform: translateX(6%); } }
.lx-tw1, .lx-tw2, .lx-sh1, .lx-sh2, .lx-beam { will-change: opacity; }
.lx-tw1 { animation: lx-fade 5.5s ease-in-out infinite; }
.lx-tw2 { animation: lx-fade 7.5s ease-in-out -3s infinite; }
@keyframes lx-fade { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.lx-sh1 { animation: lx-fade 3.2s ease-in-out infinite; }
.lx-sh2 { animation: lx-fade 4.4s ease-in-out -2s infinite; }
.lx-waves { will-change: transform; animation: lx-waves 9s ease-in-out infinite alternate; }
@keyframes lx-waves { to { transform: translateX(1.2%); } }
.lx-birds { will-change: transform; animation: lx-birds 80s linear infinite; }
@keyframes lx-birds { from { transform: translateX(-30%); } to { transform: translateX(110%); } }
.lx-sail { will-change: transform; animation: lx-sail 14s ease-in-out infinite alternate; }
@keyframes lx-sail { to { transform: translate(-2.5%, 0.3%); } }
.lx-beam { animation: lx-beam 7s ease-in-out infinite; }
.lx-blink { animation: lx-blink 2.6s steps(1) infinite; }
/* Autumn leaves fall one view's height and round again (the sheet has a copy above it), swaying. */
.lx-fall { animation: lx-fall 28s linear infinite; }
@keyframes lx-fall { from { transform: translateY(0); } to { transform: translateY(1000px); } }
.lx-sway { animation: lx-sway 5s ease-in-out infinite alternate; }
@keyframes lx-sway { from { transform: translateX(14px); } to { transform: translateX(-26px); } }
/* Now and then a shooting star over the desert. */
.lx-shoot { opacity: 0; animation: lx-shoot 11s ease-out infinite; }
@keyframes lx-shoot { 0%, 86% { opacity: 0; transform: translate(0, 0); } 88% { opacity: 1; } 94% { opacity: 0; transform: translate(-22%, 9%); } 100% { opacity: 0; } }
@keyframes lx-blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0.08; } }
@keyframes lx-beam { 0%, 100% { opacity: 0; } 18% { opacity: 1; } 40% { opacity: 0.1; } }
.scene.thumb * { animation: none !important; }
/* Photographs drift slowly, as if you'd shifted in your chair; their overlays drift with them. */
.ph-pan { position: absolute; inset: 0; will-change: transform; animation: ph-pan 80s ease-in-out infinite alternate; }
@keyframes ph-pan { from { transform: scale(1.06) translate(-1.4%, 0.6%); } to { transform: scale(1.13) translate(1.4%, -0.8%); } }
/* Relighting: a photo taken at one time of day, graded toward the time it is now. The filter
   sets the light; the tint over it colours the sky (and, at night, everything). */
.ph-tint { position: absolute; inset: 0; pointer-events: none; display: none; }
[class*="ph-"][class*="-night"] > .ph-tint, [class*="ph-"][class*="-golden"] > .ph-tint, [class*="ph-"][class*="-day"] > .ph-tint { display: block; }
.ph-day-night .ph-photo { filter: brightness(0.44) saturate(0.6) contrast(1.1); }
.ph-golden-night .ph-photo { filter: brightness(0.6) saturate(0.6) contrast(1.08); }
.ph-day-night > .ph-tint, .ph-golden-night > .ph-tint { background: linear-gradient(180deg, #0B1440, #1A2550 55%, #101634); mix-blend-mode: multiply; opacity: 0.6; }
.ph-day-golden .ph-photo { filter: sepia(0.38) saturate(1.3) brightness(0.9) contrast(1.06); }
.ph-day-golden > .ph-tint { background: linear-gradient(165deg, rgba(255, 130, 50, 0.6), rgba(255, 170, 90, 0.35) 45%, rgba(110, 50, 90, 0.45)); mix-blend-mode: overlay; }
.ph-golden-day .ph-photo { filter: saturate(0.9) brightness(1.07) hue-rotate(-8deg); }
.ph-golden-day > .ph-tint { background: linear-gradient(180deg, rgba(150, 195, 255, 0.45), rgba(255, 255, 255, 0) 60%); mix-blend-mode: soft-light; }
.ph-night-day .ph-photo { filter: brightness(1.35) contrast(0.9) saturate(0.85); }
.ph-night-day > .ph-tint { background: linear-gradient(180deg, rgba(110, 140, 190, 0.55), rgba(70, 90, 130, 0.15) 55%, transparent); mix-blend-mode: screen; }
.ph-night-golden .ph-photo { filter: brightness(1.12) contrast(0.95); }
.ph-night-golden > .ph-tint { background: linear-gradient(180deg, rgba(70, 50, 90, 0.3), rgba(230, 120, 70, 0.42) 45%, transparent 75%); mix-blend-mode: screen; }
.ph-thumb { position: relative; display: block; width: 100%; height: 100%; overflow: hidden; }
/* A rainy day: the colour drains a little, the light goes grey, and the distance fades into mist. */
.ph-overcast, .ph-mist { position: absolute; inset: 0; pointer-events: none; display: none; }
.ph-rainy > .ph-overcast, .ph-rainy > .ph-mist { display: block; }
.ph-rainy > .ph-overcast { background: #7E8790; mix-blend-mode: saturation; opacity: 0.38; }
.ph-rainy > .ph-mist { background: linear-gradient(180deg, rgba(196, 204, 212, 0.42), rgba(184, 192, 200, 0.22) 45%, rgba(150, 160, 170, 0.06) 75%, rgba(120, 130, 140, 0.1)); }
.ph-rainy[class*="-night"] > .ph-mist { background: linear-gradient(180deg, rgba(60, 70, 92, 0.4), rgba(40, 48, 66, 0.18) 55%, rgba(20, 24, 36, 0.1)); }
.ph-rain { width: 100%; height: 100%; pointer-events: none; }
.ph-thumb svg { display: block; width: 100%; height: 100%; }
/* A window that goes dark now and then, and comes back on. */
.lx-win { animation: lx-win 23s steps(1) infinite; }
@keyframes lx-win { 0%, 38% { opacity: 1; } 39%, 61% { opacity: 0; } 62%, 100% { opacity: 1; } }
.ph-glow { mix-blend-mode: screen; }
.lx-neon { opacity: 0; animation: lx-neon 9s steps(1) infinite; }
@keyframes lx-neon { 0%, 61%, 63%, 65%, 100% { opacity: 0; } 62%, 64% { opacity: 1; } 66%, 69% { opacity: 0.85; } 70% { opacity: 0; } }
.lx-flare { will-change: opacity; animation: lx-flare 7s ease-in-out infinite; }
@keyframes lx-flare { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.lx-shadow { will-change: transform; animation: lx-shadow 70s linear infinite; }
/* Clouds over a photograph drift slowly one way and back. */
.lx-cloud { will-change: transform; animation: lx-cloud 150s ease-in-out infinite alternate; }
.lx-cloud2 { animation-duration: 210s; animation-direction: alternate-reverse; }
@keyframes lx-cloud { from { transform: translateX(-7%); } to { transform: translateX(7%); } }
@keyframes lx-shadow { from { transform: translateX(-60%); } to { transform: translateX(80%); } }

/* ---------- Sitting back: the room around the typewriter ---------- */
/* The paper and the machine draw back to the middle of the desk, the window gets smaller, and
   there's more wall (for the clock) and more desk (for whatever you keep on it). */
:root[data-room] { --fs-min: 8.5px; }
/* Never narrower than 660px, though: under 641 the page would switch to the phone layout. */
[data-room] .editor-host { left: max(0px, calc(50% - max(330px, clamp(210px, 23vw, 390px)))); right: max(0px, calc(50% - max(330px, clamp(210px, 23vw, 390px)))); }
[data-room] .room { --win-w: min(960px, 54vw); }
[data-room] .window { top: max(64px, 8vh); height: calc(var(--wall-y, 60vh) - max(64px, 8vh) - 110px); }
@media (max-width: 760px) {
  :root[data-room] { --fs-min: 12px; }
  [data-room] .editor-host { left: 0; right: 0; }
  /* No room beside the paper on a phone for the desk's things, the clock or the lights. */
  :root[data-look="window"] .decor, :root[data-look="window"] .decor-wall { display: none; }
}


/* ---------- Find and replace: a small bar under the top bar ---------- */
.findbar {
  position: fixed; top: calc(64px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 55;
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
  max-width: calc(100vw - 24px);
  background: var(--card); color: var(--ink); border: 1px solid var(--card-edge); border-radius: 10px; box-shadow: var(--shadow);
  font: 13px var(--font-ui);
}
.findbar[hidden] { display: none; }
.find-row { display: flex; align-items: center; gap: 6px; }
.findbar input { width: 220px; min-width: 0; padding: 5px 8px; border: 1px solid var(--rule); border-radius: 6px; background: var(--page); color: var(--ink); font: inherit; }
.findbar input:focus { outline: none; border-color: var(--accent); }
.find-count { min-width: 74px; text-align: center; color: var(--muted); font-size: 12px; white-space: nowrap; }
.find-none .find-count { color: var(--accent); }
.find-btn { padding: 4px 8px; border-radius: 6px; background: none; color: var(--ink); font: inherit; line-height: 1.2; }
.find-btn:hover { background: var(--accent-soft); }
.find-toggle[aria-pressed="true"] { background: var(--accent-soft); font-weight: 600; }
.find-replace { display: none; }
.findbar.replacing .find-replace { display: flex; }
.cm-found { background: rgba(255, 205, 80, 0.45); border-radius: 2px; }
.cm-found-current { background: rgba(255, 140, 40, 0.75); }
@media (max-width: 600px) { .findbar input { width: 140px; } .find-count { min-width: 50px; } }

/* Text floating on a light wall needs dark ink. */
[data-look="window"]:not([data-sky="night"]) .save-state, [data-look="window"]:not([data-sky="night"]) .page-count { color: rgba(45, 35, 25, 0.62); text-shadow: none; }
/* Over the pale woods, looking down at the keys, the same dark ink. */
[data-look="desk"][data-wood="ash"] .save-state, [data-look="desk"][data-wood="ash"] .page-count,
[data-look="desk"][data-wood="oak"] .save-state, [data-look="desk"][data-wood="oak"] .page-count { color: rgba(40, 28, 16, 0.72); text-shadow: 0 1px 0 rgba(255, 245, 225, 0.35); }
#btn-look svg { display: none; }
#btn-look[data-next="window"] .ic-up, #btn-look[data-next="room"] .ic-room, #btn-look[data-next="desk"] .ic-down { display: block; }
[data-look="window"] .chip-main { flex-direction: row; align-items: center; justify-content: center; gap: 0.9cqw; }
/* (On a narrow plate the hint gives way, not the element's name.) */
[data-look="window"] .chip-label { flex: none; }
[data-look="window"] .chip-hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Focus mode: the typewriter slides down, everything else fades ---------- */
.focus .deskbar { opacity: 0; }
.focus .deskbar:hover, .focus .deskbar:focus-within { opacity: 1; }
@media (hover: none) { .focus .deskbar { opacity: 0.45; } }
.focus .CodeMirror-code .CodeMirror-line { opacity: 0.28; transition: opacity 0.3s; }
.focus .CodeMirror-code .fx-active .CodeMirror-line { opacity: 1; }
.focus .element-wrap, .focus .counter { visibility: hidden; }

/* ---------- The desk's front edge and the drawer of notebooks ---------- */
.drawer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; height: calc(var(--strip-h) + env(safe-area-inset-bottom, 0px)); pointer-events: none; }
.drawer::before {
  content: ""; position: absolute; inset: 0; pointer-events: auto;
  background: linear-gradient(180deg, rgba(255, 236, 205, 0.16), rgba(0, 0, 0, 0.18) 30%, rgba(0, 0, 0, 0.42)), var(--wood-bg);
  background-attachment: scroll, fixed;
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5), 0 -6px 14px rgba(0, 0, 0, 0.28);
}
.drawer-front {
  position: absolute; left: 50%; bottom: env(safe-area-inset-bottom, 0px); transform: translateX(-50%);
  width: min(400px, 74vw); height: calc(var(--strip-h) - 5px);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(255, 236, 205, 0.1), rgba(0, 0, 0, 0.2)), var(--wood-bg);
  background-attachment: scroll, fixed;
  border: 1px solid rgba(0, 0, 0, 0.5); border-bottom: 0; border-radius: 2px 2px 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 240, 220, 0.18);
}
.drawer-front:hover { filter: brightness(1.1); }
.drawer-plate {
  padding: 2px 9px; border-radius: 2px;
  background: #F7F1E2; color: #3B3227;
  box-shadow: 0 0 0 2px #B8924A, 0 0 0 3px rgba(0, 0, 0, 0.35), inset 0 1px 2px rgba(0, 0, 0, 0.15);
  font: 700 9.5px/1.3 var(--font-type); letter-spacing: 0.22em; text-transform: uppercase;
}
.drawer-pull {
  width: 56px; height: 9px; border-radius: 5px;
  background: linear-gradient(180deg, #F2D58C, #B88A3A 55%, #8C6427);
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.drawer-box {
  position: fixed; left: 50%; bottom: calc(var(--strip-h) + env(safe-area-inset-bottom, 0px)); z-index: 24;
  width: min(860px, calc(100vw - 24px)); height: 236px; pointer-events: auto;
  transform: translate(-50%, calc(100% + var(--strip-h) + 30px));
  transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
  border: 12px solid transparent; border-bottom: 0; border-radius: 4px 4px 0 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.25) 40%, rgba(0, 0, 0, 0.1)) padding-box,
    linear-gradient(rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.22)) padding-box,
    var(--wood-tex) 0 0 / 900px auto padding-box,
    linear-gradient(180deg, rgba(255, 240, 220, 0.12), rgba(0, 0, 0, 0.08)) border-box,
    var(--wood-tex) 0 0 / 900px auto border-box;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45), inset 0 10px 20px rgba(0, 0, 0, 0.45);
}
.drawer-open .drawer-box { transform: translate(-50%, 0); }
.drawer-inner { position: relative; height: 100%; display: flex; align-items: center; justify-content: center; gap: clamp(12px, 2.5vw, 34px); padding: 14px 24px 6px; }
.nb-mini { position: relative; width: 116px; height: 156px; flex: none; transition: transform 0.18s, box-shadow 0.18s; transform: rotate(var(--tilt, 0deg)); }
.nb-mini:nth-of-type(1) { --tilt: -3deg; }
.nb-mini:nth-of-type(2) { --tilt: 1.5deg; }
.nb-mini:nth-of-type(3) { --tilt: -1deg; }
.nb-mini:hover, .nb-mini:focus-visible { transform: rotate(var(--tilt)) translateY(-10px); }
.nb-mini.is-out { opacity: 0.18; filter: grayscale(1); pointer-events: none; }
.pencil {
  position: absolute; right: 26px; bottom: 18px; width: 170px; height: 11px; transform: rotate(-9deg);
  background:
    linear-gradient(90deg, #E8A3A0 0 14px, #C9C9C4 14px 26px, transparent 26px),
    linear-gradient(180deg, #F6CE52, #E2B42F 50%, #C99A1F);
  clip-path: polygon(0 0, 88% 0, 100% 50%, 88% 100%, 0 100%);
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.5));
}
.pencil::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 12%; background: linear-gradient(90deg, #E9CFA6 60%, #333 60%); clip-path: polygon(0 0, 100% 50%, 0 100%); }

/* An iPad lying in the drawer, with Spec on its screen: the same scripts on a plain, modern page. */
.nb-ipad {
  position: relative; flex: none; width: 122px; height: 162px; padding: 7px;
  border-radius: 14px; transform: rotate(2.5deg);
  background: linear-gradient(150deg, #44474D, #1C1D20 55%, #2C2E33);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0 0 1.5px #9A9DA3, 0 2px 3px rgba(0, 0, 0, 0.45), 0 10px 22px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s;
}
.nb-ipad:hover, .nb-ipad:focus-visible { transform: rotate(2.5deg) translateY(-10px); }
.ipad-screen { position: relative; display: flex; flex-direction: column; height: 100%; border-radius: 8px; overflow: hidden; background: #E7E9EC; }
.ipad-screen::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(118deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 42%); }
.ipad-bar { flex: none; height: 12px; display: flex; align-items: center; justify-content: space-between; padding: 0 5px; background: #F3F4F6; border-bottom: 1px solid #D6DAE0; }
.ipad-bar i { width: 9px; height: 3px; border-radius: 2px; background: #A3A9B2; }
.ipad-bar b { width: 30px; height: 6px; border-radius: 3px; background: #FFFFFF; box-shadow: inset 0 0 0 1px #CDD2D9; }
.ipad-page { flex: 1; margin: 8px 11px 0; padding: 11px 8px 0 13px; display: flex; flex-direction: column; gap: 4.5px; background: #FFFFFF; box-shadow: 0 1px 3px rgba(31, 35, 40, 0.14); }
.ipad-page i { display: block; flex: none; height: 2.5px; border-radius: 2px; background: #2E333A; opacity: 0.5; }
.ipad-page i:nth-child(1) { width: 64%; opacity: 0.85; }
.ipad-page i:nth-child(2) { width: 100%; }
.ipad-page i:nth-child(3) { width: 76%; }
.ipad-page i:nth-child(4) { width: 26%; margin: 3px 0 0 34%; opacity: 0.8; }
.ipad-page i:nth-child(5) { width: 56%; margin-left: 17%; }
.ipad-page i:nth-child(6) { width: 44%; margin-left: 17%; }
.ipad-page i:nth-child(7) { width: 92%; margin-top: 3px; }
.ipad-name {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  padding: 2px 8px; border-radius: 999px; background: #3D5A99; color: #FFFFFF;
  font: 600 9.5px/1.3 var(--font-ui); letter-spacing: 0.04em;
}
@media (max-width: 640px) {
  .drawer-inner { gap: 14px; padding: 14px 10px 6px; }
  .nb-mini { width: 76px; height: 102px; }
  .nb-ipad { zoom: 0.63; }
  .pencil { display: none; }
}

/* ---------- Notebook covers: in the drawer, flying out, and closed on the desk ---------- */
/* The cover's art is sized in container units against the cover's own box. The query container is
   always an ancestor of the element that uses them (the drawer's button, the flyer, the open
   notebook's cover frame), never the element itself: an older WebKit (macOS 13) resolves units on an
   element's own ::before against the window instead, and drew one giant wire loop on the index cards. */
.nb-mini, .nb-flyer, .nb-cover { container-type: inline-size; }
.nb-mini, .nb-cover-front { border-radius: 3px 7px 7px 3px; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4), 0 10px 22px rgba(0, 0, 0, 0.35); overflow: hidden; }
.nb-mini .nb-cover-front { box-shadow: none; }
.nb-mini-label, .nb-cover-label { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; text-align: center; }
/* Index cards: a kraft sketch pad, wire-bound at the top */
[data-kind="cards"] .nb-cover-front {
  background: radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.12), transparent 60%), repeating-linear-gradient(35deg, rgba(0, 0, 0, 0.025) 0 2px, transparent 2px 5px), #B58A57;
  border-radius: 4px;
}
[data-kind="cards"] .nb-cover-front::before {
  content: ""; position: absolute; top: 2.5cqw; left: 6%; right: 6%; height: 7cqw;
  background: radial-gradient(circle, transparent 38%, #303030 40%, #8D8D8D 55%, #303030 62%, transparent 64%) 0 0 / 7cqw 7cqw repeat-x;
}
[data-kind="cards"] .nb-cover-label {
  top: 34%; padding: 2.2cqw 4cqw; background: #FBF8F0; color: #2B2620; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  font: 700 clamp(9px, 8cqw, 30px) / 1.2 var(--font-type); letter-spacing: 0.08em; text-transform: uppercase;
}
/* Story circles: navy cloth with a gold ring */
[data-kind="circles"] .nb-cover-front {
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 3px), repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.08) 0 1px, transparent 1px 3px), linear-gradient(160deg, #3A5078, #253655);
}
[data-kind="circles"] .nb-cover-front::before {
  content: ""; position: absolute; left: 50%; top: 22%; width: 46%; aspect-ratio: 1; transform: translateX(-50%);
  border: max(2px, 1.6cqw) solid #C9A65E; border-radius: 50%; opacity: 0.9;
}
[data-kind="circles"] .nb-cover-label {
  top: 66%; color: #D9B86C; font: 700 clamp(8px, 7cqw, 28px) / 1.2 var(--font-type); letter-spacing: 0.12em; text-transform: uppercase;
}
/* Diary: oxblood leather with an elastic band */
[data-kind="diary"] .nb-cover-front {
  background: radial-gradient(ellipse at 35% 25%, rgba(255, 255, 255, 0.12), transparent 55%), radial-gradient(circle at 70% 80%, rgba(0, 0, 0, 0.2), transparent 50%), #6E2A25;
}
[data-kind="diary"] .nb-cover-front::after {
  content: ""; position: absolute; top: 0; bottom: 0; right: 13%; width: 5%; background: linear-gradient(90deg, #151515, #2C2C2C 50%, #151515);
}
[data-kind="diary"] .nb-cover-label {
  top: 40%; transform: translateX(-62%); color: #D7AF73; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.08);
  font: 700 clamp(10px, 10cqw, 40px) / 1 var(--font-type); letter-spacing: 0.2em; text-transform: uppercase;
}

/* Board Pics: an olive cloth album with a photo corner on the cover */
[data-kind="album"] .nb-cover-front {
  background: radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.1), transparent 55%), repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 4px), #4F5B3A;
}
[data-kind="album"] .nb-cover-front::before {
  content: ""; position: absolute; left: 50%; top: 16%; width: 54%; aspect-ratio: 4 / 3; transform: translateX(-50%) rotate(-2.5deg);
  background: linear-gradient(135deg, #D3DCE7, #8FA7C2) padding-box, #FBFAF4; border: 1.4cqw solid #FBFAF4; border-bottom-width: 4.5cqw; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
[data-kind="album"] .nb-cover-label {
  top: 72%; color: #E8DFC2; font: 700 clamp(8px, 7cqw, 28px) / 1.2 var(--font-type); letter-spacing: 0.12em; text-transform: uppercase;
}
.nb-mini:nth-of-type(4) { --tilt: 2deg; }
.nb[data-kind="album"] { --nb-paper: #2F2B27; }
.nb[data-kind="album"] .nb-body { background: radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.06), transparent 60%), var(--nb-paper); }
.album-view { padding: 28px 34px 40px; color: #E9E2D2; }
.album-view .view-head h2 { color: #E9E2D2; }
.album-view .view-head p { color: rgba(233, 226, 210, 0.7); }
.prints { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 24px 20px; }
.print { display: block; padding: 8px 8px 10px; background: #FBFAF4; border-radius: 2px; text-align: left; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.45), 0 10px 20px rgba(0, 0, 0, 0.4); transform: rotate(var(--tilt, 0deg)); transition: transform 0.15s; cursor: zoom-in; }
.print:hover, .print:focus-visible { transform: rotate(0deg) translateY(-3px); }
.print img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: #FBFBF9; }
.print-cap { display: block; margin-top: 7px; font: 14px var(--font-hand); color: #3A3530; }
.print-big { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; gap: 12px; padding: 18px; background: rgba(30, 26, 22, 0.96); }
.print-big img { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #FBFBF9; border: 10px solid #FBFAF4; box-sizing: border-box; }
.print-big-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: #E9E2D2; font-size: 13px; }
.print-big-bar .spacer { flex: 1; }
.print-big-bar .quiet { color: #E9E2D2; }
.print-big-bar .quiet.danger { color: #F0A090; }
.board-surface.flash::after { content: ""; position: absolute; inset: 0; background: #fff; pointer-events: none; animation: board-flash 0.4s ease-out forwards; }
@keyframes board-flash { from { opacity: 0.9; } to { opacity: 0; } }

/* ---------- An open notebook on the desk ---------- */
.nb-stage {
  position: fixed; left: 0; right: 0; top: calc(56px + env(safe-area-inset-top, 0px)); bottom: calc(var(--strip-h) + env(safe-area-inset-bottom, 0px));
  z-index: 20; display: grid; place-items: center; padding: 6px 16px 14px;
  perspective: 2600px;
  background: rgba(16, 9, 4, 0); transition: background 0.35s;
}
.nb-stage.in { background: rgba(16, 9, 4, 0.3); }
.nb {
  position: relative; width: min(1140px, 100%); height: 100%; max-height: 820px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.nb.is-hidden { visibility: hidden; }
.nb-flyer { position: fixed; z-index: 22; pointer-events: none; }
.nb-flyer .nb-cover-front { position: absolute; inset: 0; }
.nb-body {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), 0 26px 60px rgba(0, 0, 0, 0.5);
  transition: clip-path 0s;
}
.nb-cover { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.55s cubic-bezier(0.45, 0.05, 0.25, 1), opacity 0.25s; z-index: 2; pointer-events: none; }
.nb-cover-front, .nb-cover-back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.nb-cover-back { background: var(--nb-paper, #F7F2E6); border-radius: 7px 3px 3px 7px; transform: rotateY(180deg); box-shadow: inset -20px 0 30px -18px rgba(0, 0, 0, 0.35); }
.view-pane { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; transition: opacity 0.25s; }
.nb:not(.is-open) .view-pane { opacity: 0; }

/* Two-page spreads (circles, diary): the closed book is the right half; its cover swings left. */
.nb[data-style="spread"] .nb-cover { left: 50%; transform-origin: 0 50%; }
.nb[data-style="spread"].is-closed { transform: translateX(-25%); }
.nb[data-style="spread"].is-closed .nb-body, .nb[data-style="spread"].is-closing .nb-body { clip-path: inset(0 0 0 50%); }
.nb[data-style="spread"].is-closing { transform: translateX(-25%); }
.nb[data-style="spread"].is-closing .nb-body { transition-delay: 0.27s; }
.nb[data-style="spread"].is-opening .nb-body { clip-path: inset(0); transition-delay: 0.27s; }
.nb[data-style="spread"].is-opening .nb-cover, .nb[data-style="spread"].is-open .nb-cover { transform: rotateY(-180deg); }
.nb.is-open .nb-cover { visibility: hidden; }
/* The sketch pad (cards): its cover flips up over the wire binding. */
.nb[data-style="pad"] .nb-cover { transform-origin: 50% 0; }
.nb[data-style="pad"] .nb-cover-back { transform: rotateX(180deg); }
.nb[data-style="pad"].is-opening .nb-cover, .nb[data-style="pad"].is-open .nb-cover { transform: rotateX(96deg); opacity: 0; transition: transform 0.5s cubic-bezier(0.45, 0.05, 0.25, 1), opacity 0.2s 0.3s; }

.nb-close {
  display: none; flex: none; height: 36px; padding: 0 16px; border-radius: 999px;
  font: 600 12.5px var(--font-ui); color: #F4EBDC;
  background: rgba(24, 14, 7, 0.6); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.nb-out .nb-close { display: block; }
.nb-close:hover { background: rgba(24, 14, 7, 0.8); }

/* Pages */
.nb[data-kind="cards"] { --nb-paper: #F8F5EC; }
.nb[data-kind="cards"] .nb-body {
  border-radius: 4px;
  background: #F8F5EC;
  box-shadow: 0 1px 0 #E7E1D3, 0 2px 0 #DBD3C2, 0 3px 0 #CFC6B3, 0 26px 60px rgba(0, 0, 0, 0.5);
}
.nb[data-kind="cards"] .nb-body::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 30px; z-index: 2; pointer-events: none;
  background:
    radial-gradient(circle at 50% 46%, transparent 5px, #2C2C2C 5.5px, #8E8E8E 7px, #2C2C2C 8px, transparent 8.5px) 6px 2px / 24px 24px repeat-x,
    linear-gradient(180deg, #E9E3D5, #F8F5EC);
}
.nb[data-kind="circles"] { --nb-cover: #2C3F62; --nb-paper: #F9F7F1; }
.nb[data-kind="diary"] { --nb-cover: #6E2A25; --nb-paper: #FAF5E8; }
.nb[data-style="spread"] .nb-body {
  border: 11px solid var(--nb-cover); border-radius: 9px;
  background:
    linear-gradient(90deg, transparent 47%, rgba(0, 0, 0, 0.06) 48.6%, rgba(0, 0, 0, 0.22) 50%, rgba(0, 0, 0, 0.06) 51.4%, transparent 53%),
    var(--nb-paper);
}
.nb[data-kind="circles"] .nb-body {
  background:
    linear-gradient(90deg, transparent 47%, rgba(0, 0, 0, 0.06) 48.6%, rgba(0, 0, 0, 0.22) 50%, rgba(0, 0, 0, 0.06) 51.4%, transparent 53%),
    linear-gradient(rgba(60, 110, 190, 0.12) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(90deg, rgba(60, 110, 190, 0.12) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--nb-paper);
}
.nb[data-style="spread"] .view-pane { overflow: hidden; }
.page-l, .page-r { min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Notebook headings are written in pen. */
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 0 0 16px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font: 700 30px/1.1 var(--font-hand); color: var(--pen); letter-spacing: 0.005em; }
.view-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.view-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; max-width: 60ch; line-height: 1.45; }
.view-empty { max-width: 520px; margin: 40px auto; text-align: center; color: var(--muted); font: 18px/1.45 var(--font-hand); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.primary { background: var(--accent); color: #FFF8F2; padding: 8px 18px; border-radius: 8px; font-weight: 600; font-family: var(--font-ui); }
.quiet { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.quiet:hover { background: var(--accent-soft); color: var(--ink); }
.quiet.danger:hover { color: #B4412F; background: rgba(180, 65, 47, 0.1); }
.bordered { border: 1px solid rgba(0, 0, 0, 0.18); }

/* ---------- Index cards on the sketch pad ---------- */
.cards-view { padding: 46px max(20px, 3.4%) 40px; }
.card-group { margin: 22px 0 10px; font: 700 20px/1.2 var(--font-hand); color: var(--pen); }
.card-group.is-act { color: var(--accent); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 18px; }
.card {
  --card-rule: color-mix(in srgb, var(--rv-1) 55%, transparent);
  --card-line: color-mix(in srgb, var(--rv-0) 16%, transparent);
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: #FFFFFE; border-radius: 2px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(40, 25, 10, 0.16);
  padding: 10px 14px 12px; cursor: grab; transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.card:nth-child(3n+1) { transform: rotate(-0.5deg); }
.card:nth-child(3n+2) { transform: rotate(0.4deg); }
.card:hover { transform: translateY(-2px) rotate(0deg); box-shadow: 0 2px 2px rgba(0, 0, 0, 0.12), 0 10px 20px rgba(40, 25, 10, 0.2); }
.card.dragging { opacity: 0.4; cursor: grabbing; }
.card.drop-before::before, .card.drop-after::after { content: ""; position: absolute; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: var(--accent); }
.card.drop-before::before { left: -10px; }
.card.drop-after::after { right: -10px; }
.card-top { display: flex; justify-content: space-between; font: 11px var(--font-type); color: var(--muted); font-variant-numeric: tabular-nums; }
.card-head {
  display: block; width: 100%; text-align: left; margin: 4px 0 0; padding: 0 0 7px;
  font: 700 13.5px/1.35 var(--font-type); letter-spacing: 0.01em; overflow-wrap: anywhere;
  border-bottom: 1.5px solid var(--card-rule); border-radius: 0;
}
.card-head:hover { color: var(--accent); }
.card-sum {
  width: 100%; min-height: 4.5em; margin-top: 6px; padding: 0; border: 0; resize: vertical;
  font: 14px/1.5em var(--font-type); color: var(--ink); background-color: transparent;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.5em - 1px), var(--card-line) calc(1.5em - 1px), var(--card-line) 1.5em);
  background-attachment: local;
}
.card-sum:focus { outline: none; }
.card-sum::placeholder { color: var(--muted); opacity: 0.6; }
.card-foot { display: flex; flex-wrap: wrap; gap: 5px 8px; margin-top: 8px; align-items: center; }
.card-foot:empty { display: none; }
.card-chars { font: 11px var(--font-type); letter-spacing: 0.04em; color: var(--muted); }
.card-badge { font: 500 11px var(--font-ui); padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

/* ---------- Story circles on graph paper ---------- */
/* One sticky flag per circle, stuck over the top edge of the right page (the adhesive strip shows
   through at the top); they have their own row above the steps, so nothing on the page is ever under them. */
.circle-tabs { grid-column: 2; grid-row: 1; display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; padding: 0 28px 10px 42px; min-height: 0; }
.circle-tabs button {
  position: relative; display: inline-flex; gap: 8px; align-items: center;
  padding: 11px 12px 6px 13px; border-radius: 0 0 4px 4px;
  font: 700 15px/1.2 var(--font-hand); color: #2A2A2A;
  background: #FFE58A; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.16), 0 1px 0 rgba(0, 0, 0, 0.06);
  transform: rotate(-0.8deg); transform-origin: 50% 0; transition: transform 0.15s;
}
.circle-tabs button::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 7px; background: rgba(0, 0, 0, 0.09); }
.circle-tabs button:nth-child(4n+2) { background: #FFC2D1; transform: rotate(0.6deg); }
.circle-tabs button:nth-child(4n+3) { background: #BFE3FF; transform: rotate(-0.3deg); }
.circle-tabs button:nth-child(4n+4) { background: #C8F0C2; transform: rotate(0.9deg); }
.circle-tabs button:hover { transform: translateY(2px); }
.circle-tabs button[aria-selected="true"] { transform: translateY(4px); box-shadow: 0 0 0 2px var(--pen), 0 3px 5px rgba(0, 0, 0, 0.2); }
.circle-tabs button.circle-add { background: transparent; border: 1.5px dashed rgba(39, 57, 106, 0.45); border-top: 0; color: var(--pen); box-shadow: none; padding: 8px 12px 5px; transform: none; }
.circle-tabs button.circle-add::before { display: none; }
.tab-count { font: 11px var(--font-ui); color: rgba(0, 0, 0, 0.55); font-variant-numeric: tabular-nums; }
.circle-layout { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto minmax(0, 1fr); }
.circle-side { grid-row: 1 / 3; padding: 30px 46px 30px 36px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.steps.page-r { grid-column: 2; grid-row: 2; }
.circle-name-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.circle-name-field input { font: 700 24px/1.2 var(--font-hand); color: var(--pen); background: transparent; border: 0; border-bottom: 1.5px solid rgba(39, 57, 106, 0.35); border-radius: 0; padding: 2px 0; }
.circle-name-field input:focus { outline: none; border-bottom-color: var(--pen); }
.circle-diagram { width: 100%; max-width: 440px; align-self: center; height: auto; }
.dg-ring { fill: none; stroke: rgba(39, 57, 106, 0.5); stroke-width: 2; }
.dg-done { fill: none; stroke: var(--pen); stroke-width: 4; stroke-linecap: round; }
.dg-axis { stroke: rgba(39, 57, 106, 0.4); stroke-width: 1; stroke-dasharray: 4 4; }
.dg-zone { fill: var(--muted); font: 700 13px var(--font-hand); letter-spacing: 0.12em; }
.dg-step { cursor: pointer; outline: none; }
.dg-step circle { fill: #FFFEFA; stroke: rgba(39, 57, 106, 0.6); stroke-width: 1.5; transition: fill 0.15s; }
.dg-step.is-filled circle { fill: var(--pen); stroke: var(--pen); }
.dg-step.is-selected circle { stroke: var(--accent); stroke-width: 3; }
.dg-step:focus-visible circle { stroke: var(--accent); stroke-width: 3; }
.dg-num { fill: var(--pen); font: 700 15px var(--font-hand); text-anchor: middle; pointer-events: none; }
.dg-step.is-filled .dg-num { fill: #FFFEFA; }
.dg-label { fill: #2A2A2A; font: 400 15px var(--font-hand); pointer-events: none; }
.circle-side .danger { align-self: flex-start; }
.circle-side .danger.confirm, .diary-page .danger.confirm, .rev-actions .danger.confirm, .lock-box .danger.confirm { color: #fff; background: #B4412F; }
.steps { list-style: none; margin: 0; padding: 6px 34px 30px 46px; display: flex; flex-direction: column; gap: 14px; }
.step { padding: 4px 0 12px; border-bottom: 1px solid rgba(39, 57, 106, 0.16); display: flex; flex-direction: column; gap: 6px; }
.step.is-selected .step-num { background: var(--accent); }
.step-head { display: flex; gap: 10px; align-items: flex-start; }
.step-num { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 700 14px var(--font-hand); background: var(--pen); color: #FFFEFA; }
.step-name { font: 700 19px/1.2 var(--font-hand); color: var(--pen); }
.step-prompt { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.step-note { width: 100%; font: 17px/26px var(--font-hand); color: #1F2A48; background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(39, 57, 106, 0.18); border-radius: 4px; padding: 4px 9px; resize: vertical; }
.step-note:focus { outline: none; border-color: var(--pen); background: #FFFFFF; }
.step-link { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.step-link select { font: 12.5px var(--font-ui); color: var(--ink); background: #FFFFFF; border: 1px solid rgba(0, 0, 0, 0.16); border-radius: 6px; padding: 4px 7px; max-width: 100%; min-width: 0; }
.step-link .quiet { font-size: 12.5px; padding: 4px 9px; }
.step-missing { font-size: 12px; color: var(--note); }

/* ---------- The diary: an index on the left page, the day's page on the right ---------- */
.diary-layout { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; }
.diary-list { padding: 30px 46px 24px 36px; display: flex; flex-direction: column; gap: 10px; }
.diary-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.diary-tools input[type="search"] { flex: 1; min-width: 140px; font: 13px var(--font-ui); color: var(--ink); background: rgba(255, 255, 255, 0.7); border: 1px solid rgba(0, 0, 0, 0.14); border-radius: 6px; padding: 6px 9px; }
.diary-goto { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.diary-goto input { font: 12.5px var(--font-ui); color: var(--ink); background: rgba(255, 255, 255, 0.7); border: 1px solid rgba(0, 0, 0, 0.14); border-radius: 6px; padding: 4px 6px; }
.diary-tools input:focus, .diary-goto input:focus { outline: none; border-color: var(--pen); }
.diary-list ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.diary-list button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; width: 100%; text-align: left; padding: 7px 6px; border-bottom: 1px solid rgba(60, 90, 150, 0.16); border-radius: 0; }
.diary-list button:hover { background: rgba(255, 220, 120, 0.18); }
.diary-list button[aria-current="true"] { background: rgba(255, 214, 90, 0.36); }
.d-date { font: 700 18px/1.2 var(--font-hand); color: var(--pen); }
.d-sub { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; align-self: center; }
.d-preview { grid-column: 1 / -1; font: 15px/1.3 var(--font-hand); color: #4A4A4A; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-preview em { font-style: normal; opacity: 0.55; }
.d-none { font: 16px var(--font-hand); color: var(--muted); padding: 8px 6px; }
.diary-page { padding: 30px 36px 18px 50px; display: flex; flex-direction: column; gap: 6px; }
.diary-page header { display: flex; flex-direction: column; gap: 2px; padding-bottom: 6px; }
.diary-page h3 { margin: 0; font: 700 26px/1.15 var(--font-hand); color: var(--pen); text-wrap: balance; }
.d-meta { font-size: 12px; color: var(--muted); }
.diary-page textarea {
  flex: 1; min-height: 50vh; width: 100%; border: 0; resize: none; padding: 1px 0 0;
  color: #1F2A48; font: 19px/32px var(--font-hand);
  background-color: transparent;
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(60, 110, 190, 0.28) 31px 32px);
  background-attachment: local;
}
.diary-page textarea:focus { outline: none; }
.diary-page textarea::placeholder { color: var(--muted); opacity: 0.7; }
.diary-page footer { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Narrow screens: notebooks open to one page at a time and scroll as a whole. */
@media (max-width: 760px) {
  .nb[data-style="spread"] .view-pane { overflow-y: auto; }
  .nb[data-style="spread"] .nb-body { background: var(--nb-paper); }
  .nb[data-kind="circles"] .nb-body { background: linear-gradient(rgba(60, 110, 190, 0.12) 1px, transparent 1px) 0 0 / 22px 22px, linear-gradient(90deg, rgba(60, 110, 190, 0.12) 1px, transparent 1px) 0 0 / 22px 22px, var(--nb-paper); }
  .diary-layout { position: static; display: block; }
  .circle-layout { position: static; display: flex; flex-direction: column; }
  .page-l, .page-r { overflow: visible; }
  .circle-tabs { order: -1; padding: 0 18px 8px; }
  .circle-side, .diary-list, .diary-page { padding: 20px 18px; }
  .steps { padding: 0 18px 24px; }
  .diary-list ol { max-height: 220px; overflow-y: auto; }
}
@media (max-width: 760px) { .nb-close { padding: 0 12px; } .nb-out .page-count { display: none; } }

/* ---------- The filing cabinet ---------- */
.cabinet-stage {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: calc(64px + env(safe-area-inset-top, 0px)) 16px calc(var(--strip-h) + 14px);
  background: rgba(14, 8, 3, 0); transition: background 0.3s;
}
.cabinet-stage.in { background: rgba(14, 8, 3, 0.5); }
.cabinet {
  --steel-1: #9AA195; --steel-2: #79806F; --steel-3: #5E6457;
  position: relative;
  width: min(660px, 100%); height: min(100%, 820px);
  display: flex; flex-direction: column; gap: 8px;
  padding: 0 16px 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.12), transparent 8%, transparent 92%, rgba(0, 0, 0, 0.16)), linear-gradient(180deg, var(--steel-1), var(--steel-2));
  border-radius: 6px 6px 3px 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 30px 70px rgba(0, 0, 0, 0.6), 0 4px 10px rgba(0, 0, 0, 0.4);
  transform: translateX(min(110vw, 900px)) rotate(2deg);
  transition: transform 0.48s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cabinet-stage.in .cabinet { transform: none; }
.cab-top { height: 12px; margin: 0 -16px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, #B9BFB3, var(--steel-1)); box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2); }
.cab-drawer { display: block; width: 100%; flex: none; }
.cab-drawer.cab-open { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cab-inside {
  position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  margin: 0 8px; padding: 34px 22px 0;
  background: linear-gradient(180deg, #1D1F1C, #3A3E37 30%, #474C43);
  box-shadow: inset 16px 0 20px -10px rgba(0, 0, 0, 0.7), inset -16px 0 20px -10px rgba(0, 0, 0, 0.7), inset 0 26px 30px -12px rgba(0, 0, 0, 0.75);
  transform-origin: 50% 100%;
  transform: scaleY(0.2);
  transition: transform 0.5s 0.12s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cabinet-stage.in .cab-inside { transform: none; }
.cab-files { display: flex; flex-direction: column; justify-content: flex-end; min-height: 100%; padding-top: 12px; }
.cab-front, .cab-shut {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px;
  height: 78px; margin: 0 -6px; flex: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 30%, rgba(0, 0, 0, 0.12)), linear-gradient(180deg, var(--steel-1), var(--steel-2));
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 3px 6px rgba(0, 0, 0, 0.35);
}
.cab-shut { margin: 0 2px; width: auto; }
.cab-shut:hover { filter: brightness(1.07); }
.cab-card {
  min-width: 150px; padding: 3px 12px; text-align: center;
  background: #FBF7EC; color: #2E2A24;
  font: 700 12px/1.3 var(--font-type); letter-spacing: 0.08em;
  box-shadow: 0 0 0 3px #A98A4C, 0 0 0 4px rgba(0, 0, 0, 0.35), inset 0 1px 2px rgba(0, 0, 0, 0.12);
  border-radius: 1px;
}
.cab-front .cab-card { text-transform: uppercase; letter-spacing: 0.2em; }
.cab-handle { width: 110px; height: 12px; border-radius: 6px; background: linear-gradient(180deg, #FAFAF7, #B5B6B1 50%, #868782); box-shadow: 0 3px 3px rgba(0, 0, 0, 0.45), inset 0 1px 0 #FFFFFF; }
.cab-base { height: 16px; margin: 0 -16px; flex: none; background: linear-gradient(180deg, #4A5045, #2E322B); border-radius: 0 0 3px 3px; }
.cab-close {
  position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 41; height: 36px;
  padding: 7px 14px; border-radius: 999px; font: 600 12.5px var(--font-ui); color: #F4EBDC;
  background: rgba(24, 14, 7, 0.65);
}
@media (max-height: 640px) { .cab-front, .cab-shut { height: 58px; gap: 6px; } }

/* Hanging folders, back to front, each with a typed tab. */
.folder {
  --f1: #EBD49A; --f2: #D4B775;
  position: relative; height: 104px; margin-top: -58px; flex: none;
  transform: scale(calc(1 - var(--depth, 0) * 0.08)); transform-origin: 50% 100%;
  translate: 0 0; transition: translate 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s;
}
.folder:first-child { margin-top: 0; }
.folder.fmt-play { --f1: #E7AE9A; --f2: #CF8E78; }
.folder.fmt-novel { --f1: #BFD2AE; --f2: #A1B98D; }
.folder.fmt-analog { --f1: #CFC8BE; --f2: #B3AA9D; }
.folder-new { --f1: #F6F1E4; --f2: #E3DACA; }
.folder:hover, .folder:focus-within, .folder.lifted { translate: 0 -18px; }
.folder.pulled { translate: 0 -110px; opacity: 0; transition: translate 0.24s ease-in, opacity 0.24s ease-in; }
.f-open { position: absolute; inset: 0; width: 100%; text-align: left; border-radius: 0; }
.f-open:focus-visible { outline: none; }
.f-tab {
  position: absolute; top: 0; height: 30px; width: 36%; padding: 5px 9px 0;
  background: linear-gradient(180deg, var(--f1), var(--f2) 140%);
  border-radius: 7px 7px 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.f-tab.pos-left { left: 3%; } .f-tab.pos-mid { left: 32%; } .f-tab.pos-right { right: 3%; }
.f-label {
  display: block; padding: 1px 7px; background: #FFFDF6; color: #262320;
  font: 700 12.5px/1.45 var(--font-type); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.f-open:focus-visible .f-label { box-shadow: inset 0 0 0 2px var(--accent); }
.f-body {
  position: absolute; left: 0; right: 0; top: 26px; bottom: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 9px 96px 0 14px;
  background: linear-gradient(180deg, var(--f1), var(--f2));
  border-radius: 3px 3px 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 -4px 10px rgba(0, 0, 0, 0.3);
}
.f-kind { font: 700 10.5px/1.4 var(--font-type); letter-spacing: 0.16em; text-transform: uppercase; color: rgba(40, 30, 15, 0.6); }
.f-meta { font: 12px/1.4 var(--font-ui); color: rgba(40, 30, 15, 0.62); }
.f-stamp {
  margin-top: -2px; padding: 0 6px; border: 2px solid rgba(170, 40, 30, 0.75); border-radius: 3px;
  font: 700 10.5px/1.5 var(--font-type); letter-spacing: 0.12em; text-transform: uppercase; color: rgba(170, 40, 30, 0.85);
  transform: rotate(-3deg);
}
.folder-new .f-label { color: var(--accent); }
.f-del {
  position: absolute; right: 12px; top: 33px; z-index: 1;
  font: 600 11.5px var(--font-ui); color: rgba(40, 30, 15, 0.7);
  padding: 3px 9px; border-radius: 6px; background: rgba(255, 255, 255, 0.4);
  opacity: 0; transition: opacity 0.15s;
}
.folder:hover .f-del, .folder:focus-within .f-del, .f-del.confirm { opacity: 1; }
.f-del:hover { background: rgba(255, 255, 255, 0.7); }
.f-del.confirm { color: #fff; background: #B4412F; }
@media (hover: none) { .f-del { opacity: 0.85; } }

/* ---------- Sheets (dialogs) and the toast: paper on the desk ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 16px;
  background: rgba(14, 8, 3, 0.45);
}
.sheet {
  width: min(480px, 100%); max-height: 85vh; overflow: auto;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--card-edge); border-radius: 6px; box-shadow: var(--shadow);
  padding: 22px 24px;
}
.sheet h2 { margin: 0 0 6px; font: 700 19px/1.25 var(--font-type); text-wrap: balance; }
.sheet p { margin: 0 0 14px; line-height: 1.5; }
.sheet a { color: var(--accent); }
.sheet .fine { color: var(--muted); font-size: 13px; }
.sheet code { font-family: var(--font-type); font-size: 0.95em; }
.keys { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0 0 16px; }
.keys dt { font-weight: 600; font-size: 13px; white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); line-height: 1.45; }
.title-sheet { width: min(520px, 100%); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; margin: 4px 0 18px; }
.fields label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.fields .wide { grid-column: 1 / -1; }
.fields input, .fields textarea {
  font: 15px/1.4 var(--font-type); color: var(--ink);
  background: #FFFFFF; border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px;
  width: 100%; min-width: 0; resize: vertical;
}
.fields input:focus, .fields textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fields input::placeholder, .fields textarea::placeholder { color: var(--muted); opacity: 0.6; }
.sheet-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sheet-actions .spacer { flex: 1; }
@media (max-width: 480px) { .fields { grid-template-columns: minmax(0, 1fr); } }

/* Picking a format: three sheets of paper. */
.format-sheet { width: min(760px, 100%); }
.fmt-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 6px 0 16px; }
.fmt-choice { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 10px 14px; border-radius: 8px; border: 1px solid transparent; text-align: center; }
.fmt-choice:hover, .fmt-choice[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(163, 54, 43, 0.35); }
.fmt-page {
  width: 92px; height: 118px; padding: 16px 12px 0 16px; display: flex; flex-direction: column; gap: 6px;
  background: #FFFFFF; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 6px 14px rgba(40, 25, 10, 0.16);
  transition: transform 0.18s;
}
.fmt-choice:hover .fmt-page { transform: translateY(-3px) rotate(-1deg); }
.fmt-page i { display: block; height: 3px; border-radius: 2px; background: #3A3A3A; opacity: 0.7; }
.fmt-page-screenplay i:nth-child(1) { width: 60%; opacity: 1; }
.fmt-page-screenplay i:nth-child(2), .fmt-page-screenplay i:nth-child(6) { width: 100%; }
.fmt-page-screenplay i:nth-child(3) { width: 26%; margin-left: 34%; }
.fmt-page-screenplay i:nth-child(4), .fmt-page-screenplay i:nth-child(5) { width: 52%; margin-left: 18%; }
.fmt-page-play i:nth-child(1) { width: 40%; margin-left: 30%; opacity: 1; }
.fmt-page-play i:nth-child(2) { width: 60%; margin-left: 40%; opacity: 0.45; }
.fmt-page-play i:nth-child(3) { width: 26%; margin-left: 37%; }
.fmt-page-play i:nth-child(4), .fmt-page-play i:nth-child(5) { width: 100%; }
.fmt-page-play i:nth-child(6) { width: 26%; margin-left: 37%; }
.fmt-page-novel { padding-left: 12px; }
.fmt-page-novel i:nth-child(1) { width: 40%; margin: 6px 0 4px 30%; opacity: 1; }
.fmt-page-novel i:nth-child(2), .fmt-page-novel i:nth-child(5) { width: 88%; margin-left: 12%; }
.fmt-page-novel i:nth-child(3), .fmt-page-novel i:nth-child(4), .fmt-page-novel i:nth-child(6) { width: 100%; }
/* Analog: lines typed at the typist's own tab stops. */
.fmt-page-analog i:nth-child(1) { width: 30%; margin-left: 50%; }
.fmt-page-analog i:nth-child(2) { width: 34%; margin: 4px 0 4px 0; }
.fmt-page-analog i:nth-child(3) { width: 80%; margin-left: 15%; }
.fmt-page-analog i:nth-child(4) { width: 95%; }
.fmt-page-analog i:nth-child(5) { width: 60%; }
.fmt-page-analog i:nth-child(6) { width: 26%; margin-left: 50%; margin-top: 4px; }
.fmt-name { font: 700 14px var(--font-type); margin-top: 6px; }
.fmt-desc { font-size: 12px; color: var(--muted); line-height: 1.35; }
@media (max-width: 720px) { .fmt-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .fmt-choices { grid-template-columns: minmax(0, 1fr); } .fmt-choice { flex-direction: row; text-align: left; } .fmt-page { display: none; } }

/* The Tab stops sheet: the typewriter's scale, a column to a step. */
.tabs-sheet { width: min(640px, 100%); }
.tab-ruler { display: grid; grid-template-columns: repeat(65, minmax(0, 1fr)); height: 46px; margin: 4px 0 6px; border-bottom: 1px solid var(--rule); }
.tr-col { position: relative; padding: 0; border-radius: 0; min-width: 0; }
.tr-col::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 1px; height: 7px; background: var(--muted); opacity: 0.5; }
.tr-col.five::after { height: 12px; opacity: 0.7; }
.tr-col.ten::after { height: 18px; opacity: 0.9; }
.tr-col span { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); font: 600 10px var(--font-ui); color: var(--muted); }
.tr-col:hover:not(:disabled) { background: var(--accent-soft); }
.tr-col[aria-pressed="true"]::before { content: ""; position: absolute; left: 50%; top: 14px; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--accent); border-radius: 2px; }
.tr-col:disabled { cursor: default; }
.tabs-count { min-height: 1.4em; }
.name-sheet { width: min(420px, 100%); }

.toast {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top, 0px)); z-index: 60;
  transform: translate(-50%, -14px) rotate(-0.6deg); opacity: 0; pointer-events: none;
  max-width: min(560px, calc(100% - 32px));
  background: #FFFDF6; color: var(--ink);
  padding: 9px 16px; font: 14px/1.4 var(--font-type);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12), 0 8px 20px rgba(25, 14, 5, 0.3);
  transition: opacity 0.2s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) rotate(-0.6deg); }

/* ---------- Narrow screens: the notepad becomes a drawer of its own ---------- */
@media (max-width: 999px) {
  :root:not([data-ui="spec"]) .sidebar { top: calc(60px + env(safe-area-inset-top, 0px)); bottom: calc(var(--strip-h) + 14px); left: 10px; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(14, 8, 3, 0.35); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .sidebar-open .scrim { opacity: 1; pointer-events: auto; }
}
@media (max-width: 760px) {
  .page-count, .save-state { display: none; }
  .ft-kind { display: none; }
}
@media (max-width: 480px) {
  .deskbar .rev-badge { display: none; } /* (.deskbar: the badge's own rule comes later in this file) */
  .drawer-plate { display: none; }
}

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

/* ---------- Settings panel (web and iPad; the desktop app opens its own window) ---------- */
.settings-sheet { width: min(620px, 100%); height: min(720px, 90vh); max-height: none; display: flex; flex-direction: column; gap: 12px; padding: 0 0 16px; overflow: hidden; }
/* The frame is made as tall as the Settings page and this wrap scrolls it: on the iPad a frame can't be scrolled by touch. */
.settings-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.settings-sheet iframe { display: block; width: 100%; min-height: 100%; border: 0; background: transparent; }
.settings-sheet .primary { align-self: flex-end; margin-right: 20px; }

/* ---------- Revision marks ---------- */
.rv-c0 { --rv: var(--rv-0); } .rv-c1 { --rv: var(--rv-1); } .rv-c2 { --rv: var(--rv-2); } .rv-c3 { --rv: var(--rv-3); }
.rv-c4 { --rv: var(--rv-4); } .rv-c5 { --rv: var(--rv-5); } .rv-c6 { --rv: var(--rv-6); } .rv-c7 { --rv: var(--rv-7); }
.rv-text { color: var(--rv); }
.rv-text.rv-now { background: color-mix(in srgb, var(--rv) 13%, transparent); border-radius: 2px; }
.rv-stars { position: absolute; top: 0; left: 0; right: 0; height: 0; z-index: 4; pointer-events: none; }
.rv-star { position: absolute; right: calc(var(--pad-r) * -0.55); color: var(--rv); font-weight: 700; line-height: var(--lh, 1.5); }
.rv-star:not(.rv-now) { opacity: 0.55; }

.rev-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; flex: none;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--rv); background: #FBF8F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.rev-badge:hover { background: #FFFFFF; }
.rev-dot, .rev-swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--rv); flex: none; }

/* ---------- Revisions panel ---------- */
#panel-revisions { display: flex; flex-direction: column; gap: 10px; padding: 6px 14px 16px; }
#panel-revisions[hidden] { display: none; }
.rev-intro { display: flex; flex-direction: column; gap: 12px; padding: 4px 2px; }
.rev-intro p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.rev-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.rev-field select { font: inherit; font-size: 13px; padding: 5px 8px; border-radius: 7px; border: 1px solid var(--rule); background: #FFFFFF; color: var(--ink); }
.wide-btn { width: 100%; text-align: center; }
.rev-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px; background: color-mix(in srgb, var(--rv) 10%, #FFFFFF); }
.rev-head .rev-swatch { width: 12px; height: 12px; }
.rev-name { font-weight: 600; }
.rev-meta { font-size: 12px; color: var(--muted); }
.rev-stats { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.rev-show { display: flex; }
.rev-show button { flex: 1; }
.rev-nav { display: flex; gap: 6px; }
.rev-nav button { flex: 1; font-size: 12.5px; border: 1px solid var(--rule); }
.rev-changes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rev-changes button { display: grid; grid-template-columns: 2.6em minmax(0, 1fr); gap: 1px 6px; width: 100%; text-align: left; padding: 7px 8px; border-radius: 6px; }
.rev-changes button:hover { background: var(--accent-soft); }
.rev-page { grid-row: span 2; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.rev-snip { font-family: var(--font-type); font-size: 12.5px; overflow-wrap: anywhere; }
.rev-scene { font-size: 11px; letter-spacing: 0.02em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rev-history { display: flex; flex-direction: column; gap: 4px; }
.rev-past { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 4px; }
.rev-past .rev-meta { margin-left: auto; }
.rev-actions { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--rule); }

/* ---------- Page locking ---------- */
.lock-box { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--rule); }
.rev-help { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.lock-head { display: flex; align-items: center; gap: 10px; }
.lock-head svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Character name suggestions ---------- */
.ac-box {
  position: fixed; z-index: 40; min-width: 200px; max-width: 280px; padding: 4px;
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 8px; box-shadow: var(--shadow);
  font-family: var(--font-type); font-size: 14px;
}
.ac-item { padding: 5px 10px; border-radius: 5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item[aria-selected="true"] { background: var(--accent-soft); color: var(--ink); }
.ac-hint { padding: 4px 10px 2px; font: 11px var(--font-ui); color: var(--muted); border-top: 1px solid var(--rule); margin-top: 3px; }
.ac-ghost { color: var(--muted); opacity: 0.55; pointer-events: none; }

/* ---------- Things on the desk ---------- */
/* They stand on the desk only when you sit back to look around the room. */
/* What's on the desk and the wall shows whenever the wall is in view: looking up at the window, or
   sitting back to see the room. Looking down at the keys, it's out of sight. */
.decor { position: fixed; inset: 0; z-index: 3; pointer-events: none; display: none; }
[data-look="window"] .decor { display: block; }
.nb-out .decor, .focus .decor, .nb-out .decor-wall, .focus .decor-wall { opacity: 0; pointer-events: none; }
.decor, .decor-wall { transition: opacity 0.4s; }
.decor-item { position: absolute; transform: translate(-50%, -100%); pointer-events: none; }
.decor-item svg { display: block; width: 100%; height: auto; overflow: visible; }
.decor-item.is-timer, .decor-item.is-player, .decor-item.is-candle, .decor-item.is-bobble, .decor-item.is-frame, .decor-item.is-tray, .is-cat, .di-globe { pointer-events: auto; cursor: pointer; }
/* On the wall: posters, frames and clocks hang centred where you put them. */
.decor-item.on-wall { transform: translate(-50%, -50%); }
.decor-item { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.decor-item.flipped > svg { transform: scaleX(-1); }
/* Right-click finds the thing under the pointer by turning pointing on for a moment (decor.js). */
.decor.probing .decor-item { pointer-events: auto !important; }
/* The right-click menu for a thing on the desk or the wall */
.menu.decor-menu { position: fixed; right: auto; z-index: 65; min-width: 210px; }
.decor-menu[hidden] { display: none; }
.decor-menu:focus { outline: none; }
.dm-size { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 4px 4px 10px; }
.menu .dm-size .stepper button:disabled { color: var(--muted); opacity: 0.4; cursor: default; background: none; }
.decor-item.on-wall:not(.is-clock) > svg { filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.28)); }
/* In the tray, no filters at all: WebKit (the Mac and iPad apps) can paint filtered pictures in the
   wrong place or not at all inside it. Posters and frames are rectangles, so a box-shadow does. */
.dt-card[data-id^="poster-"] svg, .dt-card[data-id="frame-wall"] svg, .dt-card[data-id="frame-gilt"] svg { box-shadow: 0 3px 6px rgba(0, 0, 0, 0.22); }
.has-pic .fr-empty { display: none; }
.decor-item.is-frame:not(.has-pic):hover .fr-empty rect { fill: #EDE5D6; }
.ck-tock .ck-colon { opacity: 0.25; }
[data-sky="night"] .decor-item.is-glow { filter: none; }
.decor-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
[data-sky="night"] .decor-item { filter: brightness(0.72) saturate(0.9); }
[data-sky="night"] .decor-item.is-candle:not(.unlit) { filter: none; }

/* Arranging */
.decorating .decor-item { pointer-events: auto; cursor: grab; }
.decorating .decor-item:hover { filter: drop-shadow(0 0 0 2px #fff) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3)); }
.decor-item.dragging { cursor: grabbing; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.35)); }
.decor-item.to-tray { opacity: 0.45; }

/* String lights along the top of the wall */
.decor-wall { position: absolute; left: 3vw; right: 3vw; top: max(58px, 7vh); height: 60px; display: none; }
[data-room] .decor-wall { display: block; }
.decor-wall svg { width: 100%; height: 100%; display: block; }
.df-bulb, .df-halo2 { animation: df-twinkle 3.8s ease-in-out infinite; }
.df-b1 { animation-delay: -1.3s; } .df-b2 { animation-delay: -2.5s; }
@keyframes df-twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
:root:not([data-sky="night"]) .df-halo2 { opacity: 0.35; }

/* Candles flicker; snuffed, the flame and its glow go. */
.df-flame { animation: df-flicker 2.2s ease-in-out infinite; }
.decor-item:nth-child(2n) .df-flame { animation-duration: 2.9s; }
@keyframes df-flicker { 0%, 100% { transform: scale(1, 1) rotate(0); } 25% { transform: scale(0.94, 1.06) rotate(-2deg); } 50% { transform: scale(1.04, 0.95) rotate(1.5deg); } 75% { transform: scale(0.97, 1.03) rotate(-1deg); } }
.unlit .df-flame { display: none; }
.df-halo { opacity: 0.6; }
[data-sky="night"] .df-halo { opacity: 1; }

/* Coffee steams, the cat sleeps */
.df-wisp { animation: df-steam 4s ease-in-out infinite; opacity: 0; }
.df-wisp2 { animation-delay: -2s; }
@keyframes df-steam { 0% { opacity: 0; transform: translateY(6px); } 30% { opacity: 0.9; } 100% { opacity: 0; transform: translateY(-12px); } }
.df-breathe { animation: df-breathe 4.2s ease-in-out infinite; }
/* The cat, Estelle (decor.js): asleep, standing, walking (legs in turn, a little bob, the tail
   going), being petted (head up, happy eyes, purring), and turning round: she swings to face you
   (.cat-front) and on round the other way. */
.is-cat .cat-curl { transition: opacity 0.2s; }
.is-cat .cat-stand, .is-cat .cat-front { transition: opacity 0.12s; } /* (quick, so the turn doesn't look doubled) */
/* (These hold wherever a cat is drawn, the tray included: asleep, eyes shut, one magic eye.) */
.cat-stand, .cat-front { opacity: 0; }
.is-cat.cat-turning .cat-front { opacity: 1; }
.is-cat.cat-turning .cat-stand, .is-cat.cat-turning .cat-curl { opacity: 0; }
/* Her magic (cloudy) eye is her left one, whichever way she's facing. */
.eye-a .magic, .eye-b .clear { display: none; }
.is-cat.flipped .eye-a .magic, .is-cat.flipped .eye-b .clear { display: inline; }
.is-cat.flipped .eye-a .clear, .is-cat.flipped .eye-b .magic { display: none; }
.is-cat.cat-up:not(.cat-turning) .cat-stand, .is-cat.cat-walk:not(.cat-turning) .cat-stand { opacity: 1; }
.is-cat.cat-up .cat-curl, .is-cat.cat-walk .cat-curl { opacity: 0; }
.is-cat .cat-tail { animation: cat-tail 2.6s ease-in-out infinite alternate; }
@keyframes cat-tail { from { transform: rotate(-7deg); } to { transform: rotate(9deg); } }
.is-cat.cat-walk .leg-a { animation: cat-step 0.5s ease-in-out infinite alternate; }
.is-cat.cat-walk .leg-b { animation: cat-step 0.5s ease-in-out infinite alternate-reverse; }
@keyframes cat-step { from { transform: rotate(17deg); } to { transform: rotate(-17deg); } }
.is-cat.cat-walk .cat-body, .is-cat.cat-walk .cat-shead { animation: cat-bob 0.25s ease-in-out infinite alternate; }
@keyframes cat-bob { to { transform: translateY(-1.4px); } }
.is-cat .cat-head { transition: transform 0.35s ease-out; }
/* Her face: asleep (closed eyes, curled up), awake (open eyes), happy (being petted, or a slow
   blink: closed, smiling eyes), or annoyed (lids down, ears back, tail swishing). */
.is-cat .eyes-open, .is-cat .eyes-happy, .is-cat .eyes-sleep, .is-cat .lids-cross { transition: opacity 0.15s; }
.eyes-happy, .lids-cross, .cat-curl .eyes-open { opacity: 0; }
.is-cat.cat-pet .eyes-happy, .is-cat.cat-happy .eyes-happy { opacity: 1; }
.is-cat.cat-pet .eyes-open, .is-cat.cat-happy .eyes-open,
.is-cat.cat-pet .eyes-sleep, .is-cat.cat-happy .eyes-sleep, .is-cat.cat-annoyed .eyes-sleep { opacity: 0; }
.is-cat.cat-annoyed .cat-curl .eyes-open, .is-cat.cat-annoyed .lids-cross { opacity: 1; }
.is-cat.cat-annoyed .eyes-happy { opacity: 0; }
.is-cat .ear { transition: transform 0.25s ease-out; }
.is-cat.cat-annoyed .ear-l { transform: rotate(-30deg); }
.is-cat.cat-annoyed .ear-r { transform: rotate(30deg); }
.is-cat.cat-annoyed .cat-head { transform: rotate(-6deg) translateY(-2px); }
.is-cat.cat-annoyed .cat-tail { animation: cat-swish 0.38s ease-in-out infinite alternate; }
@keyframes cat-swish { from { transform: rotate(-14deg); } to { transform: rotate(12deg); } }
.is-cat.cat-pet .cat-head { transform: rotate(-10deg) translateY(-3px); }
.is-cat.cat-pet .df-breathe { animation: cat-purr 0.11s linear infinite; }
@keyframes cat-purr { 50% { transform: translateY(0.6px); } }
.is-cat.cat-pet .df-zzz, .is-cat.cat-up .df-zzz, .is-cat.cat-walk .df-zzz, .is-cat.cat-annoyed .df-zzz { display: none; } /* (their own animation sets their opacity) */
/* Walking behind the typewriter, she's in a layer under the desk's paper and machine. */
.decor.decor-back { z-index: 2; }
.cat-heart { position: fixed; z-index: 40; pointer-events: none; color: #E86A80; font: 16px/1 Georgia, serif; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
@keyframes df-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.012, 1.035); } }
.df-zzz { animation: df-zzz 4.2s ease-in-out infinite; }
@keyframes df-zzz { 0%, 100% { opacity: 0; transform: translateY(4px); } 50% { opacity: 0.75; transform: translateY(-3px); } }

/* Music players move only while something's playing */
.df-reel, .df-platter { transition: none; }
.playing .df-reel { animation: df-turn 2.4s linear infinite; }
.playing .df-platter { animation: df-turn 1.8s linear infinite; }
@keyframes df-turn { to { transform: rotate(360deg); } }
.df-arm { transition: transform 0.8s ease; transform: rotate(-14deg); }
.playing .df-arm { transform: rotate(0); }
.playing .df-led { fill: #FF5A47; }
.df-bars rect { transform-box: fill-box; transform-origin: bottom; }
.playing .df-bars rect { animation: df-eq 0.9s ease-in-out infinite alternate; }
.playing .df-bars rect:nth-child(2n) { animation-duration: 0.7s; }
.playing .df-bars rect:nth-child(3n) { animation-duration: 1.1s; }
@keyframes df-eq { from { transform: scaleY(0.3); } to { transform: scaleY(1); } }
:not(.playing) > svg .df-bars { opacity: 0.25; }

@media (prefers-reduced-motion: reduce) {
  .df-flame, .df-wisp, .df-breathe, .df-zzz, .df-bulb, .df-halo2, .playing .df-reel, .playing .df-platter, .playing .df-bars rect { animation: none; }
  .df-wisp { opacity: 0.5; }
}

/* The Decorate button, with the time you have to spend */
.decor-btn { position: relative; }
.decor-count {
  position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #E8B04B; color: #3A2410; font: 700 10px/16px var(--font-ui); text-align: center;
}
.decor-btn.pulse { animation: df-pulse 0.9s ease-out; }
@keyframes df-pulse { 0% { box-shadow: 0 0 0 0 rgba(232, 176, 75, 0.7); } 100% { box-shadow: 0 0 0 14px rgba(232, 176, 75, 0); } }

/* The tray: shelves of everything you have and could have */
.decor-tray {
  /* Over the wall and the window, so the whole desk stays in view while you arrange it. */
  position: fixed; z-index: 27; left: 0; right: 0; margin: 0 auto; /* (centred without a transform: see .dt-card below) */
  top: calc(58px + env(safe-area-inset-top, 0px));
  width: min(880px, calc(100vw - 24px)); max-height: min(400px, calc(var(--wall-y, 60vh) - 74px));
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 10px;
  background: var(--card); color: var(--ink); border: 1px solid var(--card-edge); border-radius: 14px; box-shadow: var(--shadow);
  font-family: var(--font-ui);
}
.dt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dt-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dt-title b { font-size: 15px; }
.dt-title span { font-size: 12.5px; color: var(--muted); }
.dt-shelves { display: flex; gap: 4px; flex-wrap: wrap; }
.dt-shelves button { padding: 5px 11px; border-radius: 999px; font-size: 12.5px; color: var(--muted); }
.dt-shelves button[aria-selected="true"] { background: var(--ink); color: var(--card); }
.dt-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; overflow-y: auto; padding: 2px; }
.dt-card {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 6px 9px; border-radius: 10px;
  background: rgba(90, 60, 30, 0.06); border: 1px solid transparent; text-align: center; position: relative;
}
.dt-card:hover { border-color: var(--card-edge); background: rgba(90, 60, 30, 0.1); }
.dt-art { height: 74px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.dt-art svg { max-height: 72px; max-width: 92px; width: auto; height: auto; overflow: visible; }
.dt-view { width: 96px; height: 62px; border-radius: 4px; overflow: hidden; display: block; box-shadow: inset 0 0 0 3px #EDE3D1; }
.dt-view svg { width: 100%; height: 100%; max-width: none; max-height: none; }
.dt-name { font-size: 12.5px; font-weight: 600; }
.dt-status { font-size: 11.5px; color: var(--muted); }
.dt-card[data-state="placed"] .dt-status { color: #3F7A4A; }
.dt-card[data-state="placed"] { box-shadow: inset 0 0 0 1.5px rgba(63, 122, 74, 0.45); }
.dt-card[data-state="buy"] .dt-status { color: var(--accent); font-weight: 600; }
.dt-card[data-state="locked"] .dt-art { opacity: 0.4; }
.dt-need { width: 70%; height: 3px; border-radius: 2px; background: rgba(90, 60, 30, 0.15); overflow: hidden; }
.dt-need i { display: block; height: 100%; background: #E8B04B; }
.dt-hint { margin: 0; font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* ---------- The timer ---------- */
.pomo {
  position: fixed; z-index: 46; width: 272px; padding: 14px 16px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--card); color: var(--ink); border: 1px solid var(--card-edge); border-radius: 14px; box-shadow: var(--shadow);
  font-family: var(--font-ui);
}
.pm-mode { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: #B4412F; font-weight: 600; }
.pomo.on-break .pm-mode { color: #3F7A4A; }
.pm-time { font: 600 46px/1 var(--font-script); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.pm-buttons { display: flex; gap: 4px; align-items: center; white-space: nowrap; flex-wrap: wrap; justify-content: center; }
.pm-go { min-width: 118px; }
.pomo.on-break .pm-go { background: #3F7A4A; }
/* Time's up on a stretch: the break, or straight on with another stretch. */
.pm-keep { font-size: 13px; padding: 6px 12px; border: 1px solid var(--card-edge); border-radius: 999px; }
.pm-keep[hidden] { display: none; }
.pomo.asking .pm-mode { color: #B4412F; }
.pm-ring { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.pm-lengths { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); }
.pm-lengths label { display: flex; align-items: center; gap: 5px; }
.pm-lengths input { width: 46px; padding: 4px 6px; border-radius: 7px; border: 1px solid var(--card-edge); background: #FFFFFF; color: var(--ink); font: 600 13px var(--font-ui); text-align: center; }
.pm-presets { display: flex; gap: 4px; }
.pm-presets button { padding: 3px 8px; border-radius: 999px; font: 500 11.5px var(--font-ui); color: var(--muted); border: 1px solid transparent; }
.pm-presets button:hover { border-color: var(--card-edge); }
.pm-presets button[aria-pressed="true"] { background: rgba(90, 60, 30, 0.1); color: var(--ink); }
/* In focus mode the top bar fades; the countdown stays, quietly, at the top of the page. */
.focus-timer {
  position: fixed; z-index: 31; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  display: none; height: 26px; padding: 0 11px 0 9px; border-radius: 999px; align-items: center; gap: 6px;
  background: rgba(24, 14, 7, 0.4); color: rgba(255, 244, 228, 0.9); font: 600 12px var(--font-ui); font-variant-numeric: tabular-nums;
  opacity: 0.7; transition: opacity 0.2s;
}
.focus-timer:hover { opacity: 1; }
.focus .focus-timer:not([hidden]) { display: inline-flex; }
.focus-timer::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #E2533F; }
.focus-timer.on-break::before { background: #6FB36F; }
.pm-done { font-size: 11.5px; color: var(--muted); min-height: 14px; }
.pomo-chip {
  height: 28px; padding: 0 11px 0 9px; border-radius: 999px; font: 600 12px var(--font-ui); font-variant-numeric: tabular-nums;
  background: rgba(24, 14, 7, 0.5); color: #FFF4E4; display: inline-flex; align-items: center; gap: 6px;
}
.pomo-chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #E2533F; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18); }
.pomo-chip.on-break::before { background: #6FB36F; }
.pomo-chip[hidden] { display: none; }
.decor-item:not(.ticking) .df-stream { opacity: 0; }
.df-dial { transition: transform 0.9s linear; }
.decor-item.is-timer.ticking { filter: drop-shadow(0 0 6px rgba(255, 210, 140, 0.35)); }
/* The timers work like the real ones (pomodoro.js): wind a hand or the red disk, turn the knob,
   turn the hourglass over or lay it on its side, and they rattle when time's up. */
.decor-item.is-timer { touch-action: none; }
.decor-item.is-timer.winding { cursor: grabbing; }
.decor-item.is-timer.winding .df-dial { transition: none; }
.di-timer-flow .df-knob-hit { cursor: ns-resize; }
.di-timer-flow .df-knob { transition: transform 0.15s; }
.di-timer-flow.on-break .df-mode { fill: #86C793; }
.di-timer-hourglass > svg { transform-origin: 50% 50%; transition: transform 0.6s cubic-bezier(0.45, 0.05, 0.3, 1); }
.di-timer-hourglass.resting > svg { transform: translateY(21.875%) rotate(90deg); } /* on its side, resting on the desk */
.di-timer-hourglass.resting .df-shadow, .di-timer-hourglass.flipping .df-shadow { opacity: 0; }
@keyframes tm-rattle { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
.decor-item.is-timer.ringing > svg { animation: tm-rattle 0.13s linear 18; transform-origin: 50% 92%; }
.di-timer-flow.ringing > svg { animation: none; }
@keyframes tm-blink { 50% { opacity: 0.12; } }
.di-timer-flow.ringing .df-digits { animation: tm-blink 0.5s steps(1) 5; }

/* ---------- The music player's panel ---------- */
.mp {
  position: fixed; z-index: 46; width: 300px; padding: 14px 14px 12px;
  display: flex; flex-direction: column; gap: 9px;
  background: var(--card); color: var(--ink); border: 1px solid var(--card-edge); border-radius: 14px; box-shadow: var(--shadow);
  font-family: var(--font-ui);
}
.mp .seg { align-self: center; }
.mp-src { display: flex; flex-direction: column; gap: 6px; }
.mp-src[hidden] { display: none; }
.mp input, .mp select { width: 100%; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--card-edge); background: #FFFFFF; color: var(--ink); font: 13px var(--font-ui); }
.mp input[hidden], .mp select[hidden] { display: none; }
.mp-lofi { align-self: flex-start; font-size: 12.5px; padding: 4px 8px; }
.mp-now { font-size: 13px; text-align: center; min-height: 16px; overflow-wrap: anywhere; }
.mp-controls { display: flex; justify-content: center; align-items: center; gap: 10px; }
.mp-controls[hidden] { display: none; }
.mp-controls .quiet { font-size: 16px; padding: 6px 10px; }
.mp-play { width: 46px; height: 46px; border-radius: 50%; background: var(--ink); color: var(--card); font-size: 16px; }
.mp-embed iframe { width: 100%; border: 0; border-radius: 12px; display: block; }
.mp-embed:empty { display: none; }
.mp-note { margin: 0; font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* ---------- Reading it through (from the paper tray) ---------- */
/* The pages as they print, two at a time, on a dimmed room. Read-only: nothing to select. */
.reader {
  position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center;
  background: rgba(18, 12, 8, 0.8); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  outline: none; -webkit-user-select: none; user-select: none;
}
.reader[hidden] { display: none; }
.rd-bar {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 8px; color: #F4EBDD; font: 13px var(--font-ui);
}
.rd-name { font-size: 14px; font-weight: 600; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-where { color: rgba(244, 235, 221, 0.68); font-variant-numeric: tabular-nums; }
.rd-gap { flex: 1; }
.rd-arrow { width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); color: #FFF; font-size: 22px; line-height: 1; padding-bottom: 3px; }
.rd-arrow:hover:not(:disabled) { background: rgba(255, 255, 255, 0.22); }
.rd-arrow:disabled { opacity: 0.28; cursor: default; }
.rd-done { padding: 7px 15px; border-radius: 999px; background: #F4EBDD; color: #2A1E14; font-weight: 600; margin-left: 6px; }
.rd-spread { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 18px; }
.rd-page {
  position: relative; flex: none; overflow: hidden; background: var(--page, #FFFEFA); color: #1B1814;
  font-family: "Courier Prime", Courier, monospace;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 40px rgba(0, 0, 0, 0.45);
}
.rd-page.rd-none { background: transparent; box-shadow: none; }
.rd-t { position: absolute; white-space: pre; font-size: calc(12px * var(--s)); line-height: 1; }
.rd-t.b { font-weight: 700; }
.rd-t.i { font-style: italic; }
.rd-t[data-l] { cursor: pointer; }
.rd-t.rd-hot { background: rgba(255, 205, 70, 0.32); box-shadow: 0 0 0 calc(2px * var(--s)) rgba(255, 205, 70, 0.32); border-radius: 1px; }
.rd-u { position: absolute; height: max(1px, calc(0.6px * var(--s))); background: #1B1814; }
.rd-hint { margin: 8px 0 calc(14px + env(safe-area-inset-bottom, 0px)); color: rgba(244, 235, 221, 0.6); font: 12px var(--font-ui); }

/* ---------- The demo and the free trial on the web (plan.js) ---------- */
/* A chip by the title says Demo or how long the trial has left; click it for the sheet. */
.plan-chip {
  font: 600 10.5px/1 var(--font-ui); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
  padding: 5px 9px; border-radius: 10px; cursor: pointer; color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.16);
}
.plan-chip:hover { background: rgba(255, 255, 255, 0.3); }
[data-look="window"]:not([data-sky="night"]) .plan-chip { color: rgba(45, 35, 25, 0.78); border-color: rgba(45, 35, 25, 0.28); background: rgba(255, 250, 240, 0.45); }
[data-look="window"]:not([data-sky="night"]) .plan-chip:hover { background: rgba(255, 250, 240, 0.8); }
.plan-sheet { width: min(460px, 100%); }
.plan-sheet .plan-reason { padding: 10px 12px; background: var(--accent-soft); border-radius: 6px; font-size: 14px; }
.plan-fields { display: grid; gap: 12px; margin: 4px 0 12px; }
.plan-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.plan-fields input { font: 15px/1.4 var(--font-type); color: var(--ink); background: #FFFFFF; border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px; width: 100%; min-width: 0; }
.plan-fields input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plan-fields input::placeholder { color: var(--muted); opacity: 0.6; }
.plan-status { min-height: 1.4em; font-size: 13.5px; color: var(--muted); margin: 0 0 10px; }
.plan-status.bad { color: var(--accent); }
.plan-sheet.busy .primary { opacity: 0.6; pointer-events: none; }

/* ---------- The whiteboard (board.js) ---------- */
.decor-item.is-board { pointer-events: auto; cursor: pointer; }
.decor-item.is-board canvas.wb-mini { position: absolute; left: 2.3%; top: 3.2%; width: 95.4%; height: 83.2%; pointer-events: none; }
.board-wrap { position: fixed; inset: 0; z-index: 49; display: flex; flex-direction: column; background: rgba(20, 14, 8, 0.6); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; overscroll-behavior: none; }
.board-wrap[hidden] { display: none; }
.board-bar { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; background: var(--card); border-bottom: 1px solid var(--card-edge); }
.board-title { font: 700 15px var(--font-type); color: var(--ink); margin-right: 6px; }
.board-bar .spacer { flex: 1; }
.board-bar .sep { width: 1px; height: 24px; background: var(--card-edge); margin: 0 4px; }
.board-bar .bt-color { width: 34px; height: 34px; border-radius: 50%; padding: 0; display: grid; place-items: center; background: transparent; border: 2px solid transparent; }
.board-bar .bt-color i { display: block; width: 20px; height: 20px; border-radius: 50%; background: var(--c); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2); }
.board-bar .bt-color[aria-pressed="true"] { border-color: var(--ink); }
.board-bar .bt-tool { display: inline-flex; align-items: center; gap: 5px; font: 500 13px var(--font-ui); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--card-edge); background: transparent; color: var(--ink); }
.board-bar .bt-tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.board-bar .bt-tool[aria-pressed="true"] { background: var(--ink); color: var(--card); border-color: var(--ink); }
.board-bar .bt-tool.danger { color: var(--accent); }
.board-bar .bt-tool.confirm { background: var(--accent); color: #fff; border-color: var(--accent); }
.board-bar .bt-hl i { width: 22px; height: 11px; border-radius: 3px; }
/* Shapes and Eraser each hold a few tools: the button takes the one last used and opens a card of the others. */
.board-bar .bt-group { position: relative; display: inline-flex; }
.board-bar .bt-tool .bt-caret { width: 10px; height: 10px; margin-left: -2px; opacity: 0.7; }
.board-bar .bt-sub { font-size: 11px; font-weight: 500; opacity: 0.75; margin-left: 5px; }
.board-bar .bt-sub:empty { display: none; }
.bt-menu { left: 0; right: auto; top: calc(100% + 6px); min-width: 200px; z-index: 6; }
.bt-menu button { justify-content: flex-start; gap: 10px; padding: 7px 10px; }
.bt-menu button svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bt-menu button > span { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.bt-menu button small { font-size: 11.5px; color: var(--muted); }
.bt-menu button[aria-checked="true"] { background: var(--accent-soft); }
.bt-menu button[aria-checked="true"]::after { content: "✓"; margin-left: auto; padding-left: 8px; color: var(--accent); }
@media (max-width: 1240px) { .board-bar .bt-tool span { display: none; } .board-bar .bt-tool { padding: 6px 8px; } .board-title { display: none; } }
/* While the board is up nothing on the page can be selected, so the pencil can't start a text
   selection (which swallowed its strokes and brought up the copy menu); a note's text still can. */
.board-open body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.board-open .board-note-text { -webkit-user-select: text !important; user-select: text !important; }
.board-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px calc(12px + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px)); }
.board-surface {
  position: relative; aspect-ratio: 16 / 10; width: min(100%, calc((100vh - 120px) * 1.6)); max-height: 100%;
  background: #FBFBF9; border: 12px solid #C6C9CE; border-radius: 5px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 20px 50px rgba(0, 0, 0, 0.45);
  touch-action: none; -webkit-touch-callout: none; cursor: crosshair;
}
.board-surface[data-tool="text"] { cursor: text; }
.board-surface[data-tool="rubber"] { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='26' height='26'><circle cx='13' cy='13' r='11' fill='rgba(255,255,255,0.55)' stroke='%23333' stroke-width='1.5'/></svg>") 13 13, crosshair; }
.board-surface[data-tool="eraser"] { cursor: cell; }
.board-surface canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; -webkit-user-select: none; user-select: none; }
.board-notes { position: absolute; inset: 0; pointer-events: none; }
.board-log { position: absolute; right: 8px; bottom: 8px; margin: 0; padding: 8px 10px; max-width: 60%; pointer-events: none; background: rgba(20, 14, 8, 0.78); color: #F4EEDC; font: 13px/1.35 ui-monospace, Menlo, monospace; border-radius: 6px; white-space: pre; }
.board-log[hidden] { display: none; }
.board-bar .bt-log { color: var(--muted); font-size: 12px; }
.board-note { position: absolute; pointer-events: auto; max-width: 46%; min-width: 120px; padding: 2px 4px 2px 20px; border-radius: 4px; touch-action: auto; }
.board-note:hover, .board-note.editing { box-shadow: 0 0 0 1px rgba(39, 57, 106, 0.35); background: rgba(255, 255, 255, 0.6); }
.board-note-text {
  min-height: 1.3em; outline: none; cursor: text; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 500 clamp(15px, 1.9vw, 24px)/1.3 var(--font-hand); color: var(--c, #1E1E22);
  -webkit-user-select: text; user-select: text; -webkit-user-modify: read-write-plaintext-only;
}
.board-note-text:empty::before { content: "Type here"; color: rgba(30, 30, 34, 0.35); pointer-events: none; }
.board-grip { position: absolute; left: 3px; top: 4px; font-size: 14px; line-height: 1; color: rgba(30, 30, 34, 0.4); cursor: grab; -webkit-user-select: none; user-select: none; opacity: 0.5; touch-action: none; padding: 2px; }
.board-note:hover .board-grip, .board-note.editing .board-grip { opacity: 1; }
.board-open .deskbar { pointer-events: none; }
