/* NotesPlus app shell: layout (F1), components, dialogs, accessibility (F4), mobile (F5), polish (F6). */

:root {
  --sb-w: 264px; --lp-w: 344px;
  --r-sm: 6px; --r: 10px; --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 6px 24px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-3: 0 18px 50px rgba(15, 23, 42, 0.22), 0 4px 12px rgba(15, 23, 42, 0.08);
  --paper-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 34px rgba(5, 23, 102, 0.07);
  --scrim: rgba(8, 12, 24, 0.45);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
[data-mode="dark"] { --shadow-1: none; --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.5); --shadow-3: 0 20px 60px rgba(0, 0, 0, 0.6); --paper-shadow: none; --scrim: rgba(0, 0, 0, 0.6); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--link); }
img { max-width: 100%; }
::selection { background: var(--accent-soft); color: var(--text); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 3000; background: var(--paper); color: var(--text); padding: 8px 14px; border-radius: var(--r); box-shadow: var(--shadow-2); }
.skip-link:focus { left: 12px; }
.spacer { flex: 1 1 auto; }
.hint { color: var(--text-2); font-size: 13px; margin: 0; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.row > .input { flex: 1 1 200px; min-width: 0; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.bullets { padding-left: 1.2em; margin: 8px 0 0; }
.bullets li { margin: 4px 0; }
kbd { font-family: var(--font-mono); font-size: 11.5px; line-height: 1; padding: 3px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface); color: var(--text-2); white-space: nowrap; }
.kbd-combo { display: inline-flex; gap: 3px; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic.sm { width: 16px; height: 16px; }
.ic.invisible { visibility: hidden; }
.ic-space { width: 20px; flex: none; }
.spin { animation: np-spin 0.9s linear infinite; }
@keyframes np-spin { to { transform: rotate(360deg); } }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 14.5px; font-weight: 600; text-decoration: none;
  white-space: nowrap; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s; position: relative; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); color: var(--on-danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); background: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost.danger, .btn.danger { color: var(--danger); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn.is-busy { color: transparent !important; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--text-2); border-right-color: transparent; animation: np-spin 0.8s linear infinite; }
.btn-primary.is-busy::after, .btn-danger.is-busy::after { border-color: var(--on-primary); border-right-color: transparent; }
.link-btn { background: none; border: 0; padding: 0 4px; color: var(--link); text-decoration: underline; font-size: inherit; display: inline-flex; align-items: center; gap: 4px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: none; border-radius: 9px; border: 0;
  background: transparent; color: var(--text-2); transition: background 0.15s, color 0.15s; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }
.icon-btn.on, .icon-btn[aria-pressed="true"] { color: var(--accent-text); }
.icon-btn.star-on { color: var(--warning); }
.icon-btn.star-on .ic, .ni-star { fill: currentColor; }

.input, .select { width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--r); border: 1px solid var(--border-strong); background: var(--paper);
  color: var(--text); font-size: 15px; transition: border-color 0.15s, box-shadow 0.15s; }
.select { width: auto; padding-right: 32px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }
.input:focus, .select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input::placeholder, textarea::placeholder { color: var(--text-2); opacity: 1; }
textarea.input { resize: vertical; line-height: 1.55; }
.field { display: grid; gap: 6px; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input-wrap { position: relative; display: block; }
.input-wrap .input { padding-right: 44px; }
.input-wrap .reveal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.field-error, .auth-error { color: var(--danger); font-size: 13.5px; margin: 0; }
.field-error:empty { display: none; }
.form { display: grid; gap: 14px; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); font-size: 14px; border-left: 3px solid; }
.callout .ic { margin-top: 1px; }
.callout.warning { background: var(--warning-soft); border-color: var(--warning); }
.callout.warning .ic { color: var(--warning); }
.callout.danger { background: var(--danger-soft); border-color: var(--danger); }
.callout.danger .ic { color: var(--danger); }
.callout.success { background: var(--success-soft); border-color: var(--success); }
.callout.success .ic { color: var(--success); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.badge .ic { width: 14px; height: 14px; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 10px; border-radius: 999px; border: 0; background: var(--accent-soft);
  color: var(--accent-text); font-size: 13px; font-weight: 600; white-space: nowrap; }
button.chip:hover { filter: brightness(0.97); }
.chip.removable { padding-right: 4px; }
.chip.removable button, .chip.removable .ic { background: none; border: 0; color: inherit; padding: 0; display: inline-flex; width: 18px; height: 18px; border-radius: 50%; align-items: center; justify-content: center; }
.chip.removable .ic { width: 14px; height: 14px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; flex-wrap: wrap; }
.seg { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 7px; border: 0; background: transparent; color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.seg .ic { width: 16px; height: 16px; }
.seg[aria-checked="true"] { background: var(--paper); color: var(--text); box-shadow: var(--shadow-1); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; position: relative; }
.switch input { position: absolute; opacity: 0; width: 40px; height: 24px; margin: 0; }
.switch-track { width: 40px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; transition: background 0.15s; }
.switch-track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.progress { width: 100%; height: 6px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-2); appearance: none; }
.progress::-webkit-progress-bar { background: var(--surface-2); }
.progress::-webkit-progress-value { background: var(--primary); }
.progress::-moz-progress-bar { background: var(--primary); }
.meter-row { display: flex; gap: 10px; align-items: center; }
.meter { width: 160px; height: 10px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); margin: 22px 0 8px; }

/* ---------- Boot ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; align-content: center; gap: 20px; background: var(--bg); z-index: 10; }
.boot-logo { animation: np-pulse 1.4s ease-in-out infinite; }
.boot-bar { width: 140px; height: 3px; border-radius: 3px; background: var(--border); overflow: hidden; }
.boot-bar span { display: block; width: 40%; height: 100%; background: var(--primary); animation: np-slide 1.1s ease-in-out infinite; }
@keyframes np-pulse { 50% { transform: scale(0.94); opacity: 0.8; } }
@keyframes np-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* ---------- Sign-in ---------- */
.auth { position: fixed; inset: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: calc(56px + var(--safe-t)) 16px calc(24px + var(--safe-b)); background: var(--bg);
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--primary) 26%, var(--bg)), var(--bg) 70%); }
.auth-tools { position: absolute; top: calc(12px + var(--safe-t)); right: 12px; display: flex; gap: 6px; }
.auth-card { width: min(420px, 100%); background: var(--paper); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-3); padding: 36px 32px 30px; }
.auth-logo { display: block; margin: 0 auto 14px; }
.auth-title { font-size: 24px; font-weight: 700; text-align: center; margin: 0 0 6px; letter-spacing: -0.01em; }
.auth-sub { text-align: center; color: var(--text-2); margin: 0 0 24px; }
.auth-form { display: grid; gap: 16px; margin-top: 18px; }
.auth-step-ic { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.auth-step-ic .ic { width: 28px; height: 28px; }
.auth-step-ic.warn { background: var(--warning-soft); color: var(--warning); margin-bottom: 14px; }
.auth-foot { color: var(--text-2); font-size: 13px; margin: 0; }
.code-input { font-family: var(--font-mono); font-size: 28px; letter-spacing: 0.45em; text-align: center; min-height: 58px; padding-left: 0.45em; }
.setup-steps { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; font-size: 14px; }
.qr { background: #fff; padding: 10px; border-radius: 12px; width: fit-content; margin: 0 auto; border: 1px solid var(--border); }
.qr img, .qr canvas { display: block; }
.secret-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.secret { font-family: var(--font-mono); font-size: 13px; background: var(--code-bg); color: var(--code-text); padding: 4px 8px; border-radius: 6px; word-break: break-all; }
.auth-modal .auth-form { margin-top: 8px; }
.auth-modal .auth-title { font-size: 18px; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: var(--sb-w) var(--lp-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { grid-column: 1; grid-row: 1; min-width: 0; }
.list-pane { grid-column: 2; grid-row: 1; min-width: 0; }
.note-pane { grid-column: 3; grid-row: 1; min-width: 0; }
html.sidebar-collapsed .app { grid-template-columns: 0 var(--lp-w) minmax(0, 1fr); }
html.sidebar-collapsed .sidebar { visibility: hidden; }
.scrim { display: none; }

/* Sidebar */
.sidebar { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); padding-left: var(--safe-l); overflow: hidden; }
.sb-head { display: flex; align-items: center; gap: 8px; padding: calc(14px + var(--safe-t)) 12px 6px 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.brand img { border-radius: 8px; }
.sb-close { margin-left: auto; display: none; }
.sb-new { display: flex; gap: 6px; padding: 8px 12px 6px; }
.sb-new .btn { flex: 1; }
.sb-scroll { flex: 1; overflow-y: auto; padding: 6px 8px 14px; }
.sb-nav { display: grid; gap: 1px; }
.sb-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border-radius: 8px; border: 0; background: transparent;
  color: var(--text); font-size: 14.5px; text-align: left; min-width: 0; }
.sb-item:hover { background: var(--surface-2); }
.sb-item[aria-current="page"] { background: var(--surface-3); color: var(--accent-text); font-weight: 600; }
.sb-item .ic { color: var(--text-2); width: 18px; height: 18px; }
.sb-item[aria-current="page"] .ic { color: var(--accent-text); }
.sb-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-count { color: var(--text-2); font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.sb-row { position: relative; display: flex; align-items: center; }
.sb-row .sb-item { padding-right: 34px; }
.sb-row .sb-count { margin-right: 2px; }
.sb-more { position: absolute; right: 4px; opacity: 0; }
.sb-row:hover .sb-more, .sb-row:focus-within .sb-more, .sb-more[aria-expanded="true"] { opacity: 1; }
.sb-row:hover .sb-count, .sb-row:focus-within .sb-count { visibility: hidden; }
.sb-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot); flex: none; margin: 0 4px; }
.sb-emoji { width: 18px; text-align: center; flex: none; font-size: 15px; }
.sb-section { margin-top: 18px; }
.sb-section-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 2px 10px; min-height: 28px; }
.sb-section-head h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); font-weight: 700; }
.sb-empty { margin: 2px 10px; font-size: 13px; color: var(--text-2); }
.sb-foot { display: flex; align-items: center; gap: 2px; padding: 8px 10px calc(8px + var(--safe-b)); border-top: 1px solid var(--border); }
[data-mode="dark"] .ic-moon, [data-mode="light"] .ic-sun { display: none; }

/* List pane */
.list-pane { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); position: relative; overflow: hidden; }
.lp-head { display: flex; align-items: center; gap: 4px; padding: calc(10px + var(--safe-t)) 10px 4px 8px; min-height: 56px; }
.lp-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; padding-left: 4px; }
.lp-title h1 { font-size: 17px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-count { font-size: 12.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lp-search { display: flex; align-items: center; gap: 8px; margin: 4px 12px 8px; min-height: 40px; padding: 0 6px 0 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid transparent; color: var(--text-2); transition: border-color 0.15s, background 0.15s; }
.lp-search:focus-within { border-color: var(--focus); background: var(--paper); }
.lp-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 15px; color: var(--text); padding: 8px 0; }
.lp-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.lp-search:focus-within .search-kbd { display: none; }
.lp-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.lp-banner { margin: 0 12px 8px; padding: 8px 10px; border-radius: 8px; background: var(--warning-soft); font-size: 13px; display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.lp-banner .ic { width: 15px; height: 15px; color: var(--warning); }
.note-list { flex: 1; overflow-y: auto; padding: 0 8px calc(24px + var(--safe-b)); overscroll-behavior: contain; }
.ni-group-label { position: sticky; top: 0; z-index: 1; background: var(--surface); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-2); padding: 12px 10px 4px; }
.note-item { display: flex; gap: 10px; padding: 10px; border-radius: 10px; border: 1px solid transparent; margin: 2px 0; cursor: pointer; position: relative; }
.note-item:hover { background: var(--surface-2); }
.note-item[aria-selected="true"] { background: var(--surface-3); border-color: var(--border); }
.note-item.is-new .ni-title span { font-style: italic; }
.ni-main { flex: 1; min-width: 0; }
.ni-title { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; line-height: 1.35; }
.ni-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ni-flag { width: 14px; height: 14px; color: var(--text-2); }
.ni-snippet { font-size: 13.5px; color: var(--text-2); margin-top: 2px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ni-snippet.muted { font-style: italic; }
.ni-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.ni-tag { color: var(--accent-text); font-weight: 600; }
.ni-nb { display: inline-flex; align-items: center; gap: 4px; }
.ni-nb::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
.ni-star { width: 14px; height: 14px; color: var(--warning); }
.ni-purge { color: var(--warning); }
.ni-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex: none; background: var(--surface-2); align-self: center; }
.note-item mark, .palette-item mark { background: var(--mark-bg); color: var(--mark-text); border-radius: 2px; }
.skeleton-list { padding: 6px 4px; }
.sk-item { padding: 12px 8px; display: grid; gap: 8px; }
.sk { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: np-shimmer 1.3s linear infinite; }
.sk-title { height: 15px; width: 62%; }
.sk-line { width: 92%; margin-top: 10px; }
.sk-line.short { width: 48%; }
@keyframes np-shimmer { to { background-position: -200% 0; } }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty-ic { width: 40px; height: 40px; color: var(--border-strong); }
.empty-state h2 { font-size: 17px; color: var(--text); margin: 12px 0 6px; }
.empty-state p { margin: 0 auto 18px; max-width: 280px; font-size: 14px; }
.fab { display: none; }

/* Note pane */
.note-pane { display: flex; flex-direction: column; min-height: 0; background: var(--bg); position: relative; outline: none; padding-right: var(--safe-r); }
.np-top { display: flex; align-items: center; gap: 6px; min-height: 56px; padding: calc(8px + var(--safe-t)) 12px 6px 16px; }
.np-back { display: none; }
.crumb { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; max-width: 230px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: 13.5px; font-weight: 500; }
.crumb span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.crumb .ic { width: 16px; height: 16px; }
.crumb-dot { display: inline-flex; align-items: center; gap: 4px; }
.crumb-dot:empty::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--dot); }
.save-status { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.save-status .ic { width: 15px; height: 15px; }
.save-status.st-offline, .save-status.st-conflict { color: var(--warning); }
.save-status.st-error { color: var(--danger); }
.save-status.st-saved .ic { color: var(--success); }
.np-actions { display: flex; align-items: center; gap: 2px; }
.np-actions .btn { margin-right: 4px; }
.np-toolbar { padding: 0 12px; border-bottom: 1px solid var(--border); background: var(--surface); position: relative; z-index: 5; min-height: 40px; }
.np-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 24px calc(120px + var(--safe-b)); display: flex; justify-content: center; gap: 24px; overscroll-behavior: contain; }
.paper-wrap { width: 100%; max-width: 880px; min-width: 0; }
.paper { background: var(--paper); border-radius: 4px; box-shadow: var(--paper-shadow); padding: clamp(24px, 5.5vw, 76px) clamp(20px, 6.5vw, 92px) clamp(40px, 6vw, 84px);
  min-height: calc(100% - 8px); border: 1px solid transparent; }
[data-mode="dark"] .paper { border-color: var(--border); }
.paper.loading .sk { margin-bottom: 14px; }
.note-title, .note-title-input { font-family: var(--font-sans); font-size: 32px; font-weight: 700; line-height: 1.22; letter-spacing: -0.015em; color: var(--text);
  margin: 0 0 10px; padding: 0; overflow-wrap: anywhere; }
.note-title.untitled { color: var(--text-2); }
.note-title-input { display: block; width: 100%; border: 0; background: transparent; resize: none; overflow: hidden; outline: none; }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--text-2); margin-bottom: 14px; }
.note-meta .sep { opacity: 0.7; }
.note-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 26px; }
.note-tags.editing { padding: 6px 8px; border: 1px dashed var(--border-strong); border-radius: 10px; }
.tag-input-wrap { position: relative; display: inline-flex; align-items: center; gap: 2px; color: var(--text-2); flex: 1; min-width: 140px; }
.tag-input { border: 0; background: transparent; outline: none; font-size: 14px; color: var(--text); min-width: 100px; flex: 1; padding: 4px 0; }
.tag-suggest { position: absolute; top: 100%; left: 0; z-index: 30; min-width: 200px; background: var(--paper); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-2); padding: 4px; }
.tag-opt { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text); text-align: left; font-size: 14px; }
.tag-opt:hover, .tag-opt:focus { background: var(--surface-2); outline: none; }
.tag-opt small { color: var(--text-2); }
.note-content.is-editing { min-height: 45vh; cursor: text; }
.note-content.mce-edit-focus { outline: none; }
.note-content[data-mce-placeholder]:not(.mce-visualblocks)::before { color: var(--text-2) !important; font-style: italic; }
.note-content:not(.is-editing) img { cursor: zoom-in; }
.note-content p.placeholder { color: var(--text-2); font-style: italic; cursor: text; }
.np-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--warning-soft); margin: -8px 0 18px; font-size: 14px; }
.np-banner .ic { color: var(--warning); }
.locked-card { text-align: center; padding: 56px 16px 40px; }
.locked-ic { width: 44px; height: 44px; color: var(--text-2); }
.locked-card h2 { margin: 12px 0 6px; font-size: 19px; }
.locked-card p { color: var(--text-2); margin: 0 0 20px; }
.backlinks { margin-top: 56px; padding-top: 16px; border-top: 1px solid var(--border); }
.backlinks h3 { display: flex; align-items: center; gap: 6px; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); margin: 0 0 10px; }
.backlinks h3 .ic { width: 15px; height: 15px; }
.backlinks ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.backlinks a { display: inline-block; padding: 4px 10px; border-radius: 8px; background: var(--surface-2); color: var(--accent-text); text-decoration: none; font-size: 14px; font-weight: 500; }
.backlinks a:hover { text-decoration: underline; }
.outline { position: sticky; top: 8px; align-self: flex-start; width: 220px; flex: none; max-height: calc(100dvh - 120px); overflow-y: auto; font-size: 13px; padding-top: 28px; }
.outline-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); margin: 0 0 8px 8px; }
.outline-list { list-style: none; padding: 0; margin: 0; }
.outline-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--text-2); padding: 5px 8px; border-radius: 6px; line-height: 1.35; }
.outline-list button:hover { background: var(--surface-2); color: var(--text); }
.outline-list .lvl-2 button { padding-left: 18px; }
.outline-list .lvl-3 button { padding-left: 30px; }
.np-empty { margin: auto; max-width: 460px; text-align: center; padding: 40px 20px; }
.np-empty-logo { width: 72px; height: 72px; opacity: 0.95; }
.np-empty h2 { font-size: 20px; margin: 16px 0 6px; }
.np-empty p { color: var(--text-2); margin: 0 0 22px; }
.np-tips { display: grid; grid-template-columns: auto auto; justify-content: center; gap: 8px 14px; margin: 30px 0 0; font-size: 13.5px; color: var(--text-2); text-align: left; }
.np-tips dt { text-align: right; }
.np-tips dd { margin: 0; }
.np-error { margin: auto; text-align: center; padding: 40px; color: var(--text-2); display: grid; gap: 12px; justify-items: center; }

/* TinyMCE (inline) skin alignment */
.np-toolbar .tox.tox-tinymce-inline { border: 0 !important; box-shadow: none !important; }
.np-toolbar .tox .tox-editor-header { border: 0 !important; box-shadow: none !important; padding: 0 !important; background: transparent !important; }
.np-toolbar .tox .tox-toolbar, .np-toolbar .tox .tox-toolbar__primary, .np-toolbar .tox .tox-toolbar__overflow, .np-toolbar .tox .tox-toolbar-overlord { background: var(--surface) !important; }
.np-toolbar .tox .tox-tbtn { color: var(--text) !important; border-radius: 7px !important; }
.np-toolbar .tox .tox-tbtn svg { fill: var(--text) !important; }
.np-toolbar .tox .tox-tbtn:hover { background: var(--surface-2) !important; }
.np-toolbar .tox .tox-tbtn--enabled, .np-toolbar .tox .tox-tbtn--enabled:hover { background: var(--accent-soft) !important; }
.np-toolbar .tox .tox-tbtn--enabled svg { fill: var(--accent-text) !important; }
.np-toolbar .tox .tox-tbtn__select-label { color: var(--text) !important; }
.np-toolbar .tox .tox-toolbar__group { border-color: var(--border) !important; }
.tox.tox-silver-sink { z-index: 1300 !important; }

/* ---------- Menus ---------- */
.menu { position: fixed; z-index: 1400; min-width: 220px; max-width: min(340px, calc(100vw - 16px)); max-height: 70vh; overflow-y: auto; background: var(--paper);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-2); padding: 6px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text); font-size: 14px; text-align: left; }
.menu-item .ic { width: 18px; height: 18px; color: var(--text-2); }
.menu-item:hover:not(:disabled), .menu-item:focus { background: var(--surface-2); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.menu-item.danger, .menu-item.danger .ic { color: var(--danger); }
.menu-item:disabled { opacity: 0.45; }
.menu-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-hint { font-size: 11px; padding: 2px 5px; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-header { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); padding: 6px 10px 4px; }
.menu .swatch { width: 12px; height: 12px; border-radius: 50%; }
.menu-scrim { position: fixed; inset: 0; z-index: 1399; background: var(--scrim); }
.menu-sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; max-width: none; width: 100%; border-radius: 18px 18px 0 0; padding: 10px 10px calc(10px + var(--safe-b)); max-height: 78vh; }
.menu-sheet .menu-item { min-height: 48px; font-size: 15.5px; }

/* ---------- Dialogs ---------- */
dialog.dlg { padding: 0; border: 0; background: transparent; color: var(--text); max-width: none; max-height: none; overflow: visible; }
dialog.dlg::backdrop { background: var(--scrim); }
.dlg-inner { --dlg-w: 560px; display: flex; flex-direction: column; width: min(var(--dlg-w), calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  background: var(--paper); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden; }
.dlg-sm .dlg-inner { --dlg-w: 440px; }
.dlg-lg .dlg-inner { --dlg-w: 840px; }
.dlg-xl .dlg-inner { --dlg-w: 1100px; }
.dlg-full .dlg-inner { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; border: 0; }
dialog.dlg-full { margin: 0; width: 100vw; height: 100dvh; }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 16px 14px 6px 22px; }
.dlg-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 700; }
.dlg-body { padding: 8px 22px 18px; overflow-y: auto; flex: 1; min-height: 0; }
.dlg-body > p:first-child { margin-top: 0; }
.dlg-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.dlg-lightbox .dlg-inner { background: transparent; border: 0; box-shadow: none; width: 100vw; height: 100dvh; max-height: none; }
.dlg-lightbox .dlg-head { position: absolute; top: calc(8px + var(--safe-t)); right: 8px; z-index: 2; padding: 0; }
.dlg-lightbox .dlg-head .icon-btn { background: rgba(0, 0, 0, 0.55); color: #fff; }
.dlg-lightbox .dlg-body { display: grid; place-items: center; padding: 16px; }
.lightbox-img { max-width: 96vw; max-height: 92dvh; object-fit: contain; border-radius: 6px; cursor: zoom-out; background: #fff; }
.dlg-palette { margin-top: 12vh; }
.dlg-palette .dlg-body { padding: 0; }
.dlg-palette .dlg-head { display: none; }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.palette-input { flex: 1; border: 0; background: transparent; outline: none; font-size: 17px; color: var(--text); min-width: 0; }
.palette-list { max-height: 56vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.palette-item .ic { color: var(--text-2); width: 18px; height: 18px; }
.palette-item[aria-selected="true"] { background: var(--surface-3); }
.pi-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-sub { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.palette-empty { padding: 18px; text-align: center; color: var(--text-2); margin: 0; }

/* Templates */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.tpl-card { display: grid; gap: 4px; align-content: start; text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.tpl-card:hover { border-color: var(--accent); background: var(--surface-2); }
.tpl-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 6px; }
.tpl-name { font-weight: 700; font-size: 15px; }
.tpl-desc { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.tpl-mine { display: grid; gap: 4px; }
.tpl-row { display: flex; align-items: center; gap: 6px; }
.tpl-row-main { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; }
.tpl-row-main:hover { background: var(--surface-2); }

/* History & diff */
.history { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; min-height: 58vh; }
.history-side { border-right: 1px solid var(--border); padding-right: 10px; overflow-y: auto; max-height: 66vh; }
.history-list { display: grid; gap: 2px; }
.history-item { display: grid; gap: 2px; text-align: left; width: 100%; padding: 10px; border-radius: 8px; border: 0; background: transparent; color: var(--text); position: relative; }
.history-item span { font-size: 12.5px; color: var(--text-2); }
.history-item .ic { position: absolute; right: 8px; top: 10px; color: var(--text-2); }
button.history-item:hover { background: var(--surface-2); }
.history-item[aria-selected="true"] { background: var(--surface-3); }
.history-item.current { background: var(--surface-2); }
.history-main { overflow-y: auto; max-height: 66vh; min-width: 0; }
.history-bar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.history-title { font-size: 22px; margin: 0 0 12px; }
.history-content { font-size: 15px; }
.diff { white-space: pre-wrap; font-family: var(--font-read); line-height: 1.75; font-size: 15px; overflow-wrap: anywhere; }
.diff ins { background: var(--success-soft); color: var(--success); text-decoration: none; border-radius: 3px; padding: 0 1px; }
.diff del { background: var(--danger-soft); color: var(--danger); border-radius: 3px; padding: 0 1px; }
.conflict-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.conflict-col { border: 1px solid var(--border); border-radius: 10px; padding: 12px; min-width: 0; }
.conflict-col h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); margin: 0 0 6px; }
.conflict-title { font-weight: 700; margin: 0 0 6px; }
.conflict-text { font-size: 13.5px; white-space: pre-wrap; max-height: 220px; overflow-y: auto; color: var(--text-2); overflow-wrap: anywhere; }
.conflict-diff summary { cursor: pointer; color: var(--link); margin: 6px 0; }

/* Share */
.share { display: grid; gap: 14px; }
.share-result { display: grid; gap: 10px; }
.share-result:empty { display: none; }
.share-qr { background: #fff; padding: 8px; border-radius: 10px; width: fit-content; border: 1px solid var(--border); }
.share-list { display: grid; }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.share-row strong, .share-row .hint { display: block; }

/* Settings */
.settings { display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 22px; min-height: 60vh; }
.set-nav { display: flex; flex-direction: column; gap: 2px; }
.set-tab { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; font-size: 14.5px; white-space: nowrap; }
.set-tab:hover { background: var(--surface-2); }
.set-tab[aria-selected="true"] { background: var(--surface-3); color: var(--accent-text); font-weight: 600; }
.set-tab .ic { width: 18px; height: 18px; }
.set-panel { overflow-y: auto; max-height: 68vh; min-width: 0; padding-right: 4px; }
.set-section { margin-bottom: 28px; }
.set-section > h3 { font-size: 15px; margin: 0 0 12px; }
.set-section > .hint { margin-bottom: 10px; }
.set-section > .row { margin-top: 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--border); }
.set-label { display: grid; gap: 2px; }
.set-label span { font-weight: 600; font-size: 14.5px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.theme-card { display: grid; gap: 8px; padding: 8px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); color: var(--text); }
.theme-card:hover { border-color: var(--border-strong); }
.theme-card[aria-checked="true"] { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-preview { display: flex; gap: 6px; height: 76px; border-radius: 8px; padding: 8px; overflow: hidden; }
.tp-side { width: 30%; border-radius: 6px; display: grid; gap: 6px; align-content: start; padding: 6px; }
.tp-dot { width: 10px; height: 10px; border-radius: 50%; }
.tp-line { height: 6px; border-radius: 3px; background: rgba(127, 127, 127, 0.28); width: 80%; }
.tp-line.short { width: 48%; }
.tp-paper { flex: 1; border-radius: 6px; padding: 8px; display: grid; gap: 6px; align-content: start; }
.tp-title { height: 8px; width: 62%; border-radius: 4px; }
.theme-name { font-size: 13.5px; font-weight: 600; text-align: center; }
.licenses { padding-left: 1.1em; margin: 0; font-size: 13.5px; display: grid; gap: 4px; color: var(--text-2); }
.color-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch-btn { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border-strong); padding: 0; flex: none; }
.swatch-btn[aria-checked="true"] { outline: 3px solid var(--focus); outline-offset: 2px; }
.emoji-input { width: 72px; text-align: center; font-size: 18px; }

/* Sketch */
.dlg-sketch .dlg-body { padding: 0; display: flex; }
.sketch { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sketch-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.swatches { display: flex; align-items: center; gap: 6px; }
.color-input { width: 30px; height: 30px; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
.sketch-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); overflow: hidden; }
.sketch-canvas { background: #fff; box-shadow: var(--shadow-2); touch-action: none; cursor: crosshair; border-radius: 4px; }

/* OCR */
.ocr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.ocr-left, .ocr-right { display: grid; gap: 10px; align-content: start; }
.ocr-drop { display: grid; place-items: center; gap: 6px; width: 100%; padding: 36px 16px; border: 2px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2); color: var(--text-2); }
.ocr-drop .ic { width: 32px; height: 32px; }
.ocr-drop span { font-weight: 600; color: var(--text); }
.ocr-preview { max-width: 100%; max-height: 300px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border); justify-self: center; }
.ocr-text { min-height: 280px; font-size: 14.5px; }

/* Shortcuts */
.shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 28px; }
.shortcuts h3 { font-size: 14px; margin: 8px 0; }
.kbd-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.kbd-table tr { border-bottom: 1px solid var(--border); }
.kbd-table th { text-align: left; font-weight: 400; padding: 7px 10px 7px 0; white-space: nowrap; }
.kbd-table td { color: var(--text-2); padding: 7px 0; }

/* Toasts */
.toasts { position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px;
  width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: 12px; background: var(--text); color: var(--paper);
  box-shadow: var(--shadow-3); font-size: 14px; animation: np-toast-in 0.2s ease-out; }
.toast .ic { width: 18px; height: 18px; }
.toast-msg { flex: 1; min-width: 0; }
.toast-action { flex: none; border: 1px solid currentColor; background: transparent; color: inherit; font-weight: 700; padding: 5px 10px; border-radius: 7px; font-size: 13px; }
.toast-close { color: inherit !important; opacity: 0.8; }
.toast-close:hover { background: transparent !important; opacity: 1; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
@keyframes np-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Share page (H6) ---------- */
body.share-page { overflow: auto; height: auto; min-height: 100%; }
.share-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 16px 10px; background: var(--surface); border-bottom: 1px solid var(--border); }
.share-bar .badge { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.share-main { max-width: 900px; margin: 24px auto; padding: 0 16px; }
.share-main .paper { min-height: 50vh; }
.share-main .sk { margin-bottom: 14px; }
.share-foot { text-align: center; color: var(--text-2); font-size: 13px; padding: 8px 16px calc(28px + var(--safe-b)); }
@media (max-width: 480px) { .share-bar .brand span { display: none; } }
@media (max-width: 759px) { .share-main { margin: 0; padding: 0; } .share-main .paper { border-radius: 0; box-shadow: none; padding: 22px 18px 40px; } }
@media print { .share-bar, .share-foot { display: none !important; } .share-main { margin: 0; padding: 0; max-width: none; } }

/* ---------- Focus mode (D9) ---------- */
html.focus-mode .app { grid-template-columns: 0 0 minmax(0, 1fr) !important; }
html.focus-mode .sidebar, html.focus-mode .list-pane { visibility: hidden; }
html.focus-mode .np-top { opacity: 0.25; transition: opacity 0.2s; }
html.focus-mode .np-top:hover, html.focus-mode .np-top:focus-within { opacity: 1; }
html.focus-mode .outline { display: none; }
html.focus-mode .paper { box-shadow: none; border-color: transparent; background: transparent; }
html.focus-mode .note-pane { background: var(--paper); }

/* ---------- Responsive (F1) ---------- */
@media (max-width: 1399px) { .outline { display: none; } }
@media (max-width: 1179px) {
  .app, html.sidebar-collapsed .app { grid-template-columns: var(--lp-w) minmax(0, 1fr); }
  .list-pane { grid-column: 1; }
  .note-pane { grid-column: 2; }
  .sidebar, html.sidebar-collapsed .sidebar { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(304px, 86vw); visibility: visible;
    transform: translateX(-105%); transition: transform 0.22s ease; box-shadow: var(--shadow-3); }
  html.drawer-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 59; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  html.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .sb-close { display: inline-flex; }
  html.focus-mode .app { grid-template-columns: 0 minmax(0, 1fr) !important; }
}
@media (max-width: 899px) and (min-width: 760px) { :root { --lp-w: 300px; } .crumb { max-width: 150px; } }
@media (max-width: 759px) {
  .app, html.sidebar-collapsed .app { grid-template-columns: 100%; overflow: hidden; }
  .list-pane, .note-pane { grid-column: 1; grid-row: 1; transition: transform 0.24s ease, visibility 0s linear 0.24s; }
  .list-pane { border-right: 0; }
  .note-pane { transform: translateX(100%); visibility: hidden; box-shadow: var(--shadow-3); z-index: 2; }
  html[data-pane="note"] .note-pane { transform: none; visibility: visible; transition: transform 0.24s ease, visibility 0s; }
  html[data-pane="note"] .list-pane { transform: translateX(-22%); visibility: hidden; }
  html[data-pane="list"] .list-pane { transition: transform 0.24s ease, visibility 0s; }
  .np-back { display: inline-flex; margin-left: -6px; }
  .np-top { padding-left: 8px; padding-right: 6px; gap: 2px; }
  .crumb { max-width: 120px; }
  .save-status { display: none; }
  .np-top .save-status.st-offline, .np-top .save-status.st-error, .np-top .save-status.st-saving, .np-top .save-status.st-conflict { display: inline-flex; }
  .btn-label { display: none; }
  .np-actions .btn { padding: 0 10px; }
  .np-scroll { padding: 0 0 calc(110px + var(--safe-b)); }
  .paper { border-radius: 0; box-shadow: none; min-height: 100%; padding: 20px 18px 48px; border: 0; }
  .note-title, .note-title-input { font-size: 26px; }
  .fab { display: grid; place-items: center; position: absolute; right: 16px; bottom: calc(18px + var(--safe-b)); width: 56px; height: 56px; border-radius: 18px; border: 0;
    background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-2); z-index: 3; }
  .fab .ic { width: 26px; height: 26px; }
  .note-list { padding-bottom: calc(96px + var(--safe-b)); }
  .search-kbd { display: none; }
  .np-toolbar { padding: 0 4px; }
  .np-empty { display: none; }
  dialog.dlg:not(.dlg-full):not(.dlg-palette) { margin: auto 0 0; width: 100vw; }
  dialog.dlg:not(.dlg-full):not(.dlg-palette) .dlg-inner { width: 100vw; border-radius: 18px 18px 0 0; max-height: 92dvh; padding-bottom: var(--safe-b); border-bottom: 0; }
  .dlg-palette { margin-top: calc(8px + var(--safe-t)); }
  .history, .settings, .ocr, .conflict-cols { grid-template-columns: 1fr; }
  .history-side { border-right: 0; border-bottom: 1px solid var(--border); max-height: 32vh; padding: 0 0 10px; }
  .set-nav { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .set-panel { max-height: none; }
  .sketch-tools { flex-wrap: nowrap; overflow-x: auto; }
  html.focus-mode .app { grid-template-columns: 100% !important; }
  .auth-card { padding: 28px 20px 24px; }
}
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn.sm { width: 36px; height: 36px; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 36px; }
  .menu-item { min-height: 44px; }
  .sb-item { min-height: 44px; }
  .sb-more { opacity: 1; }
  .sb-row .sb-count { visibility: visible !important; margin-right: 34px; }
  .search-kbd { display: none; }
  .seg { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .note-item[aria-selected="true"], .sb-item[aria-current="page"] { outline: 2px solid CanvasText; }
  .btn, .icon-btn { border: 1px solid ButtonText; }
}

/* ---------- Print: the open note only (F7) ---------- */
@media print {
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  .boot, .auth, .sidebar, .list-pane, .np-top, .np-toolbar, .scrim, .fab, .toasts, .outline, .np-banner, .backlinks, .skip-link, dialog, .menu, #np-icons { display: none !important; }
  .app { display: block !important; height: auto !important; }
  .note-pane, .np-scroll { display: block !important; overflow: visible !important; height: auto !important; padding: 0 !important; background: #fff !important; transform: none !important; visibility: visible !important; box-shadow: none !important; }
  .paper-wrap { max-width: none; }
  .paper { box-shadow: none !important; border: 0 !important; padding: 0 !important; min-height: 0 !important; background: #fff !important; color: #000; }
  .note-title { color: #000 !important; font-size: 22pt; }
  .note-meta { color: #444 !important; }
  .chip { background: none !important; color: #000 !important; border: 1px solid #999; }
}
