/* Hamsoo — application UI */
:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --hover: #eef0f6;
  --border: #e3e6ef;
  --border-strong: #d3d7e3;
  --text: #1f2430;
  --muted: #6b7385;
  --accent: #5b5bd6;
  --accent-2: #8b5cf6;
  --accent-soft: #eceefe;
  --accent-text: #4338ca;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06);
  --shadow: 0 10px 30px -12px rgba(20, 24, 40, .22), 0 2px 6px rgba(20, 24, 40, .06);
  --radius: 12px;
  --editor-bg: #ffffff;
  --mark: rgba(250, 204, 21, .45);
  --mark-cur: rgba(249, 115, 22, .55);
  --ui-font: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', 'Vazirmatn', monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f14; --surface: #151820; --surface-2: #12151c; --hover: #1f232d; --border: #252a35; --border-strong: #323846;
    --text: #e4e7ee; --muted: #949db0; --accent: #8b8cf8; --accent-2: #b48cfb; --accent-soft: #23253c; --accent-text: #c7c8ff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 16px 40px -12px rgba(0, 0, 0, .6), 0 2px 8px rgba(0, 0, 0, .35);
    --editor-bg: #12151c; --mark: rgba(250, 204, 21, .3); --mark-cur: rgba(249, 115, 22, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f14; --surface: #151820; --surface-2: #12151c; --hover: #1f232d; --border: #252a35; --border-strong: #323846;
  --text: #e4e7ee; --muted: #949db0; --accent: #8b8cf8; --accent-2: #b48cfb; --accent-soft: #23253c; --accent-text: #c7c8ff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 16px 40px -12px rgba(0, 0, 0, .6), 0 2px 8px rgba(0, 0, 0, .35);
  --editor-bg: #12151c; --mark: rgba(250, 204, 21, .3); --mark-cur: rgba(249, 115, 22, .5); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--ui-font); font-size: 14px;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; flex: none; }
.brand .logo { width: 34px; height: 34px; stroke: none; filter: drop-shadow(0 4px 10px rgba(99, 102, 241, .35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.brand-text small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.view-seg { margin-inline: auto; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; transition: background .15s, color .15s;
}
.seg-btn svg { width: 16px; height: 16px; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-checked="true"] { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-sm); }

.top-actions { display: flex; align-items: center; gap: 4px; }
.sep { width: 1px; height: 22px; background: var(--border); margin-inline: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px;
  white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.icon { width: 34px; padding: 0; justify-content: center; border-color: transparent; background: transparent; position: relative; }
.btn.icon:hover { background: var(--hover); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 0; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.danger-ghost { border-color: transparent; background: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn .chev { width: 14px; height: 14px; opacity: .85; margin-inline-start: -2px; }
.badge {
  position: absolute; bottom: 2px; inset-inline-end: 1px; font-size: 9px; font-weight: 800; line-height: 1; padding: 2px 3px;
  border-radius: 4px; background: var(--accent); color: #fff; letter-spacing: .02em;
}

/* menus */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 50; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  animation: pop .14s ease-out;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 8px 10px;
  border-radius: 8px; text-align: start; font-size: 13px; white-space: nowrap;
}
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu button svg { color: var(--muted); width: 17px; height: 17px; }
.menu [role="menuitemradio"] svg { opacity: 0; }
.menu [role="menuitemradio"][aria-checked="true"] { color: var(--accent-text); font-weight: 600; }
.menu [role="menuitemradio"][aria-checked="true"] svg { opacity: 1; color: var(--accent); }
#theme-menu [role="menuitemradio"] svg { opacity: 1; }
.lang-menu { min-width: 180px; }
.lang-menu .lang-code { margin-inline-start: auto; font-size: 10.5px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 4px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 2px; padding: 6px 12px; background: var(--surface);
  border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.tb-group { display: flex; align-items: center; gap: 1px; padding-inline: 4px; }
.tb-group + .tb-group { border-inline-start: 1px solid var(--border); }
.tb-spacer { flex: 1; min-width: 8px; }
.tb {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); transition: background .12s, color .12s; flex: none;
}
.tb:hover { background: var(--hover); color: var(--text); }
.tb.toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- workspace ---------- */
.workspace { --split: 50%; flex: 1; display: flex; min-height: 0; position: relative; }
.pane { min-width: 0; min-height: 0; position: relative; }
.editor-pane { flex: 0 0 var(--split); display: flex; flex-direction: column; background: var(--editor-bg); }
.preview-pane { flex: 1 1 0; overflow: auto; background: var(--surface); contain: layout paint; scroll-behavior: auto; }
.splitter {
  flex: none; width: 7px; cursor: col-resize; background: var(--bg); position: relative; z-index: 2;
  border-inline: 1px solid var(--border); touch-action: none;
}
.splitter::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 3px; height: 36px; border-radius: 3px;
  transform: translate(-50%, -50%); background: var(--border-strong); transition: background .15s;
}
.splitter:hover::after, .splitter.dragging::after, .splitter:focus-visible::after { background: var(--accent); }

.app[data-view="editor"] .preview-pane, .app[data-view="editor"] .splitter { display: none; }
.app[data-view="editor"] .editor-pane { flex: 1 1 auto; }
.app[data-view="preview"] .editor-pane, .app[data-view="preview"] .splitter { display: none; }
.app[data-view="preview"] .toolbar .tb-group:not(:last-child) { display: none; }

/* editor */
.editor-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#editor, .editor-highlights {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0;
  padding: 24px clamp(16px, 4vw, 40px) min(35vh, 240px); font-family: var(--mono); font-size: 15px; line-height: 1.75;
  tab-size: 4; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; letter-spacing: 0;
}
#editor {
  resize: none; outline: none; background: transparent; color: var(--text); overflow-y: auto; z-index: 1;
  caret-color: var(--accent); text-align: start;
}
#editor::placeholder { color: var(--muted); }
#editor::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
#editor.bidi-plain, .editor-highlights.bidi-plain { unicode-bidi: plaintext; }
#editor.nowrap, .editor-highlights.nowrap { white-space: pre; overflow-wrap: normal; overflow-x: auto; }
#editor.sans, .editor-highlights.sans { font-family: var(--ui-font); }
.editor-highlights { color: transparent; overflow: hidden; pointer-events: none; z-index: 0; }
.editor-highlights mark { background: var(--mark); color: transparent; border-radius: 2px; }
.editor-highlights mark.cur { background: var(--mark-cur); }

/* find bar */
.findbar {
  display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface); z-index: 3;
}
.find-row { display: flex; align-items: center; gap: 4px; }
.find-input {
  flex: 1; display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; min-width: 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
}
.find-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.find-input svg { width: 15px; height: 15px; color: var(--muted); }
.find-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 100%; }
.find-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip { display: inline-grid; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 8px; font-family: var(--mono);
  font-size: 12px; color: var(--muted); border: 1px solid transparent;
}
.chip input:checked + span { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); }

/* preview */
.md#preview { max-width: none; margin: 0 auto; padding: 32px clamp(18px, 5vw, 56px) 30vh; }
.app.narrow-preview .md#preview { max-width: 860px; }
.md pre .copy-code {
  position: absolute; top: 6px; inset-inline-end: 6px; display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 7px; border: 1px solid var(--md-pre-border); background: var(--surface); color: var(--muted);
  opacity: 0; transition: opacity .15s; font-family: var(--ui-font);
}
.md pre:hover .copy-code, .md pre .copy-code:focus-visible { opacity: 1; }
.md pre:hover[data-lang]::before { opacity: 0; }
.md pre .copy-code svg { width: 15px; height: 15px; }
.md pre .copy-code.ok { color: #16a34a; opacity: 1; }
.md [data-line].flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }
.preview-empty { color: var(--muted); text-align: center; padding-top: 18vh; }

/* outline */
.toc {
  display: none; flex: 0 0 240px; flex-direction: column; min-height: 0; background: var(--surface-2);
  border-inline-end: 1px solid var(--border);
}
.app.show-toc .toc { display: flex; }
.toc-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px 8px; font-size: 12px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
}
.toc-head svg { width: 15px; height: 15px; }
#toc-list { overflow: auto; padding: 4px 8px 24px; }
#toc-list a {
  display: block; padding: 5px 10px; border-radius: 7px; color: var(--text); text-decoration: none; font-size: 13px;
  line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-inline-start: 2px solid transparent;
}
#toc-list a:hover { background: var(--hover); }
#toc-list a.active { color: var(--accent-text); background: var(--accent-soft); }
#toc-list a[data-level="2"] { padding-inline-start: 22px; }
#toc-list a[data-level="3"] { padding-inline-start: 34px; font-size: 12.5px; color: var(--muted); }
#toc-list a[data-level="4"], #toc-list a[data-level="5"], #toc-list a[data-level="6"] { padding-inline-start: 46px; font-size: 12px; color: var(--muted); }
.toc-empty { color: var(--muted); font-size: 12.5px; padding: 8px 12px; }

/* status bar */
.statusbar {
  display: flex; align-items: center; gap: 16px; padding: 5px 16px; padding-bottom: max(5px, env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden;
}
.statusbar .grow, .grow { flex: 1; }
.stat { display: inline-flex; align-items: center; gap: 5px; }
.stat svg { width: 14px; height: 14px; }
.stat.local { color: #16a34a; font-weight: 600; }
:root[data-theme="dark"] .stat.local { color: #4ade80; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stat.local { color: #4ade80; } }
.stat.save::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }
.stat.save.pending::before { background: #f59e0b; }

/* focus mode */
.app.focus .topbar, .app.focus .toolbar, .app.focus .statusbar, .app.focus .toc { display: none !important; }
.focus-exit {
  position: fixed; top: 12px; inset-inline-end: 12px; z-index: 40; opacity: .35; transition: opacity .2s;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
}
.focus-exit:hover { opacity: 1; }

/* drop overlay */
.drop-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px);
}
.drop-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 56px; border-radius: 22px; text-align: center;
  border: 2px dashed var(--accent); background: var(--surface); box-shadow: var(--shadow);
}
.drop-card svg { width: 44px; height: 44px; color: var(--accent); stroke-width: 1.5; }
.drop-card strong { font-size: 18px; }
.drop-card span { color: var(--muted); font-size: 13px; }

/* dialogs */
.dlg {
  width: min(560px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 48px)); padding: 0; border: 1px solid var(--border);
  border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); overflow: auto;
}
.dlg.wide { width: min(860px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(10, 12, 20, .45); backdrop-filter: blur(3px); }
.dlg[open] { animation: pop .16s ease-out; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-head h2 { margin: 0; font-size: 17px; font-weight: 750; }
.dlg-sub { display: flex; align-items: center; gap: 6px; margin: 0 20px 10px; color: var(--muted); font-size: 12.5px; }
.dlg-sub svg { width: 15px; height: 15px; color: #16a34a; }
.dlg-foot { display: flex; align-items: center; gap: 6px; padding: 12px 20px 18px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); flex-wrap: wrap; }

.doc-list { list-style: none; margin: 0; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.doc-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.doc-item:hover { background: var(--hover); }
.doc-item.current { background: var(--accent-soft); }
.doc-item .doc-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--accent); }
.doc-item .doc-main { flex: 1; min-width: 0; border: 0; background: transparent; text-align: start; padding: 0; }
.doc-item .doc-title { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
.doc-item .doc-meta { display: block; font-size: 12px; color: var(--muted); }
.doc-item .tag { font-size: 11px; font-weight: 700; color: var(--accent-text); background: var(--surface); border-radius: 6px; padding: 2px 6px; }

.settings { padding: 6px 20px 8px; display: flex; flex-direction: column; }
.settings .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.settings .row:last-child { border-bottom: 0; }
.settings .row small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.range { display: inline-flex; align-items: center; gap: 10px; }
.range input { width: 140px; accent-color: var(--accent); }
.range output { min-width: 34px; text-align: end; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
.seg.small label { display: inline-flex; }
.seg.small input { position: absolute; opacity: 0; pointer-events: none; }
.seg.small span { padding: 4px 10px; border-radius: 7px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.seg.small input:checked + span { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-sm); font-weight: 600; }
.seg.small input:focus-visible + span { outline: 2px solid var(--accent); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { flex: none; width: 40px; height: 23px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .18s; }
.switch i::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(17px); }
[dir="rtl"] .switch input:checked + i::after { transform: translateX(-17px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.privacy { display: flex; gap: 8px; align-items: flex-start; margin: 8px 20px 18px; padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, #16a34a 9%, transparent); color: var(--text); font-size: 12.5px; line-height: 1.7; }
.privacy svg { color: #16a34a; margin-top: 2px; }
.help-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 8px 28px; padding: 4px 20px; }
.help-grid h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 0; }
.help-features { margin: 0; padding-inline-start: 18px; line-height: 1.8; font-size: 13.5px; }
.help-features li { margin-bottom: 6px; }
.kbd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kbd-table td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.kbd-table td:first-child { white-space: nowrap; padding-inline-end: 12px; }
.kbd-table kbd { font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; direction: ltr; display: inline-block; }
.version { color: var(--muted); font-size: 12px; margin: 0 20px 18px; }

/* toasts */
.toasts { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px; background: var(--text); color: var(--surface);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow); animation: toast .2s ease-out; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); color: #fff; }
.toast svg { width: 16px; height: 16px; }
@keyframes toast { from { opacity: 0; transform: translateY(8px); } }

/* ---------- responsive ---------- */
@media (max-width: 1320px) {
  .top-actions .lbl { display: none; }
  .top-actions .btn:not(.icon) { padding: 0 9px; }
  .brand-text small { display: none; }
}
@media (max-width: 860px) {
  .view-seg .seg-btn span { display: none; }
  .view-seg .seg-btn { padding: 6px 10px; }
  .toc { position: absolute; inset-block: 0; inset-inline-start: 0; z-index: 10; width: 260px; box-shadow: var(--shadow); }
  .app[data-view="split"] .workspace { flex-direction: column; }
  .app[data-view="split"] .editor-pane { flex: 0 0 50%; }
  .app[data-view="split"] .splitter { display: none; }
  .app[data-view="split"] .preview-pane { border-top: 1px solid var(--border); }
  .help-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .view-seg { order: 3; width: 100%; margin: 0; padding: 2px; }
  .view-seg .seg-btn { flex: 1; justify-content: center; padding: 5px 8px; }
  .view-seg .seg-btn span { display: inline; }
  .top-actions { flex: 1; min-width: 0; gap: 0; overflow-x: auto; scrollbar-width: none; }
  .top-actions::-webkit-scrollbar { display: none; }
  .top-actions > :first-child { margin-inline-start: auto; }
  .top-actions .btn .chev, .install-btn { display: none !important; }
  .top-actions .btn.primary { width: 34px; padding: 0; justify-content: center; }
  .top-actions .sep { display: none; }
  .top-actions .btn { height: 32px; }
  .top-actions .btn.icon, .top-actions .btn.ghost { width: 32px; padding: 0; justify-content: center; }
  .brand-text strong { font-size: 16px; }
  .brand .logo { width: 30px; height: 30px; }
  .toolbar { padding: 4px 8px; }
  .hide-sm { display: none; }
  .statusbar { gap: 12px; padding-inline: 12px; }
  #editor, .editor-highlights { padding: 16px 16px 80px; }
  .md#preview { padding: 20px 16px 30vh; }
  .menu { position: fixed; top: auto; bottom: 12px; left: 12px; right: 12px; inset-inline-end: 12px; min-width: 0; }
}
@media (max-width: 400px) {
  .brand-text { display: none; }
}

/* ---------- print: only the rendered document ---------- */
@media print {
  @page { margin: 16mm 14mm; }
  html, body { height: auto; overflow: visible; background: #fff !important; }
  .topbar, .toolbar, .statusbar, .toc, .editor-pane, .splitter, .toasts, .drop-overlay, .copy-code, .focus-exit { display: none !important; }
  .app, .workspace { display: block !important; height: auto !important; }
  .preview-pane { display: block !important; overflow: visible !important; contain: none !important; background: #fff !important; }
  .md#preview { padding: 0 !important; max-width: none !important; }
}

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