: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);
}

@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;
}

.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 86px;
  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;
}

.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;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 590;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--secondary);
}

.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;
}

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

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

.tree-item.selected {
  background: var(--accent);
  color: white;
}

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

.twisty {
  width: 12px;
  font-size: 10px;
  opacity: 0.7;
}

.new-btn {
  margin: 0 12px 14px;
  height: 36px;
  border-radius: 10px;
  background: var(--fill-strong);
  font-weight: 590;
}

.new-btn:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--fill-strong));
}

.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);
}

.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);
  max-width: min(160px, 34vw);
}

.ghost-tool {
  width: 32px;
}

.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,
.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;
  perspective: 5000px;
  perspective-origin: 50% 42%;
  container-type: size;
}

.desk.turning {
  overflow: visible;
}

.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;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transform-origin: center center;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.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;
}

.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;
  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;
}

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

.folio {
  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;
  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: 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%);
}

.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;
}

.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;
}

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

.ProseMirror h1,
.ProseMirror h2,
.ProseMirror h3 {
  font-weight: 650;
  margin: 0 0 0.55em;
}

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

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

.ProseMirror h3 {
  font-size: 12pt;
}

.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);
  }

  .titlebar {
    padding-left: 76px;
  }

  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) {
  .eyebrow {
    display: none;
  }

  .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); }
.eyebrow { font-size: 10px; letter-spacing: .13em; margin-bottom: 5px; }
.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); }
#document-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; }
.tree-item { min-height: 42px; margin-bottom: 3px; border-radius: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-item[data-kind="folder"] { color: var(--secondary); font-weight: 600; font-size: 12px; }
.tree-item[data-kind="document"] .twisty { width: 13px; height: 16px; border: 1.2px solid currentColor; border-radius: 2px; opacity: .55; position: relative; flex-shrink: 0; }
.tree-item[data-kind="document"] .twisty::after { content: ""; position: absolute; left: 3px; top: 5px; width: 5px; height: 1px; background: currentColor; box-shadow: 0 3px currentColor; }
.tree-item.selected { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.new-btn { display: flex; gap: 9px; align-items: center; justify-content: center; min-height: 42px; margin: 0 16px 12px; min-width: 190px; border: 1px solid var(--hairline); background: var(--chrome); font-size: 13px; box-shadow: 0 2px 3px #15244304; }
.new-btn span { font-size: 22px; font-weight: 400; }
.library-note { display: flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; margin: 0 0 22px; font-size: 10px; color: var(--secondary); }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: #35a279; display: inline-block; flex-shrink: 0; }
.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::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #35a279; margin-right: 7px; vertical-align: 2px; }
.save-state[data-state="editing"]::before { background: #d29b44; }
.save-state[data-state="error"] { color: #c34444; }
.save-state[data-state="error"]::before { background: currentColor; }
.empty-library { padding: 20px 12px; font-size: 13px; line-height: 1.6; color: var(--secondary); }
.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 .search, .shell.focus-mode .library-btn { 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; }
.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:hover { background: var(--accent-press); }
.hello-no:hover { background: var(--fill); }
.hello-actions button:active { transform: scale(.97); }
.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; }
@keyframes hello-arrive { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes hello-caret { 50% { opacity: 0; } }
@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; }
}
