/* SovereignOffice: system fonts, local assets, no remote resources.
   Colours are tokens. light-dark() follows the system setting unless the user picks a theme in Settings
   (html[data-theme]). Document surfaces (paper, grid, slides, canvases) keep their own colours in every theme. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --canvas: light-dark(#eff4fb, #0f172a);
  --panel: light-dark(#ffffff, #18243a);
  --panel-2: light-dark(#f7faff, #1c2a42);
  --sunken: light-dark(#e5edf9, #0b1323);
  --sidebar: light-dark(#eaf1fc, #111e33);
  --line: light-dark(#d7e2f3, #2b3c57);
  --line-strong: light-dark(#b8c9e4, #4a5f7f);
  --ink: light-dark(#172b4d, #edf3ff);
  --ink-soft: light-dark(#344d70, #c4d4ed);
  --muted: light-dark(#506581, #a3b7d4);
  --accent: light-dark(#1d4ed8, #93c5fd);
  --accent-solid: light-dark(#1d4ed8, #2563eb);
  --accent-hover: light-dark(#1e40af, #1d4ed8);
  --on-accent: #ffffff;
  --accent-soft: light-dark(#dbeafe, #203d62);
  --accent-ink: light-dark(#1e3a8a, #bfdbfe);
  --hover: light-dark(#e2ecfb, #263853);
  --danger: light-dark(#b3382c, #f28b7e);
  --danger-soft: light-dark(#fbebe8, #3b1e1a);
  --warn: light-dark(#85591a, #e3b765);
  --warn-soft: light-dark(#fbf2de, #392f16);
  --ok-soft: light-dark(#e5efff, #203654);
  --focus: light-dark(#1d4ed8, #93c5fd);
  --grid-header: #eff6ff;
  --paper: #ffffff;
  --paper-ink: #22332c;
  --shadow-sm: 0 1px 3px light-dark(rgb(23 43 77 / .06), rgb(2 6 23 / .4));
  --shadow-md: 0 10px 30px light-dark(rgb(23 43 77 / .10), rgb(2 6 23 / .5));
  --shadow-lg: 0 24px 70px light-dark(rgb(23 43 77 / .20), rgb(2 6 23 / .65));
  --radius: 12px;
  --radius-sm: 8px;
  --c-writer: light-dark(#37678f, #80b2d9);
  --c-spreadsheet: light-dark(#2c7554, #6fc79f);
  --c-presentation: light-dark(#a0693a, #e3a877);
  --c-database: light-dark(#725890, #bb9fd8);
  --c-paint: light-dark(#964c6b, #de8fb0);
  --c-audio: light-dark(#40748f, #84bad6);
  --c-diagram: light-dark(#7f6c1d, #d2bd62);
  --c-pdf: light-dark(#ac4034, #ee8d80);
  --c-code: light-dark(#476f80, #8bb9ca);
  font-family: var(--font);
  color: var(--ink);
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
/* Colour styles change application chrome; document colours remain document data. */
:root[data-theme="blue"] {
  color-scheme: light;
  --canvas:#eff4fb; --panel:#ffffff; --panel-2:#f7faff; --sunken:#e5edf9; --sidebar:#eaf1fc;
  --line:#d7e2f3; --line-strong:#b8c9e4; --ink:#172b4d; --ink-soft:#344d70; --muted:#506581;
  --accent:#1d4ed8; --accent-solid:#1d4ed8; --accent-hover:#1e40af;
  --accent-soft:#dbeafe; --accent-ink:#1e3a8a; --hover:#e2ecfb; --focus:#1d4ed8; --ok-soft:#e5efff;
  --grid-header:#eff6ff;
}
:root[data-theme="midnight"] {
  color-scheme: dark;
  --canvas:#0f172a; --panel:#18243a; --panel-2:#1c2a42; --sunken:#0b1323; --sidebar:#111e33;
  --line:#2b3c57; --line-strong:#4a5f7f; --ink:#edf3ff; --ink-soft:#c4d4ed; --muted:#a3b7d4;
  --accent:#93c5fd; --accent-solid:#2563eb; --accent-hover:#1d4ed8;
  --accent-soft:#203d62; --accent-ink:#bfdbfe; --hover:#263853; --focus:#93c5fd; --ok-soft:#203654;
  --grid-header:#eff6ff;
}
:root[data-theme="violet"] {
  color-scheme: light;
  --canvas:#f5f1fb; --panel:#ffffff; --panel-2:#fcfaff; --sunken:#ece5f6; --sidebar:#eee7f8;
  --line:#e2d9ef; --line-strong:#cbbbdc; --ink:#302242; --ink-soft:#514063; --muted:#695776;
  --accent:#6d28d9; --accent-solid:#6d28d9; --accent-hover:#5b21b6;
  --accent-soft:#ede9fe; --accent-ink:#4c1d95; --hover:#ebe3f6; --focus:#6d28d9; --ok-soft:#f0eafa;
  --grid-header:#f5f0ff;
}
:root[data-theme="sand"] {
  color-scheme: light;
  --canvas:#f7f2e8; --panel:#fffdf8; --panel-2:#fcf8ef; --sunken:#eee5d6; --sidebar:#f0e8da;
  --line:#e3d9c8; --line-strong:#cbbba3; --ink:#382c20; --ink-soft:#584737; --muted:#715e49;
  --accent:#855721; --accent-solid:#855721; --accent-hover:#6b4319;
  --accent-soft:#f2e4cf; --accent-ink:#65421c; --hover:#eee2cf; --focus:#855721; --ok-soft:#f3e9d7;
  --grid-header:#faf5e9;
}


.writer { --module-color: var(--c-writer); }
.spreadsheet { --module-color: var(--c-spreadsheet); }
.presentation { --module-color: var(--c-presentation); }
.database { --module-color: var(--c-database); }
.paint { --module-color: var(--c-paint); }
.audio { --module-color: var(--c-audio); }
.diagram { --module-color: var(--c-diagram); }
.pdf { --module-color: var(--c-pdf); }
.code { --module-color: var(--c-code); }
.all { --module-color: var(--accent); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
a { color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent-solid) 30%, transparent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 12.5px; line-height: 1.65; }
.icon { flex-shrink: 0; }
kbd { font: 600 11px var(--mono); padding: 2px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); background: var(--panel); }
.eyebrow, .nav-label { font-size: 11px; font-weight: 700; letter-spacing: .09em; color: var(--muted); text-transform: uppercase; }
.skip-link { position: fixed; top: -100px; left: 20px; z-index: 10000; background: var(--panel); color: var(--ink); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.skip-link:focus { top: 10px; }
.print-frame { position: fixed; top: 0; left: -10000px; width: 1000px; height: 800px; border: 0; }
.fatal { margin: 40px; padding: 30px; border: 1px solid var(--line-strong); background: var(--warn-soft); border-radius: var(--radius); line-height: 1.7; }
.fatal h1 { font-size: 24px; }
.status-dot { display: inline-block; width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--ok-soft); box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- Controls ---------- */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px; padding: 6px 13px; font: inherit; line-height: 1.2; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
button:hover { background: var(--hover); border-color: var(--line-strong); }
button:active { transform: translateY(.5px); }
button:disabled { cursor: default; opacity: .42; transform: none; }
button.primary { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--on-accent); font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
button.quiet-button, .icon-button { background: transparent; border-color: transparent; color: var(--ink-soft); }
button.quiet-button:hover, .icon-button:hover { background: var(--hover); color: var(--ink); }
.icon-button, button.icon-only { width: 34px; padding: 0; }
.icon-button { font-size: 18px; }
.btn-label { white-space: nowrap; }

input, textarea, select {
  font: inherit; color: inherit; min-width: 0; min-height: 34px; padding: 6px 10px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
textarea { resize: vertical; line-height: 1.55; }
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2395a89c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent-solid); min-height: 0; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; padding: 0; }
input[type="color"] { padding: 3px; min-width: 38px; cursor: pointer; }
input[type="search"] { appearance: none; }
label { cursor: default; }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
main { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
main:focus { outline: none; }

/* Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 4px; padding: 20px 14px 14px; background: var(--sidebar); border-right: 1px solid var(--line); min-height: 0; overflow-y: auto; }
.brand { display: flex; align-items: center; justify-content: flex-start; gap: 11px; padding: 0 4px; margin: 0 0 18px; border: 0; background: none; text-align: left; }
.brand:hover { background: none; }
.brand-mark { width: 36px; height: 38px; display: grid; place-items: center; background: var(--accent-solid); color: #f6fbf2; border-radius: 10px 10px 16px 10px; font: 600 26px Georgia, serif; box-shadow: var(--shadow-sm); }
.brand strong { display: block; font-size: 15.5px; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); letter-spacing: 0; }
.create-button { min-height: 40px; font-size: 13.5px; box-shadow: var(--shadow-sm); }
.nav-label { margin: 22px 12px 6px; font-size: 11px; }
nav { display: grid; gap: 2px; }
.nav-section { margin: 14px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .09em; color: var(--muted); }
.nav-item { justify-content: flex-start; gap: 12px; width: 100%; min-height: 38px; padding: 0 12px; border: 0; background: transparent; color: var(--ink-soft); font-size: 13.5px; text-align: left; }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.nav-icon { display: grid; place-items: center; width: 20px; color: var(--module-color); }
.recent-heading { margin-top: 22px; }
.recent-list { display: grid; align-content: start; gap: 1px; min-height: 100px; overflow: auto; }
.recent-item { justify-content: flex-start; gap: 10px; min-height: 32px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-size: 12.5px; text-align: left; }
.recent-item:hover { color: var(--ink); }
.recent-item > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-icon { display: grid; place-items: center; color: var(--module-color); }
.sidebar-bottom { margin-top: auto; padding-top: 18px; display: grid; gap: 2px; }
.settings-button { justify-content: flex-start; gap: 12px; width: 100%; min-height: 38px; padding: 0 12px; border: 0; background: transparent; color: var(--ink-soft); font-size: 13.5px; }
.about-button { justify-content: space-between; width: 100%; min-height: 32px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.about-button span { font: 11px var(--mono); }
.privacy-label { display: flex; align-items: flex-start; gap: 10px; margin-top: 8px; padding: 14px 12px 2px; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.5; color: var(--ink-soft); }
.privacy-label small { color: var(--muted); font-size: 11.5px; }
.privacy-label .status-dot { margin-top: 5px; }
.navigation-dismiss { display: none; }

/* Top bar */
.topbar { height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 14px; padding: 0 28px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.layout-controls { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.breadcrumb { color: var(--muted); font-size: 13px; }
.topbar-spacer, .toolbar-spacer { flex: 1; }
.local-badge { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 99px; background: var(--ok-soft); color: var(--accent-ink); font-size: 12px; font-weight: 550; }
#mobile-menu, .inspector-toggle { display: none; }

/* ---------- Workspace (dashboard) ---------- */
.dashboard { flex: 1; overflow: auto; scrollbar-gutter: stable; padding: 38px clamp(20px, 4vw, 56px) 44px; background:radial-gradient(ellipse at 85% 0%,color-mix(in srgb,var(--accent) 5%,transparent),transparent 60%); }
.workspace-intro, .create-grid, .library-heading, .document-library, .workspace-footnote { max-width: 1200px; margin-left: auto; margin-right: auto; }
.workspace-intro { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 32px; align-items: stretch; }
.intro-copy { align-self: center; }
.intro-storage { max-width: 54ch; font-size: 14px; line-height: 1.6; color: var(--ink-soft); }
.intro-comparison { display: inline-block; margin-bottom: 12px; color: var(--accent); text-underline-offset: 3px; }
.intro-comparison:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.workspace-intro .eyebrow { color: var(--accent); }
.workspace-intro h1 { margin: 12px 0 12px; font-size: clamp(30px, 3.6vw, 44px); font-weight: 680; line-height: 1.1; letter-spacing: -.035em; }
.workspace-intro p { margin: 0; max-width: 46ch; font-size: 15.5px; color: var(--muted); line-height: 1.6; }
.intro-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.intro-actions button { min-height: 40px; padding: 8px 18px; }
.intro-actions .primary { box-shadow:0 3px 10px color-mix(in srgb,var(--accent-solid) 18%,transparent); }
.intro-actions .quiet-button:hover, .intro-actions .quiet-button:focus-visible { text-decoration:underline; text-underline-offset:4px; }
.dropzone { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px; background: var(--panel); border: 1.5px dashed var(--line-strong); border-radius: var(--radius); transition: border-color .15s, background .15s; }
.dropzone.is-over, body.is-dragging .dropzone { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-head { display: flex; align-items: center; gap: 14px; }
.dropzone-head .drop-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.dropzone-head strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.dropzone-head span:not(.drop-icon) { font-size: 12.5px; color: var(--muted); }
.format-chips { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.format-chips li { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.format-group { flex: 0 0 112px; color: var(--muted); font-weight: 600; }
.format-ext { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--sunken); color: var(--ink-soft); font: 600 11px var(--mono); letter-spacing: .02em; }
.format-more { color: var(--muted); font-size: 11.5px; }

.create-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 14px; margin-top: 34px; margin-bottom: 40px; }
.create-card { position: relative; display: block; min-height: 142px; padding: 20px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm); transition: transform .15s, border-color .15s, box-shadow .15s; }
.create-card:hover { background: var(--panel); border-color: color-mix(in srgb, var(--module-color) 55%, var(--line)); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.app-symbol { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 14px; border-radius: 12px; color: var(--module-color); background: color-mix(in srgb, var(--module-color) 13%, transparent); }
.create-card h2 { margin: 0 0 4px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.create-card p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-soft); }
.create-card .app-alternative { display: block; margin-top: 8px; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.card-plus { position: absolute; top: 16px; right: 16px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--muted); opacity: 0; transition: opacity .15s, background .15s; }
.create-card:hover .card-plus, .create-card:focus-visible .card-plus { opacity: 1; background: color-mix(in srgb, var(--module-color) 14%, transparent); color: var(--module-color); }

.library-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.library-heading h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
.library-count { padding: 3px 10px; border-radius: 99px; background: var(--sunken); color: var(--muted); font-size: 12px; font-weight: 550; }
.library-heading input[type="search"] { margin-left: auto; width: 240px; padding-left: 12px; }
.library-heading select { max-width: 180px; }
.library-heading button { font-size: 12.5px; }
.document-library { overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.library-columns, .document-row { display: grid; grid-template-columns: minmax(150px, 1fr) 128px 170px 40px; align-items: center; gap: 10px; padding: 0 18px; }
.library-columns { height: 38px; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); background: var(--panel-2); border-bottom: 1px solid var(--line); }
.document-row { height: 64px; border-bottom: 1px solid var(--line); transition: background .1s; }
.document-row:last-child { border-bottom: 0; }
.document-row:hover { background: var(--panel-2); }
.document-name { justify-content: flex-start; gap: 13px; min-width: 0; min-height: 44px; padding: 0; border: 0; background: transparent !important; text-align: left; font-size: 14px; font-weight: 550; }
.document-name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-symbol { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; color: var(--module-color); background: color-mix(in srgb, var(--module-color) 13%, transparent); }
.type-label { justify-self: start; padding: 2px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 600; color: var(--module-color); background: color-mix(in srgb, var(--module-color) 12%, transparent); }
.modified-label { font-size: 12.5px; color: var(--muted); }
.row-delete { width: 34px; min-height: 34px; padding: 0; border: 0; background: transparent; color: var(--muted); opacity: .55; }
.document-row:hover .row-delete, .row-delete:focus-visible { opacity: 1; }
.row-delete:hover { color: var(--danger); background: var(--danger-soft); opacity: 1; }
.empty-library { padding: 48px 24px; text-align: center; }
.empty-library h3 { margin-bottom: 6px; font-size: 16px; font-weight: 600; }
.empty-library p { margin-bottom: 16px; color: var(--muted); font-size: 13px; }
.workspace-footnote { display: flex; align-items: center; gap: 16px; margin-top: 26px; padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); }
.footnote-icon { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.workspace-footnote strong { font-size: 13.5px; }
.workspace-footnote p { max-width: 62ch; margin: 3px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.workspace-footnote button { margin-left: auto; white-space: nowrap; font-size: 12.5px; }
:root[data-density="compact"] .document-row { height: 50px; }
:root[data-density="compact"] .file-symbol { width: 28px; height: 28px; border-radius: 8px; }
:root[data-density="compact"] .document-name { min-height: 40px; }

/* ---------- Editor chrome ---------- */
.editor-view { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.document-header { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; flex-shrink: 0; min-height: 68px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.document-icon { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 11px; color: var(--module-color); background: color-mix(in srgb, var(--module-color) 13%, transparent); }
.document-heading { flex: 1; min-width: 130px; }
.document-heading input { width: 100%; min-height: 30px; padding: 2px 6px; margin-left: -6px; font-size: 18px; font-weight: 620; letter-spacing: -.02em; border-color: transparent; background: transparent; text-overflow: ellipsis; }
.document-heading input:hover { border-color: var(--line); }
.document-heading input:focus { background: var(--panel); }
.save-status { display: flex; align-items: center; gap: 7px; max-width: 600px; margin-top: 1px; font-size: 12px; line-height: 1.5; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-status::before { content: ""; width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--muted); }
.save-status.saved::before { background: var(--accent); }
.save-status.saving::before, .save-status.dirty::before { background: var(--warn); }
.save-status.error { color: var(--danger); }
.save-status.error::before { background: var(--danger); }
.save-status.dirty { color: var(--warn); }
.document-actions { display: flex; gap: 6px; }
.document-actions button { min-height: 36px; padding: 0 13px; font-size: 13px; }
.module { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.module-status { display: flex; justify-content: space-between; gap: 10px; flex-shrink: 0; padding: 7px 20px; background: var(--panel-2); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }

/* Toolbars */
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; flex-shrink: 0; min-height: 48px; padding: 7px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.toolbar button { min-height: 32px; padding: 0 10px; font-size: 13px; background: transparent; border-color: transparent; color: var(--ink-soft); }
.toolbar button:hover { background: var(--hover); color: var(--ink); }
.toolbar button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.toolbar button.primary { background: var(--accent-solid); color: var(--on-accent); }
.toolbar button.primary:hover { background: var(--accent-hover); }
.toolbar button.icon-only { width: 32px; padding: 0; }
.toolbar select, .toolbar input:not([type="color"]):not([type="checkbox"]) { min-height: 32px; font-size: 13px; }
.toolbar select { max-width: 170px; padding-right: 28px; background-color: var(--panel); }
.toolbar input[type="color"] { width: 34px; height: 32px; padding: 3px; cursor: pointer; }
.toolbar input[type="number"] { width: 70px; }
.separator { align-self: center; width: 1px; height: 20px; margin: 0 6px; background: var(--line-strong); opacity: .7; }

/* ---------- Writer ---------- */
.writer-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 210px; background: var(--sunken); }
.writer-scroll { overflow: auto; padding: 32px 32px 72px; }
.writer-page { width: 100%; max-width: 800px; min-height: 1000px; margin: 0 auto; padding: 68px 76px; background: var(--paper); color: var(--paper-ink); border: 1px solid var(--line); border-radius: 3px; box-shadow: var(--shadow-md); outline: none; cursor: text; font-size: 15.5px; line-height: 1.75; overflow-wrap: anywhere; }
.writer-page h1 { margin-bottom: 26px; font-size: 40px; font-weight: 650; line-height: 1.15; letter-spacing: -.035em; }
.writer-page h2 { margin: 32px 0 14px; font-size: 23px; font-weight: 620; line-height: 1.35; letter-spacing: -.02em; }
.writer-page h3 { margin: 26px 0 12px; font-size: 18px; }
.writer-page p { margin-bottom: 20px; }
.writer-page blockquote { margin: 28px 0; padding: 10px 0 10px 22px; border-left: 3px solid #7fa88d; color: #3f6a54; font-size: 17.5px; line-height: 1.6; }
.writer-page ul, .writer-page ol { padding-left: 24px; }
.writer-page li { margin: 7px 0; padding-left: 6px; }
.writer-page img { max-width: 100%; height: auto; }
.writer-page table { width: 100%; margin: 20px 0; border-collapse: collapse; }
.writer-page td, .writer-page th { padding: 8px 10px; border: 1px solid #ccd8c9; }
.writer-page pre { padding: 14px; background: #f1f5ee; font: 13px/1.6 var(--mono); white-space: pre-wrap; border-radius: 6px; }
.writer-page a { color: #1f6a52; }
.writer-outline { padding: 28px 16px; overflow: auto; background: var(--panel); border-left: 1px solid var(--line); }
.writer-outline .eyebrow { margin-bottom: 14px; font-size: 11px; }
.outline-item { display: block; justify-content: flex-start; width: 100%; min-height: 0; padding: 7px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12.5px; line-height: 1.45; text-align: left; }
.outline-item:hover { background: var(--hover); color: var(--ink); }
.outline-item.level-H1 { font-weight: 650; color: var(--ink); }
.outline-item.level-H3 { padding-left: 20px; font-size: 12px; }
.outline-item.level-H2 { padding-left: 14px; }

/* ---------- Spreadsheet (the grid itself keeps its light document surface) ---------- */
.sheet-grid { flex: 1; min-height: 100px; overflow: hidden; background: #fff; }
.sheet-grid .tg-root { min-height: 100%; --tg-accent: var(--accent-solid); --tg-border: #e3e8df; --tg-header: var(--grid-header, #f0f4ec); --tg-text: #2f4337; --tg-bg: #fff; }
.formula-row { display: flex; align-items: center; gap: 10px; padding: 5px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.formula-row input { min-height: 30px; padding: 3px 8px; border: 0; border-radius: 6px; background: transparent; }
.formula-row input:focus { box-shadow: inset 0 -2px var(--accent-solid); background: var(--panel-2); }
.formula-row input.cell-address { width: 78px; border-right: 1px solid var(--line); border-radius: 0; font: 600 12px var(--mono); text-align: center; }
.formula-row input:last-child { flex: 1; font: 13px var(--mono); }
.fx { color: var(--muted); font: italic 17px Georgia, serif; }
.sheet-tabs { display: flex; gap: 2px; flex-shrink: 0; min-height: 40px; padding: 0 12px; overflow: auto; background: var(--panel-2); border-top: 1px solid var(--line); }
.sheet-tabs button { min-height: 40px; padding: 0 16px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); font-size: 13px; white-space: nowrap; }
.sheet-tabs button:hover { color: var(--ink); background: var(--hover); }
.sheet-tabs button.active { color: var(--accent); border-bottom-color: var(--accent-solid); font-weight: 650; background: var(--panel); }
.sheet-tabs .add-sheet { padding: 0 12px; font-size: 18px; }

/* Use the bundled tinyDatagrid tool groups without scrolling the entire page. */
.toolbar.sheet-ribbon { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; padding: 0; min-height: 0; overflow: hidden; mask-image: none; -webkit-mask-image: none; }
.sheet-ribbon-tabs { display: flex; gap: 8px; padding: 0 16px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.sheet-ribbon-tabs button { flex: 0 0 auto; min-height: 40px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; font-weight: 600; }
.sheet-ribbon-tabs button[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent-solid); background: var(--accent-soft); }
.sheet-ribbon-panel { display: flex; gap: 10px; width: 100%; max-width: 100%; min-width: 0; padding: 8px 16px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.sheet-tool-group { display: flex; flex-direction: column; justify-content: center; gap: 4px; flex: 0 0 auto; padding-right: 10px; border-right: 1px solid var(--line); }
.sheet-tool-group:last-child { padding-right: 0; border-right: 0; }
.sheet-tool-row { display: flex; align-items: center; gap: 4px; }
.sheet-group-label { color: var(--muted); text-align: center; font-size: 10px; line-height: 1.4; }
.sheet-ribbon .sheet-tool-row button .btn-label { display: inline; }
.sheet-ribbon .sheet-tool-row button { padding: 0 8px; font-size: 12px; }
.sheet-ribbon .sheet-tool-row button.icon-only { width: 32px; padding: 0; }
.sheet-ribbon details { position: relative; }
.sheet-ribbon summary { padding: 4px 10px; white-space: nowrap; cursor: pointer; }
.sheet-native-dialog { width: min(860px,calc(100vw - 24px)); max-height: 90dvh; overflow: auto; padding: 20px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); --text: var(--ink); --surface: var(--panel); --tg-text: var(--ink); --tg-muted: var(--muted); --tg-panel: var(--panel); --tg-header: var(--panel-2); --tg-border: var(--line); --tg-accent: var(--accent); --tg-hover: var(--hover); }
.sheet-native-dialog::backdrop { background: rgb(8 20 35 / .5); }
.sheet-native-dialog label { font-size: 13px; }
.sheet-native-dialog .stack { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.sheet-native-dialog .sheet-tool-row { flex-wrap: wrap; }
.sheet-native-dialog .sheet-search-results { display: grid; gap: 4px; max-height: 40dvh; overflow: auto; }
.sheet-native-dialog input:not([type="checkbox"]):not([type="color"]), .sheet-native-dialog select { max-width: 100%; min-width: 0; }
.sheet-native-dialog :is(.rule-row,.rule-choices,.rule-actions,.tool-row) { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.sheet-native-dialog .rule-choice { flex: 1 1 140px; text-align: left; }
.sheet-native-dialog .rule-list { display: grid; gap: 8px; margin: 12px 0; }
.sheet-native-dialog .rule-list > * { padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.sheet-native-dialog textarea { width: 100%; min-height: 100px; margin: 10px 0; font: 13px/1.5 var(--mono); }
.sheet-native-dialog .viz-stage { background: var(--panel); }
@media (max-width:720px) {
  .sheet-ribbon-tabs { gap: 2px; padding: 0 8px; }
  .sheet-ribbon-tabs button { padding: 0 10px; }
  .sheet-ribbon-panel { gap: 10px; padding: 8px 10px; }
  .sheet-tool-group { padding-right: 10px; }
  .sheet-native-dialog { padding: 12px; }
}

/* ---------- Presentation ---------- */
.slide-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 156px minmax(0, 1fr) 264px; }
.slide-rail { padding: 16px 12px; overflow: auto; background: var(--panel-2); border-right: 1px solid var(--line); }
.slide-rail > .eyebrow { margin: 0 0 12px 2px; }
.slide-thumb { display: block; width: 100%; min-height: 0; padding: 4px; margin-bottom: 10px; overflow: hidden; border: 2px solid transparent; border-radius: 9px; background: transparent; text-align: left; }
.slide-thumb:hover { background: var(--hover); }
.slide-thumb.active { border-color: var(--accent-solid); background: var(--accent-soft); }
.slide-thumb canvas { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; }
.slide-thumb > span { display: block; padding: 6px 2px 2px; overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.new-slide { width: 100%; font-size: 12.5px; border: 1.5px dashed var(--line-strong); background: transparent; color: var(--ink-soft); }
.slide-middle { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--sunken); }
.slide-stage { display: flex; align-items: center; justify-content: center; flex: 1; min-height: 130px; min-width: 0; overflow: hidden; background-image: radial-gradient(color-mix(in srgb, var(--muted) 38%, transparent) .7px, transparent .7px); background-size: 14px 14px; }
.slide-canvas { display: block; flex-shrink: 0; touch-action: none; box-shadow: var(--shadow-md); }
.slide-canvas:focus { outline: 0; }
.slide-notes { flex-shrink: 0; height: 82px; min-height: 60px; max-height: 190px; padding: 14px 22px; resize: vertical; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: var(--panel); color: var(--ink-soft); font-size: 13px; }
.slide-inspector { padding: 20px 16px; overflow: auto; background: var(--panel); border-left: 1px solid var(--line); font-size: 12.5px; }
.slide-inspector > .eyebrow { margin-bottom: 16px; }
.property-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin-bottom: 12px; }
.property-field > span { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.property-field input, .property-field select, .property-field textarea { width: 100%; font-size: 13px; }
.property-field input[type="color"] { height: 34px; }
.property-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.property-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.slide-inspector button { min-height: 32px; padding: 0 11px; font-size: 12.5px; }
.slide-inspector > button { margin: 0 6px 6px 0; }
.layers-title { margin-top: 24px; }
.layer-row { display: flex; align-items: center; gap: 2px; margin-bottom: 2px; border-radius: 8px; }
.layer-row:hover { background: var(--hover); }
.layer-row.selected { background: var(--accent-soft); }
.layer-row button { min-height: 30px; padding: 0 7px; border: 0; background: none; color: var(--muted); }
.layer-row button.layer-label { flex: 1; min-width: 0; justify-content: flex-start; padding-left: 9px; color: var(--ink); text-align: left; }
.layer-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.layer-row button.layer-label > span { overflow: hidden; text-overflow: ellipsis; }
.presentation-mode { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; max-width: none; max-height: none; padding: 24px; border: 0; background: #0b1510; color: #d8e3d2; }
.presentation-mode canvas { width: min(100%, 160vh); max-height: calc(100vh - 110px); height: auto; object-fit: contain; }
.present-bar { display: flex; align-items: center; gap: 20px; margin-top: 20px; font-size: 13px; }
.present-bar button { background: #ffffff14; border-color: #ffffff26; color: #fff; }
.present-bar button:hover { background: #ffffff26; }

/* ---------- Database ---------- */
.sql-banner { padding: 10px 22px; border-bottom: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font-size: 12.5px; }
.sql-banner.warning { color: var(--warn); background: var(--warn-soft); }
.sql-banner.error { color: var(--danger); background: var(--danger-soft); }
.sql-banner.success { color: var(--accent-ink); background: var(--ok-soft); }
.sql-workspace { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; background: var(--panel); }
.sql-editor-wrap { flex-shrink: 0; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.sql-editor-wrap .eyebrow { margin-bottom: 10px; }
.sql-editor { width: 100%; min-height: 160px; max-height: 500px; padding: 16px; font: 13px/1.75 var(--mono); tab-size: 2; resize: vertical; background: var(--panel); color: var(--ink); }
.query-results { flex: 1; min-height: 170px; overflow: auto; }
.result-tabs { display: flex; gap: 2px; flex-shrink: 0; overflow: auto; background: var(--panel-2); }
.result-tabs:empty { display: none; }
.result-tabs button { border: 0; border-top: 2px solid transparent; border-radius: 0; background: transparent; font-size: 12.5px; }
.result-tabs button.active { border-top-color: var(--accent-solid); background: var(--panel); color: var(--accent); }
.result-table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; white-space: nowrap; }
.result-table td, .result-table th { padding: 9px 18px; border-bottom: 1px solid var(--line); }
.result-table th { position: sticky; top: 0; background: var(--panel-2); font-size: 11.5px; font-weight: 650; color: var(--muted); }
.result-table tbody tr:nth-child(even) { background: var(--panel-2); }
.null-value { color: var(--muted); font-style: italic; }
.empty-state { max-width: 460px; margin: 32px auto; padding: 10px 25px; text-align: center; }
.empty-symbol { margin: 0 0 16px; color: var(--muted); font: 18px var(--mono); }
.empty-state h2 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.empty-state p { font-size: 13px; line-height: 1.75; color: var(--muted); }

/* ---------- Media: drawing, audio, diagram, PDF ---------- */
.media-workspace { flex: 1; min-height: 0; padding: 28px; overflow: auto; background: var(--panel); }
.media-workspace h2 { font-size: 22px; letter-spacing: -.02em; }
.media-status { font-size: 13.5px; line-height: 1.7; color: var(--muted); }
.audio-wave { display: block; width: 100%; height: 240px; border: 1px solid var(--line); border-radius: var(--radius); touch-action: none; background: var(--panel-2); }
.media-controls { display: flex; flex-wrap: wrap; gap: 16px; margin: 20px 0; }
.media-field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 550; color: var(--ink-soft); }
.media-field input { width: 130px; }
.media-field input[type="checkbox"] { width: 22px; height: 22px; }
.media-workspace audio { width: 100%; max-width: 600px; margin: 10px 0; }
.paint-layout, .diagram-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 232px; background: var(--sunken); }
.paint-scroll, .diagram-scroll { min-height: 0; padding: 24px; overflow: auto; }
.paint-canvas { display: block; max-width: 100%; height: auto; margin: 0 auto; border: 1px solid var(--line-strong); box-shadow: var(--shadow-md); background-color: #fff; background-image: conic-gradient(#e6eae3 25%, transparent 0 50%, #e6eae3 0 75%, transparent 0); background-size: 20px 20px; touch-action: none; }
.paint-layers, .diagram-inspector { padding: 18px 14px; overflow: auto; background: var(--panel); border-left: 1px solid var(--line); font-size: 13px; }
.paint-layers h3, .diagram-inspector h3 { margin-bottom: 12px; font-size: 13px; font-weight: 650; }
.paint-layers > button, .diagram-inspector > button { display: flex; justify-content: flex-start; width: 100%; margin: 6px 0; font-size: 12.5px; text-align: left; overflow-wrap: anywhere; }
.paint-layers label, .diagram-inspector label { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; font-size: 12.5px; font-weight: 550; color: var(--ink-soft); }
.paint-layers input[type="range"], .diagram-inspector input, .diagram-inspector select { width: 100%; }
.paint-layer { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.paint-layer.active, .diagram-node.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.paint-layer button { flex: 1; min-width: 0; justify-content: flex-start; padding: 8px 5px; border: 0; background: transparent; font-size: 13px; text-align: left; overflow-wrap: anywhere; }
.paint-layer input { margin-left: 10px; }
.diagram-inspector input[type="color"] { height: 38px; padding: 4px; }
.diagram-stage { max-width: 1200px; margin: auto; background: #fff; border: 1px solid var(--line-strong); box-shadow: var(--shadow-md); touch-action: none; }
.diagram-stage svg { display: block; width: 100%; height: auto; }
.diagram-stage [data-node-id] { cursor: move; }
.diagram-stage text { pointer-events: auto; user-select: none; }
.pdf-workspace { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 20px; overflow: auto; background: var(--panel); }
.pdf-workspace .hint { margin: 0; }
.pdf-open { font-size: 13.5px; }
.pdf-preview { flex: 1; width: 100%; min-height: 400px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sunken); }

/* ---------- Code ---------- */
.code-workspace { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--panel); }
.code-editing { display: flex; flex: 1; min-height: 150px; overflow: hidden; }
.code-input, .code-lines, .code-highlight { margin: 0; font: 13.5px/22px var(--mono); tab-size: 2; }
.code-input { flex: 1; width: 100%; padding: 16px; overflow: auto; resize: none; border: 0; border-radius: 0; outline-offset: -3px; background: var(--panel); color: var(--ink); white-space: pre; }
.code-input:focus { box-shadow: none; }
.code-input[wrap="soft"] { white-space: pre-wrap; overflow-wrap: anywhere; }
.code-lines { min-width: 62px; max-width: 90px; padding: 16px 12px; overflow: hidden; text-align: right; background: var(--panel-2); color: var(--muted); border-right: 1px solid var(--line); user-select: none; }
.code-diagnostic { padding: 9px 18px; border-bottom: 1px solid var(--line); background: var(--panel-2); font-size: 12.5px; overflow-wrap: anywhere; }
.code-diagnostic.ok { color: var(--accent-ink); background: var(--ok-soft); }
.code-diagnostic.problem { color: var(--danger); background: var(--danger-soft); }
.code-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; font-size: 13px; color: var(--ink-soft); }
.code-toggle input { margin: 0; }
.code-highlight { flex: 1; min-height: 100px; max-height: 45%; padding: 16px; overflow: auto; white-space: pre; background: var(--panel-2); border-top: 1px solid var(--line); }
.code-token-string { color: light-dark(#8a5a1f, #e1b274); }
.code-token-comment { color: var(--muted); font-style: italic; }
.code-token-keyword, .code-token-markup { color: light-dark(#2d62a0, #84b4ec); }
.code-token-number { color: light-dark(#93417f, #e49ad0); }
.code-token-key { color: light-dark(#1f6a52, #6fd1ab); }
.code-token-add { color: light-dark(#1b7a3d, #6fd18f); background: color-mix(in srgb, #2fb464 12%, transparent); }
.code-token-del { color: light-dark(#b3382c, #f28b7e); background: color-mix(in srgb, #e5493a 12%, transparent); }
.code .toolbar input[type="search"] { width: 190px; }

/* ---------- Dialogs, lists, toast ---------- */
.dialog { width: min(580px, 92vw); max-height: 86dvh; padding: 0; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); }
.dialog[open] { animation: dialog-in .16s ease-out; }
.dialog::backdrop { background: rgb(8 20 14 / .5); backdrop-filter: blur(3px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 14px 24px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.dialog-body { max-height: 66dvh; padding: 20px 24px 24px; overflow: auto; font-size: 13.5px; line-height: 1.7; }
.dialog-body h3 { margin: 22px 0 8px; font-size: 14px; }
.dialog-body > button { margin: 8px 8px 0 0; font-size: 13px; }
.dialog-body label { display: block; margin-top: 12px; font-weight: 550; }
.dialog-body label > input { display: block; width: 100%; margin-top: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px; background: var(--panel-2); border-top: 1px solid var(--line); border-radius: 0 0 16px 16px; }
.dialog-actions:empty { display: none; }
.collaboration-activation-dialog .dialog-body label { display: flex; align-items: center; gap: 8px; }
.collaboration-activation-dialog .dialog-body label > input[type="checkbox"] { display: inline-block; width: 16px; margin: 0; }
.dialog-input { width: 100%; font-size: 15px; padding: 11px 12px; }
.about-tagline { font: italic 21px Georgia, serif; color: var(--accent); }
.new-kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.new-kind { justify-content: flex-start; gap: 12px; min-height: 58px; padding: 0 16px; font-size: 14.5px; font-weight: 600; text-align: left; color: var(--ink); }
.new-kind .icon { color: var(--module-color); }
.new-kind:hover { border-color: color-mix(in srgb, var(--module-color) 55%, var(--line)); }
.export-options { display: grid; gap: 8px; margin: 10px 0 4px; }
.export-heading { margin: 16px 2px 2px; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.export-heading:first-child { margin-top: 4px; }
.export-options button { justify-content: flex-start; gap: 14px; min-height: 52px; padding: 8px 14px; text-align: left; font-size: 13.5px; }
.export-options button .fmt-badge { display: grid; place-items: center; flex: 0 0 52px; height: 28px; border-radius: 7px; background: var(--sunken); color: var(--ink-soft); font: 700 11px var(--mono); letter-spacing: .02em; }
.export-options button.primary .fmt-badge { background: #ffffff26; color: #fff; }
.export-options button .fmt-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.35; }
.export-options button .fmt-text small { font-size: 12px; font-weight: 400; color: var(--muted); }
.export-options button.primary .fmt-text small { color: #ffffffcc; }
.export-options button .icon { margin-left: auto; opacity: .55; }
.revision-list { display: grid; gap: 7px; }
.revision-row { display: grid; grid-template-columns: 90px 1fr; gap: 6px; min-height: 52px; text-align: left; font-size: 13px; }
.revision-row small { grid-column: 1 / -1; color: var(--accent); font-size: 12px; }
.settings-dialog { width: min(680px, 94vw); }
.settings-dialog .dialog-body { font-size: 14px; }
.settings-dialog .dialog-body h3 { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 15px; }
.settings-dialog .dialog-body h3:first-of-type, .setting-row + h3 { margin-top: 12px; padding-top: 0; border: 0; }
.setting-row + h3 { margin-top: 26px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting-row strong { font-size: 14px; }
.setting-row p { margin: 4px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.setting-row select { min-width: 160px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border-radius: 10px; }
.segmented button { min-height: 30px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-size: 12.5px; }
.segmented button:hover { color: var(--ink); background: transparent; }
.segmented button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }
.settings-status { margin: 8px 0; padding: 10px 14px; border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--ok-soft); line-height: 1.7; }
.format-table { display: grid; gap: 6px; margin: 12px 0; }
.format-table > div { display: grid; grid-template-columns: 130px 1fr; gap: 12px; align-items: baseline; font-size: 13px; }
.format-table dt, .format-table strong { font-weight: 600; }
.format-table .format-ext { margin: 0 4px 4px 0; }
.server-dialog { width: min(780px, 94vw); }
.server-list { display: grid; gap: 10px; margin: 14px 0; }
.server-row { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.server-row > div { flex: 1; min-width: 0; }
.server-row strong { overflow-wrap: anywhere; }
.server-row small { display: block; margin-top: 4px; color: var(--muted); }
.server-row button { flex-shrink: 0; }
.server-dialog .dialog-body > button { margin: 5px 8px 8px 0; }
.toast { position: fixed; z-index: 1000; left: calc(50% + 126px); bottom: 26px; display: flex; align-items: flex-start; gap: 10px; width: max-content; max-width: min(620px, 90vw); padding: 12px 18px; transform: translateX(-50%); background: light-dark(#1f3a2d, #e8f1ea); color: light-dark(#f4f8f1, #15251c); border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13.5px; line-height: 1.55; animation: toast-in .18s ease-out; }
.toast .icon { margin-top: 2px; }
.toast.error { background: light-dark(#7a2a22, #ffd9d3); color: light-dark(#fff3f1, #4a1812); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Drag & drop target */
.drop-overlay { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; padding: 24px; background: rgb(8 20 14 / .55); backdrop-filter: blur(4px); }
.drop-card { display: grid; justify-items: center; gap: 8px; max-width: 420px; padding: 40px 48px; text-align: center; color: var(--ink); background: var(--panel); border: 2px dashed var(--accent); border-radius: 20px; box-shadow: var(--shadow-lg); }
.drop-card .drop-icon { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 6px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); }
.drop-card strong { font-size: 18px; letter-spacing: -.02em; }
.drop-card span:not(.drop-icon) { font-size: 13px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (min-width: 1550px) {
  .dashboard { padding: 52px 72px 56px; }
  .workspace-intro, .create-grid, .library-heading, .document-library, .workspace-footnote { max-width: 1320px; }
  .create-card { min-height: 156px; padding: 22px; }
  .document-row { height: 70px; }
}
@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 224px minmax(0, 1fr); }
  .workspace-intro { grid-template-columns: 1fr; gap: 22px; }
  .writer-layout { grid-template-columns: minmax(0, 1fr); }
  .writer-outline { display: none; }
  .slide-layout { grid-template-columns: 128px minmax(0, 1fr) 220px; }
  .toast { left: calc(50% + 112px); }
  .document-actions .btn-label { display: none; }
  .document-actions button { width: 36px; padding: 0; }
  .document-actions button.primary { width: auto; padding: 0 12px; }
  .document-actions button.primary .btn-label { display: inline; }
  .workspace-footnote button { display: none; }
}
@media (max-width: 950px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 100; width: 270px; transform: translateX(-100%); visibility: hidden; transition: transform .16s, visibility 0s .16s; }
  .sidebar-open .sidebar { transform: translateX(0); visibility: visible; transition: transform .16s; box-shadow: 20px 0 50px rgb(8 20 14 / .3); }
  .sidebar-open .navigation-dismiss { display: block; position: fixed; inset: 0; z-index: 90; border: 0; border-radius: 0; background: rgb(8 20 14 / .5); cursor: pointer; }
  #mobile-menu { display: inline-flex; }
  #sidebar-toggle { display: none; }
  .topbar { height: 54px; padding: 0 16px; gap: 10px; }
  .dashboard { padding: 28px 24px 36px; }
  .toast { left: 50%; max-width: 90vw; }
  .slide-layout { grid-template-columns: 120px minmax(0, 1fr) 220px; }
}
@media (max-width: 720px) {
  .dashboard { padding: 22px 16px 30px; }
  .workspace-intro h1 { font-size: 30px; }
  .workspace-intro p { font-size: 14px; }
  .dropzone { display: none; }
  .create-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0 28px; }
  .create-card { min-height: 148px; padding: 14px; }
  .app-symbol { width: 34px; height: 34px; margin-bottom: 10px; }
  .card-plus { display: none; }
  .library-heading input[type="search"] { order: 4; width: 100%; margin: 0; }
  .library-heading select { margin-left: auto; max-width: 160px; }
  .library-columns, .document-row { grid-template-columns: minmax(110px, 1fr) 96px 34px; padding: 0 12px; gap: 6px; }
  .library-columns > span:nth-child(2), .type-label { display: none; }
  .document-row { height: 62px; }
  .document-name { gap: 10px; font-size: 13.5px; }
  .modified-label { font-size: 11.5px; line-height: 1.5; }
  .row-delete { opacity: 1; }
  .workspace-footnote { padding: 14px; gap: 12px; }
  .topbar .local-badge, .topbar #import .btn-label { display: none; }
  .topbar #import { width: 34px; padding: 0; }
  .document-header { flex-wrap: wrap; min-height: 0; padding: 10px 12px; gap: 8px; }
  .document-icon { width: 34px; height: 34px; }
  .document-heading { flex-basis: calc(100% - 100px); min-width: 120px; }
  .document-heading input { font-size: 16px; }
  .save-status { font-size: 11px; max-width: 200px; }
  .document-actions { gap: 4px; margin-left: auto; }

  .toolbar { flex-wrap: nowrap; gap: 2px; min-height: 46px; padding: 7px 36px 7px 10px; overflow-x: auto; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); overscroll-behavior-x: contain; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar > * { flex-shrink: 0; }
  .toolbar button { min-height: 36px; }
  .toolbar button .btn-label { display: none; }
  .toolbar button.icon-only { width: 36px; }
  .toolbar button.has-icon:not(.icon-only) { padding: 0 10px; }
  .toolbar select { max-width: 130px; min-height: 36px; }
  .module-status { padding: 7px 12px; font-size: 11px; }
  .module-status > span:last-child { max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
  .writer-scroll { padding: 14px 12px 30px; }
  .writer-page { min-height: 800px; padding: 34px 26px; font-size: 14.5px; }
  .writer-page h1 { font-size: 32px; }
  .writer-page h2 { font-size: 21px; }
  .slide-layout { grid-template-columns: 88px minmax(0, 1fr); }
  .slide-rail { padding: 12px 7px; }
  .slide-inspector { display: none; position: absolute; top: 185px; right: 0; bottom: 30px; width: 245px; z-index: 20; box-shadow: -10px 0 24px rgb(8 20 14 / .25); }
  .slide-layout.show-inspector .slide-inspector { display: block; }
  .inspector-toggle { display: inline-flex !important; }
  .slide-thumb > span { font-size: 11px; }
  .new-slide { padding: 0; }
  .new-slide .btn-label { display: none; }
  .slide-stage { min-height: 180px; }
  .slide-notes { padding: 12px; font-size: 12.5px; }
  .sql-editor-wrap { padding: 14px; }
  .sql-editor { min-height: 180px; font-size: 12.5px; }
  .sql-banner { padding: 10px 14px; }
  .paint-layout, .diagram-layout { display: flex; flex-direction: column; overflow: auto; }
  .paint-scroll, .diagram-scroll { flex-shrink: 0; padding: 12px; overflow: visible; }
  .paint-layers, .diagram-inspector { overflow: visible; border-left: 0; border-top: 1px solid var(--line); }
  .media-workspace { padding: 20px 14px; }
  .audio-wave { height: 180px; }
  .media-controls { gap: 12px; }
  .media-field input { width: 140px; }
  .pdf-workspace { padding: 12px; }
  .pdf-preview { min-height: 320px; }
  .code-input, .code-lines, .code-highlight { font-size: 12.5px; line-height: 22px; }
  .code-input { padding: 12px; }
  .code-lines { min-width: 44px; padding: 12px 8px; }
  .code .toolbar input[type="search"] { width: 150px; }
  .empty-state { margin: 20px auto; }
  .dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; border-bottom: 0; max-height: 92dvh; }
  .dialog[open] { animation: sheet-in .2s ease-out; }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: .6; } }
  .dialog-body { padding: 18px 20px; max-height: calc(92dvh - 130px); }
  .dialog-heading { padding: 12px 12px 12px 20px; }
  .dialog-actions { padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-radius: 0; }
  .new-kind-grid { grid-template-columns: 1fr; }
  .setting-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .setting-row select, .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .format-table > div { grid-template-columns: 1fr; gap: 2px; }
  .server-row { flex-wrap: wrap; }
  .server-row > div { flex-basis: 100%; }
  .toast { bottom: 16px; font-size: 12.5px; }
  .sidebar .nav-item { min-height: 42px; }
  .sidebar .recent-heading { margin-top: 14px; }
  .formula-row { gap: 6px; padding: 5px 10px; }
  .formula-row input.cell-address { width: 58px; }
  .sheet-tabs { padding-left: 4px; }
  .sheet-tabs button { padding: 0 12px; font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media print {
  .sidebar, .topbar, .toolbar, .document-header, .toast { display: none !important; }
}

/* Snapshot share management */
.share-dialog { width: min(580px, 94vw); }
.share-feedback:empty { display: none; }
.share-feedback { color: var(--danger); overflow-wrap: anywhere; }
.share-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.share-filters input { flex: 2 1 220px; min-width: 0; }
.share-filters select { flex: 1 1 180px; min-width: 0; }
.share-dialog label > select { margin-top: 6px; }
.share-badge { display: inline-block; padding: 2px 8px; margin-top: 6px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); font-size: 12px; }
.share-badge.blocked { color: var(--danger); }
.share-dialog[aria-busy="true"] { cursor: progress; }
.share-dialog .dialog-actions { flex-wrap: wrap; }

.share-dialog [hidden] { display: none; }

/* A useful first visit: real local templates, import and a clear deployment model. */
.workspace-intro h1 { max-width: 10ch; font-size: clamp(38px, 4.2vw, 58px); line-height: 1.06; text-wrap:balance; }
.workspace-intro .intro-lead { font-size: 16px; max-width: 41ch; }
.intro-trust { display: flex; flex-wrap: wrap; gap: 10px 18px; list-style: none; padding: 0; margin: 24px 0 0; color: var(--ink-soft); font-size: 12px; }
.intro-trust li { display: inline-flex; align-items: center; gap: 7px; }
.intro-trust svg { color: var(--accent); }
.workspace-preview { min-width: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-md); }
.preview-window-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--panel-2); color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
.preview-window-bar > svg { margin-left: auto; }
.preview-window-dots { display: inline-flex; gap: 4px; }
.preview-window-dots i { display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.workspace-preview-tabs { display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.preview-tab { flex: 1; min-width: 0; padding: 6px 10px; font-size: 12px; border-color: transparent; background: transparent; color: var(--muted); }
.preview-tab[aria-selected="true"] { border-color: var(--line); background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }
.workspace-preview-pane { min-height: 310px; display: grid; padding: 20px; background: var(--sunken); }
.preview-paper { max-width: 340px; width: 100%; min-width: 0; margin: auto; padding: 25px 28px; background: #fff; color: #172b4d; box-shadow: 0 2px 14px #18291e12; }
.preview-paper .preview-letterhead { font-size: 8px; letter-spacing: .1em; color: #1d4ed8; }
.preview-paper small { font-size: 9px; color: #506581; }
.preview-paper h2 { font-size: 21px; letter-spacing: -.025em; line-height: 1.18; margin: 14px 0; }
.preview-paper p { font-size: 10px; line-height: 1.7; color: #344d70; }
.preview-text-lines { display: grid; gap: 6px; margin-top: 13px; }
.preview-text-lines span { display: block; height: 3px; width: 100%; background: #e8eeea; }
.preview-text-lines span:last-child { width: 70%; }
.preview-paper .preview-signature { font: italic 16px Georgia,serif; margin: 14px 0 0; }
.preview-sheet { min-width: 0; align-self: center; background: #fff; color: #172b4d; border: 1px solid #d7e2f3; }
.preview-sheet h2 { margin: 0; padding: 12px; font-size: 16px; }
.preview-formula { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid #d7e2f3; font-size: 12px; }
.preview-formula > span { color: #1d4ed8; font-style: italic; }
.preview-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 10px; }
.preview-table th,.preview-table td { padding: 9px 6px; text-align: right; border-bottom: 1px solid #d7e2f3; overflow-wrap: anywhere; }
.preview-table th:first-child,.preview-table td:first-child { text-align: left; width: 72%; }
.preview-table th { background: #eff6ff; font-size: 9px; font-weight: 600; }
.preview-total { color: #157957; background: #f2f8f4; font-weight: 700; }
.preview-sheet > p { margin: 0; padding: 9px 12px; font-size: 10px; color: #506581; }
.preview-slide { align-self: center; padding: 28px; background: #172b4d; color: #fff; aspect-ratio: 16/10; display: flex; flex-direction: column; justify-content: center; }
.preview-slide .eyebrow { color: #93c5fd; font-size: 9px; letter-spacing: .12em; }
.preview-slide h2 { font-size: clamp(25px,2.4vw,34px); letter-spacing: -.035em; line-height: 1.1; margin: 14px 0; }
.preview-slide p { color: #c4d4ed; font-size: 11px; max-width: 31ch; }
.preview-slide-blocks { display: flex; gap: 8px; margin-top: 14px; }
.preview-slide-blocks span { width: 36px; padding: 7px 0; text-align: center; border: 1px solid #4a5f7f; border-radius: 5px; font-size: 10px; }
.preview-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px; padding: 10px 14px; }
.preview-footer > span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.preview-footer button { min-height: 28px; font-size: 11px; padding: 5px 8px; }
.workspace-capabilities { display: flex; align-items: center; justify-content: space-between; gap: 18px; max-width: 1200px; margin: 30px auto 0; padding: 17px 0; border-bottom: 1px solid var(--line); }
.workspace-capabilities strong { display: block; font-size: 14px; }
.workspace-capabilities span { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; }
.workspace-capabilities button { flex-shrink: 0; font-size: 12px; }
.dashboard > .dropzone { max-width: 1200px; margin: 0 auto 30px; }
.template-dialog { width: min(890px,94vw); }
.template-dialog .dialog-body > select { width: 100%; margin: 3px 0 20px; }
.template-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.template-card { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding: 18px; text-align: left; background: var(--panel-2); }
.template-card .app-symbol { margin-bottom: 6px; }
.template-card h3 { font-size: 15px; line-height: 1.35; margin: 8px 0; }
.template-card p { margin: 0 0 13px; font-size: 12px; line-height: 1.55; color: var(--muted); }
.template-card small { font-size: 11px; line-height: 1.5; color: var(--ink-soft); }
.template-action { display: block; margin-top: auto; padding-top: 14px; font-size: 12px; color: var(--accent); }
.backup-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.backup-preview { max-height: 220px; overflow: auto; padding-left: 18px; }
.capability-list { padding-left: 20px; }
.capability-list li { margin: 10px 0; }
.about-source-link { display: block; margin: 12px 0; }
:root[data-deployment="public-static"] #collaborate,:root[data-deployment="public-static"] #server-workspace { display: none; }
@media (min-width:1550px) { .workspace-capabilities,.dashboard > .dropzone { max-width: 1320px; } }
@media (max-width:1200px) { .workspace-intro { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 24px; } .workspace-intro h1 { font-size: 43px; } .intro-actions button { padding: 8px 12px; } }
@media (max-width:1050px) { .workspace-intro { grid-template-columns: 1fr; } .workspace-intro h1 { max-width: 15ch; } .workspace-preview { max-width: 600px; width: 100%; } }
@media (max-width:720px) {
  .workspace-intro h1 { font-size: 38px; max-width: 12ch; }
  .workspace-intro .intro-lead { font-size: 14px; }
  .intro-trust { gap: 9px 14px; margin-top: 18px; font-size: 11px; }
  .workspace-preview-pane { min-height: 280px; padding: 15px; }
  .preview-paper { padding: 20px 23px; }
  .workspace-capabilities { flex-wrap: wrap; gap: 10px; margin-top: 24px; }
  .workspace-capabilities button { padding-left: 0; }
  .template-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .template-card { padding: 12px; }
  .template-card h3 { font-size: 13px; }
}
@media (max-width:380px) { .template-grid { grid-template-columns: 1fr; } }

/* Hide application chrome independently while retaining reachable restore controls. */
html[data-sidebar-hidden="true"] .app-shell { grid-template-columns: minmax(0,1fr); }
html[data-sidebar-hidden="true"] .sidebar { display: none; }
html[data-topbar-hidden="true"] .topbar { display: none; }
.layout-restore { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; max-width: 100%; }
.layout-restore .icon-button { width: 36px; height: 36px; }
.layout-restore-slot { display: flex; align-items: center; flex-shrink: 0; min-height: 44px; padding: 4px 28px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
#document-layout-controls { flex: 0 0 auto; }
.document-header #focus-exit { display: none; }
.document-actions { margin-left: auto; }
@media (max-width:720px) { .layout-restore-slot { padding: 4px 12px; } }
@media print { .layout-restore, .layout-restore-slot { display: none !important; } }

/* Keep spreadsheet chrome reversible without hiding cell coordinates or sheet tabs. */
.sheet-tools-hidden > .toolbar,.sheet-tools-hidden > .formula-row,
html[data-focus-mode="true"] #module > .sheet-toolbar,
html[data-focus-mode="true"] #module > .formula-row {display:none;}
.sheet-tools-toggle {position:fixed;right:12px;bottom:42px;z-index:80;background:var(--panel);box-shadow:var(--shadow-md);}
html[data-focus-mode="true"] .sheet-tools-toggle {display:none;}
@media print {.sheet-tools-toggle {display:none!important;}}

/* Compact document actions retain the same controls and editor state. */
.document-more { position: relative; }
.document-more > summary { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: var(--radius-sm); list-style: none; cursor: pointer; min-height: 36px; }
.document-more > summary::-webkit-details-marker { display: none; }
.document-more[open] > summary { background: var(--panel-2); border-color: var(--accent); }
.document-more-items { position: absolute; right: 0; top: calc(100% + 8px); z-index: 85; display: flex; flex-direction: column; gap: 4px; min-width: 200px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow-md); }
.document-actions .document-more-items button { width: 100%; min-height: 44px; justify-content: flex-start; padding: 0 12px; border-color: transparent; }
.document-actions .document-more-items .btn-label { display: inline; }
.layout-restore #focus-exit { min-height: 36px; padding: 0 10px; font-size: 12px; }
html[data-sidebar-hidden="true"] .toast { left: 50%; }
.breadcrumb { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar > button { flex-shrink: 0; }
@media (max-width:720px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar .breadcrumb { flex: 1 1 0; }
  .topbar-spacer { display: none; }
  .topbar #import { font-size: 0; }
  .document-actions { max-width: 100%; flex-wrap: wrap; }
}

.editor-loading { position: fixed; z-index: 1000; right: 16px; bottom: 42px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink-soft); box-shadow: var(--shadow-md); font-size: 13px; }
@media print { .editor-loading { display: none !important; } }

.theme-setting { align-items: flex-start; }
.theme-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; flex:0 0 330px; max-width:100%; }
.theme-choice { min-width:0; flex-direction:column; gap:7px; padding:8px; font-size:12px; }
.theme-choice[aria-pressed="true"] { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); color:var(--accent-ink); background:var(--accent-soft); font-weight:600; }
.theme-swatch { display:flex; gap:4px; align-items:center; width:100%; height:28px; padding:5px; border-radius:5px; background:var(--swatch-canvas); border:1px solid rgb(127 127 127 / .2); }
.theme-swatch i:first-child { width:8px; height:100%; border-radius:2px; background:var(--swatch-accent); }
.theme-swatch i:nth-child(2) { flex:1; height:100%; border-radius:2px; background:#ffffff; }
.theme-swatch i:last-child { width:12px; height:8px; border-radius:2px; background:var(--swatch-accent); }
.theme-swatch-system { background:linear-gradient(90deg,#eff4fb 50%,#0f172a 50%); }
@media (max-width:720px) { .theme-grid { flex-basis:auto; width:100%; } }

/* Large, faint scattered stars sit below every control and document surface. */
body { isolation:isolate; }
.ambient-stars { position:fixed; inset:0; z-index:-1; overflow:hidden; pointer-events:none; user-select:none; contain:strict; }
.ambient-orbit { position:absolute; inset:0; }
.ambient-star { position:absolute; width:calc(clamp(52px,6vw,96px) * var(--star-scale,1)); height:calc(clamp(52px,6vw,96px) * var(--star-scale,1)); fill:#d6b76a; opacity:var(--star-opacity,.09); transform:translate3d(-50%,-50%,0) rotate(var(--star-rotation,0deg)); animation:star-drift var(--star-duration) ease-in-out var(--star-delay) infinite alternate; }
@keyframes star-drift { from { transform:translate3d(-50%,-50%,0) rotate(var(--star-rotation,0deg)); } to { transform:translate3d(calc(-50% + var(--star-drift-x,8px)),calc(-50% + var(--star-drift-y,6px)),0) rotate(calc(var(--star-rotation,0deg) + 5deg)); } }
.ambient-paused .ambient-star { animation-play-state:paused; }
@media (prefers-reduced-motion:reduce) { .ambient-star { animation:none; } .create-card { transition:none; } .create-card:hover { transform:none; } }
@media print { .ambient-stars { display:none !important; } }

/* Release accessibility: retain keyboard focus on document surfaces. */
.slide-canvas:focus-visible, .code-input:focus-visible, .diagram-stage:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.editor-keyboard-help { margin: 0; padding: 6px 16px; background: var(--panel-2); }
.paint-coordinates { padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.paint-coordinate-fields { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 6px 0; }
.paint-coordinates summary { cursor: pointer; padding: 6px; }
.paint-coordinates input[type=number] { width: 90px; }
.save-status.error { white-space: normal; overflow: visible; }
@media (min-width: 721px) and (max-width: 1360px) { .document-heading { min-width: 240px; } .document-actions { flex-wrap: wrap; } }
@media (max-width: 720px) { .slide-layout { grid-template-columns: 1fr; } .slide-rail { display: flex; gap: 8px; max-height: 100px; border-right: 0; border-bottom: 1px solid var(--line); } .slide-thumb { width: 105px; flex-shrink: 0; margin: 0; } .slide-rail > .eyebrow { display: none; } .slide-stage { padding: 8px; } }
@media (forced-colors: active) { .slide-canvas:focus-visible, .code-input:focus-visible, .diagram-stage:focus-visible { outline-color: Highlight; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.slide-stage.manual-zoom { overflow: auto; align-items: flex-start; justify-content: flex-start; padding: 24px; }
.slide-layout.hide-slide-rail { grid-template-columns: minmax(0, 1fr) 264px; }
.slide-layout.hide-slide-rail .slide-rail { display: none; }
@media (max-width: 950px) { .slide-layout.hide-slide-rail { grid-template-columns: minmax(0, 1fr) 220px; } }
@media (max-width: 720px) { .slide-layout { grid-template-rows: auto minmax(0, 1fr); } .slide-layout.hide-slide-rail { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); } }
