:root {
  color-scheme: light dark;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
    "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display",
    "Segoe UI", system-ui, sans-serif;
  --page: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Times New Roman",
    serif;
  --accent: #007aff;
  --accent-press: #0066d6;
  --label: #1d1d1f;
  --secondary: rgba(60, 60, 67, 0.64);
  --tertiary: rgba(60, 60, 67, 0.36);
  --fill: rgba(120, 120, 128, 0.16);
  --fill-strong: rgba(120, 120, 128, 0.24);
  --hairline: rgba(60, 60, 67, 0.22);
  --sidebar: rgba(246, 246, 247, 0.62);
  --chrome: rgba(255, 255, 255, 0.42);
  --paper: #fffefa;
  --paper-edge: #f1f0eb;
  --ink: #1c1914;
  --desk: #eef0f4;
  --desk-deep: #e2e5eb;
  --shadow: rgba(32, 43, 65, 0.16);
  --sheet: rgba(22, 22, 24, 0.38);
  --titlebar: 76px;
  --sidebar-w: 252px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Plugins borrow the app's quiet typography. An ink-blue status light is the
   only new visual accent; it means a microphone is actually in use. */
.plugins-section { border-top: 1px solid var(--hairline); padding-top: 18px; margin-top: 18px; }
.plugins-heading, .plugin-card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.plugins-heading h3, .plugin-card h3 { margin: 0; font-family: var(--display); font-size: 16px; letter-spacing: -.02em; }
.plugins-section > p { font-size: 12px; }
.plugin-list { display: grid; gap: 10px; }
.plugin-card { padding: 16px; border: 1px solid var(--hairline); border-radius: 14px; background: var(--chrome); }
.sheet-card .plugin-card p { margin: 8px 0; font-size: 12px; line-height: 1.5; }
.plugin-badge { font-size: 10px; color: var(--secondary); white-space: nowrap; }
.plugin-details { color: var(--secondary); font-size: 11px; }
.plugin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.plugin-actions button:first-child { color: var(--accent); }
.sheet-card.app-settings-card, .sheet-card.plugin-browser-card { width: min(640px, calc(100% - 32px)); padding: 0; }
.settings-header { padding: 26px 28px 16px; }
.settings-eyebrow { color: var(--secondary); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.settings-header h2 { margin: 6px 0 8px; }
.sheet-card .settings-header p { margin: 0; font-size: 12px; color: var(--secondary); }
.settings-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--hairline); }
.settings-tabs button { flex: 1 0 auto; padding: 13px 8px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--secondary); font: inherit; font-size: 12px; white-space: nowrap; cursor: pointer; }
.settings-tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--label); }
.settings-pages { padding: 8px 28px 12px; min-height: 280px; }
.settings-pages [role="tabpanel"][hidden], #plugin-settings[hidden], #plugins-section[hidden], #plugin-settings > div[hidden] { display: none; }
.sheet-card .settings-footer { margin: 0; padding: 16px 28px; border-top: 1px solid var(--hairline); }
.plugin-browser-card #plugins-section, .plugin-browser-card #plugin-settings { padding: 0 28px 8px; }
.plugin-browser-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 18px; }
.plugin-browser-card .plugin-card { border-left: 3px solid var(--hairline); }
.plugin-browser-card .plugin-card[data-installed="true"] { border-left-color: var(--accent); }
.plugin-settings-action { margin-left: auto; }
.plugin-browser-card #plugins-status { margin: 12px 28px 18px; }
.plugin-browser-card #plugin-progress { margin: 12px 28px 0; width: calc(100% - 56px); }
.plugin-back { margin-bottom: 18px; }
.plugin-browser-card #plugin-settings-heading { font-family: var(--display); font-size: 24px; letter-spacing: -.025em; margin: 0 0 8px; }
.plugin-browser-card .plugin-scope { color: var(--secondary); border-bottom: 1px solid var(--hairline); padding-bottom: 18px; margin-bottom: 22px; font-size: 12px; }
.plugin-browser-card .field select { padding: 10px 12px; color: inherit; border: 1px solid var(--hairline); border-radius: 8px; background: var(--fill); font: inherit; }
.plugin-browser-card .setting-row { align-items: flex-start; }
.plugin-browser-card .autocomplete-controls { flex-shrink: 0; }
.sheet-card .ghost-tool { min-height: 36px; height: auto; min-width: 0; max-width: 100%; padding: 8px 12px; border: 1px solid var(--hairline); border-radius: 8px; background: var(--fill); line-height: 1.3; white-space: normal; overflow-wrap: anywhere; text-align: center; }
.sheet-card .segmented { flex-shrink: 0; flex-wrap: wrap; max-width: 100%; }
.sheet-card .segmented button { width: auto; min-height: 34px; height: auto; padding: 8px 12px; line-height: 1.3; white-space: nowrap; }
.settings-pages .setting-row, .plugin-browser-card .setting-row { flex-wrap: wrap; }
.settings-pages .setting-body, .plugin-browser-card .setting-body { flex-basis: 220px; }
@media (max-width: 650px) { .settings-header { padding: 22px 20px 14px; } .settings-pages, .plugin-browser-card #plugins-section, .plugin-browser-card #plugin-settings { padding-left: 20px; padding-right: 20px; } .plugin-browser-toolbar { flex-wrap: wrap; } .plugin-browser-card .setting-row { flex-wrap: wrap; } }
.plugin-preferences { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 12px; margin: 14px 0; }
.plugin-preferences select { padding: 6px 8px; border: 1px solid var(--hairline); border-radius: 7px; background: var(--fill); }
.plugin-command-label { display: flex; align-items: center; gap: 6px; }
.sheet-card .plugin-command-help { font-size: 11px; margin-bottom: 14px; }
#plugin-progress { width: 100%; accent-color: var(--accent); margin-top: 12px; }
.dictation-controls { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dictation-controls[hidden], .plugins-section[hidden], #plugin-progress[hidden] { display: none; }
.dictation-controls button { flex-shrink: 0; }
.dictation-controls[data-recording="true"] button { color: var(--accent); }
.dictation-controls[data-recording="true"] #dictation-toggle::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--accent); }
.dictation-controls[data-paused="true"] #dictation-toggle::before { background: var(--secondary); }
.dictation-controls button[hidden] { display: none; }
#dictation-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.dictation-preview { opacity: .65; text-decoration: underline dotted; text-underline-offset: .16em; white-space: pre-wrap; pointer-events: none; }
@media print { .dictation-preview { display: none; } }
button:focus-visible, .plugin-preferences select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 900px) { #dictation-status { max-width: 120px; } }
@media (max-width: 650px) { #dictation-status { max-width: 80px; } .plugin-card-head { flex-wrap: wrap; gap: 4px; } }

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0a84ff;
    --accent-press: #409cff;
    --label: #f5f5f7;
    --secondary: rgba(235, 235, 245, 0.62);
    --tertiary: rgba(235, 235, 245, 0.3);
    --fill: rgba(120, 120, 128, 0.28);
    --fill-strong: rgba(120, 120, 128, 0.4);
    --hairline: rgba(235, 235, 245, 0.18);
    --sidebar: rgba(28, 28, 30, 0.55);
    --chrome: rgba(28, 28, 30, 0.45);
    --desk: #1c1d21;
    --desk-deep: #121317;
    --shadow: rgba(0, 0, 0, 0.55);
    --sheet: rgba(0, 0, 0, 0.52);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  font-family: var(--ui);
  color: var(--label);
  background: var(--desk-deep);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

html[data-os="darwin"] {
  background: transparent;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

/* Desktop opening: paper gathers, ink draws, then the imprint evaporates. */
.logo-reveal {
  --reveal-paper: #eef0f4;
  --reveal-ink: #1b1e23;
  --reveal-halo: #ffffff;
  --reveal-rule: #a4adbc;
  --reveal-out: cubic-bezier(.25, 1, .5, 1);
  --reveal-spring: cubic-bezier(.3, 1.25, .4, 1);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  color: var(--reveal-ink);
  background: var(--reveal-paper);
  animation: logo-reveal-curtain 5200ms cubic-bezier(.4, 0, .2, 1) both;
}
.logo-reveal::backdrop { background: transparent; }
.logo-reveal-drag {
  position: absolute;
  inset: 0 0 auto;
  height: 76px;
  -webkit-app-region: drag;
  app-region: drag;
}
.logo-reveal-light {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 43%, var(--reveal-halo), transparent 64%);
  animation: logo-reveal-light 4600ms var(--ease) both;
  pointer-events: none;
}
.logo-reveal-composition {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 72px;
  pointer-events: none;
  animation: logo-reveal-depart 5200ms var(--ease) both;
}
.logo-reveal-emblem {
  position: relative;
  width: clamp(116px, 22vh, 180px);
  aspect-ratio: 1;
  margin-bottom: 24px;
  perspective: 700px;
}
.logo-reveal-pages { position: absolute; inset: 0; transform-style: preserve-3d; }
.logo-reveal-page {
  --page-x: -132px;
  --page-y: 36px;
  --page-turn: -42deg;
  position: absolute;
  inset: 12% 21%;
  border: 1px solid color-mix(in srgb, var(--reveal-rule) 48%, transparent);
  border-radius: 3px 9px 3px 3px;
  background: color-mix(in srgb, var(--reveal-halo) 50%, transparent);
  box-shadow: 0 12px 24px -16px var(--reveal-rule);
  animation: logo-reveal-paper 2200ms var(--reveal-out) both;
}
.logo-reveal-page:nth-child(2) { --page-x: 126px; --page-y: -42px; --page-turn: 38deg; animation-delay: 140ms; }
.logo-reveal-page:nth-child(3) { --page-x: 18px; --page-y: 90px; --page-turn: -17deg; animation-delay: 280ms; }
.logo-reveal-page::after {
  content: "";
  position: absolute;
  inset: 30% 20% 20%;
  opacity: .3;
  background: repeating-linear-gradient(transparent 0 11px, var(--reveal-rule) 11px 12px);
}
.logo-reveal-ghost {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
  stroke: currentColor;
  animation: logo-reveal-float 4200ms var(--reveal-out) both;
}
.logo-reveal-outline, .logo-reveal-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: logo-reveal-ink 1900ms cubic-bezier(.65, 0, .35, 1) 250ms both;
}
.logo-reveal-line { animation-duration: 900ms; animation-delay: 1500ms; }
.logo-reveal-line-last { animation-delay: 1720ms; }
.logo-reveal-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: logo-reveal-awaken 1900ms ease 1050ms both;
}
.logo-reveal-shadow {
  position: absolute;
  bottom: -9%;
  left: 25%;
  width: 50%;
  height: 8%;
  border-radius: 50%;
  background: var(--reveal-ink);
  filter: blur(9px);
  animation: logo-reveal-shadow 4200ms var(--ease) both;
}
.logo-reveal-wordmark {
  display: flex;
  font-family: var(--page);
  font-size: clamp(34px, 5vw, 46px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -.045em;
}
.logo-reveal-wordmark span {
  display: block;
  animation: logo-reveal-letter 1200ms var(--reveal-out) both;
  animation-delay: calc(1350ms + var(--letter) * 70ms);
}
.logo-reveal-rule {
  width: 28px;
  height: 1px;
  margin-top: 23px;
  background: var(--reveal-rule);
  animation: logo-reveal-rule 1300ms var(--ease) 2300ms both;
}
.logo-reveal-skip {
  position: absolute;
  right: 28px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--secondary);
  font-size: 11px;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}
.logo-reveal-skip span { color: var(--tertiary); font-size: 15px; }
.logo-reveal-skip:hover { background: var(--fill); color: var(--label); }
.logo-reveal-skip:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@keyframes logo-reveal-curtain {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes logo-reveal-light {
  0% { opacity: 0; transform: scale(.6); }
  45%, 100% { opacity: 1; transform: scale(1.06); }
}
@keyframes logo-reveal-paper {
  0% { opacity: 0; transform: translate3d(var(--page-x), var(--page-y), -160px) rotate(var(--page-turn)) rotateY(-50deg); }
  25% { opacity: .8; }
  70% { opacity: .5; }
  100% { opacity: 0; transform: translate3d(0, 0, 0) rotate(0) rotateY(0) scale(.84); }
}
@keyframes logo-reveal-float {
  0% { opacity: 0; transform: translateY(54px) scale(.72) rotate(-5deg); }
  12% { opacity: 1; }
  38% { transform: translateY(-12px) scale(1.045) rotate(1.5deg); }
  62% { transform: translateY(4px) scale(.997) rotate(-.5deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
@keyframes logo-reveal-ink { to { stroke-dashoffset: 0; } }
@keyframes logo-reveal-awaken {
  0% { opacity: 0; transform: scaleY(.05); }
  22%, 64%, 88%, 100% { opacity: 1; transform: scaleY(1); }
  76% { opacity: 1; transform: scaleY(.12); }
}
@keyframes logo-reveal-shadow {
  0% { opacity: 0; transform: scale(.55); }
  38% { opacity: .09; transform: scale(1.04); }
  62% { opacity: .08; transform: scale(.97); }
  100% { opacity: .09; transform: scale(1); }
}
@keyframes logo-reveal-letter {
  0% { opacity: 0; transform: translateY(26px) scale(.96); filter: blur(8px); }
  55% { opacity: 1; transform: translateY(-3px) scale(1.004); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes logo-reveal-rule {
  0% { opacity: 0; transform: scaleX(0); }
  60% { opacity: .65; transform: scaleX(1.08); }
  100% { opacity: .65; transform: scaleX(1); }
}
@keyframes logo-reveal-depart {
  0%, 80% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
  100% { opacity: 0; transform: translateY(-22px) scale(1.07); filter: blur(7px); }
}
@media (prefers-color-scheme: dark) {
  .logo-reveal { --reveal-paper: #1c1d21; --reveal-ink: #f0f1f4; --reveal-halo: #30343f; --reveal-rule: #747f92; }
  .logo-reveal-shadow { background: #000; }
}
@media (max-height: 480px) {
  .logo-reveal-composition { padding-block: 32px 44px; }
  .logo-reveal-emblem { width: 100px; margin-bottom: 12px; }
  .logo-reveal-rule { margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .logo-reveal, .logo-reveal * { animation: none !important; }
}
/* Measurement hook for the small-window fit check: settled layout, no motion. */
.logo-reveal.is-measure, .logo-reveal.is-measure * { animation: none !important; }

.shell {
  display: grid;
  grid-template-columns: minmax(0, var(--sidebar-w)) minmax(0, 1fr);
  grid-template-rows: var(--titlebar) minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.titlebar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: var(--titlebar);
  padding: 8px 16px 8px 20px;
  background: var(--chrome);
  border-bottom: 0.5px solid var(--hairline);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  app-region: drag;
  -webkit-app-region: drag;
}

html[data-os="win32"] .titlebar,
html[data-os="linux"] .titlebar {
  padding-left: 20px;
}

/* Keep the writing controls below, rather than beside, the native traffic lights. */
html[data-os="darwin"]:not([data-shell="web"]) {
  --titlebar: 76px;
}

html[data-os="darwin"]:not([data-shell="web"]) .titlebar {
  padding: 32px 16px 8px 8px;
}

.titlebar-lead {
  min-width: 0;
  flex: 1 1 140px;
}

.titlebar-trail {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 1 auto;
  min-width: 0;
}

html[data-shell="web"] .titlebar {
  padding-left: 20px;
}

.library-btn {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 590;
  color: var(--secondary);
}

.titlebar-lead,
.titlebar-trail,
.search,
.search input,
.library-btn,
.icon-button,
.toolbar,
.sidebar button,
.sheet {
  app-region: no-drag;
  -webkit-app-region: no-drag;
}

.doc-title {
  margin: 0;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 590;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  min-width: 80px;
}

.search {
  position: relative;
  flex: 0 1 280px;
  width: min(280px, 42vw);
  min-width: 120px;
}

.search input {
  width: 100%;
  height: 30px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px 0 28px;
  background: var(--fill);
  outline: none;
}

.search input:focus {
  background: var(--fill-strong);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

.search-icon {
  position: absolute;
  left: 9px;
  top: 8px;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--secondary);
  border-radius: 99px;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: 6px;
  height: 1.5px;
  background: var(--secondary);
  transform: rotate(45deg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--sidebar);
  border-right: 0.5px solid var(--hairline);
  backdrop-filter: saturate(160%) blur(32px);
  -webkit-backdrop-filter: saturate(160%) blur(32px);
}

.sidebar-scroll {
  flex: 1;
  overflow: auto;
  padding: 10px 12px 16px;
  outline: none;
}

.outline-filter {
  flex: none;
  width: auto;
  min-width: 0;
  margin: 0 12px 8px;
}

.outline-item {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px 7px calc(10px + (var(--depth, 0) * 14px));
  border-radius: 8px;
  border-left: 2px solid transparent;
  text-align: left;
  color: var(--label);
  font-size: 13px;
  line-height: 1.4;
}

.outline-item:hover {
  background: var(--fill);
}

.outline-item.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.outline-item:focus-visible,
button:focus-visible,
select:focus-visible,
.doc-title:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.outline-level {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--secondary);
  opacity: 0.8;
  min-width: 16px;
}

.outline-item.active .outline-level {
  color: var(--accent);
  opacity: 1;
}

.outline-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outline-item[data-level="1"] .outline-text {
  font-weight: 600;
}

.outline-item[data-level="3"] {
  color: var(--secondary);
}

.outline-item[data-level="3"].active {
  color: var(--accent);
}

.empty-outline { padding: 20px 12px; font-size: 13px; line-height: 1.6; color: var(--secondary); }

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 40px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  min-width: 0;
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--hairline);
  background: color-mix(in srgb, var(--chrome) 70%, transparent);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  /* Keep toolbar popups (e.g. the Export menu) above the stage: the
     backdrop-filter already seals descendants into this layer, and the
     later-positioned .stage would otherwise paint over the overflow. */
  position: relative;
  z-index: 5;
}

.toolbar-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toolbar select,
.ghost-tool {
  height: 26px;
  border: 0;
  border-radius: 6px;
  padding: 0 8px;
  background: var(--fill);
}

.toolbar select { max-width: min(160px, 34vw); }

/* Labels determine text-button width. Only actual icon controls are square. */
.ghost-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: none;
  flex-shrink: 0;
  white-space: nowrap;
}

.segmented,
.stepper {
  display: flex;
  padding: 2px;
  border-radius: 8px;
  background: var(--fill);
}

.segmented button,
.stepper button {
  height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 590;
}

.segmented.compact button { min-width: 32px; width: auto; padding: 0 10px; white-space: nowrap; flex-shrink: 0; }

.segmented.icon-segments button,
.stepper button {
  width: 32px;
  padding: 0;
}

.segmented button.on,
.segmented button.is-on {
  background: color-mix(in srgb, white 82%, var(--fill));
  box-shadow: 0 0.5px 0.5px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  .segmented button.on,
  .segmented button.is-on {
    background: #636366;
    color: white;
    box-shadow: none;
  }
}

.stepper button:hover,
.ghost-tool:hover {
  background: color-mix(in srgb, white 70%, transparent);
}

.save-state,
#page-indicator {
  margin: 0;
  font-size: 12px;
  font-weight: 510;
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
}

#font-color {
  width: 28px;
  height: 26px;
  border: 0;
  background: transparent;
  padding: 0;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(255, 255, 255, 0.14), transparent 55%),
    linear-gradient(180deg, var(--desk) 0%, var(--desk-deep) 100%);
}

.desk {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  container-type: size;
}

.desk.turning {
  overflow: visible;
  /* Perspective on the flattened frame distorts idle-page hit testing in
     Chromium. Only the non-interactive page-turn animation needs it. */
  perspective: 5000px;
  perspective-origin: 50% 42%;
}

.book-frame {
  position: relative;
  flex: 0 0 auto;
  overflow: visible;
  transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

.book {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 210mm;
  height: 297mm;
  margin: -148.5mm 0 0 -105mm;
  /* Flat at rest so text rasterizes axis-aligned with subpixel
     antialiasing, exactly like Continuous/Magic Paper. The 3D context
     returns only while a page turn is animating (see below). */
  transform-style: flat;
  -webkit-transform-style: flat;
  transform-origin: center center;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Page turns animate their own 3D tilt, so restore the 3D scene then. */
.desk.turning .book,
.book[data-turn] {
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.book[data-spread="open"] {
  width: 420mm;
  margin: -148.5mm 0 0 -210mm;
}

/* Ghost pages need the same clipping viewport as the live editor. */
.ghost-doc { height: 100%; min-height: 0; overflow: hidden; }
.book[data-edge-turn] .leaf.left { visibility: hidden; }
.book[data-edge-turn] .stack { left: 50%; }
.book[data-turn] .corner { visibility: hidden; }
.flipper[hidden] { display: none; }

.ghost-doc,
.ghost-doc * {
  pointer-events: none;
  user-select: none;
}

.leaf.left {
  display: none;
  width: 50%;
  z-index: 2;
}

.leaf.right {
  z-index: 3;
}

.book[data-spread="open"] .leaf.left {
  display: block;
}

.book[data-spread="open"] .leaf.right {
  width: 50%;
  left: 50%;
}

.book[data-spread="open"] .stack {
  border-radius: 8px;
  transform: translate3d(0, 1.1%, -22px);
}

.book[data-spread="open"] .flipper.cover-right {
  left: 50%;
  width: 50%;
}

.book[data-spread="open"] .flipper.cover-left {
  left: 0;
  width: 50%;
}

.page-body,
#paper-content,
#left-content {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/*
 * The live editor must never be a scroll container: page offsets assume
 * scrollTop 0, and ProseMirror's selection scrolling otherwise shifts the
 * text inside its clip (e.g. navigating back with the caret deep in the
 * document). `clip` keeps the visual clipping without scrollability; older
 * engines ignore it and fall back to `hidden` above, where the JS reset in
 * layoutSpread/layoutContinuous still protects the offset.
 */
#paper-content {
  overflow: clip;
}

/* Virtual sheets have no DOM text position until input materializes the page. */
#paper-content[data-virtual-page] { position: relative; }
.virtual-page-caret { position: absolute; top: .15em; left: 0; width: 1px; height: 1.2em; background: var(--ink); pointer-events: none; animation: virtual-caret-blink 1s step-end infinite; }
@keyframes virtual-caret-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .virtual-page-caret { animation: none; } }
@media print { .virtual-page-caret { display: none; } }

.book[data-side="verso"] .stack {
  border-radius: 14px 3px 4px 14px;
  transform: translate3d(-1.4%, 1.1%, -18px);
}

.book[data-spread="open"][data-side="verso"] .stack,
.book[data-spread="open"][data-side="recto"] .stack {
  border-radius: 8px;
  transform: translate3d(0, 1.1%, -22px);
}

.book[data-side="verso"] .sheet-paper,
.sheet-paper.is-verso-face {
  border-radius: 12px 3px 4px 12px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset -18px 0 28px rgba(90, 60, 20, 0.05),
    0 18px 40px var(--shadow);
}

.verso-sheet {
  border-radius: 12px 3px 4px 12px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset -18px 0 28px rgba(90, 60, 20, 0.05),
    0 18px 40px var(--shadow);
}

.stack,
.leaf,
.flipper {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.stack {
  border-radius: 3px 14px 14px 4px;
  background:
    repeating-linear-gradient(
      90deg,
      #dedfdc 0 1px,
      #cdcfcb 1px 2px,
      #eeeee9 2px 3px
    );
  transform: translate3d(1.4%, 1.1%, -18px);
  box-shadow: 18px 28px 50px var(--shadow);
}

.sheet-paper {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 20mm 20mm 16mm;
  /* Own 3D plane: Chromium mis-projects click hit-testing for flattened
     content under the book's tilt — clicks below the page's vertical middle
     fall through to the paper instead of reaching the editor. */
  transform: translateZ(0);
  border-radius: 3px 12px 12px 4px;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.42), transparent 36%),
    linear-gradient(180deg, var(--paper), var(--paper-edge));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 18px 0 28px rgba(90, 60, 20, 0.05),
    0 18px 40px var(--shadow);
  color: var(--ink);
  overflow: hidden;
}

.book .leaf > .sheet-paper, .continuous-page { cursor: text; }
body[data-phone-access="true"] .book .leaf > .sheet-paper,
body[data-phone-access="true"] .continuous-page { cursor: default; }

.page-body {
  overflow: hidden;
  font-family: var(--page);
  font-size: 12pt;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.folio {
  /* Keep the writing viewport stable while an edge-turn temporarily hides a
     page number. Without a reserved line, the grid gives that page 18 extra
     pixels and pagination can expose the next page's first line. */
  min-height: 18px;
  line-height: 18px;
  font-family: var(--page);
  font-style: italic;
  font-size: 13px;
  color: color-mix(in srgb, var(--ink) 55%, transparent);
  text-align: center;
}

.corner {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 5;
  width: 56px;
  height: 56px;
  /* Give the controls their own plane above the tilted paper. */
  transform: translateZ(1px);
  background: linear-gradient(135deg, transparent 50%, rgba(40, 30, 10, 0.1) 50%);
  transition: transform 0.25s ease, filter 0.25s ease;
}

.corner:hover {
  transform: translateZ(1px) scale(1.06);
  filter: brightness(0.96);
}

.corner.back {
  left: 0;
  right: auto;
  background: linear-gradient(-135deg, transparent 50%, rgba(40, 30, 10, 0.1) 50%);
}

button.corner:active {
  transform: translateZ(1px) scale(0.96);
}

.flipper {
  z-index: 6;
  pointer-events: none;
  transform-origin: left center;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 3px 12px 12px 4px;
  background-color: var(--paper);
  background-image: linear-gradient(180deg, var(--paper), var(--paper-edge));
  box-shadow: 0 18px 40px var(--shadow);
  overflow: hidden;
}

.flipper.spine-right {
  transform-origin: right center;
}

.flipper.spine-right .flip-face {
  border-radius: 12px 3px 4px 12px;
}

.flipper.spine-left .flip-face.back { border-radius: 12px 3px 4px 12px; }
.flipper.spine-right .flip-face.back { border-radius: 3px 12px 12px 4px; }

.flip-face.back {
  transform: rotateY(180deg);
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, rgba(80, 50, 20, 0.12), transparent 18%),
    linear-gradient(180deg, var(--paper-edge), var(--paper));
}

.flipper.spine-right .flip-face.back {
  background-color: var(--paper);
  background-image:
    linear-gradient(-90deg, rgba(80, 50, 20, 0.12), transparent 18%),
    linear-gradient(180deg, var(--paper-edge), var(--paper));
}

.flip-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.18),
    transparent 18%,
    transparent 72%,
    rgba(0, 0, 0, 0.22)
  );
  mix-blend-mode: multiply;
  opacity: 0;
  backface-visibility: hidden;
}

.sheet {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--sheet);
  backdrop-filter: blur(18px);
  z-index: 20;
}

.sheet[hidden] {
  display: none;
}

.sheet-card {
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 22px 22px 18px;
  border-radius: 18px;
  color: #1c1914;
  background: color-mix(in srgb, var(--paper) 88%, white);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  animation: rise 0.38s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet-card h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: -0.03em;
  color: #1c1914;
}

.sheet-card p {
  margin: 6px 0 16px;
  color: rgba(60, 60, 67, 0.64);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 590;
  color: rgba(60, 60, 67, 0.64);
}

.field input {
  height: 36px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  background: rgba(120, 120, 128, 0.16);
  outline: none;
  color: #1c1914;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* Sidebar version history: tabs share the sidebar with the outline. */
#outline-pane,
#history-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#outline-pane[hidden],
#history-pane[hidden] {
  display: none;
}
.sidebar-tabs {
  gap: 8px;
}
.sidebar-tab-group button {
  width: auto;
  padding: 0 10px;
}
.sidebar-tab-group button[aria-selected="true"] {
  background: color-mix(in srgb, white 82%, var(--fill));
  box-shadow: 0 0.5px 0.5px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
}
@media (prefers-color-scheme: dark) {
  .sidebar-tab-group button[aria-selected="true"] {
    background: #636366;
    color: white;
    box-shadow: none;
  }
}
.history-note {
  flex: none;
  margin: 0 12px 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--secondary);
}
.history-note:empty {
  display: none;
}
.history-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 20px;
  min-width: 225px;
}
.history-row {
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  text-align: left;
  background: var(--fill);
  color: var(--label);
  display: grid;
  gap: 6px;
  cursor: default;
}
.history-row.is-current {
  outline: 1.5px solid var(--accent);
  outline-offset: -1.5px;
}
.history-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.history-kind {
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}
.history-time {
  font-size: 11px;
  color: var(--secondary);
  white-space: nowrap;
}
.history-message {
  font-size: 12px;
  color: var(--secondary);
  overflow-wrap: anywhere;
}
.history-actions {
  display: flex;
  gap: 8px;
}
.history-actions button {
  height: 28px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: color-mix(in srgb, var(--label) 12%, transparent);
  color: var(--label);
}
.history-actions button:hover {
  background: color-mix(in srgb, var(--label) 22%, transparent);
}

/* Hover diff card: what this version changed, red/green like git. */
.diff-card {
  position: fixed;
  z-index: 60;
  width: min(430px, calc(100vw - 32px));
  max-height: min(52vh, 480px);
  overflow: auto;
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--label);
  background: color-mix(in srgb, var(--sidebar) 88%, var(--desk));
  border: 0.5px solid var(--hairline);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
  backdrop-filter: saturate(160%) blur(24px);
  -webkit-backdrop-filter: saturate(160%) blur(24px);
}
.diff-card[hidden] {
  display: none;
}
.diff-card-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--secondary);
}
.diff-para {
  margin: 0 0 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.diff-para:last-child {
  margin-bottom: 0;
}
.diff-gap {
  margin: 0 0 8px;
  color: var(--secondary);
  letter-spacing: 0.2em;
}
.diff-card del {
  background: rgba(216, 48, 49, 0.16);
  color: #c0392b;
  text-decoration: line-through;
  border-radius: 3px;
}
.diff-card ins {
  background: rgba(39, 174, 96, 0.2);
  color: #1e8449;
  text-decoration: none;
  border-radius: 3px;
}
@media (prefers-color-scheme: dark) {
  .diff-card del {
    color: #ff8a80;
  }
  .diff-card ins {
    color: #7dcea0;
  }
}

.ghost,
.fill {
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  font-weight: 590;
}

.ghost:hover {
  background: var(--fill);
}

.fill {
  background: var(--accent);
  color: white;
}

.fill:hover {
  background: var(--accent-press);
}

@keyframes rise {
  from {
    transform: translateY(18px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.ProseMirror {
  outline: none;
  min-height: 100%;
  color: var(--ink);
  will-change: transform;
}

/* Outside the document: never measured, copied, printed, or saved as writing. */
.autocomplete-ghost {
  position: fixed;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  user-select: none;
  color: #8c8984;
  white-space: pre;
}
.autocomplete-ghost[hidden] { display: none; }
.autocomplete-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.autocomplete-ghost kbd {
  flex-shrink: 0;
  padding: 0 4px;
  border: 1px solid #bdb9b2;
  border-radius: 3px;
  font: 10px/16px -apple-system, BlinkMacSystemFont, sans-serif;
  color: #87837b;
}
@media print { .autocomplete-ghost { display: none !important; } }

/* Ink-stroke typing: the native caret hides while the fake one glides. */
.inking .ProseMirror {
  caret-color: transparent;
}

.ink-stroke {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}

.ink-caret {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border-radius: 1px;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 2px;
  border-top: 1px solid color-mix(in srgb, var(--hairline) 55%, transparent);
  text-align: left;
}

.setting-body {
  flex: 1;
  min-width: 0;
}

.setting-body h3 {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 590;
  letter-spacing: -0.01em;
  color: #1c1914;
}

.setting-body p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(60, 60, 67, 0.64);
}

.autocomplete-controls { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; flex-shrink: 0; }
.setting-body .autocomplete-status { margin-top: 6px; white-space: pre-line; }
.autocomplete-controls button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.switch {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 27px;
  border-radius: 99px;
  background: rgba(120, 120, 128, 0.28);
  transition: background-color 180ms ease;
}

.switch span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 23px;
  height: 23px;
  border-radius: 99px;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 180ms var(--ease);
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch[aria-checked="true"] span {
  transform: translateX(19px);
}

@media (prefers-color-scheme: dark) {
  .setting-body h3 { color: #eef2f8; }
  .setting-body p { color: #a0a8b8; }
}

.ProseMirror p {
  margin: 0 0 0.7em;
}

/* Space above a heading should exceed the space below it: the gap above binds
   the heading to the section it opens, the gap below binds it to the prose it
   introduces. With margin-top at 0 a heading inherited all of its space from the
   preceding paragraph's bottom margin, so it sat closer to the text it was
   introducing than to the text it was replacing — the wrong way round, and the
   reason headings read as attached to the block above rather than opening a
   new one. The em values are relative to the heading's own size, so this scales
   across the whole scale instead of being tuned per level. */
.ProseMirror h1,
.ProseMirror h2,
.ProseMirror h3 {
  font-weight: 650;
  margin: 1.1em 0 0.5em;
}

.ProseMirror h1 {
  font-size: 18pt;
}

.ProseMirror h2 {
  font-size: 14pt;
}

/* h3 was 12pt — exactly the body size. It was distinguishable only by weight,
   which is a weight difference the eye reads as emphasis rather than as
   hierarchy, so an h3 looked like a bolded paragraph instead of a heading.
   12.5pt clears body without approaching h2, and keeps the step from h2 at a
   deliberate ratio rather than the previous 1.17/1.29 unevenness. */
.ProseMirror h3 {
  font-size: 12.5pt;
}

.ProseMirror .page-break {
  display: block;
  border: 0;
  height: 0;
  min-height: 0;
  margin: 0;
  background: none;
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 760px) {
  :root {
    --sidebar-w: 100%;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--titlebar) minmax(72px, 26vh) minmax(0, 1fr);
  }

  html[data-os="win32"] .titlebar,
  html[data-os="linux"] .titlebar,
  html[data-shell="web"] .titlebar {
    padding-left: 12px;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 0.5px solid var(--hairline);
  }

  .search {
    min-width: 96px;
  }
}

@media (max-height: 480px) {
  .titlebar {
    padding-top: 4px;
    padding-bottom: 4px;
  }
}

.tip {
  position: fixed;
  z-index: 80;
  max-width: min(280px, calc(100vw - 16px));
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(30, 30, 32, 0.92);
  color: #f5f5f7;
  font-size: 11px;
  font-weight: 510;
  line-height: 1.3;
  letter-spacing: -0.01em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: none;
}

.tip[hidden] {
  display: none;
}

#bold {
  font-weight: 700;
}

#italic {
  font-style: italic;
}

#underline {
  text-decoration: underline;
}

/* The welcome scene and workspace share a cool silver, ink, and blue palette. */
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; color: var(--secondary); }
.icon-button svg, .welcome-privacy svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover { background: var(--fill); color: var(--label); }
button, select, input { transition: background-color 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 240ms var(--ease); }
button:active { transform: scale(.96); }
button:disabled { opacity: .45; cursor: wait; }
[hidden] { display: none !important; }
.shell { transition: grid-template-columns 440ms var(--ease); }
.titlebar { gap: 16px; background: var(--chrome); }
.prelude-brand { display: inline-flex; align-items: center; gap: 7px; }
.prelude-brand img { width: 16px; height: 16px; border-radius: 4px; }
.prelude-mark { width: 72px; height: 72px; margin: 0 0 27px; border-radius: 16px; background: #f5f6f8; box-shadow: 0 5px 10px #14223812; }
@media (prefers-color-scheme: dark) {
  .prelude-brand img, .prelude-mark { filter: invert(1); }
}
.doc-title { font-size: 18px; letter-spacing: -.035em; padding: 2px 0; }
.titlebar-trail { gap: 16px; }
.search { width: 210px; }
.search input { height: 36px; background: var(--fill); font-size: 13px; padding-left: 32px; border-radius: 10px; }
.search-icon { top: 10px; left: 12px; }
.library-btn { max-width: none; width: auto; height: 36px; background: transparent; white-space: nowrap; flex-shrink: 0; }
.sidebar { overflow: hidden; transition: opacity 240ms ease, transform 440ms var(--ease); }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; min-width: 210px; padding: 30px 24px 14px; font-size: 12px; font-weight: 600; color: var(--secondary); }
#outline-count { font-variant-numeric: tabular-nums; font-size: 11px; padding: 3px 7px; border-radius: 6px; background: var(--fill); }
.sidebar-scroll { padding: 0 12px 20px; min-width: 225px; }
.outline-filter { margin: 0 12px 8px; min-width: 190px; }
.outline-filter input { height: 36px; font-size: 13px; padding-left: 32px; border-radius: 10px; }
.outline-filter .search-icon { top: 10px; left: 12px; }
.outline-item { min-height: 42px; margin-bottom: 3px; border-radius: 9px; }
.empty-outline { padding: 20px 14px; }
.toolbar { padding: 12px 22px; gap: 8px; background: var(--chrome); border-bottom-color: color-mix(in srgb, var(--hairline) 45%, transparent); }
.toolbar-cluster { gap: 10px; }
.toolbar select, .ghost-tool { height: 30px; font-size: 12px; background: transparent; }
.segmented, .stepper { background: var(--fill); }
.workspace-status { display: flex; align-items: center; gap: 20px; padding: 0 24px; background: var(--chrome); color: var(--secondary); font-size: 11px; border-top: 1px solid color-mix(in srgb, var(--hairline) 35%, transparent); }
.workspace-status .save-state { margin-right: auto; font-size: 11px; }
.save-state[data-state="error"] { color: #c34444; }
.shell.sidebar-hidden, .shell.focus-mode { grid-template-columns: 0 minmax(0, 1fr); }
.shell.sidebar-hidden .sidebar, .shell.focus-mode .sidebar { opacity: 0; pointer-events: none; transform: translateX(-24px); }
.shell.focus-mode .toolbar { display: none; }
.shell.focus-mode .workspace { grid-template-rows: minmax(0, 1fr) 40px; }
.shell.focus-mode #open-library { display: none; }
.shell.focus-mode #focus-mode { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.sheet-card { padding: 32px; border-radius: 24px; background: #fafbfc; box-shadow: 0 32px 100px #15244330, 0 0 0 1px #ffffff90 inset; }
.sheet-card h2 { font-size: 30px; letter-spacing: -.045em; margin-top: 16px; }
.sheet-card p { line-height: 1.65; margin-bottom: 24px; }
.dialog-symbol { display: grid; place-items: center; width: 44px; height: 44px; background: #e7efff; color: #007aff; border-radius: 13px; font-size: 28px; }
.field input { height: 44px; background: #eef0f4; }
.sheet-actions button { height: 42px; font-size: 13px; }
#new-error { color: #bb3030; }
.gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 28px 20px;
  background: linear-gradient(180deg, var(--desk), var(--desk-deep));
  color: var(--label);
  isolation: isolate;
}
.gate-haze {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at 50% 38%, var(--chrome), transparent 65%);
  pointer-events: none;
}
.prelude-window {
  width: min(440px, 100%);
  margin: auto;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  background: color-mix(in srgb, var(--sidebar) 90%, var(--desk));
  box-shadow: 0 30px 80px #14223820, 0 8px 20px #1422380a, inset 0 1px 0 #ffffff60;
  backdrop-filter: saturate(150%) blur(32px);
  overflow: hidden;
  animation: prelude-arrive 650ms var(--ease) both;
}
.prelude-titlebar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  border-bottom: 1px solid color-mix(in srgb, var(--hairline) 50%, transparent);
  background: var(--chrome);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--secondary);
}
.gate-dismiss { position: absolute; right: 8px; top: 6px; font-size: 24px; }
.gate-room {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 38px 32px;
  text-align: center;
}
.prelude-book { position: relative; width: 70px; height: 88px; margin: 0 0 27px; perspective: 700px; }
.prelude-book > span {
  position: absolute;
  inset: 0;
  border-radius: 2px 6px 6px 2px;
  background: var(--paper);
  border: 1px solid #d7dadc;
  box-shadow: 0 5px 10px #14223812;
  transform-origin: left center;
}
.prelude-book > span:first-child { transform: rotate(9deg) translateX(5px); background: var(--paper-edge); }
.prelude-book > span:nth-child(2) { transform: rotate(3deg) translateX(2px); }
.prelude-book > span:last-child { transform: rotate(-6deg); background: linear-gradient(90deg, var(--paper-edge), var(--paper) 14%); animation: prelude-page 950ms var(--ease) both; }
.prelude-book i { position: absolute; top: 25px; left: 17px; width: 32px; height: 1px; background: #b9bec6; box-shadow: 0 6px #d0d4da, 0 12px #d0d4da, 0 18px #d0d4da; }
.gate-kicker { margin: 0 0 9px; font-size: 11px; font-weight: 500; color: var(--secondary); }
.gate-ask { margin: 0; font-family: var(--display); font-size: 27px; line-height: 1.2; letter-spacing: -.035em; font-weight: 600; }
.gate-copy { margin: 14px 0 0; font-size: 13px; line-height: 1.65; color: var(--secondary); max-width: 310px; }
.gate-copy:empty { display: none; }
.gate-actions { display: flex; flex-direction: column; width: 100%; gap: 9px; margin-top: 27px; }

/* Helper token pairing, shown only when the page is cross-origin from the
   helper. Sits above the actions so the value is entered before the button
   that submits it. Built by web-api.ts rather than declared in index.html, so a
   same-origin build has no such element in the document at all. */
.gate-token { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 20px; }
.gate-token label { font-size: 12px; color: var(--secondary); }
.gate-token input {
  width: 100%; min-height: 36px; padding: 8px 12px;
  border-radius: 9px; font: inherit; font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--label); background: var(--chrome);
  border: 1px solid var(--hairline);
}
.gate-token input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.gate-token-error { margin: 0; font-size: 12px; color: #b3261e; }
.gate-yes, .gate-ghost {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 38px; padding: 8px 14px;
  border-radius: 9px; font-size: 13px; font-weight: 550;
  color: var(--label); background: var(--chrome);
  border: 1px solid var(--hairline);
}
.gate-yes, .gate[data-state="pick"] #choose-library, #reconnect-library {
  background: var(--accent); color: white; border-color: transparent;
  box-shadow: inset 0 1px 0 #ffffff30, 0 2px 4px #007aff18;
}
.gate-ghost:hover { background: var(--fill); }
.gate-yes:hover, .gate[data-state="pick"] #choose-library:hover, #reconnect-library:hover { background: var(--accent-press); }
.gate-actions button:active { transform: scale(.98); }
.prelude-footer {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 45px; padding: 12px 18px;
  font-size: 10px; line-height: 1.5; color: var(--secondary);
  border-top: 1px solid color-mix(in srgb, var(--hairline) 50%, transparent);
  background: var(--chrome);
}
.prelude-footer svg { width: 12px; height: 14px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.gate-plates { display: grid; width: 100%; gap: 8px; }
.gate-plates:empty, .gate:not([data-state="found"]) .gate-plates { display: none; }
.gate-stick { display: flex; width: 100%; text-align: left; padding: 13px 14px; border: 1px solid var(--hairline); border-radius: 9px; background: var(--chrome); margin-top: 16px; color: var(--label); }
.gate-stick.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.gate-body { min-width: 0; }
.gate-stamp { margin: 0 0 4px; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.gate-meta { margin: 0; color: var(--secondary); font-size: 11px; }
.gate-plug { display: none; }
.gate[data-state="listen"] .prelude-book { animation: prelude-listen 1.6s ease-in-out infinite; }
@keyframes prelude-arrive { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes prelude-page { from { transform: rotate(-6deg) rotateY(-35deg); } to { transform: rotate(-6deg); } }
@keyframes prelude-listen { 50% { opacity: .5; } }
.hello {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 28px 20px;
  background: linear-gradient(180deg, var(--desk), var(--desk-deep));
  color: var(--label);
  isolation: isolate;
}
.hello-haze {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at 50% 38%, var(--chrome), transparent 65%);
  pointer-events: none;
}
.hello-card {
  width: min(500px, 100%);
  margin: auto;
  padding: 62px 52px 54px;
  text-align: center;
  border: 1px solid var(--hairline);
  border-radius: 24px;
  background: color-mix(in srgb, var(--sidebar) 90%, var(--desk));
  box-shadow: 0 30px 80px #14223820, 0 8px 20px #1422380a, inset 0 1px 0 #ffffff60;
  backdrop-filter: saturate(150%) blur(32px);
  animation: hello-arrive 720ms var(--ease) both;
}
.hello-big {
  margin: 0;
  min-height: 1.2em;
  font-family: var(--display);
  font-size: 46px;
  line-height: 1.1;
  letter-spacing: -.04em;
  font-weight: 650;
}
.hello-small {
  min-height: 4.6em;
  margin: 20px auto 0;
  max-width: 360px;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: -.01em;
  color: var(--secondary);
}
.hello-typing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: .95em;
  margin-left: 4px;
  vertical-align: -.12em;
  border-radius: 1px;
  background: var(--accent);
  animation: hello-caret 900ms steps(1, end) infinite;
}
.hello-actions { display: flex; justify-content: center; gap: 10px; margin-top: 26px; animation: hello-arrive 480ms var(--ease) both; }
.hello-actions button {
  min-width: 128px;
  min-height: 40px;
  padding: 8px 20px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 550;
  color: var(--label);
  background: var(--chrome);
}
.hello-yes { background: var(--accent); color: white; border-color: transparent; box-shadow: inset 0 1px 0 #ffffff30, 0 2px 4px #007aff18; }
.hello-yes:not(:disabled):hover { background: var(--accent-press); }
.hello-no:hover { background: var(--fill); }
.hello-actions button:active { transform: scale(.97); }
.hello-actions button:disabled { opacity: .45; cursor: default; transform: none; }
.hello-picked {
  margin: 20px 0 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: #ff3b30;
}
.hello-note {
  margin: 20px auto 0;
  max-width: 360px;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -.01em;
  color: var(--secondary);
}
.hello-note:empty { display: none; }
.hello-welcome { width: min(560px, 100%); }
.hello-welcome .hello-small { min-height: 0; }
.hello-list {
  margin: 24px auto 0;
  padding: 0;
  max-width: 430px;
  list-style: none;
  text-align: left;
  display: grid;
  gap: 10px;
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: -.01em;
  color: var(--secondary);
}
.hello-list:empty { display: none; }
.hello-list li { position: relative; padding-left: 22px; animation: hello-arrive 480ms var(--ease) both; }
.hello-list li::before { content: "—"; position: absolute; left: 0; color: var(--accent); }
@keyframes hello-arrive { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes hello-caret { 50% { opacity: 0; } }
.onboard { width: min(580px, 100%); }
.onboard-rail { display: flex; justify-content: center; gap: 8px; margin-bottom: 30px; }
.onboard-rail[hidden] { display: none; }
.onboard-dot { font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--secondary); padding: 5px 11px; border: 1px solid var(--hairline); border-radius: 999px; background: var(--chrome); }
.onboard-dot.is-on { color: white; background: var(--accent); border-color: transparent; }
.onboard-dot.is-done { color: var(--accent); border-color: var(--accent); background: transparent; }
.onboard-step { transition: opacity 320ms var(--ease), transform 320ms var(--ease); }
.onboard-step.is-entering { opacity: 0; transform: translateX(26px); }
.onboard-emblem { margin: 0 auto 27px; }
.onboard-choices { display: grid; gap: 10px; margin-top: 28px; text-align: left; }
.onboard-choice { display: flex; align-items: center; gap: 12px; padding: 15px 16px; border: 1px solid var(--hairline); border-radius: 14px; background: var(--chrome); color: var(--label); font-size: 14px; cursor: pointer; text-decoration: none; transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease); }
.onboard-choice strong { display: block; font-size: 14.5px; letter-spacing: -.01em; }
.onboard-choice small { display: block; margin-top: 3px; font-size: 12.5px; line-height: 1.5; color: var(--secondary); }
.onboard-choice:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 8px 22px #14223814; }
.onboard-choice:active { transform: scale(.99); }
.onboard-choice.is-primary { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--chrome)); }
.onboard-go { margin-left: auto; color: var(--accent); font-size: 18px; flex-shrink: 0; }
.onboard-checks { margin: 24px auto 0; padding: 0; max-width: 380px; list-style: none; display: grid; gap: 10px; text-align: left; }
.onboard-checks li { position: relative; padding: 11px 14px 11px 40px; border: 1px solid var(--hairline); border-radius: 11px; background: var(--chrome); font-size: 13.5px; color: var(--secondary); }
.onboard-checks li::before { content: ""; position: absolute; left: 14px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; border: 1.5px solid var(--secondary); opacity: .5; box-sizing: border-box; }
.onboard-checks li.is-on { color: var(--label); border-color: var(--accent); }
.onboard-checks li.is-on::before { border-color: var(--accent); opacity: 1; animation: onboard-pulse 900ms ease-in-out infinite; }
.onboard-checks li.is-done { color: var(--label); }
.onboard-checks li.is-done::before { content: "✓"; border: none; color: var(--accent); opacity: 1; font-size: 14px; font-weight: 700; margin-top: -10px; }
.onboard-stamp { width: 64px; height: 64px; margin: 0 auto 22px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: white; font-size: 26px; font-weight: 700; animation: onboard-pop 480ms var(--ease) both; }
.onboard-link { background: none; border: none; color: var(--accent); font-size: 13px; margin-top: 16px; cursor: pointer; padding: 4px 8px; }
.onboard-link:hover { text-decoration: underline; }
.onboard-link:disabled { opacity: .45; cursor: default; text-decoration: none; }
.launch-guide { margin-top: 28px; text-align: left; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.launch-guide h2 { margin: 0 0 14px; font-family: var(--display); font-size: 20px; letter-spacing: -.02em; }
.launch-guide > p { color: var(--secondary); }
.launch-guide details { border-top: 1px solid var(--hairline); padding: 13px 0; }
.launch-guide summary { cursor: pointer; font-weight: 600; }
.launch-guide ol { margin: 14px 0 0; padding-left: 24px; display: grid; gap: 10px; }
.launch-guide li { padding-left: 4px; }
.launch-guide li::marker { color: var(--accent); font-weight: 600; }
.launch-help { margin: 16px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--fill); color: var(--secondary); font-size: 13px; }
.launch-help a { color: var(--accent); }
.launch-help a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.launch-reminder { margin: 8px 0 0; padding-top: 16px; border-top: 1px solid var(--hairline); font-size: 13px; }
.onboard-veil { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 20px; border-radius: 24px; background: color-mix(in srgb, var(--desk) 55%, transparent); backdrop-filter: blur(6px); animation: hello-arrive 240ms var(--ease) both; }
.onboard-popup { width: min(380px, 100%); padding: 34px 30px 28px; text-align: center; border: 1px solid var(--hairline); border-radius: 18px; background: color-mix(in srgb, var(--sidebar) 92%, var(--desk)); box-shadow: 0 24px 60px #14223828, inset 0 1px 0 #ffffff60; }
.onboard-warn { width: 44px; height: 44px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 50%; background: #ff9f0a; color: white; font-size: 24px; font-weight: 700; }
.onboard-popup h2 { margin: 0; font-family: var(--display); font-size: 22px; letter-spacing: -.03em; }
.onboard-popup p { margin: 12px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--secondary); }
.onboard-progress { margin: 20px auto 0; max-width: 380px; height: 8px; border-radius: 999px; background: var(--fill); border: 1px solid var(--hairline); overflow: hidden; }
.onboard-progress span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width 200ms ease; }
.onboard-checks li.is-failed { color: #ff3b30; border-color: #ff3b30; }
.onboard-checks li.is-failed::before { content: "✕"; border: none; color: #ff3b30; opacity: 1; font-size: 13px; font-weight: 700; margin-top: -10px; }
.onboard-checks li.is-skipped { opacity: .55; }
.onboard-checks li.is-skipped::before { content: "–"; border: none; opacity: .7; font-size: 14px; font-weight: 700; margin-top: -11px; }

/* USB setup: a small piece of hardware, with the checks gathered beneath it. */
.onboard { --usb-good: #248344; --usb-caution: #a46008; }
.onboard .hello-actions .hello-yes { background: var(--accent); color: white; border-color: transparent; }
.onboard .hello-actions .hello-yes:not(:disabled):hover { background: var(--accent-press); }
.onboard .hello-actions { flex-wrap: wrap; }
.onboard :is(button, input, summary):focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 65%, transparent); outline-offset: 4px; }
.onboard h1:focus { outline: none; }
.onboard [hidden] { display: none !important; }
.usb-setup .hello-big { font-size: clamp(30px, 5vw, 39px); line-height: 1.12; text-wrap: balance; }
.usb-setup .hello-small { min-height: 0; margin-top: 14px; font-size: 15px; text-wrap: pretty; overflow-wrap: anywhere; }
.usb-setup .gate-kicker { margin-top: 0; }
.usb-footnote { margin: 16px auto 0; max-width: 350px; color: var(--secondary); font-size: 12px; line-height: 1.55; text-wrap: pretty; }
.usb-volume { display: inline-flex; max-width: 100%; padding: 5px 12px; margin: 16px 0 0; border-radius: 7px; background: var(--fill); font-size: 12px; font-weight: 550; overflow-wrap: anywhere; }
.usb-figure { position: relative; width: 168px; height: 156px; margin: -12px auto 24px; display: grid; place-items: center; perspective: 700px; }
.usb-device { position: relative; width: 65px; height: 118px; transform: rotate(-13deg); filter: drop-shadow(6px 12px 10px #17253625); transition: transform 850ms var(--ease); }
.usb-connector { position: absolute; top: 0; left: 10px; width: 45px; height: 36px; border: 1px solid #8c939b; border-radius: 4px 4px 1px 1px; background: linear-gradient(90deg, #b1b8c1, #e5e9ed 22%, #bfc6cf 80%, #9098a2); box-shadow: inset 0 1px 0 #ffffffc0; display: flex; justify-content: center; gap: 9px; padding-top: 9px; }
.usb-connector i { width: 8px; height: 10px; border-radius: 1px; background: #505966; box-shadow: inset 0 2px 2px #19212b80, 0 1px 0 #ffffffa0; }
.usb-body { position: absolute; inset: 29px 0 0; overflow: hidden; border: 1px solid #a2aab5; border-radius: 9px 9px 17px 17px; background: linear-gradient(105deg, #fafbfd 0%, #e5e8ed 15%, #cbd1d9 65%, #b0b8c4 96%, #e6eaf0 100%); box-shadow: inset 1px 0 1px #ffffff, inset 0 -2px 1px #8c96a580; }
.usb-seam { position: absolute; inset: 5px 5px auto; height: 1px; background: #a4aeb94d; }
.usb-monogram { position: absolute; inset: 20px 0 auto; font-family: var(--display); font-size: 25px; font-weight: 650; letter-spacing: -.08em; color: #7d8796; text-shadow: 0 1px 0 #ffffffa0; }
.usb-light { position: absolute; width: 5px; height: 5px; bottom: 13px; left: 29px; border-radius: 50%; background: #8893a2; box-shadow: inset 0 1px 2px #45505c50; }
.usb-orbit { position: absolute; width: 140px; height: 140px; border-radius: 50%; border: 1px solid var(--hairline); opacity: 0; transition: opacity 500ms ease; }
.usb-result-mark { position: absolute; right: 25px; bottom: 13px; display: none; place-items: center; width: 30px; height: 30px; border: 3px solid var(--desk); border-radius: 50%; color: white; background: var(--usb-good); font-size: 16px; font-weight: 650; }
.usb-figure[data-state="ready"] .usb-device { animation: usb-hover 4s ease-in-out infinite; }
.usb-figure[data-state="connect"] .usb-device { animation: usb-connect 2.8s var(--ease) infinite; }
.usb-figure[data-state="testing"] .usb-device { transform: rotate(0); }
.usb-figure[data-state="testing"] .usb-orbit { opacity: 1; border-color: var(--fill); border-top-color: var(--accent); animation: usb-scan 1.6s linear infinite; }
.usb-figure[data-state="testing"] .usb-light { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: onboard-pulse 1s ease-in-out infinite; }
.usb-figure:is([data-state="connected"], [data-state="passed"]) .usb-light { background: var(--usb-good); }
.usb-figure:is([data-state="passed"], [data-state="caution"], [data-state="failed"]) .usb-result-mark { display: grid; animation: onboard-pop 500ms var(--ease) both; }
.usb-figure:is([data-state="caution"], [data-state="failed"]) .usb-result-mark { background: var(--usb-caution); }
.usb-testing .usb-figure, .usb-reviewed .usb-figure { width: 138px; height: 124px; margin-bottom: 18px; }
.usb-testing .usb-device, .usb-reviewed .usb-device { scale: .82; }
.usb-testing .usb-orbit { width: 120px; height: 120px; }
.usb-checks { list-style: none; padding: 0; margin: 24px 0 0; text-align: left; border-block: 1px solid var(--hairline); }
.usb-check { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 11px 2px; transition: opacity 300ms ease; }
.usb-check + .usb-check { border-top: 1px solid color-mix(in srgb, var(--hairline) 55%, transparent); }
.usb-check-mark { display: grid; place-items: center; flex-shrink: 0; width: 23px; height: 23px; border-radius: 50%; background: var(--fill); color: var(--secondary); font-size: 13px; font-weight: 650; }
.usb-check-body { min-width: 0; }
.usb-check strong { display: block; font-size: 13px; font-weight: 550; }
.usb-check-detail { display: block; margin-top: 3px; color: var(--secondary); font-size: 11.5px; line-height: 1.5; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.usb-check[data-state="waiting"] { opacity: .55; }
.usb-check[data-state="running"] .usb-check-mark { color: transparent; background: none; border: 2px solid var(--fill); border-top-color: var(--accent); animation: usb-scan 1s linear infinite; }
.usb-check[data-state="pass"] .usb-check-mark { color: var(--usb-good); background: color-mix(in srgb, var(--usb-good) 12%, transparent); }
.usb-check:is([data-state="warn"], [data-state="fail"]) .usb-check-mark { color: var(--usb-caution); background: color-mix(in srgb, var(--usb-caution) 12%, transparent); }
.usb-space { margin-top: 24px; text-align: left; }
.usb-space-label { font-size: 14px; font-weight: 600; }
.usb-space-field { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--secondary); }
.usb-space-field input { width: 122px; padding: 10px 12px; border: 1px solid var(--hairline); border-radius: 9px; background: var(--chrome); color: var(--label); font-size: 16px; font-variant-numeric: tabular-nums; }
.usb-space .usb-footnote { margin: 10px 0 0; max-width: none; }
.usb-details { margin-top: 12px; text-align: left; font-size: 12px; color: var(--secondary); line-height: 1.6; }
.usb-details summary { cursor: pointer; color: var(--accent); }
.usb-details p { margin: 8px 0 0; }
.usb-about { padding-top: 14px; border-top: 1px solid var(--hairline); }
.usb-consent { display: flex; gap: 10px; align-items: flex-start; text-align: left; margin-top: 18px; font-size: 12px; line-height: 1.6; color: var(--secondary); }
.usb-consent input { width: 16px; height: 16px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--accent); }
.usb-assessment { margin-top: 20px; padding: 14px 16px; border-radius: 12px; text-align: left; background: var(--fill); }
.usb-assessment strong { font-size: 13px; font-weight: 600; }
.usb-assessment p { margin: 5px 0 0; font-size: 12px; color: var(--secondary); line-height: 1.6; }
.usb-assessment:is([data-state="blocked"], [data-state="space"], [data-state="caution"]) { background: color-mix(in srgb, var(--usb-caution) 9%, transparent); }
.usb-assessment[data-state="good"] { background: color-mix(in srgb, var(--usb-good) 9%, transparent); }
.usb-risk-review { text-align: left; }
.usb-risk-review .hello-big { text-align: left; }
.usb-risk-review .hello-small { margin-left: 0; max-width: none; }
.usb-risk-review .gate-kicker { color: var(--usb-caution); }
.usb-risk-page { animation: hello-arrive 300ms var(--ease) both; }
.usb-risk-finding { margin-top: 24px; padding: 0 0 18px; border-bottom: 1px solid var(--hairline); }
.usb-risk-finding strong { font-size: 13px; }
.usb-risk-finding p { margin: 8px 0 0; font-size: 13px; color: var(--secondary); line-height: 1.6; overflow-wrap: anywhere; }
.usb-risk-impact { background: color-mix(in srgb, var(--usb-caution) 10%, transparent); border-left: 3px solid var(--usb-caution); }
.usb-risk-impact p { color: var(--label); font-size: 14px; }
.usb-risk-review .usb-consent { color: var(--label); font-size: 13px; }
.usb-risk-summary { list-style: none; margin: 24px 0; padding: 0; border-block: 1px solid var(--hairline); }
.usb-risk-summary li { padding: 14px 0; }
.usb-risk-summary li + li { border-top: 1px solid var(--hairline); }
.usb-risk-summary strong { color: var(--usb-caution); font-size: 13px; }
.usb-risk-summary p { margin: 5px 0 0; font-size: 12px; color: var(--secondary); line-height: 1.6; }
.usb-risk-review .usb-space-label { display: block; margin-top: 24px; }
.usb-risk-input { display: block; width: 100%; margin-top: 10px; border: 1px solid var(--hairline); border-radius: 9px; padding: 12px; font-size: 16px; background: var(--chrome); color: var(--label); }
.onboard .hello-actions .usb-risk-proceed:not(:disabled) { color: var(--usb-caution); border-color: var(--usb-caution); }
@keyframes usb-hover { 50% { transform: translateY(-6px) rotate(-9deg); } }
@keyframes usb-connect { 0%, 100% { transform: translateY(5px) rotate(-13deg); } 45%, 70% { transform: translateY(-5px) rotate(-13deg); } }
@keyframes usb-scan { to { rotate: 360deg; } }
@media (prefers-color-scheme: dark) {
  .onboard { --usb-good: #5ac878; --usb-caution: #efb45c; }
  .usb-device { filter: drop-shadow(6px 12px 12px #00000055); }
}
@media (max-width: 520px) {
  .onboard-rail { gap: 5px; }
  .onboard-dot { font-size: 10px; padding: 5px 7px; }
  .usb-figure { margin-top: 0; }
  .usb-setup .hello-actions button { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .onboard *, .onboard *::before { animation: none !important; transition: none !important; }
  .usb-figure[data-state="testing"] .usb-light { box-shadow: none; }
}
@keyframes onboard-pulse { 50% { opacity: .35; } }
@keyframes onboard-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .onboard-step { transition: none; }
  .onboard-step.is-entering { opacity: 1; transform: none; }
  .onboard-stamp { animation: none; }
  .onboard-checks li.is-on::before { animation: none; }
}
@media (prefers-color-scheme: dark) {
  .prelude-window, .hello-card { box-shadow: 0 30px 80px #00000050, inset 0 1px 0 #ffffff08; }
  .hello-picked { color: #ff453a; }
  .sheet-card { background: #242830; color: #eef2f8; }
  .sheet-card h2 { color: #eef2f8; }
  .sheet-card p, .field { color: #a0a8b8; }
  .field input { background: #343b48; color: #eef2f8; }
}
@media (min-width: 761px) and (max-width: 1000px) {
  :root { --sidebar-w: 215px; }
  .toolbar { padding: 10px 12px; }
  .toolbar-cluster { gap: 4px; }
}
@media (max-width: 760px) {
  :root { --titlebar: 68px; --sidebar-w: 252px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--titlebar) minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: var(--titlebar); bottom: 0; width: 252px; z-index: 12; background: color-mix(in srgb, var(--sidebar) 95%, var(--desk)); box-shadow: 20px 0 50px #15244320; border-right: 1px solid var(--hairline); }
  .shell.sidebar-hidden, .shell.focus-mode { grid-template-columns: minmax(0, 1fr); }
  .shell.sidebar-hidden .sidebar, .shell.focus-mode .sidebar { transform: translateX(-100%); visibility: hidden; }
  .titlebar { gap: 8px; padding-right: 12px; }
  .titlebar-trail { gap: 4px; }
  .doc-title { font-size: 15px; }
  .titlebar-trail .search { width: 120px; min-width: 80px; }
  .library-btn { font-size: 11px; padding: 0 6px; }
  .toolbar { padding: 8px 12px; gap: 6px; }
  .toolbar-cluster { gap: 4px; }
  .toolbar select { max-width: 104px; }
  .gate-room { padding: 32px 24px 28px; }
  .hello-card { padding: 46px 28px 40px; }
  .hello-big { font-size: 34px; }
  .hello-small { font-size: 15px; }
  .hello-actions button { min-width: 108px; }
}
@media (max-width: 440px) {
  .titlebar-trail .search { display: none; }
  .workspace-status { padding: 0 14px; gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.continuous-scroll { position: absolute; inset: 0; overflow: auto; overflow-x: hidden; overflow-anchor: none; }
.continuous-scroll::after { content: ""; display: block; width: 1px; height: var(--continuous-height, 100%); pointer-events: none; }
.continuous-stack { position: absolute; transform-origin: top left; }
.continuous-page { position: absolute; left: 0; width: 210mm; height: 297mm; border-radius: 3px; transform: none; box-shadow: 0 3px 12px var(--shadow); transition: box-shadow 450ms var(--ease); }
.continuous-page.is-live { box-shadow: 0 14px 34px var(--shadow); }

.magic-paper { overscroll-behavior: contain; }
.magic-paper .continuous-page { backface-visibility: hidden; transform-origin: center; }

.magic-curl {
  position: absolute;
  inset: 0;
  perspective: 2400px;
  pointer-events: none;
}
.magic-curl-surface {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}
.magic-curl-strip {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
  will-change: transform;
}
.magic-curl-face {
  position: absolute;
  inset: 0 auto 0 0;
  overflow: hidden;
  backface-visibility: hidden;
  contain: paint;
}
.magic-curl-back { transform: rotateY(180deg); }
.magic-curl-face .magic-curl-page {
  top: 0;
  margin: 0;
  box-shadow: none;
  border-radius: 0;
  visibility: visible;
}
.magic-curl-shade {
  position: absolute;
  inset: 0;
  background: #493c2c;
  opacity: 0;
  will-change: opacity;
}

/* The library is a room in the same workspace. Only its book bindings bring color. */
.bookshelf button:focus-visible, .shelf-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.shelf-travelling .desk, .shelf-travelling .continuous-scroll { visibility: hidden; }
.bookshelf {
  --shelf-wood: #b6ac9e;
  --shelf-front: #a89d8e;
  --shelf-edge: #dcd5cb;
  position: fixed;
  inset: 0;
  z-index: 13;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 46% 0%, #fafbfd 0%, transparent 62%), linear-gradient(150deg, var(--desk), var(--desk-deep));
  overflow: hidden;
}
.shelf-header { position: relative; flex-shrink: 0; display: flex; align-items: end; justify-content: space-between; gap: 24px; width: min(1120px, calc(100% - 96px)); margin: 0 auto; padding: calc(var(--titlebar) + 24px) 0 34px; app-region: drag; -webkit-app-region: drag; }
.shelf-header button, .shelf-header input { app-region: no-drag; -webkit-app-region: no-drag; }
.shelf-back { position: absolute; top: calc(var(--titlebar) + 4px); left: 0; font-size: 12px; color: var(--secondary); padding: 3px 0; }
.shelf-back:hover { color: var(--label); }
.shelf-heading h2 { margin: 0; font-family: var(--display); font-size: 36px; font-weight: 550; letter-spacing: -.045em; }
.shelf-count { margin: 9px 0 0; font-size: 12px; color: var(--secondary); }
.shelf-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; align-items: center; padding-bottom: 2px; }
.shelf-group-btn { min-height: 36px; padding: 0 12px; border: 1px solid var(--hairline); border-radius: 9px; background: var(--chrome); font-size: 12px; color: var(--secondary); white-space: nowrap; }
.shelf-group-btn[aria-pressed="true"] { color: var(--label); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--chrome)); }
.shelf-folder-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; margin: 0 28px 4px; font-family: var(--ui); font-size: 14px; font-weight: 550; color: var(--label); overflow-wrap: anywhere; }
.shelf-folder-count { font-size: 11px; font-weight: 400; color: var(--secondary); }
.shelf-search { width: 180px; height: 36px; padding: 0 13px; border: 1px solid var(--hairline); border-radius: 9px; background: var(--chrome); font-size: 12px; }
.shelf-new { min-height: 36px; padding: 0 15px; font-size: 12px; font-weight: 550; border-radius: 9px; background: var(--label); color: var(--desk); box-shadow: 0 2px 4px #14223812; white-space: nowrap; }
.shelf-new:hover { opacity: .85; }
.shelf-new-cluster { position: relative; flex-shrink: 0; margin-left: auto; app-region: no-drag; -webkit-app-region: no-drag; }
.shelf-header:has(.shelf-new-menu:not([hidden])) { z-index: 15; }
.shelf-new-divider { height: 1px; margin: 4px 6px; background: var(--hairline); }
.shelf-view { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--hairline); border-radius: 10px; background: var(--chrome); }
.shelf-view-btn { min-height: 30px; padding: 0 13px; font-size: 12px; font-weight: 550; border-radius: 8px; color: var(--secondary); transition: background 240ms var(--ease), color 240ms, box-shadow 240ms var(--ease), transform 160ms var(--ease); white-space: nowrap; }
.shelf-view-btn:hover { color: var(--label); }
.shelf-view-btn:active { transform: scale(.97); }
.shelf-view-btn.is-active { background: var(--label); color: var(--desk); box-shadow: 0 2px 6px #14223822; }
.shelf-scroll { overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; padding: 8px 24px 80px; scrollbar-gutter: stable both-edges; overscroll-behavior: contain; }
.shelf-rows { width: min(1120px, 100%); margin: 0 auto; }
.shelf-row { position: relative; padding: 28px 28px 0; margin-bottom: 62px; }
.shelf-row::before { content: ""; position: absolute; inset: 0 10px 1px; pointer-events: none; border-radius: 3px; background: linear-gradient(180deg, #52617400 0%, #52617403 44%, #3c485a0b 85%, #202a3b1a 100%); box-shadow: inset 0 -35px 35px -30px #17203128; }
.shelf-books { display: grid; grid-template-columns: repeat(var(--shelf-columns), minmax(0, 1fr)); gap: 28px; align-items: end; position: relative; z-index: 2; }
.shelf-slot { --volume-width: 164px; position: relative; display: flex; flex-direction: column; align-items: center; padding-bottom: 7px; min-width: 0; }
.shelf-book { width: var(--volume-width); height: calc(var(--volume-width) * 1.4142857); position: relative; display: block; text-align: center; overflow: visible; transition: transform 420ms var(--ease); }
.shelf-book::after { content: ""; position: absolute; left: 8%; right: -10%; bottom: -9px; height: 14px; background: #17191d50; border-radius: 50%; filter: blur(7px); z-index: -1; transition: opacity 400ms; }
.shelf-book:hover, .shelf-book:focus-visible { transform: translateY(-12px); }
.shelf-book:active { transform: translateY(-8px) scale(.99); }
.shelf-book:hover::after { opacity: .55; }
.shelf-book { cursor: grab; transition: transform 420ms var(--ease), box-shadow 220ms ease; will-change: transform; }
.shelf-book.is-dragging { opacity: .55; cursor: grabbing; transform: translateY(-14px) scale(1.04); }
.shelf-book.drop-target { box-shadow: 0 0 0 3px var(--accent), 0 0 28px -4px var(--accent); transform: translateY(-12px) scale(1.03); }
.shelf-caption { position: absolute; top: calc(100% + 32px); max-width: calc(100% + 18px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; letter-spacing: .01em; color: var(--secondary); transition: opacity 200ms ease; }
/* Captions belong to settled slots; hide them while bindings are airborne. */
.bookshelf.is-settling .shelf-caption { opacity: 0 !important; transition: opacity 160ms ease; }
.shelf-book[aria-current="true"] + .shelf-caption::before { content: ""; display: inline-block; width: 4px; height: 4px; margin: 0 6px 2px 0; border-radius: 50%; background: var(--accent); }
.shelf-plank { position: relative; z-index: 3; height: 17px; margin: 0 -28px; border-radius: 1px 1px 2px 2px; background: linear-gradient(180deg, #ffffff50, transparent 16%, #00000008 80%, #0000001c), repeating-linear-gradient(0deg, transparent 0 2px, #65584712 2px 3px), linear-gradient(90deg, var(--shelf-wood), var(--shelf-front) 48%, var(--shelf-wood)); box-shadow: 0 1px 0 #ffffff55 inset, 0 -1px 0 #70665840 inset, 0 2px 2px #18212d14, 0 10px 14px -4px #18212d26, 0 28px 35px -13px #18212d2b; }
.shelf-plank::before { content: ""; position: absolute; left: 0; right: 0; height: 13px; bottom: 100%; background: linear-gradient(180deg, var(--shelf-wood), var(--shelf-edge)); clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 100%, 0 100%); }
.shelf-status { flex-shrink: 0; margin: 0; padding: 0 24px 16px; text-align: center; font-size: 12px; color: var(--label); }
.shelf-status:empty { display: none; }
.shelf-empty { padding: 70px 24px; text-align: center; }
.shelf-empty h3 { font-family: var(--page); font-size: 28px; font-weight: 400; }
.shelf-empty p { color: var(--secondary); font-size: 13px; }

/* All dimensions derive from the cover width, including the travelling binding. */
.bound-book, .travel-binding { --book-depth: calc(var(--volume-width) * .065); position: absolute; inset: 0; transform-style: preserve-3d; }
.bound-book { transform: rotateY(-16deg) rotateX(3deg); }
.volume-cover, .volume-back, .volume-pages, .volume-spine { position: absolute; }
.volume-cover, .volume-back { inset: 0; border-radius: calc(var(--volume-width) * .015) calc(var(--volume-width) * .03) calc(var(--volume-width) * .03) calc(var(--volume-width) * .015); background-color: var(--cloth); }
.volume-cover {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32% 12% 34% 16%;
  text-align: center;
  color: #e4d2ac;
  background-image: linear-gradient(90deg, #00000035, #ffffff0a 3%, #00000025 5%, transparent 8%, #ffffff06 48%, #0000000a), repeating-linear-gradient(0deg, #ffffff06 0 .6px, #00000006 .6px 1.5px), repeating-linear-gradient(90deg, #ffffff04 0 .6px, transparent .6px 2px);
  box-shadow: inset 0 1px 1px #ffffff30, inset -1px 0 1px #00000040, inset 1px 0 1px #ffffff20, 2px 4px 7px #00000018;
  backface-visibility: hidden;
  transform: translateZ(calc(var(--volume-width) * .006));
  text-shadow: 0 1px 1px #00000070;
}
.volume-cover::before { content: ""; position: absolute; inset: 9% 9% 9% 13%; border: 1px solid #d9c49b42; border-radius: 1px; box-shadow: 0 0 0 3px #00000004, 0 0 0 4px #d9c49b12; pointer-events: none; }
.volume-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(128deg, #ffffff0c, transparent 45%, #00000012); border-radius: inherit; pointer-events: none; }
.cover-imprint { position: absolute; top: 15%; left: 17%; right: 13%; font-family: var(--ui); font-size: calc(var(--volume-width) * .037); line-height: 1.5; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; opacity: .8; }
.cover-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; max-width: 100%; font-family: var(--page); font-size: calc(var(--volume-width) * var(--title-size, .132)); line-height: 1.2; font-weight: 400; letter-spacing: -.035em; overflow-wrap: anywhere; text-wrap: balance; }
.cover-rule { width: 18%; height: 1px; flex-shrink: 0; margin-top: 12%; background: #d9c49b80; box-shadow: 0 1px 0 #00000040; }
.cover-footer { position: absolute; bottom: 15%; left: 20%; right: 16%; font-family: var(--page); font-size: calc(var(--volume-width) * .052); font-style: italic; line-height: 1.35; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; opacity: .7; }
.volume-back { transform: translateZ(calc(var(--book-depth) * -1)); box-shadow: 0 10px 18px #12182728; }
.volume-pages { top: 1.3%; bottom: 1.3%; left: 1%; right: 1.6%; background: repeating-linear-gradient(0deg, #e5dfd2 0 1px, #f5f0e5 1px 2px, #cfc7b7 2px 2.5px); border-radius: 1px 4px 4px 1px; transform: translateZ(calc(var(--book-depth) * -.45)) translateX(calc(var(--volume-width) * .023)); box-shadow: 1px 1px 0 #cdc3b2, 2px 2px 0 #f3ecdd, 3px 3px 0 #c4b9a7; }
.volume-spine { width: var(--book-depth); top: 0; bottom: 0; left: 0; transform-origin: left center; transform: rotateY(90deg); background: linear-gradient(90deg, #00000045, #ffffff0a 40%, #00000030), var(--cloth); border-radius: 2px; color: #d5c29d; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.volume-spine::before, .volume-spine::after { content: ""; position: absolute; top: 10%; left: 0; right: 0; height: 2px; border-block: 1px solid #d9c49b50; }
.volume-spine::after { top: auto; bottom: 10%; }
.spine-title { writing-mode: vertical-rl; font-family: var(--page); font-size: calc(var(--volume-width) * .045); line-height: 1; white-space: nowrap; max-height: 70%; overflow: hidden; text-overflow: ellipsis; letter-spacing: .03em; }
.travel-book { position: fixed; top: 0; left: 0; z-index: 15; transform-origin: center; transform-style: preserve-3d; perspective: 6000px; pointer-events: none; will-change: transform; }
.travel-page { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border-radius: 3px 12px 12px 4px; transform: translateZ(0); box-shadow: inset 18px 0 28px #5a3c140d; }
.travel-hinge { position: absolute; inset: 0; transform-origin: left center; transform-style: preserve-3d; will-change: transform; }
.travel-outside { transform: translateZ(2px); }
.travel-inside { backface-visibility: hidden; transform: rotateY(180deg); border-radius: 12px 3px 4px 12px; }
.travel-endpaper { position: absolute; inset: 0; background: linear-gradient(90deg, #e5dfd1, #f1ece0 6%, #eae4d7); box-shadow: inset -20px 0 30px #42352118; }
.travel-shade { position: absolute; inset: 0; background: linear-gradient(90deg, #17171660, #17171608 80%); opacity: 0; transform: translateZ(1px); pointer-events: none; }
@media (prefers-color-scheme: dark) {
  .bookshelf { --shelf-wood: #514b45; --shelf-front: #423d38; --shelf-edge: #756b60; background: radial-gradient(ellipse at 46% 0%, #31353e, transparent 65%), linear-gradient(150deg, var(--desk), var(--desk-deep)); }
  .shelf-row::before { background: linear-gradient(180deg, transparent, #00000040); box-shadow: inset 0 -35px 35px -30px #00000080; }
  .shelf-plank { box-shadow: 0 1px 0 #ffffff20 inset, 0 -1px 0 #00000060 inset, 0 2px 3px #00000040, 0 12px 20px -4px #00000065, 0 28px 40px -13px #00000070; }
}
@media (min-width: 1400px) { .shelf-slot { --volume-width: 180px; } .shelf-row { padding-top: 38px; } }
@media (max-width: 760px) {
  .shelf-header { width: calc(100% - 48px); flex-wrap: wrap; padding: calc(var(--titlebar) + 18px) 0 24px; gap: 20px; }
  .shelf-heading h2 { font-size: 30px; }
  .shelf-actions { width: 100%; flex-wrap: wrap; }
  .shelf-search { flex: 1; min-width: 0; }
  .shelf-row { padding-inline: 16px; }
  .shelf-plank { margin-inline: -16px; }
  .shelf-books { gap: 22px; }
  .shelf-scroll { padding-inline: 16px; }
  .shelf-slot { --volume-width: 150px; }
}
@media (max-width: 440px) { .shelf-slot { --volume-width: 124px; } }
@media (max-width: 350px) { .shelf-slot { --volume-width: 164px; } }
@media (prefers-reduced-motion: reduce) { .shelf-book:hover, .shelf-book:focus-visible { transform: none; } }

/* A small binding studio: familiar cloth cover, quiet details alongside it. */
.sheet-card.book-details-card { width: min(720px, calc(100% - 32px)); padding: 32px; }
.book-details-eyebrow { font-family: var(--ui); font-size: 11px; font-weight: 550; letter-spacing: .12em; text-transform: uppercase; color: var(--secondary); }
.book-details-card .book-details-header h2 { margin-top: 10px; }
.book-details-card .book-details-header p { max-width: 480px; margin-bottom: 28px; }
.book-details-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 40px; align-items: center; }
.book-details-fields { min-width: 0; }
.book-details-fields .field { margin-bottom: 20px; }
.book-details-fields input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.book-details-fields input[readonly] { opacity: .7; }
.book-field-hint { font-weight: 400; font-size: 11px; line-height: 1.5; color: var(--secondary); }
.book-cover-preview { margin: 0; padding: 20px 0; text-align: center; perspective: 1200px; }
#new-cover { --volume-width: 208px; position: relative; width: var(--volume-width); height: calc(var(--volume-width) * 1.4142857); margin: 0 auto; }
.book-cover-preview figcaption { margin-top: 24px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--secondary); }
#new-cover-color {
  display: block;
  width: 100%;
  height: 28px;
  margin-top: 8px;
  appearance: none;
  background: linear-gradient(90deg, hsl(0, 22%, 30%), hsl(60, 22%, 30%), hsl(120, 22%, 30%), hsl(180, 22%, 30%), hsl(240, 22%, 30%), hsl(300, 22%, 30%), hsl(360, 22%, 30%));
  border-radius: 999px;
  border: 1px solid var(--hairline);
}
#new-cover-color::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink, #1c1916);
  box-shadow: 0 1px 4px #00000040;
}
#new-cover-color::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink, #1c1916);
}
.book-details-card .sheet-actions { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--hairline); }
.book-details-card #new-error { margin: 0; color: #c34b50; }
.sheet-actions .danger { background: #ae3943; color: #fff; }
@media (max-width: 600px) {
  .sheet-card.book-details-card { padding: 24px; }
  .book-details-layout { grid-template-columns: minmax(0, 1fr) 132px; gap: 20px; }
  #new-cover { --volume-width: 124px; }
}
@media (max-width: 420px) {
  .book-details-layout { grid-template-columns: 1fr; gap: 0; }
  .book-cover-preview { padding: 10px 0; }
  #new-cover { --volume-width: 140px; }
}

/* Compact mode: every binding stands shoulder to shoulder, spines out. */
.bookshelf.is-compact .shelf-row { padding: 20px 28px 0; }
.bookshelf.is-compact .shelf-books { display: flex; flex-wrap: nowrap; align-items: flex-end; justify-content: center; gap: 5px; min-height: 258px; padding: 6px 12px 0; }
.bookshelf.is-compact .shelf-slot { padding-bottom: 7px; }
.bookshelf.is-compact .shelf-book { width: auto; height: auto; transition: transform 520ms cubic-bezier(.16, 1, .3, 1), box-shadow 320ms ease, filter 320ms ease; }
.bookshelf.is-compact .shelf-book::after { left: 6%; right: 6%; bottom: -7px; height: 10px; filter: blur(6px); }
.bookshelf.is-compact .shelf-book:hover, .bookshelf.is-compact .shelf-book:focus-visible { transform: translateY(-12px) scale(1.05); }
.bookshelf.is-compact .shelf-book:hover .compact-spine, .bookshelf.is-compact .shelf-book:focus-visible .compact-spine { filter: brightness(1.12); box-shadow: inset 1px 0 0 #ffffff38, inset -1px 0 1px #00000055, inset 0 1px 0 #ffffff2e, 0 14px 22px -8px #12182755; }
.bookshelf.is-compact .shelf-book:hover::after, .bookshelf.is-compact .shelf-book:focus-visible::after { opacity: .6; }
.bookshelf.is-compact .shelf-book:active { transform: translateY(-7px) scale(1.01); }
.bookshelf.is-compact .shelf-book.is-dragging { transform: translateY(-14px) scale(1.07); opacity: .6; }
.bookshelf.is-compact .shelf-book.drop-target { box-shadow: 0 0 0 2.5px var(--accent), 0 0 24px -4px var(--accent); transform: translateY(-12px) scale(1.06); border-radius: 5px; }
.bookshelf.is-compact .shelf-book.is-spine[aria-current="true"]::before { content: ""; position: absolute; left: 50%; bottom: -15px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); z-index: 4; }
.compact-spine { position: relative; width: var(--spine-w, 36px); height: var(--spine-h, 220px); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 24px 0 20px; border-radius: 3px 5px 5px 3px / 5px; background: linear-gradient(90deg, #0000005c, #ffffff17 12%, #ffffff09 32%, #0000002c 86%, #0000005e), linear-gradient(180deg, #ffffff17, transparent 20%, transparent 80%, #00000034), repeating-linear-gradient(0deg, #ffffff05 0 .7px, transparent .7px 2px), var(--cloth); background-color: var(--cloth); box-shadow: inset 1px 0 0 #ffffff2c, inset -1px 0 1px #00000055, inset 0 1px 0 #ffffff22, 0 7px 14px -6px #1218274d; color: #e6d3ab; text-shadow: 0 1px 1px #00000075; transition: filter 260ms ease, box-shadow 280ms ease; will-change: transform; }
.compact-spine::before { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; background: linear-gradient(180deg, #ffffff2e, #ffffff08 30%, #00000038 85%); opacity: .8; pointer-events: none; }
.compact-spine::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(115deg, #ffffff14, transparent 42%, #00000014); pointer-events: none; }
.compact-title { writing-mode: vertical-rl; font-family: var(--page); font-size: 12.5px; font-weight: 400; letter-spacing: .045em; line-height: 1; white-space: nowrap; max-height: 60%; overflow: hidden; text-overflow: ellipsis; }
.compact-band { width: 68%; height: 6px; flex-shrink: 0; border-top: 1px solid #d9c49b59; border-bottom: 1px solid #d9c49b59; opacity: .85; }
.bookshelf.is-compact .shelf-caption { top: auto; bottom: calc(100% + 12px); left: 50%; max-width: 190px; padding: 5px 10px; border-radius: 8px; background: var(--label); color: var(--desk); font-size: 11px; font-weight: 550; letter-spacing: 0; transform: translate(-50%, 5px); opacity: 0; pointer-events: none; transition: opacity 220ms ease, transform 300ms var(--ease); z-index: 6; box-shadow: 0 6px 18px #12182738; }
.bookshelf.is-compact .shelf-book[aria-current="true"] + .shelf-caption::before { display: none; }
.bookshelf.is-compact .shelf-slot:hover .shelf-caption, .bookshelf.is-compact .shelf-book:focus-visible + .shelf-caption { opacity: 1; transform: translate(-50%, 0); }
/* Floating stage for the covers/spines turn-and-settle flight. */
.shelf-transition-stage { position: fixed; inset: 0; z-index: 14; pointer-events: none; }
.shelf-transition-stage > * { pointer-events: none !important; will-change: transform, opacity; }
.model-flight { position: fixed; margin: 0; }
/* True 3D cuboid book: cover front, cloth back, spine + page sides, page top. */
.book-model { position: relative; width: var(--w); height: var(--h); transform-style: preserve-3d; }
.m-face { position: absolute; backface-visibility: hidden; }
.m-front {
  inset: 0; transform: translateZ(calc(var(--d) / 2));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32% 12% 34% 16%;
  text-align: center;
  color: #e4d2ac;
  background-color: var(--cloth);
  background-image: linear-gradient(90deg, #00000035, #ffffff0a 3%, #00000025 5%, transparent 8%, #ffffff06 48%, #0000000a), repeating-linear-gradient(0deg, #ffffff06 0 .6px, #00000006 .6px 1.5px), repeating-linear-gradient(90deg, #ffffff04 0 .6px, transparent .6px 2px);
  border-radius: calc(var(--w) * .015) calc(var(--w) * .03) calc(var(--w) * .03) calc(var(--w) * .015);
  box-shadow: inset 0 1px 1px #ffffff30, inset -1px 0 1px #00000040, inset 1px 0 1px #ffffff20;
  text-shadow: 0 1px 1px #00000070;
  overflow: hidden;
}
.m-front::before { content: ""; position: absolute; inset: 9% 9% 9% 13%; border: 1px solid #d9c49b42; border-radius: 1px; box-shadow: 0 0 0 3px #00000004, 0 0 0 4px #d9c49b12; pointer-events: none; }
.m-front::after { content: ""; position: absolute; inset: 0; background: linear-gradient(128deg, #ffffff0c, transparent 45%, #00000012); border-radius: inherit; pointer-events: none; }
.m-back { inset: 0; transform: rotateY(180deg) translateZ(calc(var(--d) / 2)); background-color: var(--cloth); border-radius: calc(var(--w) * .015) calc(var(--w) * .03) calc(var(--w) * .03) calc(var(--w) * .015); }
.m-spine {
  top: 0; left: calc(var(--w) - var(--d) / 2); width: var(--d); height: var(--h);
  transform: rotateY(90deg);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 24px 0 20px;
  color: #e6d3ab;
  background-color: var(--cloth);
  background-image: linear-gradient(90deg, #0000005c, #ffffff17 12%, #ffffff09 32%, #0000002c 86%, #0000005e), linear-gradient(180deg, #ffffff17, transparent 20%, transparent 80%, #00000034), repeating-linear-gradient(0deg, #ffffff05 0 .7px, transparent .7px 2px);
  box-shadow: inset 1px 0 0 #ffffff2c, inset -1px 0 1px #00000055, inset 0 1px 0 #ffffff22;
  text-shadow: 0 1px 1px #00000075;
  border-radius: 3px 5px 5px 3px / 5px;
  overflow: hidden;
}
.m-pages {
  top: 0; left: calc(var(--d) / -2); width: var(--d); height: var(--h);
  transform: rotateY(-90deg);
  background: repeating-linear-gradient(0deg, #e5dfd2 0 1px, #f5f0e5 1px 2px, #cfc7b7 2px 2.5px);
  border-radius: 1px;
}
.m-top {
  left: 0; top: calc(var(--d) / -2); width: var(--w); height: var(--d);
  transform: rotateX(90deg);
  background: repeating-linear-gradient(90deg, #e5dfd2 0 1px, #f5f0e5 1px 2px, #cfc7b7 2px 2.5px);
  border-radius: 1px;
}
@media (max-width: 760px) {
  .bookshelf.is-compact .shelf-books { gap: 4px; min-height: 232px; padding-inline: 4px; }
  .bookshelf.is-compact .shelf-row { padding-inline: 16px; }
  .shelf-view { order: -1; }
}
@media (prefers-reduced-motion: reduce) {
  .bookshelf.is-compact .shelf-book, .bookshelf.is-compact .shelf-book:hover, .bookshelf.is-compact .shelf-book:focus-visible { transform: none; transition: none; }
  .bookshelf.is-compact .shelf-caption { transition: none; }
}

/* File transfer and library creation menus. */
.file-tool { width: auto; padding: 0 10px; font-size: 12px; font-weight: 590; white-space: nowrap; }
.file-tool:hover { background: color-mix(in srgb, white 70%, transparent); }
.export-cluster { position: relative; }
.export-menu, .shelf-new-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 178px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--chrome) 88%, var(--paper));
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  box-shadow: 0 12px 32px var(--shadow);
}
.export-menu[hidden], .shelf-new-menu[hidden] { display: none; }
.export-menu button, .shelf-new-menu button {
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 510;
  white-space: nowrap;
}
.export-menu button:hover, .shelf-new-menu button:hover, .shelf-new-menu button:focus-visible { background: var(--fill); }
.shelf-new-menu { min-width: 222px; max-width: calc(100vw - 48px); }
.shelf-new-menu button:focus-visible { outline-offset: -2px; }
.shelf-book-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  z-index: 40;
  min-width: 196px;
  background: color-mix(in srgb, var(--desk) 62%, var(--paper));
}
.shelf-book-menu-heading {
  margin: 4px 10px 6px;
  font-family: var(--page);
  font-size: 13px;
  font-style: italic;
  color: var(--secondary);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shelf-book-menu .is-danger { color: #c34b50; }
.shelf-book-menu .is-danger:hover, .shelf-book-menu .is-danger:focus-visible {
  background: color-mix(in srgb, #c34b50 12%, var(--chrome));
}

/* Web PDF fallback: print only the exported document, never the app chrome. */
#print-root { display: none; }
@media print {
  body.printing-doc .shell,
  body.printing-doc .bookshelf,
  body.printing-doc .gate,
  body.printing-doc .sheet,
  body.printing-doc .hello,
  body.printing-doc .tip,
  body.printing-doc .shelf-transition-stage {
    display: none !important;
  }
  body.printing-doc #print-root { display: block; }
  /* Was hardcoded Georgia while the editor rendered Iowan Old Style, so a printed
     page was set in a different typeface from the one the writer composed in.
     Stated literally rather than as var(--page) so scripts/export-parity.test.ts
     can compare it against PAGE_FONT_STACK directly — the exporter writes the
     constant into generated HTML, so tying this to the CSS token would let the
     two drift apart without anything noticing. */
  #print-root { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Times New Roman", serif; color: #000; line-height: 1.5; font-size: 12pt; }
  #print-root h1.doc-title { font-size: 18pt; }
  #print-root h1 { font-size: 18pt; }
  #print-root h2 { font-size: 14pt; }
  #print-root h3 { font-size: 12.5pt; }
  #print-root hr.page-break { break-after: page; border: 0; margin: 0; }
}

.analytics-fields {
  display: grid;
  gap: 10px;
  padding: 2px 2px 14px;
}
.analytics-fields[hidden] { display: none; }
.analytics-fields .segmented { justify-self: start; }
.analytics-fields .field { margin-bottom: 0; }
.analytics-fields .field input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* Updates use the existing settings and status-bar controls. */
.update-setting[hidden], #update-notice[hidden], #appearance-row[hidden], #recording-row[hidden] { display: none; }
.update-setting { flex-wrap: wrap; gap: 12px; }
.update-setting .setting-body { flex: 1 1 220px; }
#update-action { flex-shrink: 0; }
#update-action:disabled { opacity: .55; cursor: wait; }
#update-notice { color: var(--accent); font-size: 11px; }
.wifi-sheet { z-index: 10000; }
.wifi-card { max-width: 520px; }
.wifi-card label { display: block; margin-top: 12px; font-size: 12px; }
.wifi-card select, .wifi-card textarea { box-sizing: border-box; width: 100%; margin-top: 6px; padding: 8px; color: inherit; background: transparent; border: 1px solid currentColor; border-radius: 4px; }
.wifi-card textarea { font: 11px/1.6 monospace; overflow-wrap: anywhere; resize: none; }
.wifi-qr { width: 220px; max-width: 100%; margin: 18px auto; background: white; }
.wifi-qr svg { display: block; width: 100%; height: auto; }
