/* =========================================================
   Morrow — a quieter place to write
   Design system, layout and editor styles
   ========================================================= */

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 100%;
  font-display: swap;
  src: url("../fonts/instrument-sans-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Instrument Sans";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/instrument-sans-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url("../fonts/newsreader-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 300 600;
  font-display: swap;
  src: url("../fonts/newsreader-italic.woff2") format("woff2");
}

:root {
  --font-ui: "Instrument Sans", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-reading: "Newsreader", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-mono: "SFMono-Regular", ui-monospace, "Cascadia Code", "Roboto Mono", monospace;
  --sidebar-w: 276px;
  --topbar-h: 62px;
  --tools-w: 344px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --radius-sm: 9px;
  --radius-md: 13px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2efe7;
  --bg-deep: #ebe6da;
  --surface: #faf8f3;
  --surface-raised: #fffdf9;
  --paper: #fffdf9;
  --paper-edge: #f3efe5;
  --ink: #252720;
  --ink-soft: #505249;
  --muted: #83847a;
  --faint: #a7a79c;
  --line: #e5dfd3;
  --line-soft: #eee9df;
  --line-strong: #d8d1c2;
  --accent: #506d53;
  --accent-strong: #3d5741;
  --accent-soft: #e5ede1;
  --accent-softer: #eef3eb;
  --accent-ink: #364b39;
  --warm: #a97b57;
  --warm-soft: #f3e8dc;
  --danger: #ad594f;
  --danger-soft: #f7e7e3;
  --highlight: #f1e4bd;
  --selection: #dbe7d3;
  --mark-underline: #c36d5f;
  --glass: rgba(248, 246, 240, .82);
  --sidebar-bg: #eae6dc;
  --sidebar-active: rgba(255, 253, 248, .78);
  --toolbar-bg: rgba(255, 253, 249, .86);
  --shadow-xs: 0 1px 2px rgba(52, 45, 31, .05);
  --shadow-sm: 0 4px 16px rgba(52, 45, 31, .06), 0 1px 3px rgba(52, 45, 31, .05);
  --shadow-md: 0 14px 44px rgba(52, 45, 31, .09), 0 3px 10px rgba(52, 45, 31, .04);
  --shadow-lg: 0 30px 80px rgba(52, 45, 31, .14), 0 8px 24px rgba(52, 45, 31, .06);
  --grain-opacity: .032;
  --glow-a: rgba(184, 199, 162, .34);
  --glow-b: rgba(226, 195, 148, .24);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121411;
  --bg-deep: #0d0f0c;
  --surface: #191c17;
  --surface-raised: #20231e;
  --paper: #1d201b;
  --paper-edge: #22261f;
  --ink: #eae9df;
  --ink-soft: #c9cabf;
  --muted: #8f9285;
  --faint: #686c60;
  --line: #2c3028;
  --line-soft: #252920;
  --line-strong: #3a4035;
  --accent: #a3bd9e;
  --accent-strong: #c0d5b9;
  --accent-soft: #283225;
  --accent-softer: #222a1f;
  --accent-ink: #c3d8bc;
  --warm: #c59b78;
  --warm-soft: #33291f;
  --danger: #d98b7f;
  --danger-soft: #34221f;
  --highlight: #5b4e2b;
  --selection: #35452f;
  --mark-underline: #df9387;
  --glass: rgba(20, 23, 18, .82);
  --sidebar-bg: #151814;
  --sidebar-active: rgba(255, 255, 255, .055);
  --toolbar-bg: rgba(29, 32, 27, .88);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, .2), 0 1px 3px rgba(0, 0, 0, .14);
  --shadow-md: 0 14px 44px rgba(0, 0, 0, .3), 0 3px 10px rgba(0, 0, 0, .16);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, .46), 0 8px 24px rgba(0, 0, 0, .22);
  --grain-opacity: .045;
  --glow-a: rgba(82, 107, 73, .18);
  --glow-b: rgba(146, 110, 67, .13);
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
input, select { min-width: 0; }
svg { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
::selection { background: var(--selection); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -64px; left: 18px; z-index: 500;
  background: var(--ink); color: var(--bg); padding: 10px 16px;
  border-radius: 8px; text-decoration: none; transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* =========================================================
   App frame, ambience
   ========================================================= */
.app {
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}
.app.sidebar-collapsed { --sidebar-w: 0px; }
.app.sidebar-collapsed .sidebar { display: none; }
.app.sidebar-collapsed .menu-btn { display: grid; }
.app::after {
  content: "";
  position: absolute; inset: 0; z-index: 100;
  pointer-events: none; opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
:root[data-theme="dark"] .app::after { mix-blend-mode: screen; }
.ambient { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.ambient span { position: absolute; border-radius: 999px; filter: blur(90px); }
.ambient span:first-child { width: 600px; height: 500px; right: 4%; top: -180px; background: var(--glow-a); }
.ambient span:last-child { width: 520px; height: 420px; left: 30%; bottom: -230px; background: var(--glow-b); }

/* =========================================================
   Sidebar / library
   ========================================================= */
.sidebar {
  width: var(--sidebar-w);
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--sidebar-bg) 92%, white 8%), var(--sidebar-bg) 45%, color-mix(in srgb, var(--sidebar-bg) 92%, var(--bg-deep) 8%));
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.sidebar-inner {
  display: flex; flex-direction: column;
  width: var(--sidebar-w); height: 100%;
  padding: 22px 15px 14px;
}
.brand-row { display: flex; align-items: center; justify-content: space-between; padding: 0 5px 0 3px; height: 36px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0; border-radius: 10px; }
.brand:hover .brand-mark { transform: rotate(-4deg) scale(1.04); }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 11px;
  color: #f7f3e8;
  background: linear-gradient(145deg, #5d765e, #3d5842);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24), 0 4px 12px rgba(46, 66, 48, .22);
  transition: transform .3s var(--ease-spring);
}
.brand-mark svg { width: 23px; height: 23px; stroke-width: 1.6; }
.brand-type { font-family: var(--font-reading); font-size: 23px; font-weight: 500; letter-spacing: -.025em; position: relative; }
.brand-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--warm); margin-left: 3px; vertical-align: 9px; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border-radius: 9px; color: var(--ink-soft);
  transition: background .18s, color .18s, transform .18s;
  position: relative; flex: 0 0 auto;
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.quiet { color: var(--muted); }
.icon-btn.quiet:hover { color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }

.sidebar-top { display: flex; flex-direction: column; gap: 10px; }
.new-doc-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 47px; padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--accent-strong) 72%, transparent);
  border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 96%, white 4%), var(--accent-strong));
  color: #f8f6ee; font-weight: 600; font-size: 13.5px; letter-spacing: .005em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 5px 15px rgba(47, 67, 49, .17);
  transition: transform .2s var(--ease), box-shadow .2s, filter .2s;
}
.new-doc-btn:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 8px 20px rgba(47, 67, 49, .24); filter: brightness(1.035); }
.new-doc-btn:active { transform: translateY(0) scale(.995); }
.new-doc-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: rgba(255,255,255,.12); }
.new-doc-icon svg { width: 16px; height: 16px; stroke-width: 2; }
.new-doc-btn kbd {
  margin-left: auto; font-family: var(--font-ui); font-size: 10px; color: rgba(255,255,255,.64);
  padding: 2px 5px; border: 1px solid rgba(255,255,255,.17); border-radius: 5px; background: rgba(255,255,255,.06);
}
.search-field {
  position: relative; display: flex; align-items: center; width: 100%; height: 38px;
  border: 1px solid transparent; border-radius: 10px;
  background: color-mix(in srgb, var(--ink) 4.7%, transparent);
  color: var(--muted); transition: border .18s, background .18s, box-shadow .18s;
}
.search-field:focus-within { background: var(--surface); border-color: var(--line-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
.search-field > svg { width: 16px; height: 16px; margin-left: 11px; flex: 0 0 auto; }
.search-field input { width: 100%; height: 100%; padding: 0 30px 0 8px; border: 0; outline: 0; background: transparent; font-size: 12.5px; color: var(--ink); }
.search-field input::placeholder { color: var(--muted); opacity: .82; }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-kbd { position: absolute; right: 10px; font-size: 10px; color: var(--faint); border: 1px solid var(--line-strong); border-radius: 4px; width: 17px; height: 17px; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 50%, transparent); }

.library-head { display: flex; align-items: center; justify-content: space-between; padding: 24px 9px 9px; }
.section-label {
  display: block; font-size: 9.5px; font-weight: 650; letter-spacing: .13em;
  text-transform: uppercase; color: var(--muted);
}
.library-count, .count-pill {
  min-width: 21px; height: 19px; padding: 0 6px;
  display: inline-grid; place-items: center; border-radius: 999px;
  font-size: 10px; font-weight: 600; color: var(--muted);
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}
.doc-list { display: flex; flex-direction: column; gap: 3px; overflow: auto; min-height: 0; margin: 0 -4px; padding: 0 4px 12px; }
.doc-list::-webkit-scrollbar { width: 4px; }
.doc-list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.doc-item { position: relative; display: flex; align-items: center; border-radius: 10px; color: var(--ink-soft); transition: background .16s; }
.doc-item:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.doc-item.is-active { background: var(--sidebar-active); color: var(--ink); box-shadow: 0 1px 2px rgba(55,48,32,.035); }
.doc-item.is-active::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2.5px;
  border-radius: 3px; background: var(--accent); opacity: .8;
}
.doc-open { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; text-align: left; padding: 9px 3px 9px 9px; border-radius: 10px; }
.doc-glyph {
  flex: 0 0 auto; display: grid; place-items: center; width: 27px; height: 31px;
  border-radius: 6px; color: var(--muted);
  background: color-mix(in srgb, var(--ink) 4%, var(--surface-raised));
  border: 1px solid var(--line-soft);
  box-shadow: 0 1px 1px rgba(50,45,30,.03);
  transition: color .16s, border .16s;
}
.doc-glyph svg { width: 14px; height: 14px; }
.doc-item.is-active .doc-glyph { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 20%, var(--line)); }
.doc-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.doc-name { font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .002em; }
.doc-meta { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.doc-meta .pin-glyph { color: var(--accent); display: inline-flex; }
.doc-meta .pin-glyph svg { width: 9px; height: 9px; transform: rotate(35deg); }
.doc-tools-btn { opacity: 0; width: 26px; height: 26px; margin-right: 4px; color: var(--muted); display: grid; place-items: center; border-radius: 6px; transition: opacity .15s, background .15s; flex: 0 0 auto; }
.doc-tools-btn svg { width: 15px; height: 15px; }
.doc-item:hover .doc-tools-btn, .doc-tools-btn[aria-expanded="true"] { opacity: 1; }
.doc-tools-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.library-empty { text-align: center; color: var(--muted); padding: 30px 14px; font-size: 11.5px; line-height: 1.5; }
.library-empty p { margin: 10px 0 3px; font-weight: 600; color: var(--ink-soft); }
.empty-orbit { width: 44px; height: 44px; border: 1px dashed var(--line-strong); border-radius: 50%; display: inline-grid; place-items: center; color: var(--muted); background: color-mix(in srgb, var(--surface) 35%, transparent); }
.empty-orbit svg { width: 18px; height: 18px; }

.sidebar-foot { margin-top: auto; padding-top: 10px; }
.goal-card {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 9px; border-radius: 11px; text-align: left;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-raised) 46%, transparent);
  transition: background .18s, border-color .18s;
}
.goal-card:hover { background: color-mix(in srgb, var(--surface-raised) 80%, transparent); border-color: var(--line-strong); }
.goal-ring { position: relative; width: 36px; height: 36px; flex: 0 0 auto; }
.goal-ring svg { width: 36px; height: 36px; transform: rotate(-90deg); }
.goal-track, .goal-value { fill: none; stroke-width: 3; }
.goal-track { stroke: var(--line-strong); }
.goal-value { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100.53; stroke-dashoffset: 100.53; transition: stroke-dashoffset .6s var(--ease); }
.goal-pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9px; font-weight: 650; color: var(--accent-ink); }
.goal-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.goal-numbers { font-size: 11px; color: var(--muted); white-space: nowrap; }
.goal-numbers strong { color: var(--ink); font-weight: 650; font-size: 12px; }
.goal-chevron { width: 13px !important; height: 13px !important; color: var(--faint); margin-left: auto; }
.storage-pill { display: flex; align-items: center; gap: 7px; width: 100%; padding: 10px 9px 5px; color: var(--muted); font-size: 10px; }
.storage-pill:hover { color: var(--ink-soft); }
.storage-pill svg { width: 13px; height: 13px; margin-left: auto; opacity: .65; }
.storage-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent); }
.sidebar-actions { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 7px; padding: 9px 2px 0 5px; }
.theme-switch { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); padding: 5px 4px; border-radius: 7px; }
.theme-switch:hover { color: var(--ink); }
.theme-icon { display: grid; place-items: center; width: 20px; height: 20px; }
.theme-icon svg { width: 15px; height: 15px; }
.theme-icon .moon-icon { display: none; }
:root[data-theme="dark"] .theme-icon .sun-icon { display: none; }
:root[data-theme="dark"] .theme-icon .moon-icon { display: block; }
.switch-track { width: 25px; height: 14px; padding: 2px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .2s; }
.switch-thumb { display: block; width: 10px; height: 10px; border-radius: 50%; background: var(--surface-raised); box-shadow: 0 1px 2px rgba(0,0,0,.12); transition: transform .22s var(--ease-spring); }
:root[data-theme="dark"] .switch-track { background: var(--accent-strong); }
:root[data-theme="dark"] .switch-thumb { transform: translateX(11px); background: #1a1d18; }
.sidebar-scrim { display: none; }

/* =========================================================
   Main + topbar
   ========================================================= */
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px 0 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  position: relative; z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12px; }
.crumb { color: var(--muted); padding: 3px 2px; border-radius: 5px; transition: color .15s; white-space: nowrap; }
button.crumb:hover { color: var(--ink); }
.crumb-sep { color: var(--faint); font-size: 11px; }
.crumb.current { color: var(--ink-soft); font-weight: 550; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-center { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; }
.save-state { display: flex; align-items: center; gap: 7px; font-size: 10.5px; color: var(--muted); border-radius: 99px; padding: 5px 10px; border: 1px solid transparent; transition: .18s; white-space: nowrap; }
.save-state:hover { border-color: var(--line); background: var(--surface); color: var(--ink-soft); }
.save-pip { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.save-state.is-saving .save-pip { animation: pip-pulse .9s ease infinite; background: var(--warm); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warm) 14%, transparent); }
.save-state.is-error { color: var(--danger); }
.save-state.is-error .save-pip { background: var(--danger); box-shadow: none; }
@keyframes pip-pulse { 50% { opacity: .35; transform: scale(.72); } }
.topbar-actions { display: flex; align-items: center; gap: 3px; flex: 0 0 auto; }
.topbar-divider { width: 1px; height: 18px; background: var(--line); margin: 0 7px; }
.export-btn {
  display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px;
  border-radius: 8px; color: var(--ink-soft); font-size: 12px; font-weight: 550;
  border: 1px solid transparent; transition: background .18s, border .18s, color .18s;
}
.export-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.export-btn > svg:first-child { width: 16px; height: 16px; }
.export-btn .chev { width: 12px; height: 12px; color: var(--faint); }
.spell-toggle { position: relative; }
.spell-badge {
  position: absolute; top: 1px; right: 0; min-width: 15px; height: 15px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 99px;
  background: var(--warm); color: #fff; font-size: 8.5px; font-weight: 700;
  border: 1.5px solid var(--bg); line-height: 1;
}
.spell-toggle.is-active { background: var(--accent-soft); color: var(--accent-ink); }
.fs-exit { display: none; }
.is-fullscreen .fs-enter { display: none; }
.is-fullscreen .fs-exit { display: block; }
.menu-anchor { position: relative; }

/* =========================================================
   Workspace and editor canvas
   ========================================================= */
.workspace { flex: 1; min-height: 0; display: flex; position: relative; }
.editor-pane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.editor-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  scroll-behavior: smooth; overscroll-behavior: contain;
  background:
    radial-gradient(ellipse at 50% -5%, color-mix(in srgb, var(--paper) 55%, transparent), transparent 50%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 75%, transparent), var(--bg) 70%);
}
.editor-scroll::-webkit-scrollbar { width: 10px; }
.editor-scroll::-webkit-scrollbar-track { background: transparent; }
.editor-scroll::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink) 15%, transparent); border: 3px solid transparent; background-clip: content-box; border-radius: 99px; }
.editor-scroll::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--ink) 26%, transparent); border: 2px solid transparent; background-clip: content-box; }
.canvas { width: 100%; max-width: 952px; margin: 0 auto; padding: 16px 34px 0; }

.toolbar-shell {
  position: sticky; top: 14px; z-index: 30;
  padding: 5px;
  border-radius: 15px;
  background: color-mix(in srgb, var(--glass) 90%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.28);
  backdrop-filter: blur(20px) saturate(1.18);
  -webkit-backdrop-filter: blur(20px) saturate(1.18);
  margin-bottom: 16px;
}
:root[data-theme="dark"] .toolbar-shell { box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.045); }
.toolbar { display: flex; align-items: center; gap: 2px; height: 36px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 0 3px; }
.toolbar::-webkit-scrollbar { display: none; }
.tool-group { display: flex; align-items: center; gap: 1px; flex: 0 0 auto; }
.tool-btn {
  width: 31px; height: 31px; display: grid; place-items: center; border-radius: 7px;
  color: var(--ink-soft); transition: background .15s, color .15s, transform .12s; position: relative;
  flex: 0 0 auto;
}
.tool-btn:hover { background: color-mix(in srgb, var(--ink) 6.5%, transparent); color: var(--ink); }
.tool-btn:active { transform: scale(.93); }
.tool-btn.is-active { background: var(--accent-soft); color: var(--accent-ink); }
.tool-btn svg { width: 17px; height: 17px; }
.tool-sep { width: 1px; height: 19px; background: var(--line); margin: 0 5px; flex: 0 0 auto; }
.tool-btn.has-caret .color-dot { position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); width: 12px; height: 2.5px; border-radius: 2px; background: var(--ink); }
.style-select-wrap { position: relative; display: flex; align-items: center; flex: 0 0 auto; }
.style-select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent;
  font-size: 11.5px; font-weight: 550; color: var(--ink-soft); padding: 0 24px 0 8px;
  height: 31px; border-radius: 7px; cursor: pointer; outline: none; max-width: 120px;
}
.style-select:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.select-chev { position: absolute; right: 6px; width: 11px; height: 11px; pointer-events: none; color: var(--faint); }

.paper {
  position: relative;
  width: 100%;
  min-height: 68vh;
  background: var(--paper);
  border: 1px solid color-mix(in srgb, var(--line) 80%, var(--paper));
  border-radius: 19px;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255,255,255,.25) inset;
  padding: 40px clamp(34px, 7.5vw, 78px) 36px;
  overflow: hidden;
  animation: page-in .7s var(--ease) both;
}
:root[data-theme="dark"] .paper { box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.03); }
@keyframes page-in { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
.paper::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(115deg, rgba(255,255,255,.22), transparent 34%);
}
:root[data-theme="dark"] .paper::before { background: linear-gradient(115deg, rgba(255,255,255,.025), transparent 34%); }
.paper-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; z-index: 1; }
.doc-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 9px; font-weight: 650;
  letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink);
  background: var(--accent-soft); padding: 4px 8px; border-radius: 5px;
}
.doc-tag::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.paper-date { font-size: 10.5px; color: var(--faint); }
.doc-title {
  display: block; width: 100%; margin: 18px 0 10px; padding: 0;
  border: 0; outline: 0; background: transparent;
  font-family: var(--font-reading); font-weight: 450; font-size: clamp(34px, 4.2vw, 47px);
  line-height: 1.07; letter-spacing: -.035em; color: var(--ink);
  position: relative; z-index: 1;
}
.doc-title::placeholder { color: var(--faint); }
.doc-info { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 10.5px; min-height: 23px; position: relative; z-index: 1; }
.doc-info strong { color: var(--ink-soft); font-weight: 600; }
.info-dot { width: 2.5px; height: 2.5px; border-radius: 50%; background: var(--faint); opacity: .7; }
.info-link { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--muted); padding: 2px 4px; border-radius: 5px; margin-left: 2px; }
.info-link:hover { color: var(--accent-ink); background: var(--accent-softer); }
.info-link svg { width: 12px; height: 12px; }
.ink-rule { height: 1px; background: linear-gradient(90deg, var(--line), var(--line-soft) 65%, transparent); margin: 22px 0 28px; position: relative; }
.ink-rule::before { content: ""; position: absolute; left: 0; top: -1px; width: 42px; height: 2px; background: var(--accent); opacity: .55; border-radius: 2px; }

/* Editor typography */
.editor {
  position: relative; z-index: 1;
  min-height: 46vh;
  font-family: var(--font-reading);
  font-size: 19.5px;
  font-weight: 380;
  line-height: 1.82;
  color: color-mix(in srgb, var(--ink) 94%, var(--ink-soft));
  letter-spacing: .002em;
  outline: none;
  caret-color: var(--accent);
  overflow-wrap: break-word;
}
.editor:empty::before {
  content: attr(data-placeholder);
  color: var(--faint);
  font-style: italic;
  pointer-events: none;
}
.editor > *:first-child { margin-top: 0; }
.editor p, .editor > div { margin: 0 0 1.05em; }
.editor h1, .editor h2, .editor h3 {
  font-family: var(--font-reading); color: var(--ink); letter-spacing: -.025em;
  line-height: 1.18; font-weight: 520; margin: 1.55em 0 .55em;
}
.editor h1 { font-size: 2.05em; }
.editor h2 { font-size: 1.52em; }
.editor h3 { font-size: 1.22em; }
.editor blockquote {
  margin: 1.35em 0; padding: 2px 0 2px 22px;
  border-left: 1.5px solid var(--accent);
  color: color-mix(in srgb, var(--ink) 74%, var(--muted));
  font-style: italic; font-size: 1.04em;
}
.editor ul, .editor ol { margin: .7em 0 1.1em; padding-left: 1.35em; }
.editor li { margin: .25em 0; padding-left: .2em; }
.editor li::marker { color: var(--accent); }
.editor a { color: var(--accent-ink); text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 3px; }
.editor a:hover { text-decoration-color: var(--accent); }
.editor strong, .editor b { font-weight: 620; color: var(--ink); }
.editor em, .editor i { font-style: italic; }
.editor u { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.editor s, .editor strike { color: var(--muted); }
.editor code {
  font-family: var(--font-mono); font-size: .79em; padding: .14em .36em;
  border-radius: 4px; background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--ink-soft); border: 1px solid var(--line-soft);
}
.editor pre {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.65;
  background: color-mix(in srgb, var(--ink) 4.5%, var(--paper));
  border: 1px solid var(--line); border-radius: 10px; padding: 15px 17px;
  white-space: pre-wrap; overflow-x: auto; margin: 1.2em 0; color: var(--ink-soft);
}
.editor hr { border: 0; height: 1px; background: var(--line-strong); width: 34%; margin: 2em auto; }
.editor img { max-width: 100%; height: auto; border-radius: 8px; margin: 1em 0; }
.editor .morrow-mark { background: var(--highlight); border-radius: 2px; padding: 0 .12em; }
.editor:focus-visible { outline: none; }
.editor [contenteditable="false"] { user-select: none; }
.editor ::selection { background: var(--selection); }
.paper-end { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 40px; padding-top: 24px; opacity: .6; }
.paper-end span { width: 34px; height: 1px; background: var(--line-strong); }
.paper-end svg { width: 16px; height: 16px; color: var(--accent); stroke-width: 1.4; }
.canvas-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 4px 22px; color: var(--faint); font-size: 9.5px; }
.canvas-footer > span:first-child { display: inline-flex; align-items: center; gap: 5px; }
.canvas-footer svg { width: 11px; height: 11px; }
.footer-brand { letter-spacing: .12em; font-size: 8.5px; color: var(--faint); opacity: .85; }
.footer-brand span { margin: 0 4px; color: var(--line-strong); }

/* Spelling + find highlights */
::highlight(morrow-spell) {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: var(--mark-underline);
  text-decoration-thickness: 1.4px;
  text-underline-offset: 3px;
  background-color: transparent;
}
::highlight(morrow-find) { background-color: color-mix(in srgb, var(--warm) 28%, transparent); color: inherit; }
::highlight(morrow-find-current) { background-color: color-mix(in srgb, var(--warm) 52%, transparent); color: inherit; }

/* Status bar */
.statusbar {
  height: 34px; flex: 0 0 34px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; font-size: 9.5px; color: var(--muted);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  position: relative; z-index: 25;
}
.status-left, .status-right { display: flex; align-items: center; gap: 9px; min-width: 0; }
.status-live { display: inline-flex; align-items: center; gap: 5px; color: var(--accent-ink); font-weight: 550; }
.status-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--accent) 12%, transparent); }
.status-sep { width: 1px; height: 9px; background: var(--line-strong); }
.status-hint { color: var(--faint); }
.status-link { display: inline-flex; align-items: center; gap: 4px; padding: 3px 5px; border-radius: 4px; color: var(--muted); font-size: 9.5px; white-space: nowrap; }
.status-link:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.status-link svg { width: 12px; height: 12px; }
.status-link kbd { font-family: var(--font-ui); font-size: 8px; border: 1px solid var(--line-strong); border-radius: 3px; padding: 1px 3px; color: var(--faint); background: var(--surface); }

/* =========================================================
   Writing tools panel
   ========================================================= */
.tools-panel {
  width: 0; flex: 0 0 auto; overflow: hidden; opacity: 0;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface);
  border-left: 0 solid var(--line);
  transition: width .34s var(--ease), opacity .24s, border-width .34s;
  position: relative; z-index: 35;
}
.app.tools-open .tools-panel { width: var(--tools-w); opacity: 1; border-left-width: 1px; }
.tools-head { width: var(--tools-w); flex: 0 0 auto; display: flex; justify-content: space-between; align-items: flex-start; padding: 25px 22px 15px; }
.tools-head h2 { margin: 4px 0 0; font-family: var(--font-reading); font-size: 23px; font-weight: 500; letter-spacing: -.025em; }
.tools-tabs { width: var(--tools-w); flex: 0 0 auto; display: flex; padding: 0 17px; border-bottom: 1px solid var(--line); gap: 2px; }
.tools-tab {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 10px 10px 11px; font-size: 11px; font-weight: 550; color: var(--muted);
  border-bottom: 1.5px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tools-tab:hover { color: var(--ink-soft); }
.tools-tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-count { min-width: 16px; height: 15px; padding: 0 4px; display: grid; place-items: center; border-radius: 99px; background: var(--warm-soft); color: var(--warm); font-size: 8.5px; font-weight: 650; }
.tools-scroll { width: var(--tools-w); flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; padding: 18px 22px 26px; }
.tools-scroll::-webkit-scrollbar { width: 4px; }
.tools-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.tools-section { display: none; animation: section-in .3s var(--ease); }
.tools-section.is-active { display: block; }
@keyframes section-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.tools-note {
  display: flex; gap: 11px; padding: 13px; border-radius: 11px;
  background: var(--accent-softer); border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--line));
  margin-bottom: 17px;
}
.note-icon { flex: 0 0 auto; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-xs); }
.note-icon svg { width: 15px; height: 15px; }
.tools-note strong { display: block; font-size: 11px; font-weight: 600; margin-bottom: 3px; color: var(--ink-soft); }
.tools-note p { margin: 0; font-size: 10px; line-height: 1.55; color: var(--muted); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; padding: 3px 1px; }
.toggle-row strong { display: block; font-size: 11px; font-weight: 550; color: var(--ink-soft); }
.toggle-row small { display: block; font-size: 9.5px; line-height: 1.45; color: var(--muted); margin-top: 2px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui { flex: 0 0 auto; width: 33px; height: 19px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .2s; }
.toggle-ui::after { content: ""; position: absolute; width: 13px; height: 13px; border-radius: 50%; left: 3px; top: 3px; background: var(--surface-raised); box-shadow: 0 1px 3px rgba(0,0,0,.16); transition: transform .22s var(--ease-spring); }
.toggle-row input:checked + .toggle-ui { background: var(--accent); }
.toggle-row input:checked + .toggle-ui::after { transform: translateX(14px); background: #f8f6ee; }
.toggle-row input:focus-visible + .toggle-ui { outline: 2px solid var(--accent); outline-offset: 3px; }
.tools-divider { height: 1px; background: var(--line); margin: 17px 0; }
.spell-summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.spell-summary h3 { font-size: 12px; font-weight: 600; margin: 4px 0 0; color: var(--ink-soft); }
.spell-list { display: flex; flex-direction: column; gap: 5px; }
.spell-item { border: 1px solid var(--line); border-radius: 9px; background: var(--surface-raised); overflow: hidden; transition: border-color .16s, box-shadow .16s; }
.spell-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.spell-item-main { display: flex; align-items: center; gap: 8px; padding: 9px 10px; width: 100%; text-align: left; }
.spell-word { font-family: var(--font-reading); font-size: 15px; font-weight: 450; color: var(--danger); text-decoration: underline wavy color-mix(in srgb, var(--danger) 60%, transparent); text-underline-offset: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spell-arrow { color: var(--faint); font-size: 10px; }
.spell-suggestion { font-size: 11px; color: var(--accent-ink); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spell-item-actions { margin-left: auto; display: flex; gap: 1px; flex: 0 0 auto; }
.mini-act { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 5px; color: var(--muted); }
.mini-act:hover { background: var(--accent-softer); color: var(--accent-ink); }
.mini-act svg { width: 13px; height: 13px; }
.spell-empty { padding: 25px 10px 18px; text-align: center; }
.spell-empty .empty-orbit { width: 42px; height: 42px; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 28%, var(--line)); background: var(--accent-softer); }
.spell-empty p { font-size: 11.5px; font-weight: 600; margin: 11px 0 4px; color: var(--ink-soft); }
.spell-empty > span:last-child { font-size: 10px; line-height: 1.55; color: var(--muted); max-width: 220px; display: block; margin: 0 auto; }
.inline-form { display: flex; gap: 6px; margin-bottom: 17px; }
.inline-form input { flex: 1; height: 34px; border: 1px solid var(--line); background: var(--surface-raised); border-radius: 7px; padding: 0 9px; outline: 0; font-size: 11px; }
.inline-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
.small-btn {
  height: 34px; padding: 0 13px; border-radius: 7px; background: var(--accent);
  color: #f8f6ee; font-size: 10.5px; font-weight: 600; transition: filter .16s;
}
.small-btn:hover { filter: brightness(1.07); }
.small-btn.ghost { background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft); font-weight: 550; }
.small-btn.ghost:hover { background: var(--accent-softer); border-color: var(--line-strong); filter: none; }
.dict-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.personal-list { display: flex; flex-wrap: wrap; gap: 5px; }
.personal-chip { display: inline-flex; align-items: center; gap: 4px; height: 25px; padding: 0 4px 0 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-raised); font-size: 10.5px; color: var(--ink-soft); }
.personal-chip button { width: 17px; height: 17px; display: grid; place-items: center; border-radius: 4px; color: var(--muted); }
.personal-chip button:hover { background: var(--danger-soft); color: var(--danger); }
.personal-chip svg { width: 10px; height: 10px; }
.dict-empty { font-size: 10px; line-height: 1.55; color: var(--muted); padding: 8px 0; }
.tools-caption { font-size: 9.5px; color: var(--muted); margin: -2px 0 8px; line-height: 1.45; }
.typo-list { display: flex; flex-direction: column; gap: 0; max-height: 285px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); }
.typo-row { display: flex; align-items: center; gap: 6px; padding: 7px 9px; font-size: 10px; border-bottom: 1px solid var(--line-soft); }
.typo-row:last-child { border-bottom: 0; }
.typo-wrong { color: var(--danger); text-decoration: line-through; }
.typo-arrow { color: var(--faint); }
.typo-right { color: var(--accent-ink); }
.typo-row .typo-meta { margin-left: auto; font-size: 8px; color: var(--faint); letter-spacing: .04em; text-transform: uppercase; }
.stats-hero { border: 1px solid var(--line); background: var(--surface-raised); border-radius: 12px; padding: 15px; margin-bottom: 13px; }
.stats-big { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 10px; }
.stats-big span { font-family: var(--font-reading); font-size: 38px; line-height: 1; font-weight: 450; letter-spacing: -.03em; }
.stats-big small { font-size: 10px; color: var(--muted); }
.stats-goalbar { height: 3px; border-radius: 99px; background: var(--line); overflow: hidden; }
.stats-goalbar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .45s var(--ease); }
.stats-hero p { margin: 8px 0 0; font-size: 9.5px; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stats-grid > div { background: var(--surface-raised); padding: 11px 12px; min-width: 0; }
.stats-grid strong { display: block; font-size: 15px; font-weight: 500; margin-top: 3px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-actions { display: flex; flex-direction: column; gap: 5px; }
.panel-btn { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: 7px; color: var(--ink-soft); font-size: 10.5px; text-align: left; border: 1px solid var(--line); background: var(--surface-raised); }
.panel-btn:hover { border-color: var(--line-strong); background: var(--accent-softer); color: var(--accent-ink); }
.panel-btn svg { width: 14px; height: 14px; color: var(--muted); }
.local-card { display: flex; gap: 10px; margin-top: 16px; padding: 12px; border-radius: 9px; background: color-mix(in srgb, var(--ink) 3%, transparent); border: 1px solid var(--line-soft); }
.local-icon { flex: 0 0 auto; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; background: var(--accent-soft); color: var(--accent); }
.local-icon svg { width: 13px; height: 13px; }
.local-card strong { display: block; font-size: 10px; color: var(--ink-soft); margin-bottom: 2px; }
.local-card p { margin: 0; font-size: 9.5px; line-height: 1.5; color: var(--muted); }
.tools-foot { width: var(--tools-w); flex: 0 0 auto; height: 35px; display: flex; align-items: center; gap: 5px; border-top: 1px solid var(--line); padding: 0 22px; font-size: 8.5px; color: var(--faint); }
.live-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent); }
.tools-foot-sep { color: var(--line-strong); }
.tools-scrim { display: none; }

/* =========================================================
   Popover, menus, modals, find, palette, toasts
   ========================================================= */
.spell-pop {
  position: fixed; z-index: 220; width: 272px;
  background: var(--surface-raised); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: pop-in .18s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
.spell-pop-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 11px 10px 7px 13px; }
.spell-pop-head strong { display: block; font-family: var(--font-reading); font-size: 19px; font-weight: 500; margin-top: 2px; color: var(--danger); }
.spell-pop-head .icon-btn { width: 25px; height: 25px; }
.spell-pop-head .icon-btn svg { width: 14px; height: 14px; }
.spell-pop-suggestions { padding: 4px 6px 8px; display: flex; flex-direction: column; max-height: 190px; overflow-y: auto; }
.suggestion-btn { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 8px; border-radius: 6px; font-size: 12px; color: var(--ink-soft); }
.suggestion-btn:hover { background: var(--accent-softer); color: var(--accent-ink); }
.suggestion-btn svg { width: 12px; height: 12px; color: var(--accent); opacity: .6; }
.suggestion-btn.is-primary { font-weight: 600; color: var(--accent-ink); }
.suggestion-empty { font-size: 10.5px; color: var(--muted); padding: 6px 8px 9px; line-height: 1.5; }
.spell-pop-actions { display: flex; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--ink) 2%, transparent); }
.spell-pop-actions button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 9px 4px; font-size: 9.5px; color: var(--muted); }
.spell-pop-actions button:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, transparent); }
.spell-pop-actions button:first-child { border-right: 1px solid var(--line); }
.spell-pop-actions svg { width: 11px; height: 11px; }

.menu-layer { position: fixed; inset: 0; z-index: 210; pointer-events: none; }
.menu {
  position: fixed; z-index: 211; min-width: 205px; padding: 5px;
  background: var(--surface-raised); border: 1px solid var(--line);
  border-radius: 11px; box-shadow: var(--shadow-lg);
  animation: menu-in .16s var(--ease); pointer-events: auto;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: none; } }
.menu-label { padding: 7px 9px 4px; font-size: 8.5px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 9px; border-radius: 6px; font-size: 11.5px; color: var(--ink-soft); text-align: left; }
.menu-item:hover { background: var(--accent-softer); color: var(--ink); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-soft); }
.menu-item svg { width: 15px; height: 15px; color: var(--muted); flex: 0 0 auto; }
.menu-item:hover svg { color: currentColor; }
.menu-item .menu-hint { margin-left: auto; font-size: 8.5px; color: var(--faint); letter-spacing: .03em; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 3px; }
.menu-swatches { display: grid; grid-template-columns: repeat(5, 28px); gap: 5px; padding: 7px; }
.swatch { width: 26px; height: 26px; border-radius: 6px; border: 1px solid rgba(0,0,0,.09); position: relative; }
.swatch:hover { transform: scale(1.07); }
.swatch.is-selected::after { content: ""; position: absolute; inset: 3px; border: 1.5px solid white; border-radius: 3px; mix-blend-mode: difference; }
.menu-wide { min-width: 225px; }
.menu-check { margin-left: auto; width: 13px; height: 13px; color: var(--accent); }

.modal-layer { position: fixed; inset: 0; z-index: 250; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(18,20,16,.36); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: fade-in .2s; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal { width: min(560px, 100%); max-height: min(780px, calc(100dvh - 48px)); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: modal-in .28s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 22px 15px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 3px 0 0; font-family: var(--font-reading); font-size: 25px; font-weight: 500; letter-spacing: -.028em; }
.modal-head p { margin: 6px 0 0; font-size: 10.5px; line-height: 1.55; color: var(--muted); max-width: 390px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--ink) 1.8%, transparent); }
.btn { height: 35px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 11px; font-weight: 550; color: var(--ink-soft); }
.btn:hover { border-color: var(--line-strong); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #f8f6ee; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.06); }
.modal .field-label { display: block; font-size: 10.5px; font-weight: 550; color: var(--ink-soft); margin: 0 0 6px; }
.modal .field { width: 100%; height: 37px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 10px; font-size: 12px; outline: none; }
.modal .field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
.modal .field-hint { font-size: 9.5px; line-height: 1.5; color: var(--muted); margin: 6px 0 0; }
.form-row { display: flex; gap: 10px; align-items: flex-end; }
.form-row .field { flex: 1; }
.option-list { display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.option-row { display: flex; align-items: center; gap: 9px; background: var(--surface); padding: 10px 11px; border-bottom: 1px solid var(--line-soft); font-size: 11px; color: var(--ink-soft); }
.option-row:last-child { border-bottom: 0; }
.option-row:hover { background: var(--accent-softer); }
.option-row svg { width: 15px; height: 15px; color: var(--muted); }
.option-row .menu-hint { margin-left: auto; font-size: 9px; color: var(--faint); }
.version-list { display: flex; flex-direction: column; gap: 6px; }
.version-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.version-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: 0 0 auto; }
.version-item:first-child .version-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.version-copy { min-width: 0; }
.version-copy strong { display: block; font-size: 11px; font-weight: 550; }
.version-copy span { font-size: 9.5px; color: var(--muted); }
.version-item .btn { margin-left: auto; height: 28px; padding: 0 9px; font-size: 9.5px; }
.version-empty { text-align: center; color: var(--muted); font-size: 11px; padding: 26px 10px; }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 10.5px; color: var(--ink-soft); }
.shortcut-keys { display: flex; gap: 3px; }
kbd { font-family: var(--font-ui); font-size: 9px; font-weight: 500; color: var(--muted); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 4px; padding: 2px 5px; box-shadow: 0 1px 0 var(--line); }
.about-lockup { display: flex; align-items: center; gap: 14px; margin-bottom: 15px; }
.about-mark { width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(145deg, #5d765e, #3d5842); color: #f7f3e8; display: grid; place-items: center; box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 6px 18px rgba(47,67,49,.22); }
.about-mark svg { width: 31px; height: 31px; }
.about-lockup h3 { margin: 0; font-family: var(--font-reading); font-size: 28px; font-weight: 500; letter-spacing: -.03em; }
.about-lockup span { font-size: 10px; color: var(--muted); }
.about-copy { font-size: 11.5px; line-height: 1.65; color: var(--ink-soft); }
.about-copy p { margin: 0 0 11px; }
.about-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 14px; }
.meta-chip { font-size: 9px; padding: 4px 7px; border-radius: 5px; color: var(--muted); border: 1px solid var(--line); background: var(--surface); }
.about-links { display: flex; gap: 14px; margin-top: 14px; font-size: 10px; }
.about-links a { color: var(--accent-ink); text-decoration: none; }
.about-links a:hover { text-decoration: underline; }

.find-bar { position: fixed; z-index: 180; top: calc(var(--topbar-h) + 12px); right: 26px; width: 390px; max-width: calc(100vw - 32px); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-md); padding: 6px; animation: menu-in .17s var(--ease); }
.find-row { display: flex; align-items: center; gap: 3px; }
.find-row + .find-row { border-top: 1px solid var(--line-soft); margin-top: 4px; padding-top: 4px; }
.find-icon { width: 15px; height: 15px; color: var(--muted); margin-left: 7px; flex: 0 0 auto; }
.find-row input:not([type="checkbox"]) { flex: 1; height: 28px; border: 0; outline: 0; background: transparent; font-size: 11.5px; padding: 0 6px; }
.find-row input::placeholder { color: var(--faint); }
.find-count { font-size: 9px; color: var(--muted); white-space: nowrap; padding: 0 5px; }
.find-row .icon-btn { width: 25px; height: 25px; }
.find-row .icon-btn svg { width: 14px; height: 14px; }
.find-case { font-size: 9px; color: var(--muted); display: flex; align-items: center; gap: 3px; padding: 0 5px; white-space: nowrap; }
.find-case input { accent-color: var(--accent); width: 12px; height: 12px; }
.replace-row .small-btn { height: 26px; padding: 0 8px; font-size: 9.5px; }
.replace-row { padding-right: 4px; }

.palette-layer { position: fixed; inset: 0; z-index: 260; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 20px 20px; background: rgba(18,20,16,.32); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade-in .16s; }
.palette { width: min(560px, 100%); max-height: min(580px, 76dvh); display: flex; flex-direction: column; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: modal-in .22s var(--ease); }
.palette-input-wrap { display: flex; align-items: center; gap: 9px; padding: 0 15px; height: 52px; border-bottom: 1px solid var(--line); }
.palette-input-wrap > svg { width: 17px; height: 17px; color: var(--muted); }
.palette-input-wrap input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 14px; }
.palette-input-wrap input::placeholder { color: var(--faint); }
.palette-input-wrap kbd { font-size: 8px; }
.palette-list { overflow-y: auto; padding: 6px; min-height: 90px; }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 7px; text-align: left; color: var(--ink-soft); font-size: 11.5px; }
.palette-item:hover, .palette-item.is-selected { background: var(--accent-softer); color: var(--ink); }
.palette-item svg { width: 15px; height: 15px; color: var(--muted); flex: 0 0 auto; }
.palette-item .palette-hint { margin-left: auto; font-size: 8.5px; color: var(--faint); }
.palette-empty { padding: 28px 15px; text-align: center; font-size: 11px; color: var(--muted); }
.palette-foot { display: flex; align-items: center; gap: 12px; padding: 9px 13px; border-top: 1px solid var(--line); font-size: 8.5px; color: var(--faint); }
.palette-foot > span { display: flex; align-items: center; gap: 3px; }
.palette-foot kbd { font-size: 8px; padding: 1px 4px; }
.palette-brand { margin-left: auto; letter-spacing: .1em; text-transform: uppercase; font-size: 7.5px; }

.toast-region { position: fixed; left: 50%; bottom: 48px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 7px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; padding: 9px 14px 9px 10px; border-radius: 99px; color: var(--surface-raised); background: var(--ink); box-shadow: var(--shadow-lg); font-size: 11px; font-weight: 450; animation: toast-in .32s var(--ease-spring); pointer-events: auto; }
.toast .toast-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 17%, transparent); color: var(--surface); flex: 0 0 auto; }
.toast .toast-icon svg { width: 12px; height: 12px; }
.toast.is-leaving { animation: toast-out .22s var(--ease) forwards; }
:root[data-theme="dark"] .toast { background: #e9e8de; color: #1b1e19; }
:root[data-theme="dark"] .toast .toast-icon { background: rgba(0,0,0,.09); color: #1b1e19; }
@keyframes toast-in { from { opacity: 0; transform: translateY(11px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(7px) scale(.97); } }

.drop-overlay { position: fixed; inset: 0; z-index: 400; display: none; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); }
.drop-overlay.is-visible { display: flex; }
.drop-overlay > div { display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(520px, calc(100vw - 48px)); padding: 50px; border: 1.5px dashed var(--accent); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg); text-align: center; }
.drop-overlay svg { width: 34px; height: 34px; color: var(--accent); margin-bottom: 4px; }
.drop-overlay strong { font-family: var(--font-reading); font-size: 28px; font-weight: 500; letter-spacing: -.025em; }
.drop-overlay span { font-size: 10.5px; color: var(--muted); }

/* =========================================================
   Focus, fullscreen and responsive
   ========================================================= */
.app.is-focus { --sidebar-w: 0px; }
.app.is-focus .sidebar { display: none; }
.app.is-focus .topbar { background: transparent; border-bottom-color: transparent; backdrop-filter: none; }
.app.is-focus .topbar-center { opacity: .75; }
.app.is-focus .canvas { max-width: 860px; }
.app.is-focus .paper { box-shadow: var(--shadow-sm); border-color: transparent; background: color-mix(in srgb, var(--paper) 78%, transparent); }
.app.is-focus .statusbar { border-top-color: transparent; background: transparent; }
.app.is-focus .menu-btn { display: grid; }
.app.is-focus .crumb, .app.is-focus .crumb-sep { opacity: 0; pointer-events: none; }
.app.is-focus .exit-focus { display: grid !important; }
.is-fullscreen .sidebar { display: none; }
.is-fullscreen .app, .app.is-fullscreen { --sidebar-w: 0px; }
.is-fullscreen .topbar { height: 50px; flex-basis: 50px; background: transparent; border-bottom-color: color-mix(in srgb, var(--line) 55%, transparent); }
.is-fullscreen .canvas { max-width: 900px; }
.is-fullscreen .tools-panel { display: none; }
.is-fullscreen .menu-btn { display: grid; }
.is-fullscreen .statusbar { height: 30px; flex-basis: 30px; }
:fullscreen .app::after, .app:fullscreen::after { display: none; }

@media (min-width: 1500px) {
  .canvas { max-width: 1000px; }
  .paper { padding-left: 88px; padding-right: 88px; }
  .editor { font-size: 20px; }
}
@media (max-width: 1180px) {
  .tools-panel { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: var(--tools-w); transform: translateX(100%); opacity: 0; border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); transition: transform .32s var(--ease), opacity .2s; }
  .app.tools-open .tools-panel { width: var(--tools-w); transform: none; opacity: 1; }
  .tools-scrim { position: absolute; inset: 0; z-index: 34; background: rgba(20,23,18,.22); backdrop-filter: blur(2px); display: block; }
  .tools-scrim[hidden] { display: none !important; }
  .topbar-center { position: static; transform: none; margin-left: auto; margin-right: 4px; }
  .topbar-left { flex: 1; }
}
@media (max-width: 1020px) {
  .app { display: block; height: 100dvh; }
  .main { height: 100%; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 120; width: 282px; transform: translateX(-102%); transition: transform .34s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar-inner { width: 282px; }
  .app.sidebar-mobile-open .sidebar { transform: none; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 110; background: rgba(18,20,16,.32); backdrop-filter: blur(3px); }
  .sidebar-scrim[hidden] { display: none !important; }
  .menu-btn { display: grid; }
  .app.sidebar-collapsed .sidebar { display: block; }
  .app.sidebar-collapsed .sidebar-inner { display: flex; }
  .desktop-only { display: none !important; }
  .topbar { padding: 0 13px; gap: 8px; }
  .crumb.current { max-width: 170px; }
  .canvas { padding: 11px 20px 0; }
}
@media (max-width: 720px) {
  :root { --topbar-h: 56px; }
  .topbar-center { display: none; }
  .topbar-divider { display: none; }
  .crumb:first-child, .crumb-sep { display: none; }
  .crumb.current { max-width: 150px; }
  .export-btn { width: 32px; padding: 0; justify-content: center; }
  .export-btn span, .export-btn .chev { display: none; }
  .canvas { padding: 8px 11px 0; }
  .toolbar-shell { top: 8px; border-radius: 13px; margin-bottom: 11px; }
  .paper { border-radius: 14px; padding: 27px 23px 26px; min-height: 72vh; }
  .doc-title { font-size: clamp(30px, 9vw, 40px); margin-top: 14px; }
  .editor { font-size: 18.5px; line-height: 1.75; }
  .doc-info { gap: 6px; }
  .info-link { margin-left: 0; }
  .ink-rule { margin: 18px 0 23px; }
  .statusbar { height: 31px; flex-basis: 31px; padding: 0 12px; }
  .status-left { gap: 7px; }
  .status-hint, .status-sep:nth-of-type(2), #selection-count, #selection-sep { display: none; }
  .status-right .status-link:first-child, .status-right .status-link kbd { display: none; }
  .status-right { gap: 3px; }
  .canvas-footer { padding-bottom: 16px; }
  .footer-brand { display: none; }
  .tools-panel { top: var(--topbar-h); width: min(360px, 92vw); }
  .app.tools-open .tools-panel { width: min(360px, 92vw); }
  .tools-head, .tools-tabs, .tools-scroll, .tools-foot { width: min(360px, 92vw); }
  .tools-head { padding-left: 18px; padding-right: 18px; }
  .tools-scroll { padding-left: 18px; padding-right: 18px; }
  .find-bar { top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .modal-layer { padding: 12px; align-items: flex-end; }
  .modal { max-height: calc(100dvh - 24px); border-radius: 15px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 17px; padding-right: 17px; }
  .palette-layer { padding: 7vh 12px 12px; }
  .toast-region { bottom: 42px; width: calc(100vw - 24px); }
  .toast { max-width: 100%; }
}
@media (max-width: 450px) {
  .app { --sidebar-w: 0px; }
  .topbar-actions .icon-btn:nth-of-type(2) { display: none; }
  .doc-title { font-size: 32px; }
  .paper { padding: 23px 18px 22px; }
  .editor { font-size: 18px; }
  .styles-select { max-width: 100px; }
  .tool-sep { margin: 0 2px; }
  .info-link { font-size: 9.5px; }
  .share-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Print / PDF */
@media print {
  @page { margin: 22mm 20mm; }
  html, body { height: auto; overflow: visible; background: #fff !important; color: #111 !important; }
  .app::after, .ambient, .sidebar, .topbar, .statusbar, .toolbar-shell, .tools-panel, .canvas-footer, .paper-topline, .doc-info, .ink-rule, .paper-end { display: none !important; }
  .app, .main, .workspace, .editor-pane, .editor-scroll { display: block !important; height: auto !important; overflow: visible !important; background: #fff !important; }
  .canvas { max-width: 100% !important; padding: 0 !important; }
  .paper { border: 0 !important; box-shadow: none !important; border-radius: 0 !important; padding: 0 !important; background: #fff !important; min-height: 0 !important; }
  .paper::before { display: none; }
  .doc-title { font-size: 32pt; margin: 0 0 18pt; color: #111 !important; }
  .editor { font-size: 11.5pt; line-height: 1.7; color: #111 !important; min-height: 0; }
  .editor a { color: #111 !important; }
  .editor blockquote { border-left-color: #999 !important; }
  ::highlight(morrow-spell), ::highlight(morrow-find) { text-decoration: none; background: transparent; }
}

/* =========================================================
   Extended components
   ========================================================= */
.theme-animating,
.theme-animating body,
.theme-animating .sidebar,
.theme-animating .topbar,
.theme-animating .paper,
.theme-animating .toolbar-shell,
.theme-animating .tools-panel {
  transition: background-color .3s ease, color .3s ease, border-color .3s ease;
}
.spell-item { display: flex; align-items: center; }
.spell-item-main { flex: 1; min-width: 0; }
.spell-item-actions { display: flex; align-items: center; gap: 1px; padding-right: 5px; flex: 0 0 auto; }
.spell-suggestion { min-width: 0; }

.toast-copy { line-height: 1.35; }
.toast-action {
  margin-left: 2px; padding: 4px 8px; border-radius: 99px;
  font-size: 10px; font-weight: 650; color: currentColor;
  background: color-mix(in srgb, currentColor 13%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
}
.toast-action:hover { background: color-mix(in srgb, currentColor 20%, transparent); }

.confirm-copy { margin: 0; font-size: 12px; line-height: 1.65; color: var(--ink-soft); }

.setting-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 9px; margin-top: 17px; overflow: hidden; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 13px; border-bottom: 1px solid var(--line-soft); background: var(--surface); cursor: pointer; }
.setting-row:last-child { border-bottom: 0; }
.setting-row.static { cursor: default; }
.setting-row strong { display: block; font-size: 11px; font-weight: 550; color: var(--ink-soft); }
.setting-row small { display: block; font-size: 9.5px; line-height: 1.5; color: var(--muted); margin-top: 2px; }
.setting-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; }
.setting-row .btn { height: 30px; font-size: 10px; flex: 0 0 auto; }
.storage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
.storage-grid > div { padding: 14px; background: var(--surface); }
.storage-grid strong { display: block; margin-top: 5px; font-family: var(--font-reading); font-size: 25px; font-weight: 450; letter-spacing: -.02em; }
.storage-note { margin: 14px 0 0; padding: 11px 12px; border-radius: 8px; background: var(--warm-soft); color: var(--ink-soft); font-size: 10px; line-height: 1.55; }
.modal a { color: var(--accent-ink); }
.modal a:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .spell-item-main { padding-right: 3px; }
  .spell-item-actions { padding-right: 2px; }
  .modal { max-height: calc(100dvh - 20px); }
}
@media print {
  .toast-region, .find-bar, .spell-pop, .menu-layer, .palette-layer, .modal-layer, .drop-overlay, .tools-scrim, .sidebar-scrim { display: none !important; }
}

/* Adaptive formatting bar for the narrower canvas when Writing tools are open */
.canvas { container-type: inline-size; }
@container (max-width: 850px) {
  .toolbar { gap: 1px; }
  .toolbar .tool-btn { width: 28px; height: 29px; }
  .toolbar .tool-btn svg { width: 16px; height: 16px; }
  .tool-sep { margin: 0 3px; }
  .style-select { max-width: 108px; padding-right: 20px; font-size: 11px; }
  .select-chev { right: 4px; }
}
@container (max-width: 795px) {
  .toolbar .align-group .tool-btn[data-command="justifyFull"] { display: none; }
}
@container (max-width: 755px) {
  .toolbar .align-group .tool-btn[data-command="justifyRight"] { display: none; }
  .toolbar .tool-btn[data-command="strikeThrough"] { display: none; }
}

:root[data-theme="dark"] .new-doc-btn {
  color: #192216;
  background: linear-gradient(180deg, #b4cbb0, #8ea98a);
  border-color: #c4d8bf;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 5px 16px rgba(0,0,0,.24);
}
:root[data-theme="dark"] .new-doc-btn:hover { filter: brightness(1.04); }
:root[data-theme="dark"] .new-doc-btn kbd { color: rgba(25,34,22,.62); border-color: rgba(25,34,22,.2); background: rgba(255,255,255,.18); }
:root[data-theme="dark"] .new-doc-icon { background: rgba(25,34,22,.13); }
:root[data-theme="dark"] .goal-card { background: rgba(255,255,255,.025); }
:root[data-theme="dark"] .theme-switch { color: var(--ink-soft); }

/* Keep the workspace full-width when the library is hidden or the editor is immersive. */
.app.sidebar-collapsed,
.app.is-focus,
.is-fullscreen .app,
.app:fullscreen {
  grid-template-columns: minmax(0, 1fr);
}
@media (max-width: 720px) {
  .toolbar {
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent 100%);
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent 100%);
    padding-right: 18px;
  }
}

/* Native fullscreen paints black behind transparent regions; keep the room warm. */
.app:fullscreen,
.is-fullscreen .app {
  background: var(--bg);
}
.is-fullscreen .topbar {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom-color: var(--line);
}
.is-fullscreen .statusbar {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-top-color: var(--line);
}

.noscript {
  position: fixed; inset: 0; z-index: 900; display: grid; place-items: center;
  padding: 24px; background: var(--bg);
}
.noscript-card {
  max-width: 440px; padding: 28px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.noscript-card strong { font-family: var(--font-reading); font-size: 26px; font-weight: 500; }
.noscript-card p { margin: 9px 0 0; font-size: 12px; line-height: 1.65; color: var(--muted); }

.app.is-focus .crumbs { display: none; }
.is-fullscreen .tools-panel { display: flex; }
@media (max-width: 1180px) {
  .is-fullscreen .tools-panel { display: flex; }
}

.library-head-actions { display: flex; align-items: center; gap: 4px; }
.library-import {
  width: 23px; height: 23px; display: grid; place-items: center;
  border-radius: 6px; color: var(--muted); transition: background .16s, color .16s;
}
.library-import:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.library-import svg { width: 13px; height: 13px; }

.toolbar-shell { position: sticky; }
.toolbar-more {
  display: none;
  position: absolute; right: 5px; top: 5px; z-index: 4;
  width: 32px; height: 36px; place-items: center;
  border-radius: 0 10px 10px 0;
  color: var(--ink-soft);
  background: linear-gradient(90deg, transparent, var(--toolbar-bg) 24%);
  padding-left: 10px;
}
.toolbar-more:hover { color: var(--ink); }
.toolbar-more svg { width: 14px; height: 14px; }
.toolbar-shell.is-overflowing .toolbar-more { display: grid; }
.toolbar-shell.is-overflowing .toolbar { padding-right: 28px; }
