/* Dispatch — lab prototype styles. Clean, iOS-inspired: Satoshi for UI, JetBrains Mono for the editor. */

/* ========================================================= */
/* Tokens                                                    */
/* ========================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

:root, [data-theme="light"] {
  --color-bg: #FFFFFF;
  --color-canvas: #F5F5F8;
  --color-surface: #FAFAFC;
  --color-surface-2: #F1F1F5;
  --color-surface-3: #E7E7EC;
  --color-border: #D6D6DC;
  --color-border-light: #E8E8ED;
  --color-text: #1D1D1F;
  --color-text-secondary: #55555B;
  --color-text-tertiary: #78787F;
  --color-text-placeholder: #9C9CA3;
  --color-accent: #0A6CFF;
  --color-accent-hover: #0057D9;
  --color-accent-text: #0058D6;
  --color-accent-bg: rgba(10, 108, 255, 0.08);
  --color-accent-bg-strong: rgba(10, 108, 255, 0.16);
  --color-red: #E5342A;
  --color-red-bg: rgba(229, 52, 42, 0.09);
  --color-orange: #E07800;
  --color-orange-bg: rgba(224, 120, 0, 0.12);
  --color-green: #1E9E4A;
  --color-green-bg: rgba(30, 158, 74, 0.11);
  --color-violet: #6E4BDB;
  --color-violet-bg: rgba(110, 75, 219, 0.10);
  --color-mark: rgba(255, 204, 0, 0.45);
  --color-mark-current: rgba(255, 149, 0, 0.6);
  --hover: rgba(0, 0, 0, 0.045);
  --shadow-sm: 0 1px 2px rgba(16, 16, 24, 0.05);
  --shadow-md: 0 6px 20px rgba(16, 16, 24, 0.08), 0 1px 3px rgba(16, 16, 24, 0.06);
  --shadow-lg: 0 18px 50px rgba(16, 16, 24, 0.14), 0 2px 6px rgba(16, 16, 24, 0.06);

  --font-body: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --text-2xs: 11px; --text-xs: 12px; --text-sm: 13.5px; --text-base: 15px; --text-lg: 17px; --text-xl: 22px; --text-2xl: 30px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
  --r-sm: 6px; --r-md: 9px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --topbar-h: 52px;
  --sidebar-w: 300px;
  --panel-w: 272px;
  --tap: 36px;
}
[data-theme="dark"] {
  --color-bg: #1C1C1E;
  --color-canvas: #141416;
  --color-surface: #222225;
  --color-surface-2: #2C2C2F;
  --color-surface-3: #3A3A3D;
  --color-border: #48484C;
  --color-border-light: #333336;
  --color-text: #F5F5F7;
  --color-text-secondary: #C2C2C8;
  --color-text-tertiary: #9A9AA1;
  --color-text-placeholder: #75757C;
  --color-accent: #3D8BFF;
  --color-accent-hover: #63A1FF;
  --color-accent-text: #7CB1FF;
  --color-accent-bg: rgba(61, 139, 255, 0.14);
  --color-accent-bg-strong: rgba(61, 139, 255, 0.28);
  --color-red: #FF6B61;
  --color-red-bg: rgba(255, 107, 97, 0.14);
  --color-orange: #FFAA40;
  --color-orange-bg: rgba(255, 170, 64, 0.15);
  --color-green: #4ADE80;
  --color-green-bg: rgba(74, 222, 128, 0.13);
  --color-violet: #A78BFA;
  --color-violet-bg: rgba(167, 139, 250, 0.15);
  --color-mark: rgba(255, 214, 10, 0.35);
  --color-mark-current: rgba(255, 159, 10, 0.6);
  --hover: rgba(255, 255, 255, 0.06);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.6);
}
@media (max-width: 768px) { :root { --tap: 44px; --topbar-h: 56px; } }

body { min-height: 100dvh; font-family: var(--font-body); font-size: var(--text-base); line-height: 1.5; color: var(--color-text); background: var(--color-canvas); overflow-x: hidden; }
button { cursor: pointer; background: none; border: 0; font: inherit; color: inherit; text-align: inherit; }
button:disabled { cursor: default; opacity: .4; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--color-accent-text); }
::selection { background: var(--color-accent-bg-strong); }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: var(--r-sm); }
button, a, input, select, textarea { transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), opacity .15s var(--ease), transform .15s var(--ease); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* ========================================================= */
/* Small shared pieces                                       */
/* ========================================================= */
.eyebrow { font-size: var(--text-2xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--color-text-tertiary); }
.muted { color: var(--color-text-tertiary); }
.small { font-size: var(--text-xs); }
.mono { font-family: var(--font-mono); }
.warn { color: var(--color-orange); font-weight: 500; }
code { font-family: var(--font-mono); font-size: .88em; }
.kbd { display: inline-flex; align-items: center; gap: 2px; font-family: var(--font-mono); font-size: var(--text-2xs); font-weight: 500; line-height: 1; padding: 4px 6px; border-radius: var(--r-sm); color: var(--color-text-tertiary); background: var(--color-surface-2); border: 1px solid var(--color-border-light); white-space: nowrap; }
.kbd-sm { padding: 3px 5px; font-size: 10px; }
.kbd-btn { cursor: pointer; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--tap); padding: 0 var(--s4); border-radius: var(--r-md); font-size: var(--text-sm); font-weight: 600; white-space: nowrap; background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); }
.btn:hover:not(:disabled) { background: var(--color-surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn-ghost { background: transparent; box-shadow: none; border-style: dashed; color: var(--color-text-secondary); }
.btn-danger { background: var(--color-red); border-color: var(--color-red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--color-red); filter: brightness(.95); }
.btn-danger-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--color-red); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--color-red-bg); }
.btn-sm { min-height: 30px; padding: 0 var(--s3); font-size: var(--text-xs); }
.btn-block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: var(--tap); height: var(--tap); padding: 0 8px; border-radius: var(--r-md); color: var(--color-text-tertiary); font-size: var(--text-sm); font-weight: 600; }
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--color-text); }
.icon-btn.on { color: var(--color-orange); background: var(--color-orange-bg); }
.icon-btn-danger:hover:not(:disabled) { color: var(--color-red); background: var(--color-red-bg); }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border-radius: var(--r-full); font-size: var(--text-xs); font-weight: 600; background: var(--color-surface-2); color: var(--color-text-secondary); border: 1px solid transparent; }
.chip-filter { background: var(--color-accent-bg); color: var(--color-accent-text); }
.chip-filter:hover { background: var(--color-accent-bg-strong); }
.chip-add { border: 1px dashed var(--color-border); background: transparent; color: var(--color-text-tertiary); }
.chip-add:hover { border-color: var(--color-accent); color: var(--color-accent-text); }
.chip-ghost { background: transparent; border: 1px solid var(--color-border-light); color: var(--color-text-tertiary); }
.chip-ghost:hover { border-color: var(--color-border); color: var(--color-text); }
.pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-full); font-size: var(--text-2xs); font-weight: 700; letter-spacing: .02em; background: var(--color-surface-2); color: var(--color-text-secondary); white-space: nowrap; }
.pill-sim { background: var(--color-violet-bg); color: var(--color-violet); }
.pill-local { background: var(--color-green-bg); color: var(--color-green); }
.count-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--color-surface-2); color: var(--color-text-secondary); font-size: var(--text-2xs); font-weight: 700; }
.tag-pill { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: var(--r-full); background: var(--color-surface-2); color: var(--color-text-secondary); white-space: nowrap; }
.input { width: 100%; min-height: var(--tap); padding: 0 var(--s3); border: 1px solid var(--color-border); border-radius: var(--r-md); background: var(--color-bg); font-size: var(--text-sm); outline: none; }
textarea.input { padding: var(--s2) var(--s3); line-height: 1.5; resize: vertical; }
.input:focus, .tag-input:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg-strong); }
.input.invalid, .capture-input.invalid { border-color: var(--color-red); box-shadow: 0 0 0 3px var(--color-red-bg); }
.input:disabled { opacity: .6; }

.switch { display: flex; align-items: center; gap: var(--s3); min-height: var(--tap); font-size: var(--text-sm); color: var(--color-text-secondary); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { position: relative; flex: none; width: 38px; height: 22px; border-radius: var(--r-full); background: var(--color-surface-3); transition: background .2s var(--ease); }
.switch-ui::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.switch input:checked + .switch-ui { background: var(--color-green); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.empty-list { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: var(--s8) var(--s4); text-align: center; color: var(--color-text-tertiary); font-size: var(--text-sm); }
.empty-list b { color: var(--color-text-secondary); font-weight: 600; }

/* ========================================================= */
/* Top bar                                                   */
/* ========================================================= */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: var(--s4); padding: 0 var(--s4); background: color-mix(in srgb, var(--color-bg) 88%, transparent); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--color-border-light); }
.topbar-left { display: flex; align-items: center; gap: var(--s1); flex: none; }
.menu-btn { display: none; }
.logo { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-width: var(--tap); height: var(--tap); padding: 0 var(--s2) 0 var(--s1); border-radius: var(--r-md); }
.logo:hover { background: var(--hover); }
.logo-icon { color: var(--color-text); flex: none; }
.logo-text { font-weight: 700; font-size: var(--text-lg); letter-spacing: -.02em; }
.topbar-nav { display: flex; align-items: center; gap: 2px; margin: 0 auto; padding: 3px; border-radius: var(--r-lg); background: var(--color-surface-2); }
.nav-tab { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 var(--s3); border-radius: var(--r-md); font-size: var(--text-sm); font-weight: 600; color: var(--color-text-tertiary); white-space: nowrap; }
.nav-tab svg { opacity: .8; }
.nav-tab:hover { color: var(--color-text); }
.nav-tab.active { color: var(--color-text); background: var(--color-bg); box-shadow: var(--shadow-sm); }
.nav-tab.active svg { color: var(--color-accent); opacity: 1; }
.topbar-right { display: flex; align-items: center; gap: var(--s2); flex: none; }
.search-trigger { display: inline-flex; align-items: center; gap: var(--s2); height: var(--tap); padding: 0 6px 0 var(--s3); min-width: 190px; border-radius: var(--r-md); border: 1px solid var(--color-border-light); background: var(--color-surface); color: var(--color-text-tertiary); font-size: var(--text-sm); }
.search-trigger:hover { border-color: var(--color-border); color: var(--color-text-secondary); }
.search-trigger-text { flex: 1; text-align: left; }
.capture-trigger { display: inline-flex; align-items: center; gap: 6px; height: var(--tap); padding: 0 var(--s3); border-radius: var(--r-md); background: var(--color-accent); color: #fff; font-size: var(--text-sm); font-weight: 700; }
.capture-trigger:hover { background: var(--color-accent-hover); }

/* ========================================================= */
/* Views                                                     */
/* ========================================================= */
.view { display: none; margin-top: var(--topbar-h); }
.view.active { display: block; }
.view-drafts.active { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--panel-w); height: calc(100dvh - var(--chrome-h, var(--topbar-h))); background: var(--color-bg); }

/* ========================================================= */
/* Sidebar and draft list                                    */
/* ========================================================= */
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--color-surface); border-right: 1px solid var(--color-border-light); }
.sidebar-header { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3) var(--s3) var(--s2); }
.ws-picker { position: relative; }
.ws-picker-btn { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 48px; padding: 6px var(--s3); border-radius: var(--r-lg); border: 1px solid transparent; }
.ws-picker-btn:hover, .ws-picker-btn[aria-expanded="true"] { background: var(--color-bg); border-color: var(--color-border-light); box-shadow: var(--shadow-sm); }
.ws-picker-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); background: var(--color-bg); border: 1px solid var(--color-border-light); font-size: 16px; }
.ws-picker-text { flex: 1; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.ws-picker-label { font-size: var(--text-2xs); color: var(--color-text-tertiary); font-weight: 600; }
.ws-picker-name { font-weight: 700; font-size: var(--text-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-menu { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; padding: var(--s1); background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); display: none; }
.ws-menu.open { display: block; animation: pop .18s var(--ease); }
.ws-option { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: var(--tap); padding: 6px var(--s3); border-radius: var(--r-md); font-size: var(--text-sm); font-weight: 500; }
.ws-option:hover { background: var(--hover); }
.ws-option.active { background: var(--color-accent-bg); color: var(--color-accent-text); font-weight: 700; }
.ws-option-name { flex: 1; }
.ws-option-count { font-size: var(--text-2xs); color: var(--color-text-tertiary); font-weight: 600; }
.ws-menu-sep { height: 1px; margin: var(--s1) var(--s2); background: var(--color-border-light); }
.ws-option-manage { color: var(--color-text-secondary); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

.list-search { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r-md); background: var(--color-surface-2); color: var(--color-text-tertiary); border: 1px solid transparent; }
.list-search:focus-within { background: var(--color-bg); border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg-strong); }
.list-search input { flex: 1; min-width: 0; height: var(--tap); border: 0; outline: none; background: none; font-size: var(--text-sm); color: var(--color-text); }
.list-search input::placeholder { color: var(--color-text-placeholder); }
.filter-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 -2px; padding: 0 2px; }
.filter-tabs::-webkit-scrollbar { display: none; }
.ftab { flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 7px; border-radius: var(--r-md); font-size: var(--text-xs); font-weight: 600; color: var(--color-text-tertiary); white-space: nowrap; }
.ftab:hover { background: var(--hover); color: var(--color-text-secondary); }
.ftab.active { background: var(--color-accent-bg); color: var(--color-accent-text); }
.ftab-count { font-size: 10.5px; padding: 1px 6px; border-radius: var(--r-full); background: var(--color-surface-3); color: var(--color-text-secondary); }
.ftab.active .ftab-count { background: var(--color-accent); color: #fff; }
.list-chips:empty { display: none; }

.draft-list { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s1) var(--s2) var(--s3); scrollbar-width: thin; scrollbar-color: var(--color-border-light) transparent; }
.draft-item { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: var(--s3); border-radius: var(--r-lg); border: 1px solid transparent; margin-bottom: 2px; }
.draft-item:hover { background: var(--hover); }
.draft-item.active { background: var(--color-bg); border-color: var(--color-border-light); box-shadow: var(--shadow-md); }
.draft-item.active .draft-title { color: var(--color-accent-text); }
.draft-title { font-size: var(--text-sm); font-weight: 700; line-height: 1.3; color: var(--color-text); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.draft-flag { color: var(--color-orange); margin-right: 5px; }
.draft-preview { font-size: var(--text-xs); line-height: 1.45; color: var(--color-text-tertiary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.draft-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.draft-meta:empty { display: none; }
.draft-date, .draft-words { font-size: var(--text-2xs); color: var(--color-text-tertiary); font-weight: 500; margin-right: 2px; }
.sidebar-footer { padding: var(--s2) var(--s3) var(--s3); border-top: 1px solid var(--color-border-light); }

/* ========================================================= */
/* Editor                                                    */
/* ========================================================= */
.editor-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--color-bg); }
.editor-toolbar { display: flex; align-items: center; gap: var(--s2); min-height: 52px; padding: var(--s2) var(--s4); border-bottom: 1px solid var(--color-border-light); }
.back-btn { display: none; color: var(--color-accent-text); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-md); background: var(--color-surface-2); }
.seg { min-height: 28px; padding: 0 var(--s3); border-radius: 7px; font-size: var(--text-xs); font-weight: 700; color: var(--color-text-tertiary); }
.seg:hover { color: var(--color-text); }
.seg.active { background: var(--color-bg); color: var(--color-text); box-shadow: var(--shadow-sm); }
.toolbar-spacer { flex: 1; }
.toolbar-icons { display: flex; align-items: center; gap: 2px; }
.actions-toggle { display: none; color: var(--color-accent-text); }
.more-wrap { position: relative; display: none; }
.more-menu { position: absolute; z-index: 30; right: 0; top: calc(100% + 6px); width: 230px; padding: var(--s1); display: none; background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.more-menu.open { display: block; animation: pop .18s var(--ease); }
.more-menu button { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-md); font-size: var(--text-sm); font-weight: 500; }
.more-menu button:hover { background: var(--hover); }
.more-menu button > span:first-child { width: 20px; text-align: center; }
.actions-toggle-text { font-size: var(--text-sm); }

.findbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding: var(--s2) var(--s4); background: var(--color-surface); border-bottom: 1px solid var(--color-border-light); }
.findbar-fields { display: flex; gap: var(--s2); flex: 1 1 320px; min-width: 0; }
.field-inline { flex: 1; min-width: 0; }
.field-inline input { width: 100%; min-height: 32px; padding: 0 var(--s3); border: 1px solid var(--color-border); border-radius: var(--r-md); background: var(--color-bg); font-size: var(--text-sm); outline: none; }
.field-inline input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg-strong); }
.findbar-actions { display: flex; align-items: center; gap: var(--s2); }
.find-count { font-size: var(--text-xs); color: var(--color-text-tertiary); min-width: 76px; text-align: right; }
.status-banner { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s4); font-size: var(--text-sm); background: var(--color-orange-bg); color: var(--color-text); border-bottom: 1px solid var(--color-border-light); }

.editor-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.editor-scroll { min-height: 0; overflow-y: auto; padding: var(--s8) var(--s8) var(--s12); scrollbar-width: thin; scrollbar-color: var(--color-border-light) transparent; }
.mode-panel { display: none; max-width: 760px; margin: 0 auto; }
.mode-panel.active { display: block; }

/* Edit mode: a transparent textarea over a highlighted copy of the same text */
.md-editor { position: relative; }
.md-highlight, .md-input { font-family: var(--font-mono); font-size: 15px; line-height: 1.75; letter-spacing: 0; tab-size: 2; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; margin: 0; padding: 0; border: 0; }
.md-highlight { color: var(--color-text-secondary); min-height: 60vh; pointer-events: none; }
.md-input { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; overflow: hidden; background: transparent; color: transparent; caret-color: var(--color-accent); outline: none; }
.md-input::selection { background: var(--color-accent-bg-strong); color: transparent; }
.hl-h { color: var(--color-text); font-weight: 700; }
.hl-h0 { color: var(--color-text); }
.hl-h1 { color: var(--color-accent-text); }
.hl-mark { color: var(--color-text-placeholder); font-weight: 400; }
.hl-bold { color: var(--color-text); font-weight: 700; }
.hl-italic { font-style: italic; color: var(--color-text); }
.hl-code { color: var(--color-red); background: var(--color-surface-2); border-radius: 4px; }
.hl-link { color: var(--color-accent-text); text-decoration: underline; text-decoration-color: var(--color-accent-bg-strong); text-underline-offset: 3px; }
.hl-bullet { color: var(--color-accent-text); font-weight: 700; }
.hl-task.done { color: var(--color-text-tertiary); }
.hl-task.done .hl-task-text { text-decoration: line-through; text-decoration-color: var(--color-text-placeholder); }
.hl-task.done .hl-bullet { color: var(--color-green); }
.hl-quote { color: var(--color-text-tertiary); font-style: italic; }
.hl-table { color: var(--color-text-secondary); }
.md-highlight mark { background: var(--color-mark); color: inherit; border-radius: 2px; }
.md-highlight mark.current { background: var(--color-mark-current); }

/* Preview mode */
.md-preview { font-size: 17px; line-height: 1.7; color: var(--color-text); }
.md-preview > * + * { margin-top: .85em; }
.md-preview h1 { font-size: 30px; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; }
.md-preview h2 { font-size: 22px; line-height: 1.3; letter-spacing: -.01em; font-weight: 700; margin-top: 1.5em; }
.md-preview h3 { font-size: 17px; font-weight: 700; margin-top: 1.3em; }
.md-preview p { color: var(--color-text); }
.md-preview ul, .md-preview ol { padding-left: 1.4em; }
.md-preview li + li { margin-top: .3em; }
.md-preview li::marker { color: var(--color-accent-text); font-weight: 700; }
.md-preview ul.tasks { list-style: none; padding-left: 0; }
.md-preview .task label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; min-height: 28px; }
.md-preview .task input { flex: none; width: 18px; height: 18px; margin-top: 5px; accent-color: var(--color-green); cursor: pointer; }
.md-preview .task.done span { color: var(--color-text-tertiary); text-decoration: line-through; }
.md-preview blockquote { border-left: 3px solid var(--color-accent); padding: 2px 0 2px var(--s4); color: var(--color-text-secondary); font-style: italic; }
.md-preview code { background: var(--color-surface-2); padding: 1px 6px; border-radius: 5px; color: var(--color-red); }
.md-preview pre { background: var(--color-surface-2); padding: var(--s4); border-radius: var(--r-md); overflow-x: auto; }
.md-preview a { text-underline-offset: 3px; }
.md-preview hr { border: 0; border-top: 1px solid var(--color-border-light); }
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border-light); border-radius: var(--r-md); }
.md-preview table, .sheet { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.md-preview th, .md-preview td, .sheet th, .sheet td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--color-border-light); white-space: nowrap; }
.md-preview th, .sheet th { background: var(--color-surface); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-tertiary); }
.md-preview tr:last-child td { border-bottom: 0; }
.preview-foot { margin-top: var(--s8) !important; padding-top: var(--s4); border-top: 1px solid var(--color-border-light); font-size: var(--text-xs); color: var(--color-text-tertiary); }
.md-mini { font-size: 14px; line-height: 1.55; }
.md-mini > * + * { margin-top: .45em; }
.md-mini h1 { font-size: 19px; } .md-mini h2 { font-size: 16px; margin-top: .9em; } .md-mini h3 { font-size: 14px; margin-top: .8em; }
.md-mini .task label { min-height: 0; } .md-mini .task input { width: 14px; height: 14px; margin-top: 4px; }

/* Arrange mode */
.arrange-hint { font-size: var(--text-sm); color: var(--color-text-tertiary); margin-bottom: var(--s4); }
.arrange-list { list-style: none; display: flex; flex-direction: column; gap: var(--s2); }
.arrange-item { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: start; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3) var(--s2); background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); cursor: grab; }
.arrange-item:hover { border-color: var(--color-border); }
.arrange-item.dragging { opacity: .45; }
.arrange-item.drop-target { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg-strong); }
.arrange-item.just-moved, .ae-step.just-moved { animation: flash 0.7s var(--ease); }
@keyframes flash { 0% { background: var(--color-accent-bg-strong); } 100% { background: var(--color-bg); } }
.arrange-handle { color: var(--color-text-placeholder); letter-spacing: -2px; padding-top: 6px; user-select: none; }
.arrange-kind { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-md); background: var(--color-surface-2); color: var(--color-text-secondary); font-size: var(--text-xs); font-weight: 700; }
.arrange-body { min-width: 0; padding-top: 3px; overflow: hidden; }
.arrange-body .table-wrap { max-width: 100%; }
.arrange-body a { pointer-events: none; }
.arrange-btns { display: flex; gap: 2px; }

/* Outline column (wide screens) */
.outline { display: none; padding: var(--s8) var(--s5); border-left: 1px solid var(--color-border-light); background: var(--color-surface); overflow-y: auto; }
.outline .eyebrow + * { margin-top: var(--s3); }
.outline-list { list-style: none; margin-bottom: var(--s8); }
.outline-list button { display: block; width: 100%; padding: 5px var(--s2); border-radius: var(--r-sm); font-size: var(--text-sm); color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.outline-list button:hover { background: var(--hover); color: var(--color-text); }
.outline-list .ol-l1 button { font-weight: 700; color: var(--color-text); }
.outline-list .ol-l3 button { padding-left: var(--s5); font-size: var(--text-xs); }
.outline-stats { display: grid; gap: var(--s3); }
.outline-stats div { display: flex; justify-content: space-between; gap: var(--s2); font-size: var(--text-sm); }
.outline-stats dt { color: var(--color-text-tertiary); }
.outline-stats dd { font-weight: 600; text-align: right; }

.editor-status { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 44px; padding: var(--s2) var(--s4); border-top: 1px solid var(--color-border-light); background: var(--color-bg); }
.editor-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.tag-edit { padding: 0; overflow: hidden; }
.tag-name { padding: 3px 4px 3px 8px; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; }
.tag-name:hover { color: var(--color-accent-text); }
.tag-x { padding: 3px 7px 3px 3px; font-size: 13px; line-height: 1; color: var(--color-text-tertiary); }
.tag-x:hover { color: var(--color-red); }
.tag-add { min-height: 24px; padding: 0 8px; border-radius: var(--r-full); border: 1px dashed var(--color-border); font-size: var(--text-2xs); font-weight: 700; color: var(--color-text-tertiary); }
.tag-add:hover { border-color: var(--color-accent); color: var(--color-accent-text); }
.tag-input-inline { width: 120px; min-height: 26px; padding: 0 8px; border-radius: var(--r-full); border: 1px solid var(--color-accent); background: var(--color-bg); font-size: var(--text-xs); outline: none; box-shadow: 0 0 0 3px var(--color-accent-bg-strong); }
.editor-meta { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--color-text-tertiary); white-space: nowrap; }
.meta-sep { opacity: .5; }

.empty-editor { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s2); padding: var(--s8); text-align: center; background: var(--color-bg); }
.empty-illustration { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--color-accent-bg); color: var(--color-accent); font-size: 28px; margin-bottom: var(--s2); }
.empty-editor h3 { font-size: var(--text-lg); }
.empty-editor p { color: var(--color-text-tertiary); font-size: var(--text-sm); margin-bottom: var(--s3); }
.editor-pane.is-empty > :not(.empty-editor) { visibility: hidden; }

/* ========================================================= */
/* Action panel                                              */
/* ========================================================= */
.action-panel { display: flex; flex-direction: column; min-height: 0; background: var(--color-surface); border-left: 1px solid var(--color-border-light); }
.sheet-handle { display: none; width: 40px; height: 5px; border-radius: var(--r-full); background: var(--color-border); margin: var(--s2) auto 0; }
.action-panel-header { display: flex; align-items: baseline; gap: var(--s2); padding: var(--s4) var(--s4) var(--s2); }
.action-panel-header h3 { font-size: var(--text-base); font-weight: 700; }
.action-target { flex: 1; min-width: 0; font-size: var(--text-xs); color: var(--color-text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-close { display: none; align-self: center; }
.action-search { margin: 0 var(--s3); }
.group-tabs { display: flex; gap: 2px; padding: var(--s3) var(--s3) var(--s1); overflow-x: auto; scrollbar-width: none; }
.group-tabs::-webkit-scrollbar { display: none; }
.gtab { min-height: 30px; padding: 0 10px; border-radius: var(--r-md); font-size: var(--text-xs); font-weight: 700; color: var(--color-text-tertiary); white-space: nowrap; }
.gtab:hover { background: var(--hover); color: var(--color-text-secondary); }
.gtab.active { background: var(--color-accent-bg); color: var(--color-accent-text); }
.action-grid { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: var(--s2) var(--s3); scrollbar-width: thin; scrollbar-color: var(--color-border-light) transparent; }
.action-btn { position: relative; display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 44px; padding: 6px var(--s2); border-radius: var(--r-md); font-size: var(--text-sm); font-weight: 600; color: var(--color-text-secondary); }
.action-btn:hover { background: var(--color-bg); color: var(--color-text); box-shadow: var(--shadow-sm); }
.action-btn:active { transform: scale(.99); }
.action-icon { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: var(--r-md); background: var(--color-bg); border: 1px solid var(--color-border-light); font-size: 15px; }
.action-name { flex: 1; min-width: 0; line-height: 1.3; }
.sim-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--color-violet); opacity: .7; }
.action-footer { padding: var(--s3); border-top: 1px solid var(--color-border-light); }
.panel-backdrop { display: none; }

/* ========================================================= */
/* Pages: actions and workspaces                             */
/* ========================================================= */
.page { width: 100%; max-width: 1440px; margin: 0 auto; padding: var(--s8) var(--s8) var(--s12); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s6); margin-bottom: var(--s6); }
.page-head h1 { font-size: var(--text-2xl); line-height: 1.15; letter-spacing: -.025em; margin-top: var(--s1); }
.page-sub { max-width: 620px; margin-top: var(--s2); color: var(--color-text-tertiary); font-size: var(--text-base); }
.card { background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-xl); box-shadow: var(--shadow-sm); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.section-head h4, .ae-section > h4 { display: flex; align-items: center; gap: var(--s2); font-size: var(--text-sm); font-weight: 700; }
.ae-section > h4 { margin-bottom: var(--s2); }

.ae-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 280px; gap: var(--s5); align-items: start; }
.lib-list { position: sticky; top: calc(var(--chrome-h) + var(--s5)); display: flex; flex-direction: column; gap: var(--s3); padding: var(--s3); max-height: calc(100dvh - var(--chrome-h) - var(--s10)); overflow: hidden; }
.lib-toggle { display: none; }
.lib-groups { overflow-y: auto; margin: 0 calc(var(--s3) * -1); padding: 0 var(--s3); scrollbar-width: thin; }
.lib-group + .lib-group { margin-top: var(--s4); }
.lib-group .eyebrow { padding: 0 var(--s2) var(--s2); }
.lib-item { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 48px; padding: 6px var(--s2); border-radius: var(--r-md); }
.lib-item:hover { background: var(--hover); }
.lib-item.active { background: var(--color-accent-bg); }
.lib-item.active b { color: var(--color-accent-text); }
.lib-icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: var(--r-md); background: var(--color-surface-2); font-size: 16px; }
.lib-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.lib-text b { font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-text span { font-size: var(--text-2xs); color: var(--color-text-tertiary); }

.ae-main { padding: var(--s6); min-width: 0; }
.ae-head { display: flex; align-items: flex-start; gap: var(--s4); padding-bottom: var(--s5); margin-bottom: var(--s5); border-bottom: 1px solid var(--color-border-light); }
.ae-icon-wrap { position: relative; }
.ae-icon-btn { display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--r-lg); background: var(--color-surface-2); border: 1px solid var(--color-border-light); font-size: 26px; }
.ae-icon-btn:hover { border-color: var(--color-border); background: var(--color-bg); }
.icon-pop { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; display: none; grid-template-columns: repeat(5, 44px); gap: 4px; padding: var(--s2); background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.icon-pop.open { display: grid; animation: pop .18s var(--ease); }
.icon-pop button { width: 44px; height: 44px; border-radius: var(--r-md); font-size: 20px; }
.icon-pop button:hover { background: var(--hover); }
.ae-head-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ae-name { width: 100%; border: 0; outline: none; background: none; font-size: var(--text-xl); font-weight: 700; letter-spacing: -.015em; padding: 4px 6px; margin-left: -6px; border-radius: var(--r-sm); }
.ae-desc { display: block; width: 100%; border: 0; outline: none; background: none; font-size: var(--text-sm); line-height: 1.45; color: var(--color-text-tertiary); padding: 4px 6px; margin-left: -6px; border-radius: var(--r-sm); resize: none; overflow: hidden; }
.ae-name:hover, .ae-desc:hover { background: var(--hover); }
.ae-name:focus, .ae-desc:focus { background: var(--color-surface); box-shadow: 0 0 0 2px var(--color-accent-bg-strong); }
.ae-section { margin-bottom: var(--s6); }
.add-step { position: relative; }
.step-menu { position: absolute; z-index: 20; right: 0; top: calc(100% + 6px); width: 270px; max-height: 360px; overflow-y: auto; display: none; padding: var(--s2); background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.step-menu.open { display: block; animation: pop .18s var(--ease); }
.step-menu .eyebrow { padding: var(--s2) var(--s2) var(--s1); }
.step-menu button { display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: 38px; padding: 0 var(--s2); border-radius: var(--r-md); font-size: var(--text-sm); }
.step-menu button:hover { background: var(--hover); }
.step-menu button .pill { margin-left: auto; }
.ae-steps { list-style: none; display: flex; flex-direction: column; gap: var(--s2); counter-reset: step; }
.ae-step { padding: var(--s3) var(--s4) var(--s4); background: var(--color-surface); border: 1px solid var(--color-border-light); border-radius: var(--r-lg); }
.ae-step:hover { border-color: var(--color-border); }
.ae-step.dragging { opacity: .45; }
.ae-step.drop-target { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg-strong); }
.ae-step-top { display: flex; align-items: center; gap: var(--s2); min-height: 36px; }
.ae-step-handle { color: var(--color-text-placeholder); letter-spacing: -2px; cursor: grab; user-select: none; }
.ae-step-num { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--color-bg); border: 1px solid var(--color-border-light); font-size: var(--text-2xs); font-weight: 700; color: var(--color-text-tertiary); }
.ae-step-icon { font-size: 16px; }
.ae-step-label { font-size: var(--text-sm); }
.ae-step-btns { display: flex; gap: 2px; margin-left: auto; }
.ae-step > p { margin: var(--s1) 0 0 60px; }
.step-fields { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s2) var(--s3); align-items: center; margin-top: var(--s3); }
.step-fields label { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-tertiary); text-align: right; }
.step-fields textarea { align-self: stretch; }
.code-input { width: 100%; min-height: 120px; padding: var(--s3); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; color: var(--color-text); background: var(--color-surface-2); border: 1px solid var(--color-border-light); border-radius: var(--r-md); resize: vertical; outline: none; tab-size: 2; white-space: pre; overflow: auto; }
.code-input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg-strong); }
.ae-options { display: flex; flex-direction: column; gap: 2px; }
.ae-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding-top: var(--s5); border-top: 1px solid var(--color-border-light); }
.ae-footer-right { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.ae-saved { transition: color .3s; }
.ae-saved.flash { color: var(--color-green); }
.ae-tags { position: sticky; top: calc(var(--chrome-h) + var(--s5)); padding: var(--s5); }
.ae-tags h4 { font-size: var(--text-sm); margin-bottom: var(--s1); }
.ae-tags > p { margin-bottom: var(--s4); line-height: 1.5; }
.tag-list { display: flex; flex-direction: column; gap: 2px; }
.tag-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 6px var(--s2); border-radius: var(--r-md); }
.tag-item:hover { background: var(--hover); }
.tag-item code { padding: 2px 7px; border-radius: var(--r-sm); background: var(--color-accent-bg); color: var(--color-accent-text); font-size: 12px; }
.tag-item span { font-size: var(--text-2xs); color: var(--color-text-tertiary); }

.ws-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr) 380px; gap: var(--s5); align-items: start; }
.ws-list { display: flex; flex-direction: column; gap: 2px; padding: var(--s2); position: sticky; top: calc(var(--chrome-h) + var(--s5)); }
.ws-item { display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: 0 var(--s3); border-radius: var(--r-md); font-size: var(--text-sm); font-weight: 600; }
.ws-item:hover { background: var(--hover); }
.ws-item.active { background: var(--color-accent-bg); color: var(--color-accent-text); }
.ws-item-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); background: var(--color-surface-2); font-size: 16px; }
.ws-item-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-item-count { font-size: var(--text-2xs); color: var(--color-text-tertiary); }
.ws-form { display: flex; flex-direction: column; gap: var(--s5); padding: var(--s6); min-width: 0; }
.field { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.field > label, .field > .label { font-size: var(--text-xs); font-weight: 700; color: var(--color-text-secondary); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s5); }
.ws-icons { display: flex; flex-wrap: wrap; gap: 6px; }
.ws-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md); border: 1.5px solid var(--color-border-light); font-size: 19px; }
.ws-icon:hover { border-color: var(--color-border); }
.ws-icon.active { border-color: var(--color-accent); background: var(--color-accent-bg); }
.tag-input { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 44px; padding: 6px var(--s2); border: 1px solid var(--color-border); border-radius: var(--r-md); background: var(--color-bg); cursor: text; }
.tag-input input { flex: 1; min-width: 140px; min-height: 30px; border: 0; outline: none; background: none; font-size: var(--text-sm); }
.tag-chip { display: inline-flex; align-items: center; gap: 2px; min-height: 28px; padding: 0 2px 0 10px; border-radius: var(--r-full); font-size: var(--text-xs); font-weight: 700; }
.tag-chip button { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 15px; line-height: 1; opacity: .7; }
.tag-chip button:hover { opacity: 1; background: rgba(0, 0, 0, .06); }
.tag-chip.inc { background: var(--color-accent-bg); color: var(--color-accent-text); }
.tag-chip.exc { background: var(--color-red-bg); color: var(--color-red); }
.field { position: relative; }
.suggest { position: absolute; z-index: 15; top: calc(100% + 4px); left: 0; right: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: var(--s3); background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.suggest::before { content: 'Tags in your drafts'; flex-basis: 100%; font-size: var(--text-2xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-tertiary); }
.field:not(:focus-within) .suggest { display: none; }
.suggest:empty { display: none; }
.toggles { display: flex; flex-direction: column; }
.ws-form-footer { display: flex; justify-content: space-between; gap: var(--s3); padding-top: var(--s5); border-top: 1px solid var(--color-border-light); }
.ws-form-footer .btn-primary { margin-left: auto; }
.ws-preview { position: sticky; top: calc(var(--chrome-h) + var(--s5)); padding: var(--s5); max-height: calc(100dvh - var(--chrome-h) - var(--s10)); overflow-y: auto; }
.ws-preview > p { margin-bottom: var(--s3); }
.ws-preview-list { display: flex; flex-direction: column; gap: 2px; margin: 0 calc(var(--s2) * -1); }
.preview-item { cursor: default; }
.preview-item:hover { background: transparent; }

/* ========================================================= */
/* Phone preview                                             */
/* ========================================================= */
.view-phone { background: radial-gradient(1200px 600px at 70% 20%, var(--color-accent-bg), transparent 60%), var(--color-canvas); }
.phone-stage { display: grid; grid-template-columns: minmax(0, 420px) auto; justify-content: center; align-items: center; gap: clamp(32px, 6vw, 112px); max-width: 1200px; min-height: calc(100dvh - var(--chrome-h)); margin: 0 auto; padding: var(--s8); }
.phone-notes h1 { font-size: var(--text-2xl); line-height: 1.15; letter-spacing: -.025em; margin-top: var(--s1); }
.gesture-list { list-style: none; display: flex; flex-direction: column; gap: var(--s3); margin: var(--s6) 0; }
.gesture-list li { display: flex; align-items: center; gap: var(--s4); padding: var(--s3) var(--s4); background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.gesture-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--color-accent-bg); color: var(--color-accent-text); font-weight: 700; }
.gesture-list div { display: flex; flex-direction: column; line-height: 1.35; }
.gesture-list b { font-size: var(--text-sm); }
.gesture-list span { font-size: var(--text-xs); color: var(--color-text-tertiary); }
.phone-frame { position: relative; display: flex; flex-direction: column; width: 375px; height: min(780px, calc(100dvh - var(--chrome-h) - 64px)); min-height: 560px; background: var(--color-bg); border-radius: 48px; border: 10px solid #111114; box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, .06) inset; overflow: hidden; }
[data-theme="dark"] .phone-frame { border-color: #000; box-shadow: 0 0 0 1px #3a3a3d, var(--shadow-lg); }
.phone-status { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 28px; font-size: 14px; font-weight: 700; flex: none; }
.phone-island { width: 96px; height: 26px; border-radius: 20px; background: #111114; }
.phone-batt { font-size: 9px; letter-spacing: -1px; }
.phone-content { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pv { display: none; flex: 1; min-height: 0; flex-direction: column; }
.pv.active { display: flex; }
.pv-header { display: flex; align-items: baseline; justify-content: space-between; padding: var(--s3) var(--s5) var(--s2); }
.pv-header h2 { font-size: 30px; letter-spacing: -.02em; }
.pv-count { font-size: var(--text-xs); color: var(--color-text-tertiary); }
.pv-search { padding: 0 var(--s4) var(--s2); }
.pv-items { flex: 1; overflow-y: auto; padding-bottom: 90px; scrollbar-width: none; }
.pv-items::-webkit-scrollbar { display: none; }
.pv-row { position: relative; border-bottom: 1px solid var(--color-border-light); overflow: hidden; }
.pv-under { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 var(--s5); font-size: var(--text-sm); font-weight: 700; color: #fff; opacity: 0; }
.pv-under-flag { background: var(--color-orange); justify-content: flex-start; }
.pv-under-archive { background: var(--color-green); justify-content: flex-end; }
.pv-row.show-flag .pv-under-flag, .pv-row.show-archive .pv-under-archive { opacity: 1; }
.pv-item { position: relative; display: flex; flex-direction: column; gap: 3px; width: 100%; padding: var(--s3) var(--s5); background: var(--color-bg); touch-action: pan-y; user-select: none; }
.pv-item:hover { background: var(--color-surface); }
.pv-editor-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s1) var(--s2); border-bottom: 1px solid var(--color-border-light); }
.pv-editor-head .icon-btn { min-width: 44px; height: 44px; }
#pvBack { color: var(--color-accent-text); }
.pv-editor-actions { display: flex; gap: 2px; }
.pv-text { flex: 1; min-height: 0; width: 100%; padding: var(--s4) var(--s5); border: 0; outline: none; resize: none; background: var(--color-bg); font-family: var(--font-mono); font-size: 14px; line-height: 1.7; color: var(--color-text); }
.pv-meta { padding: var(--s2) var(--s5) 70px; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--color-text-tertiary); border-top: 1px solid var(--color-border-light); }
.pv-drawer { position: absolute; left: 0; right: 0; bottom: 64px; z-index: 6; padding: 0 var(--s4) var(--s4); background: var(--color-bg); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .15); transform: translateY(calc(100% + 70px)); transition: transform .3s var(--ease); visibility: hidden; }
.pv-drawer.open { transform: none; visibility: visible; }
.pv-drawer .sheet-handle { display: block; margin: var(--s2) auto var(--s3); }
.pv-drawer h4 { font-size: var(--text-sm); margin-bottom: var(--s3); }
.pv-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.pv-action { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 76px; padding: var(--s2) 4px; border-radius: var(--r-md); font-size: 11px; font-weight: 600; color: var(--color-text-secondary); text-align: center; }
.pv-action:hover { background: var(--hover); }
.pv-action-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--color-surface-2); font-size: 19px; }
.pv-tabs { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; display: flex; justify-content: space-around; padding: 6px 0 14px; background: color-mix(in srgb, var(--color-bg) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--color-border-light); }
.pv-tab { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; min-height: 44px; font-size: 10.5px; font-weight: 600; color: var(--color-text-tertiary); }
.pv-tab.active { color: var(--color-accent-text); }
.pv-fab { position: absolute; right: var(--s5); bottom: 84px; z-index: 5; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--color-accent); color: #fff; box-shadow: 0 10px 24px rgba(10, 108, 255, .35); }
.pv-fab:hover { background: var(--color-accent-hover); transform: scale(1.04); }

/* ========================================================= */
/* Overlays: capture, palette, modal                         */
/* ========================================================= */
.overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 12vh var(--s4) var(--s4); background: rgba(10, 10, 16, .38); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; visibility: hidden; transition: opacity .2s var(--ease), visibility .2s; overflow-y: auto; }
.overlay.open { opacity: 1; visibility: visible; }
.overlay > * { transform: translateY(-12px) scale(.98); transition: transform .3s var(--ease); }
.overlay.open > * { transform: none; }
.overlay-modal { z-index: 70; padding-top: 8vh; }

.capture-card { width: 100%; max-width: 580px; padding: var(--s5); background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); }
.capture-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.capture-head h2 { flex: 1; font-size: var(--text-lg); }
.capture-input { width: 100%; padding: var(--s3) var(--s4); border: 1px solid var(--color-border); border-radius: var(--r-lg); background: var(--color-surface); font-family: var(--font-mono); font-size: 15px; line-height: 1.6; resize: vertical; outline: none; }
.capture-input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg-strong); background: var(--color-bg); }
.capture-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: var(--s3); }
.capture-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s4); flex-wrap: wrap; }
.capture-buttons { display: flex; gap: var(--s2); flex-wrap: wrap; }

.palette { width: 100%; max-width: 620px; background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden; }
.palette-search { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s4); border-bottom: 1px solid var(--color-border-light); color: var(--color-text-tertiary); }
.palette-search input { flex: 1; min-width: 0; height: 56px; border: 0; outline: none; background: none; font-size: var(--text-lg); color: var(--color-text); }
.palette-results { max-height: min(420px, 55vh); overflow-y: auto; padding: var(--s2); }
.pal-group + .pal-group { margin-top: var(--s2); }
.pal-group .eyebrow { padding: var(--s2) var(--s3) var(--s1); }
.pal-item { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-md); font-size: var(--text-sm); }
.pal-item:hover { background: var(--hover); }
.pal-item.active { background: var(--color-accent-bg); }
.pal-icon { width: 22px; text-align: center; font-size: 16px; }
.pal-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.pal-hint { font-size: var(--text-2xs); color: var(--color-text-tertiary); font-family: var(--font-mono); white-space: nowrap; }
.palette-foot { display: flex; gap: var(--s4); padding: var(--s2) var(--s4); border-top: 1px solid var(--color-border-light); font-size: var(--text-xs); color: var(--color-text-tertiary); }

.modal { width: 100%; max-width: 560px; padding: var(--s6); background: var(--color-bg); border: 1px solid var(--color-border-light); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); }
.modal-wide { max-width: 860px; }
.modal-run { max-width: 640px; }
.modal-head { display: flex; align-items: flex-start; gap: var(--s3); margin-bottom: var(--s2); }
.modal-head > div { flex: 1; min-width: 0; }
.modal-head h2 { flex: 1; font-size: var(--text-xl); line-height: 1.25; letter-spacing: -.01em; }
.modal-head .icon-btn { margin: -6px -8px 0 auto; }
.modal-icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: var(--r-lg); background: var(--color-surface-2); font-size: 22px; }
.modal-sub { margin-bottom: var(--s4); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--color-border-light); }
.modal-foot-btns { display: flex; gap: var(--s2); margin-left: auto; }
.modal-foot-center { justify-content: center; }

.run-steps { list-style: none; display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s4); }
.run-step { padding: var(--s4); border: 1px solid var(--color-border-light); border-radius: var(--r-lg); background: var(--color-surface); }
.run-step-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); font-size: var(--text-sm); }
.run-step-head .pill { margin-left: auto; }
.run-step-icon { font-size: 16px; }
.field-grid { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: var(--s2) var(--s3); align-items: center; margin-bottom: var(--s3); font-size: var(--text-sm); }
.field-grid > label { font-size: var(--text-xs); color: var(--color-text-tertiary); font-weight: 600; }
.field-grid > span { min-width: 0; overflow-wrap: anywhere; }
.msg-preview { max-height: 200px; overflow-y: auto; padding: var(--s3); border-radius: var(--r-md); background: var(--color-bg); border: 1px solid var(--color-border-light); font-size: var(--text-sm); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--color-text-secondary); }
.msg-slack { border-left: 3px solid #4A154B; }
.msg-mastodon { border-left: 3px solid #6364FF; }
.msg-linkedin { border-left: 3px solid #0A66C2; }
.msg-discord { border-left: 3px solid #5865F2; }
.msg-imessage { background: var(--color-accent); color: #fff; border-color: transparent; border-radius: 18px 18px 4px 18px; }
.code-preview { max-height: 240px; overflow: auto; padding: var(--s3); border-radius: var(--r-md); background: var(--color-surface-2); font-family: var(--font-mono); font-size: 12px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.share-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.share-target { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 84px; padding: var(--s3) var(--s2); border-radius: var(--r-lg); background: var(--color-bg); border: 1px solid var(--color-border-light); font-size: var(--text-xs); font-weight: 600; }
.share-target span { font-size: 24px; }
.share-target:hover { border-color: var(--color-accent); }
.todo-preview { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.todo-preview li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r-md); background: var(--color-bg); font-size: var(--text-sm); }
.todo-circle { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--color-red); }
.sheet-new td { background: var(--color-green-bg); }
.link-list { list-style: none; display: flex; flex-direction: column; gap: var(--s2); }
.link-list a { display: flex; flex-direction: column; gap: 2px; padding: var(--s3); border-radius: var(--r-md); background: var(--color-bg); border: 1px solid var(--color-border-light); text-decoration: none; overflow-wrap: anywhere; }
.link-list a:hover { border-color: var(--color-accent); }
.link-list b { color: var(--color-text); font-size: var(--text-sm); }
.print-preview { max-height: 280px; overflow-y: auto; padding: var(--s5) var(--s6); background: #fff; color: #1d1d1f; border-radius: var(--r-md); border: 1px solid var(--color-border-light); box-shadow: var(--shadow-sm); }
.run-step select.input, .run-step input.input { margin-bottom: 0; }
.run-step .code-input { margin: var(--s2) 0; }

.result { text-align: center; }
.result h2 { font-size: var(--text-xl); margin: var(--s3) 0 var(--s1); }
.result > p { font-size: var(--text-sm); max-width: 420px; margin: 0 auto; }
.result-badge { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto; border-radius: 50%; font-size: 26px; font-weight: 700; }
.result-badge.is-done { background: var(--color-green-bg); color: var(--color-green); }
.result-badge.is-sim { background: var(--color-violet-bg); color: var(--color-violet); }
.result-badge.is-error { background: var(--color-red-bg); color: var(--color-red); }
.result-steps { list-style: none; display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s5); text-align: left; }
.result-steps li { display: flex; gap: var(--s3); padding: var(--s3); border-radius: var(--r-lg); background: var(--color-surface); border: 1px solid var(--color-border-light); }
.result-steps li > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.result-steps b { font-size: var(--text-sm); }
.rs-icon { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; font-size: 12px; font-weight: 700; }
.rs-done .rs-icon { background: var(--color-green-bg); color: var(--color-green); }
.rs-sim .rs-icon { background: var(--color-violet-bg); color: var(--color-violet); }
.rs-error .rs-icon { background: var(--color-red-bg); color: var(--color-red); }
.rs-tag { font-size: var(--text-xs); font-weight: 700; color: var(--color-violet); }
.rs-note { font-size: var(--text-xs); color: var(--color-text-tertiary); overflow-wrap: anywhere; }

.history { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--s4); margin-top: var(--s2); }
.history-list { list-style: none; display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow-y: auto; }
.history-item { display: flex; flex-direction: column; gap: 1px; width: 100%; padding: var(--s2) var(--s3); border-radius: var(--r-md); font-size: var(--text-xs); color: var(--color-text-tertiary); border: 1px solid transparent; }
.history-item b { font-size: var(--text-sm); color: var(--color-text); }
.history-item:hover { background: var(--hover); }
.history-item.active { background: var(--color-accent-bg); border-color: var(--color-accent-bg-strong); }
.history-diff { font-family: var(--font-mono); font-size: 10.5px; }
.history-view { max-height: 420px; overflow-y: auto; padding: var(--s4) var(--s5); border-radius: var(--r-lg); border: 1px solid var(--color-border-light); background: var(--color-surface); }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3) var(--s5); }
.info-grid > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.info-grid dt { font-size: var(--text-2xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-tertiary); }
.info-grid dd { font-size: var(--text-sm); overflow-wrap: anywhere; }
.info-grid dd .chip, .info-grid dd .tag-pill { margin: 0 4px 4px 0; }
.info-wide { grid-column: 1 / -1; }

/* ========================================================= */
/* Toasts                                                    */
/* ========================================================= */
.toasts { position: fixed; z-index: 90; right: var(--s5); bottom: var(--s5); display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2); pointer-events: none; }
.toast { display: flex; align-items: center; gap: var(--s3); max-width: 380px; padding: var(--s3) var(--s4); background: #1d1d1f; color: #f5f5f7; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); font-size: var(--text-sm); font-weight: 500; pointer-events: auto; animation: toastIn .3s var(--ease); }
[data-theme="dark"] .toast { background: #f5f5f7; color: #1d1d1f; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }
.toast-icon { font-size: 15px; }
.toast-msg { flex: 1; }
.toast-undo { flex: none; min-height: 30px; padding: 0 var(--s3); margin: -4px -6px -4px 0; border-radius: var(--r-md); font-weight: 700; color: #7CB1FF; }
[data-theme="dark"] .toast-undo { color: var(--color-accent); }
.toast-undo:hover { background: rgba(255, 255, 255, .1); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

/* ========================================================= */
/* Responsive                                                */
/* ========================================================= */
@media (min-width: 1400px) {
  .editor-body { grid-template-columns: minmax(0, 1fr) 232px; }
  .outline { display: block; }
}
@media (min-width: 1700px) {
  :root { --sidebar-w: 340px; --panel-w: 300px; }
  .editor-body { grid-template-columns: minmax(0, 1fr) 260px; }
  .mode-panel { max-width: 820px; }
  .page { max-width: 1640px; }
  .ae-grid { grid-template-columns: 340px minmax(0, 1fr) 320px; }
  .ws-grid { grid-template-columns: 300px minmax(0, 1fr) 440px; }
}
@media (max-width: 1240px) {
  .search-trigger { min-width: 0; }
  .search-trigger-text { display: none; }
  .ae-grid { grid-template-columns: 280px minmax(0, 1fr); }
  .ae-tags { grid-column: 2; position: static; }
  .ws-grid { grid-template-columns: 240px minmax(0, 1fr); }
  .ws-preview { grid-column: 2; position: static; max-height: none; }
}
@media (max-width: 1024px) {
  .view-drafts.active { grid-template-columns: 292px minmax(0, 1fr); }
  .actions-toggle { display: inline-flex; }
  .action-panel { position: fixed; z-index: 50; top: var(--chrome-h); right: 0; bottom: 0; width: min(340px, 88vw); border-left: 1px solid var(--color-border-light); box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform .3s var(--ease); visibility: hidden; }
  .action-panel.open { transform: none; visibility: visible; }
  .panel-close { display: inline-flex; }
  .panel-backdrop { display: block; position: fixed; inset: 0; top: var(--chrome-h); z-index: 45; background: rgba(10, 10, 16, .3); opacity: 0; visibility: hidden; transition: opacity .2s; }
  .panel-backdrop.open { opacity: 1; visibility: visible; }
  .editor-scroll { padding: var(--s6) var(--s6) var(--s10); }
  .capture-trigger-text { display: none; }
  .capture-trigger { width: var(--tap); padding: 0; justify-content: center; }
  .nav-tab { padding: 0 10px; }
  .ae-grid, .ws-grid { grid-template-columns: minmax(0, 1fr); }
  .ae-tags, .ws-preview { grid-column: auto; }
  .lib-list { position: static; max-height: none; }
  .lib-toggle { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 48px; padding: 0 var(--s2); border-radius: var(--r-md); text-align: left; }
  .lib-toggle:hover { background: var(--hover); }
  .lib-current { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lib-toggle-hint { font-size: var(--text-xs); font-weight: 600; color: var(--color-accent-text); }
  .lib-list:not(.open) .list-search, .lib-list:not(.open) .lib-groups { display: none; }
  .lib-groups { max-height: 50vh; }
  .ws-list { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .ws-list::-webkit-scrollbar { display: none; }
  .ws-item { flex: none; }
}
@media (max-width: 900px) {
  .phone-stage { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: left; }
  .phone-notes { max-width: 560px; }
}
@media (max-width: 768px) {
  .topbar { gap: var(--s2); padding: 0 var(--s2); }
  .menu-btn { display: inline-flex; color: var(--color-text); }
  .logo-text { font-size: var(--text-base); }
  .topbar-nav { position: fixed; top: var(--chrome-h); left: 0; right: 0; z-index: 39; flex-direction: column; align-items: stretch; gap: 2px; margin: 0; padding: var(--s2); border-radius: 0 0 var(--r-xl) var(--r-xl); background: var(--color-bg); border-bottom: 1px solid var(--color-border-light); box-shadow: var(--shadow-lg); transform: translateY(-8px); opacity: 0; visibility: hidden; transition: opacity .18s var(--ease), transform .18s var(--ease), visibility .18s; }
  .topbar-nav.open { opacity: 1; visibility: visible; transform: none; }
  .nav-tab { height: 48px; padding: 0 var(--s4); font-size: var(--text-base); border-radius: var(--r-md); }
  .nav-tab.active { box-shadow: none; background: var(--color-accent-bg); color: var(--color-accent-text); }
  .nav-tab-phone { display: none; }
  .topbar-right { margin-left: auto; gap: 4px; }
  .search-trigger { width: var(--tap); padding: 0; justify-content: center; border: 0; background: none; }
  .search-trigger .kbd { display: none; }
  .theme-toggle { min-width: 40px; }

  .ftab { min-height: 40px; }
  .ws-picker-btn { min-height: 52px; }

  .editor-toolbar { padding: var(--s1) var(--s2); gap: 2px; min-height: 56px; }
  .seg { min-height: 38px; padding: 0 10px; font-size: var(--text-sm); }
  .actions-toggle-text { display: none; }
  #findBtn, #flagBtn, #historyBtn, #infoBtn { display: none; }
  .more-wrap { display: block; }
  .editor-scroll { padding: var(--s5) var(--s4) var(--s10); }
  .md-highlight, .md-input { font-size: 16px; line-height: 1.7; }
  .md-preview { font-size: 16.5px; }
  .md-preview h1 { font-size: 26px; }
  .editor-status { padding: var(--s1) var(--s3); min-height: 48px; }
  .meta-hide { display: none; }
  .tag-name { padding: 8px 4px 8px 10px; }
  .tag-x { padding: 8px 10px 8px 4px; font-size: 15px; }
  .tag-add { min-height: 32px; padding: 0 12px; }
  .findbar { padding: var(--s2) var(--s3); }
  .findbar-fields { flex-basis: 100%; }
  .field-inline input { min-height: 44px; font-size: 16px; }
  .findbar-actions { width: 100%; }
  .findbar-actions .btn { min-height: 44px; flex: 1; }
  .find-count { min-width: 0; text-align: left; }
  .arrange-item { grid-template-columns: auto minmax(0, 1fr) auto; padding: var(--s3); }
  .arrange-handle { display: none; }
  .arrange-btns { flex-direction: column; }
  .status-banner { flex-wrap: wrap; padding: var(--s2) var(--s3); }
  .status-banner .btn { min-height: 40px; }

  .action-panel { top: auto; left: 0; right: 0; width: 100%; max-height: 82dvh; border-left: 0; border-radius: 20px 20px 0 0; transform: translateY(105%); padding-bottom: env(safe-area-inset-bottom); }
  .sheet-handle { display: block; }
  .action-panel-header { padding-top: var(--s3); }
  .action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .action-btn { min-height: 52px; background: var(--color-bg); border: 1px solid var(--color-border-light); font-size: var(--text-xs); }
  .action-btn .kbd { display: none; }
  .gtab { min-height: 44px; padding: 0 var(--s4); font-size: var(--text-sm); }
  .panel-backdrop { top: 0; }

  .page { padding: var(--s5) var(--s4) var(--s10); }
  .page-head { flex-direction: column; align-items: stretch; gap: var(--s4); }
  .page-head h1 { font-size: 26px; }
  .page-head .btn { align-self: flex-start; }
  .ae-main, .ws-form { padding: var(--s4); }
  .ae-head { gap: var(--s3); flex-wrap: wrap; }
  .ae-icon-btn { width: 52px; height: 52px; }
  .ae-name { font-size: 19px; }
  .step-fields { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .step-fields label { text-align: left; margin-top: var(--s2); }
  .ae-step { padding: var(--s2) var(--s3) var(--s3); }
  .ae-step-top { flex-wrap: wrap; }
  .ae-step-handle { display: none; }
  .ae-step > p { margin-left: 0; }
  .step-menu { position: fixed; z-index: 55; left: var(--s3); right: var(--s3); top: auto; bottom: var(--s3); width: auto; max-height: 62dvh; padding: var(--s3); border-radius: var(--r-xl); box-shadow: 0 -12px 40px rgba(0, 0, 0, .22); }
  .step-menu button { min-height: 44px; }
  .ae-footer, .ws-form-footer { flex-direction: column-reverse; align-items: stretch; }
  .ae-footer-right { flex-direction: column-reverse; align-items: stretch; }
  .ae-footer .btn, .ws-form-footer .btn { width: 100%; }
  .ws-form-footer .btn-primary { margin-left: 0; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .input { font-size: 16px; }
  .tag-input input { font-size: 16px; }
  .icon-pop { grid-template-columns: repeat(5, 44px); }
  .lib-item { min-height: 52px; }
  .tag-item { min-height: 48px; justify-content: center; }
  .chip, .tag-chip { min-height: 36px; }
  .tag-chip button { width: 32px; height: 32px; }

  .phone-stage { padding: var(--s5) var(--s4); }
  .phone-frame { width: min(375px, 100%); height: 700px; }

  .overlay { padding: var(--s4) var(--s3); align-items: flex-start; }
  .overlay-modal { padding-top: var(--s4); }
  .capture-card, .modal { padding: var(--s4); }
  .capture-input { font-size: 16px; }
  .capture-buttons { width: 100%; }
  .capture-buttons .btn { flex: 1; }
  .palette-search input { font-size: 16px; }
  .palette-foot { display: none; }
  .modal-foot-btns { width: 100%; }
  .modal-foot-btns .btn { flex: 1; }
  .history { grid-template-columns: minmax(0, 1fr); }
  .history-list { max-height: 200px; }
  .info-grid { grid-template-columns: minmax(0, 1fr); }
  .field-grid { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .field-grid > label { margin-top: var(--s2); }
  .share-target { min-height: 76px; }
  .toasts { left: var(--s3); right: var(--s3); bottom: var(--s3); align-items: stretch; }
  .toast { max-width: none; }
  .toast-undo { min-height: 40px; }
  .icon-btn { min-width: 44px; }
}
@media (max-width: 640px) {
  .view-drafts.active { grid-template-columns: minmax(0, 1fr); }
  .view-drafts .editor-pane { display: none; }
  .view-drafts.is-editing .sidebar { display: none; }
  .view-drafts.is-editing .editor-pane { display: flex; }
  .sidebar { border-right: 0; }
  .sidebar-header { padding: var(--s3) var(--s4) var(--s2); }
  .draft-list { padding: var(--s1) var(--s3) var(--s3); }
  .draft-item { padding: var(--s3) var(--s3); min-height: 64px; }
  .ftab { min-height: 44px; min-width: 44px; justify-content: center; padding: 0 10px; font-size: var(--text-sm); }
  .sidebar-footer { padding: var(--s2) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom)); }
  .back-btn { display: inline-flex; }
  .ae-head-fields { flex: 1 1 calc(100% - 72px); }
  .ae-head .pill { order: 3; margin-left: 68px; }
}
@media (max-width: 380px) {
  .logo-text { display: none; }
  .seg { padding: 0 8px; }
  .action-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ========================================================= */
/* Print: "Export as PDF" prints only the draft              */
/* ========================================================= */
#printRoot { display: none; }
@media print {
  body > *:not(#printRoot) { display: none !important; }
  #printRoot { display: block; max-width: 680px; margin: 0 auto; color: #000; font-size: 12pt; }
  #printRoot a { color: #000; }
}
