/* =====================================================================
   Study Notes — app styles
   ===================================================================== */

:root {
  --font: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 272px;
  --panel-w: 280px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

[data-theme="dark"] {
  --bg: #0f1115;
  --bg-elev: #15181e;
  --bg-sidebar: #12141a;
  --surface: #1a1d24;
  --surface-2: #20242d;
  --hover: rgba(255, 255, 255, .055);
  --active: rgba(124, 131, 255, .16);
  --border: #262a34;
  --border-strong: #333845;
  --text: #e7e9ee;
  --text-2: #b6bccb;
  --muted: #858da0;
  --accent: #7c83ff;
  --accent-strong: #6366f1;
  --accent-soft: rgba(124, 131, 255, .14);
  --accent-text: #fff;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --success: #4ade80;
  --warning: #fbbf24;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --code-bg: #0b0d11;
  --scrollbar: #2c313c;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-sidebar: #f7f7f5;
  --surface: #f6f6f4;
  --surface-2: #efefec;
  --hover: rgba(15, 23, 42, .05);
  --active: rgba(99, 102, 241, .11);
  --border: #e6e6e3;
  --border-strong: #d6d6d2;
  --text: #1f2329;
  --text-2: #3d4450;
  --muted: #737985;
  --accent: #5b5ff0;
  --accent-strong: #4f46e5;
  --accent-soft: rgba(91, 95, 240, .1);
  --accent-text: #fff;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, .08);
  --success: #16a34a;
  --warning: #d97706;
  --shadow: 0 12px 40px rgba(15, 23, 42, .14), 0 2px 8px rgba(15, 23, 42, .06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --code-bg: #f6f8fa;
  --scrollbar: #d4d4d0;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .55; }
input, textarea, select { font: inherit; color: inherit; }
kbd {
  font-family: var(--font);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}
code { font-family: var(--mono); }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.mono { font-family: var(--mono); font-size: 13px; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.error { color: var(--danger); }
.warn { color: var(--warning); }
.danger-text { color: var(--danger); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.link-btn { text-decoration: underline; text-underline-offset: 2px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- Boot ---------- */
.boot { height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-weight: 500; font-size: 13px;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover:not(:disabled) { background: var(--hover); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn svg { flex: none; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); box-shadow: none; }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--hover); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn kbd { background: rgba(255, 255, 255, .15); border-color: transparent; color: inherit; }
.btn.on { color: var(--accent); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 6px;
  color: var(--muted);
  transition: background .12s, color .12s;
  flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.xs { width: 22px; height: 22px; border-radius: 5px; }
.icon-btn.xs svg { width: 14px; height: 14px; }
.icon-btn.on { color: var(--warning); }

.input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-lg { height: 42px; font-size: 15px; }
.input-sm { height: 28px; font-size: 12.5px; }
.select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.select.input-sm { width: auto; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field.inline .select { min-width: 220px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-2); }
.check input { margin-top: 3px; accent-color: var(--accent); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 60%), var(--bg);
}
.login-card {
  width: min(380px, 100%);
  display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center;
  padding: 36px 30px; border-radius: 16px;
  background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.login-card h1 { margin: 6px 0 0; font-size: 22px; letter-spacing: -.01em; }
.login-card p { margin: 0 0 8px; }
.login-logo { display: grid; place-items: center; }
.login-error { color: var(--danger); min-height: 1.2em; font-size: 13px; margin: 0 !important; }
.setup-steps { text-align: left; color: var(--text-2); padding-left: 18px; line-height: 1.7; }
.setup-steps code { background: var(--surface); padding: 1px 5px; border-radius: 4px; }

/* ---------- Layout ---------- */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: auto; position: relative; background: var(--bg); }
.scrim { display: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  transition: margin-left .2s var(--ease), transform .2s var(--ease);
  user-select: none;
}
.app.sidebar-hidden .sidebar, .app.focus-mode .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.only-collapsed { display: none; }
.app.sidebar-hidden .only-collapsed, .app.focus-mode .only-collapsed { display: inline-grid; }
.only-mobile { display: none; }

.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 14px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; }
.brand span:first-child { display: grid; }

.sb-search, .sb-new {
  display: flex; align-items: center; gap: 8px;
  margin: 2px 10px; padding: 0 10px; height: 32px;
  border-radius: var(--radius);
  color: var(--muted); font-size: 13px;
}
.sb-search { border: 1px solid var(--border); background: var(--bg); }
.sb-search:hover { border-color: var(--border-strong); color: var(--text-2); }
.sb-search kbd, .sb-new kbd { margin-left: auto; }
.sb-new { color: var(--text-2); font-weight: 500; }
.sb-new:hover { background: var(--hover); color: var(--text); }
.sb-new span { display: grid; }

.sb-scroll { flex: 1; overflow-y: auto; padding: 6px 6px 12px; }
.sb-nav { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  height: 30px; padding: 0 9px; border-radius: 6px;
  color: var(--text-2); font-weight: 500;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--active); color: var(--text); }
.nav-icon { display: grid; color: var(--muted); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-label { flex: 1; }
.badge { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--accent-strong); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; }

.sb-section { margin-top: 14px; }
.sb-section-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 0 6px 0 10px; height: 24px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.sb-section-head.clickable:hover { color: var(--text-2); }
.sb-section-head .icon-btn { opacity: 0; }
.sb-section:hover .sb-section-head .icon-btn { opacity: 1; }
.twisty-inline { display: grid; transition: transform .15s; }
.twisty-inline svg { width: 12px; height: 12px; }
.twisty-inline.open { transform: rotate(90deg); }

.tree-row {
  position: relative;
  display: flex; align-items: center; gap: 4px;
  height: 30px; padding-right: 4px; border-radius: 6px;
  color: var(--text-2); cursor: pointer;
}
.tree-row:hover { background: var(--hover); color: var(--text); }
.tree-row.active { background: var(--active); color: var(--text); font-weight: 500; }
.fav-row { padding-left: 10px; gap: 8px; }
.nb-row { font-weight: 550; color: var(--text); padding-left: 2px; }
.nb-row::before { content: ""; position: absolute; left: -6px; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; background: var(--nb-color); opacity: .9; }
.twisty { width: 20px; height: 20px; border-radius: 4px; display: grid; place-items: center; color: var(--muted); flex: none; transition: transform .15s; }
.twisty svg { width: 12px; height: 12px; }
.twisty:hover { background: var(--hover); color: var(--text); }
.twisty.open { transform: rotate(90deg); }
.twisty.empty { visibility: hidden; }
.row-icon { width: 20px; text-align: center; flex: none; font-size: 14.5px; line-height: 1; }
.row-icon.faded { opacity: .55; filter: grayscale(.4); }
.row-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-count { font-size: 11px; color: var(--muted); padding: 0 4px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; margin: 0 4px; opacity: .85; }
.row-actions { display: none; gap: 1px; }
.tree-row:hover .row-actions { display: flex; }
.tree-row:hover .row-count, .tree-row:hover .status-dot { display: none; }
.tree-empty { display: block; width: 100%; text-align: left; padding: 4px 10px 4px 34px; font-size: 12.5px; color: var(--muted); border-radius: 6px; }
.tree-empty:hover { background: var(--hover); color: var(--text-2); }
.nb-block + .nb-block { margin-top: 2px; }
.tree-row.dragging { opacity: .4; }
.tree-row.drop-inside { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tree-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.tree-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 8px; }
.tag { display: inline-flex; gap: 5px; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 12px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); }
.tag span { color: var(--muted); font-size: 11px; }
.tag:hover { border-color: var(--border-strong); color: var(--text); }
.tag.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

.sb-foot { display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-top: 1px solid var(--border); }
.sb-foot .icon-btn { font-weight: 700; font-size: 13px; }

/* ---------- Menus ---------- */
.menu {
  position: fixed; z-index: 1000;
  min-width: 210px; max-width: 320px; max-height: 70vh; overflow-y: auto;
  padding: 5px; border-radius: 10px;
  background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: pop .12s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  height: 30px; padding: 0 8px; border-radius: 6px; text-align: left; font-size: 13px; color: var(--text-2);
}
.menu-item:hover, .menu-item:focus { background: var(--hover); color: var(--text); outline: none; }
.menu-item.active { color: var(--text); font-weight: 600; }
.menu-item.active::after { content: "✓"; margin-left: auto; color: var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item kbd { margin-left: auto; }
.menu-icon { width: 18px; display: grid; place-items: center; color: var(--muted); flex: none; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.menu-header { padding: 6px 8px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.emoji-picker { width: 320px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; max-height: 230px; overflow-y: auto; }
.emoji-btn { font-size: 19px; height: 32px; border-radius: 6px; }
.emoji-btn:hover { background: var(--hover); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; border-radius: 10px;
  background: #1f2330; color: #f1f3f8; font-size: 13px;
  box-shadow: var(--shadow); border: 1px solid rgba(255, 255, 255, .06);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s var(--ease);
  max-width: min(560px, 92vw);
}
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left: 3px solid #4ade80; }
.toast-error { border-left: 3px solid #f87171; }
.toast-action { color: #a5b4fc; font-weight: 600; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 900;
  display: grid; place-items: start center; padding: 9vh 16px 16px;
  background: rgba(8, 10, 14, .55); backdrop-filter: blur(3px);
  animation: fade .12s;
  overflow-y: auto;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(460px, 100%);
  border-radius: 14px; background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: pop .15s var(--ease);
  display: flex; flex-direction: column; max-height: 84vh;
}
.modal-wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-body { padding: 10px 18px 16px; overflow-y: auto; }
.modal-body p { margin-top: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }

.emoji-big { width: 54px; height: 54px; font-size: 28px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); flex: none; align-self: flex-end; }
.emoji-big:hover { border-color: var(--border-strong); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--bg-elev); }
.swatch.active { border-color: var(--text); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  height: 46px; padding: 0 12px; flex: none;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
}
.note-view .topbar { border-bottom-color: var(--border); }
.crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; white-space: nowrap; font-size: 13px; }
.crumb { color: var(--muted); padding: 3px 6px; border-radius: 5px; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
a.crumb:hover { background: var(--hover); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 500; }
.crumb-sep { color: var(--border-strong); }
.save-status { font-size: 12px; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.save-status.saving, .save-status.dirty { color: var(--text-2); }
.save-status.error, .save-status.conflict { color: var(--danger); font-weight: 500; }
.save-status.saved::before { content: "✓ "; color: var(--success); }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.seg-btn { width: 30px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Note view ---------- */
.note-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.head-slot { flex: none; }
.note-head { max-width: 980px; margin: 0 auto; padding: 22px 32px 10px; width: 100%; }
.mode-split .note-head { max-width: none; padding: 16px 28px 10px; }
.mode-read .note-head { padding: 8px 0 18px; max-width: none; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.draft-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 12px; border-radius: var(--radius); background: color-mix(in srgb, var(--warning) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); font-size: 13px; }
.draft-banner span { flex: 1; }
.title-row { display: flex; align-items: flex-start; gap: 10px; }
.note-icon { font-size: 34px; line-height: 1; height: 46px; min-width: 46px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.note-icon:hover { background: var(--hover); }
.note-icon.empty { font-size: 12.5px; color: var(--muted); min-width: auto; padding: 0 8px; height: 30px; margin-top: 8px; opacity: 0; transition: opacity .15s; }
.note-head:hover .note-icon.empty, .note-icon.empty:focus { opacity: 1; }
/* No icon yet: show “Add icon” above the title (on hover) instead of leaving a gap beside it */
.title-row:has(.note-icon.empty) { flex-direction: column; gap: 0; }
.title-row:has(.note-icon.empty) .note-icon.empty { margin: 0 0 2px -8px; height: 26px; }
.title-row:has(.note-icon.empty) .note-title { width: 100%; }
.note-title {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent; resize: none; overflow: hidden;
  font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; padding: 4px 0;
  color: var(--text);
}
.note-title::placeholder { color: var(--border-strong); }
.props { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-size: 12.5px; }
.prop { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 6px; color: var(--text-2); border: 1px solid var(--border); background: var(--bg-elev); }
.prop:hover { border-color: var(--border-strong); color: var(--text); }
.prop-status { border-color: color-mix(in srgb, var(--c) 40%, var(--border)); background: color-mix(in srgb, var(--c) 10%, transparent); color: var(--text); }
.prop-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 8px; border-radius: 20px; font-size: 12px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); white-space: nowrap; }
.chip.sm { height: 20px; font-size: 11px; padding: 0 6px; }
.chip a:hover { color: var(--accent); }
.chip-x { color: var(--muted); font-size: 14px; line-height: 1; padding: 0 0 1px 2px; }
.chip-x:hover { color: var(--danger); }
.tag-input { width: 90px; height: 24px; border: 1px dashed var(--border-strong); border-radius: 20px; padding: 0 9px; background: transparent; outline: none; font-size: 12px; }
.tag-input:focus { border-style: solid; border-color: var(--accent); width: 140px; }
.prop-progress { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.mini-progress { width: 60px; height: 5px; border-radius: 4px; background: var(--surface-2); overflow: hidden; display: inline-block; }
.mini-progress span { display: block; height: 100%; background: var(--success); border-radius: 4px; transition: width .3s; }
.prop-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.prop-meta.link:hover { color: var(--accent); }

.note-body { flex: 1; min-height: 0; display: flex; position: relative; }
.pane { min-width: 0; min-height: 0; }
.pane-edit { flex: 1; display: flex; flex-direction: column; }
.pane-preview { flex: 1; overflow-y: auto; }
.mode-write .pane-preview { display: none; }
.mode-read .pane-edit { display: none; }
.mode-split .pane-edit { border-right: 1px solid var(--border); }

.toolbar {
  display: flex; align-items: center; gap: 1px; flex-wrap: wrap;
  padding: 5px 16px; border-bottom: 1px solid var(--border); flex: none;
}
.mode-write .toolbar { justify-content: center; }
.tb-btn { height: 28px; min-width: 28px; padding: 0 6px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
.tb-btn:hover { background: var(--hover); color: var(--text); }
.tb-text { white-space: nowrap; font-weight: 700; font-size: 12px; font-family: var(--mono); }
.tb-sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }
.editor-wrap { flex: 1; min-height: 0; display: flex; }
.editor {
  flex: 1; width: 100%; height: 100%;
  border: 0; outline: none; resize: none;
  padding: 22px 28px 40vh;
  background: transparent; color: var(--text);
  font-family: var(--mono); font-size: 13.8px; line-height: 1.7;
  tab-size: 2;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}
.mode-write .editor { max-width: 900px; margin: 0 auto; padding-left: 32px; padding-right: 32px; font-size: 14.5px; }
.editor::placeholder { color: var(--muted); opacity: .7; }
.editor.drop-target { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -8px; }

.preview-inner { max-width: 860px; margin: 0 auto; padding: 24px 36px 30vh; }
.mode-read .preview-inner { padding-top: 34px; }
.preview-empty { color: var(--muted); padding: 30px 0; font-style: italic; }

/* ---------- Live mode (Notion-style: type in the formatted page) ---------- */
.live-toolbar { display: none; }
.mode-live .pane-edit { display: none; }
.mode-live .live-toolbar {
  display: flex; justify-content: center; position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px);
}
.mode-live .preview-inner { padding-top: 28px; max-width: 820px; }
.mode-live .note-head { padding: 0 0 14px; max-width: none; margin-bottom: 8px; }
.live-input {
  display: block; width: 100%; resize: none; overflow: hidden; outline: none;
  padding: 7px 10px; border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
  background: var(--bg-elev); color: var(--text);
  font-family: var(--mono); font-size: 14px; line-height: 1.65; tab-size: 2;
  font-variant-ligatures: none; font-feature-settings: 'liga' 0, 'calt' 0;
}
.live-input::placeholder { color: var(--muted); opacity: .8; }
.live-input.drop-target { background: var(--accent-soft); }
.live-tail { min-height: 34vh; cursor: text; }

/* ---------- Live editor (edit the formatted page directly) ---------- */
.wy-root, .live-tail { display: none; }
.mode-live .wy-root { display: block; }
.mode-live .live-tail { display: block; }
.mode-live .preview-body { display: none; }
.wy { outline: none; caret-color: var(--accent); min-height: 2em; position: relative; }
.wy > .wy-block:first-child > :first-child, .wy > .wy-island:first-child > :first-child { margin-top: 0; }
.wy.wy-empty::before { content: attr(data-placeholder); color: var(--muted); opacity: .75; position: absolute; left: 0; top: 0; pointer-events: none; }
.wy-island { position: relative; border-radius: 10px; cursor: pointer; transition: box-shadow .12s; }
.wy-island:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.wy-island:hover::after { content: '✎ Click to edit'; position: absolute; bottom: 8px; right: 10px; font-size: 11px; color: var(--muted); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; pointer-events: none; }
.wy-island.editing { cursor: auto; box-shadow: none; margin: 0 0 1em; }
.wy-island.editing::after { display: none; }
.wy-island-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; user-select: none; }
.wy-uploading { color: var(--muted); font-style: italic; font-size: .9em; }
.wy a.wikilink { cursor: pointer; }
.wy li.task-item > input[type=checkbox] { cursor: pointer; }


.side-panel { width: 0; overflow: hidden; flex: none; border-left: 1px solid transparent; background: var(--bg-sidebar); transition: width .18s var(--ease); display: flex; flex-direction: column; }
.panel-open .side-panel { width: var(--panel-w); border-left-color: var(--border); }
.panel-tabs { display: flex; align-items: center; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--border); flex: none; }
.panel-tab { padding: 6px 9px; font-size: 12.5px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.panel-tab:hover { color: var(--text); }
.panel-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.panel-tabs .icon-btn { margin-left: auto; }
.panel-body { flex: 1; overflow-y: auto; padding: 12px; width: var(--panel-w); }
.outline-item { display: block; width: 100%; text-align: left; padding: 4px 8px; border-radius: 5px; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline-item:hover { background: var(--hover); color: var(--text); }
.outline-item.lvl-1 { font-weight: 600; color: var(--text); }
.outline-item.lvl-2 { padding-left: 18px; }
.outline-item.lvl-3 { padding-left: 30px; font-size: 12.5px; }
.outline-item.lvl-4 { padding-left: 42px; font-size: 12px; color: var(--muted); }
.panel-link { display: block; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.panel-link:hover { background: var(--hover); }
.history-item { display: flex; justify-content: space-between; width: 100%; padding: 7px 8px; border-radius: 6px; font-size: 13px; text-align: left; }
.history-item:hover { background: var(--hover); }
.version-preview h2 { margin-top: 0; }

/* Editor popups (slash / link) */
.popup {
  position: fixed; z-index: 950; width: 300px; max-height: 330px; overflow-y: auto;
  padding: 5px; border-radius: 10px; background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.popup-group { padding: 6px 8px 3px; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.popup-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 8px; border-radius: 6px; text-align: left; font-size: 13px; }
.popup-item.active { background: var(--active); }
.popup-icon { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; font-size: 12px; font-weight: 700; font-family: var(--mono); flex: none; color: var(--text-2); }
.popup-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popup-sub { font-size: 11px; color: var(--muted); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popup-empty { padding: 10px; font-size: 12.5px; color: var(--muted); }

/* ---------- Pages ---------- */
.page { width: 100%; max-width: 1040px; margin: 0 auto; padding: 18px 40px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 10px 0 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.page-title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.page-title.editable { outline: none; border-radius: 6px; padding: 0 4px; margin-left: -4px; }
.page-title.editable:hover { background: var(--hover); }
.page-title.editable:focus { background: var(--hover); box-shadow: 0 0 0 2px var(--accent-soft); }
.section { margin-top: 30px; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 12px; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-elev); text-align: left; transition: border-color .12s, transform .12s, box-shadow .12s; }
.quick:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.quick-icon { width: 36px; height: 36px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.quick strong { display: block; font-size: 13.5px; }
.quick small { color: var(--muted); font-size: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.stat { padding: 14px 16px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-elev); }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.accent .stat-value { color: var(--accent); }
.stat.good .stat-value { color: var(--success); }

.heatmap-wrap { padding: 16px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-elev); overflow-x: auto; }
.heatmap { display: flex; gap: 3px; width: max-content; margin-left: auto; }
.hm-col { display: flex; flex-direction: column; gap: 3px; }
.hm-cell { width: 13px; height: 13px; border-radius: 3px; background: var(--surface-2); display: inline-block; }
.hm-cell.lvl-1 { background: transparent; }
.hm-cell.lvl1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); }
.hm-cell.lvl2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
.hm-cell.lvl3 { background: color-mix(in srgb, var(--accent) 78%, var(--surface-2)); }
.hm-cell.lvl4 { background: var(--accent); }
.hm-legend { display: flex; align-items: center; gap: 4px; margin-top: 10px; justify-content: flex-end; }
.hm-legend .hm-cell { width: 11px; height: 11px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-elev); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--hover); }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.nb-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-elev); overflow: hidden; transition: border-color .12s, transform .12s; min-height: 128px; }
.nb-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--nb-color); }
.nb-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.nb-card-top { display: flex; align-items: center; justify-content: space-between; }
.nb-card-icon { font-size: 24px; }
.nb-card-name { font-weight: 600; font-size: 14.5px; }
.nb-card-desc { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stack-bar { display: flex; height: 6px; border-radius: 4px; overflow: hidden; background: var(--surface-2); margin-top: auto; }
.stack-bar span { display: block; height: 100%; }
.nb-new { align-items: center; justify-content: center; flex-direction: row; color: var(--muted); border-style: dashed; background: transparent; font-weight: 500; }
.nb-new::before { display: none; }
.nb-new:hover { color: var(--text); }

.empty-state { text-align: center; padding: 56px 20px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty-state h3, .empty-state h2 { margin: 8px 0 2px; }
.empty-state p { margin: 0 0 10px; max-width: 420px; }
.empty-icon { font-size: 40px; }

.onboarding { max-width: 620px; margin: 8vh auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.onboarding h1 { font-size: 30px; margin: 10px 0 0; letter-spacing: -.02em; }
.onboarding p { max-width: 520px; margin: 0; }
.onb-preview { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 14px 0 10px; }
.study-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

/* Notebook page */
.nb-hero { display: flex; align-items: center; gap: 14px; margin: 14px 0 18px; }
.page-icon { font-size: 40px; width: 64px; height: 64px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--nb-color) 14%, transparent); border: 1px solid color-mix(in srgb, var(--nb-color) 30%, transparent); flex: none; }
.page-icon:hover { filter: brightness(1.1); }
.nb-hero p { margin: 4px 0 0; }
.nb-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.fchip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 20px; border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.fchip:hover { border-color: var(--border-strong); }
.fchip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.fchip-count { font-size: 11px; opacity: .65; }

.note-table { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-elev); }
.nt-row { display: grid; grid-template-columns: minmax(0, 2.6fr) 130px minmax(0, 1.3fr) 130px 90px; gap: 12px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.nt-row:last-child { border-bottom: 0; }
.nt-row:not(.nt-head):hover { background: var(--hover); }
.nt-head { cursor: default; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface); padding: 7px 14px; }
.nt-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nt-title > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.nt-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-path { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-tags { display: flex; gap: 4px; overflow: hidden; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 20px; font-size: 12px; background: var(--surface); border: 1px solid var(--border); white-space: nowrap; }
.pill-status { border-color: color-mix(in srgb, var(--c) 35%, var(--border)); background: color-mix(in srgb, var(--c) 10%, transparent); }
.pill-status:hover { border-color: var(--c); }
.pill-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

/* Templates */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.tpl-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-elev); text-align: left; transition: border-color .12s, transform .12s; }
.tpl-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.tpl-blank { width: 100%; margin-bottom: 4px; }
.tpl-icon { font-size: 24px; line-height: 1; width: 40px; height: 40px; border-radius: 10px; background: var(--surface); display: grid; place-items: center; flex: none; }
.tpl-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tpl-text strong { font-size: 13.5px; }
.tpl-text small { font-size: 12px; color: var(--muted); line-height: 1.4; }
.modal .section { margin-top: 18px; }
.tpl-preview { display: flex; flex-direction: column; gap: 14px; }
.tpl-form { flex-direction: row; gap: 12px; }
.tpl-form .field { flex: 1; }
.tpl-preview-body { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 6px 22px; max-height: 50vh; overflow-y: auto; background: var(--bg); }

/* Palette */
.palette-backdrop { padding-top: 12vh; }
.palette { width: min(640px, 100%); border-radius: 14px; background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; animation: pop .14s var(--ease); }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input { flex: 1; height: 52px; border: 0; outline: none; background: transparent; font-size: 16px; color: var(--text); }
.palette-list { max-height: 56vh; overflow-y: auto; padding: 6px; }
.palette-section { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; text-align: left; }
.palette-item.active { background: var(--active); }
.pi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pi-main > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-main small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-act { display: grid; place-items: center; color: var(--muted); }
.inline-sub { color: var(--muted); }
.snippet mark, .pi-main mark { background: color-mix(in srgb, var(--warning) 35%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.palette-foot { padding: 8px 16px; border-top: 1px solid var(--border); }

/* Settings */
.settings { display: flex; flex-direction: column; gap: 22px; }
.settings section h3 { margin: 0 0 4px; font-size: 14px; }
.settings section p { margin: 0 0 10px; }
.settings .field { min-width: 220px; }
.shortcut-list { display: flex; flex-direction: column; gap: 2px; }
.shortcut { display: flex; justify-content: space-between; gap: 16px; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.shortcut:last-child { border-bottom: 0; }

/* Study */
.inline-code-block { background: var(--code-bg); border: 1px solid var(--border); padding: 10px 14px; border-radius: 8px; font-family: var(--mono); font-size: 13px; }
.deck-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-elev); overflow: hidden; }
.deck-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.deck-row:last-child { border-bottom: 0; }
.deck-title { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-title:hover { color: var(--accent); }
.study-page .study-actions { justify-content: flex-start; margin-top: 22px; }
.review-page { max-width: 760px; }
.review-top { display: flex; align-items: center; gap: 12px; margin: 8px 0 12px; }
.progress { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-bottom: 26px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s var(--ease); }
.review-card { min-height: 280px; padding: 34px 38px; border-radius: 18px; border: 1px solid var(--border); background: var(--bg-elev); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 22px; }
.review-source { font-size: 12px; color: var(--muted); }
.review-source a:hover { color: var(--accent); }
.review-q { font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.review-a { font-size: 17px; padding-top: 22px; border-top: 1px dashed var(--border-strong); animation: fade .2s; }
.review-a.hidden { display: none; }
.md-inline p { margin: 0; }
.review-controls { display: flex; justify-content: center; gap: 10px; margin: 22px 0 10px; flex-wrap: wrap; }
.grade { flex-direction: column; height: 56px; min-width: 110px; gap: 0; }
.grade small { font-size: 11px; opacity: .75; font-weight: 400; }
.grade-again { color: var(--danger); }
.grade-hard { color: var(--warning); }
.grade-good { color: var(--success); }
.grade-easy { color: var(--accent); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 3000; background: rgba(0, 0, 0, .85); display: grid; place-items: center; padding: 24px; cursor: zoom-out; animation: fade .15s; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: var(--shadow); }

/* ---------- Share page ---------- */
.share-body { background: var(--bg); }
.share-top { display: flex; align-items: center; justify-content: space-between; max-width: 860px; margin: 0 auto; padding: 14px 24px; color: var(--muted); font-size: 12.5px; }
.share-main { max-width: 860px; margin: 0 auto; padding: 10px 24px 80px; }
.share-head { border-bottom: 1px solid var(--border); margin-bottom: 24px; padding-bottom: 12px; }
.share-title { font-size: 32px; letter-spacing: -.02em; margin: 10px 0 4px; }

/* ---------- Focus mode ---------- */
.app.focus-mode .topbar { opacity: .25; transition: opacity .2s; }
.app.focus-mode .topbar:hover { opacity: 1; }
.app.focus-mode .toolbar { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .panel-open .side-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 500; top: 0; bottom: 0; left: 0; margin-left: 0 !important; transform: translateX(-100%); box-shadow: var(--shadow); }
  .app.sidebar-open .sidebar { transform: none; }
  .app.sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 400; background: rgba(0, 0, 0, .45); }
  .only-mobile { display: inline-grid; }
  .only-collapsed { display: none !important; }
  .page { padding: 10px 18px 80px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .note-head { padding: 14px 18px 8px; }
  .note-title { font-size: 24px; }
  .editor, .mode-write .editor { padding: 16px 18px 40vh; font-size: 14px; }
  .preview-inner { padding: 16px 18px 30vh; }
  .seg-btn[data-mode="split"] { display: none; }
  .btn-sm.btn-ghost { padding: 0 6px; }
  .topbar .save-status { display: none; }
  .nt-row { grid-template-columns: minmax(0, 1fr) auto 70px; }
  .hide-sm { display: none !important; }
  .tpl-form { flex-direction: column; }
  .crumb { max-width: 120px; }
  .crumbs .crumb:not(.current), .crumbs .crumb-sep { display: none; }
}
@media (max-width: 520px) {
  .quick-actions { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; }
  .review-card { padding: 22px; }
}

/* ---------- Print ---------- */
@media print {
  body.printing .sidebar, body.printing .topbar, body.printing .pane-edit, body.printing .side-panel,
  body.printing .props, body.printing .draft-banner, body.printing .note-icon.empty, body.printing #toasts { display: none !important; }
  body.printing .app, body.printing .main, body.printing .note-view, body.printing .note-body { display: block !important; height: auto !important; overflow: visible !important; }
  body.printing .pane-preview { display: block !important; overflow: visible !important; }
  body.printing .preview-inner { padding: 0 !important; max-width: none; }
  body.printing .live-toolbar, body.printing .live-tail { display: none !important; }

  body.printing .head-slot .note-head { padding: 0 0 12px; }
  body.printing .copy-btn { display: none; }
  body.printing .fc-a { filter: none !important; }
}
