/* ============================== theme ============================== */
:root {
  --bg: #f7f6f3; --surface: #ffffff; --raised: #ffffff; --text: #1f2328; --muted: #6b6f76; --border: #e4e2dc;
  --hover: rgba(31,35,40,.06); --active: #fdefc4; --accent: #f2b705; --accent-ink: #4a3600; --primary: #2463eb;
  --shadow-sm: 0 1px 2px rgba(31,35,40,.06), 0 1px 3px rgba(31,35,40,.08);
  --shadow: 0 2px 6px rgba(31,35,40,.08), 0 8px 24px rgba(31,35,40,.10);
  --danger: #d93025; --search: #ecebe6; --mark: #ffe066; --radius: 14px;
  --n-default: transparent; --n-red: #fbd3cf; --n-orange: #fde0c8; --n-yellow: #fff4b8; --n-green: #dcf1cf;
  --n-teal: #c9eae2; --n-blue: #d6e6f5; --n-purple: #e6dbf3; --n-pink: #f8dde6; --n-brown: #ece4d6; --n-gray: #ebebee;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #17181b; --surface: #1f2125; --raised: #26282d; --text: #e8eaed; --muted: #9aa0a6; --border: #34363c;
  --hover: rgba(232,234,237,.07); --active: #4a3a12; --accent: #f6c33f; --accent-ink: #2b2000; --primary: #8ab4f8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5); --shadow: 0 4px 12px rgba(0,0,0,.45), 0 12px 32px rgba(0,0,0,.35);
  --danger: #f28b82; --search: #26282d; --mark: #8a6d00;
  --n-red: #5c2b29; --n-orange: #614a19; --n-yellow: #635d19; --n-green: #345920;
  --n-teal: #16504b; --n-blue: #2d555e; --n-purple: #42275e; --n-pink: #5b2245; --n-brown: #442f19; --n-gray: #3c3f43;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body.big-text .main, body.big-text .editor, body.big-text .dialog { zoom: 1.15; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
textarea:focus-visible, .composer input:focus-visible, .ed-head input:focus-visible, .search input:focus-visible { outline: none; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ============================== buttons ============================== */
.icon-btn { width: 40px; height: 40px; border-radius: 50%; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: none; transition: background .15s, color .15s, transform .1s; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm svg { width: 18px; height: 18px; }
.btn { border-radius: 10px; padding: 8px 18px; font-weight: 600; transition: filter .15s, background .15s; }
.btn.primary { background: var(--primary); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #17181b; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .6; cursor: default; }
.btn.text:hover, .btn.small:hover { background: var(--hover); }
.btn.small { padding: 4px 12px; border: 1px solid var(--border); font-size: 13px; background: var(--surface); }
.btn.wide { width: 100%; padding: 12px; }
.link { color: var(--primary); font-weight: 600; padding: 0; }

/* ============================== splash ============================== */
.splash { min-height: 100vh; display: grid; place-content: center; gap: 14px; text-align: center; color: var(--muted); padding: 24px; }
.splash .logo { animation: pulse 1.4s ease-in-out infinite; }
.splash p { margin: 0; max-width: 300px; }

/* ============================== auth ============================== */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background:
  radial-gradient(1200px 600px at 10% -10%, rgba(242,183,5,.18), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, rgba(36,99,235,.12), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow); display: grid; gap: 14px; animation: pop .25s ease-out; }
.auth-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-card input, .dialog input, .dialog select { border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; background: var(--bg); font-size: 16px; }
.auth-card input:focus, .dialog input:focus, .dialog select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.auth-sub { margin: -6px 0 4px; color: var(--muted); }
.auth-switch { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
.optional { font-weight: 400; color: var(--muted); }
.fine { margin: 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.err { color: var(--danger); margin: 0; font-size: 13.5px; }
.err:empty { display: none; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 600; color: var(--text); white-space: nowrap; letter-spacing: -.01em; }
.brand.big { font-size: 26px; font-weight: 700; justify-content: center; }
.logo { width: 30px; height: 34px; border-radius: 8px; background: linear-gradient(160deg, #ffd45c, #f2b705); position: relative; flex: none; box-shadow: 0 2px 6px rgba(242,183,5,.35); }
.logo::after { content: ""; position: absolute; left: 7px; right: 7px; top: 10px; height: 13px; border-top: 2.5px solid #fff; border-bottom: 2.5px solid #fff; }

/* ============================== top bar ============================== */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; height: calc(64px + var(--safe-top)); padding: var(--safe-top) 12px 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.search { flex: 1; min-width: 0; max-width: 720px; margin-left: 40px; display: flex; align-items: center; gap: 10px; background: var(--search); border-radius: 12px; padding: 0 8px 0 14px; height: 46px; color: var(--muted); transition: background .15s, box-shadow .15s; }
.search:focus-within { background: var(--surface); box-shadow: var(--shadow-sm); }
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 16px; color: var(--text); min-width: 0; }
.search input::-webkit-search-cancel-button { display: none; }
.search .icon-btn { width: 32px; height: 32px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #7e57c2; color: #fff; font-weight: 700; margin-left: 6px; text-transform: uppercase; box-shadow: var(--shadow-sm); }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--search); border-radius: 999px; padding: 5px 10px; white-space: nowrap; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #f2b705; animation: pulse 1.2s ease-in-out infinite; }
.conn.offline::before { background: var(--danger); animation: none; }
.menu { position: absolute; z-index: 60; background: var(--raised); border-radius: 12px; box-shadow: var(--shadow); padding: 6px 0; min-width: 220px; border: 1px solid var(--border); animation: pop .12s ease-out; }
.menu button { display: block; width: 100%; text-align: left; padding: 9px 18px; font-size: 14px; }
.menu button:hover { background: var(--hover); }
.menu .danger { color: var(--danger); }
.menu-note { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.menu-head { padding: 8px 18px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-sep { border-top: 1px solid var(--border); margin: 4px 0; }
.account-menu { top: calc(58px + var(--safe-top)); right: 12px; position: fixed; }

/* ============================== sidebar ============================== */
.layout { display: flex; }
.sidebar { width: 272px; flex: none; padding-top: 8px; position: sticky; top: calc(64px + var(--safe-top)); height: calc(100vh - 64px - var(--safe-top)); overflow-y: auto; transition: width .15s; }
.sidebar.collapsed { width: 80px; }
.sidebar.collapsed .nav-item span:not(:first-child) { display: none; }
.nav-item { display: flex; align-items: center; gap: 24px; height: 46px; width: calc(100% - 12px); padding: 0 16px 0 24px; border-radius: 0 999px 999px 0; font-size: 14px; font-weight: 500; text-align: left; transition: background .12s; }
.sidebar.collapsed .nav-item { width: 48px; margin-left: 16px; padding-left: 14px; border-radius: 50%; }
.nav-item:hover { background: var(--hover); }
.nav-item span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { display: none; } /* no note counts in the side menu */
.nav-item.sub { height: 38px; padding-left: 44px; gap: 18px; font-weight: 400; }
.nav-item.sub svg { width: 17px; height: 17px; }
.sidebar.collapsed .nav-item.sub { padding-left: 14px; }
.nav-item.active { background: var(--active); font-weight: 600; }
.nav-item.active .count { color: inherit; }
.side-foot { padding: 16px 24px 24px; font-size: 12px; color: var(--muted); }
.label-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; margin-top: 10px; margin-right: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: rgba(0,0,0,.07); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root[data-theme="dark"] .label-chip { background: rgba(255,255,255,.11); }
.label-menu, .sort-menu { min-width: 200px; max-width: 280px; max-height: 340px; overflow-y: auto; }
.label-menu button, .sort-menu button { display: flex; align-items: center; gap: 10px; }
.label-menu button svg, .sort-menu button svg { width: 16px; height: 16px; flex: none; }
.label-menu .sel, .sort-menu .sel { font-weight: 700; }
.lbl-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.lbl-row input { flex: 1; min-width: 0; }
.lbl-empty { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.main { flex: 1; min-width: 0; padding: 24px 16px calc(96px + var(--safe-bottom)); }

/* ============================== banners ============================== */
.vault-bar { display: flex; align-items: center; gap: 10px; max-width: 620px; margin: 0 auto 16px; padding: 8px 12px 8px 16px; border-radius: 12px; background: var(--active); font-size: 14px; }
.vault-bar button { margin-left: auto; }

/* ============================== composer ============================== */
.composer { max-width: 620px; margin: 0 auto 32px; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); transition: box-shadow .2s; }
.composer input, .ed-head input { width: 100%; border: 0; background: none; outline: none; padding: 14px 18px 4px; font-size: 16px; font-weight: 600; }
/* Note name: a short label for the note (like a file name), separate from the title inside it. */
.name-input { width: 100%; border: 0; border-bottom: 1px dashed var(--border); background: none; outline: none; padding: 10px 18px 8px; font-size: 12.5px; font-weight: 700; letter-spacing: .03em; color: var(--muted); }
.name-input::placeholder { font-weight: 500; letter-spacing: 0; }
.name-input:focus { color: var(--text); border-bottom-color: var(--primary); }
.card-name { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .03em; color: var(--muted); margin-bottom: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-name svg { width: 13px; height: 13px; flex: none; }
.card-name span { overflow: hidden; text-overflow: ellipsis; }
.locked-card .card-name { justify-content: center; color: var(--text); font-size: 13.5px; margin: 0; }
.c-body { display: flex; align-items: flex-start; }
.c-body textarea { flex: 1; }
textarea { border: 0; background: none; outline: none; resize: none; padding: 12px 18px; font-size: 15px; line-height: 1.55; width: 100%; }
.composer:not(.open) textarea { font-weight: 500; padding: 14px 18px; }
.composer #cListBtn { margin: 4px 6px; }
.composer.open #cListBtn, .composer.open #cMoreBtn { display: none; }
.composer #cMoreBtn { margin: 4px 6px 4px 0; }
.c-tools, .ed-foot { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 6px; gap: 6px; }
.tool-row { display: flex; align-items: center; flex-wrap: wrap; }

/* ============================== checklist ============================== */
.checklist { flex: 1; padding: 6px 4px 6px 8px; }
.ck { display: flex; align-items: flex-start; gap: 4px; border-radius: 8px; }
.ck input[type=checkbox] { width: 18px; height: 18px; margin: 9px 8px 0; accent-color: var(--accent); flex: none; }
.ck .ck-text { flex: 1; border: 0; background: none; outline: none; padding: 7px 0; font-size: 15px; resize: none; line-height: 1.45; }
.ck.done .ck-text { text-decoration: line-through; color: var(--muted); }
.ck .icon-btn { opacity: 0; }
.ck:hover .icon-btn, .ck:focus-within .icon-btn { opacity: 1; }
@media (hover: none) { .ck .icon-btn { opacity: .6; } }
.ck-add { color: var(--muted); padding: 7px 10px; display: flex; gap: 12px; align-items: center; font-size: 15px; }
.done-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 8px 6px 2px 10px; border-top: 1px solid var(--border); margin-top: 6px; }
.done-head .link { font-size: 12.5px; }

/* ============================== cards ============================== */
.sec { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 0 auto 10px; max-width: 1240px; padding-left: 8px; }
.grid { column-width: 240px; column-gap: 16px; max-width: 1240px; margin: 0 auto 32px; }
.list-view .grid { column-width: auto; columns: 1; max-width: 620px; }
.list-view .sec { max-width: 620px; }
.card { break-inside: avoid; margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); position: relative; cursor: default; transition: box-shadow .18s, transform .18s, border-color .18s; overflow: hidden; box-shadow: var(--shadow-sm); animation: cardIn .22s ease-out both; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card.has-color { border-color: transparent; }
.card-content { padding: 14px 18px 8px; cursor: pointer; }
.card-title { font-weight: 600; font-size: 16px; margin-bottom: 6px; word-wrap: break-word; padding-right: 22px; letter-spacing: -.005em; }
/* Long notes show a preview that fades out at the bottom (tap to read it all). */
.card-body { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.5; max-height: calc(1.5em * 14); overflow: hidden; color: color-mix(in srgb, var(--text) 88%, var(--muted)); }
.card-body.clipped { -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent); mask-image: linear-gradient(to bottom, #000 70%, transparent); }
.card-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; padding-right: 0 !important; }
.card-content { padding-bottom: 10px; }
/* Keep the top-right corner free for the pin button, so it never covers the text. */
.card:not(.locked-card) .card-content::before { content: ""; float: right; width: 26px; height: 24px; }
.card a, .card-body a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.card-items { font-size: 14px; }
.card-items div { display: flex; gap: 8px; padding: 1px 0; }
.card-items .box { width: 14px; height: 14px; border: 2px solid var(--muted); border-radius: 4px; flex: none; margin-top: 3px; }
.card-items .more { color: var(--muted); padding-top: 4px; }
.card-meta { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
/* Buttons share the card's width evenly, so they always fit even on narrow phone cards. */
.card-tools { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); justify-items: center; align-items: center; padding: 0 4px 6px; opacity: 0; transition: opacity .15s; }
.card-tools .icon-btn.sm { width: 100%; max-width: 34px; border-radius: 10px; }
.card:hover .card-tools, .card:focus-within .card-tools { opacity: 1; }
@media (hover: none) { .card-tools { opacity: 1; } .card:hover { transform: none; } }
.card .pin-btn { position: absolute; top: 6px; right: 6px; opacity: 0; }
.card:hover .pin-btn, .card .pin-btn.on { opacity: 1; }
.pin-btn.on { color: var(--text); }
.lock-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.lock-badge svg { width: 14px; height: 14px; }
.locked-card .card-content { display: grid; place-items: center; text-align: center; gap: 6px; padding: 30px 16px 22px; color: var(--muted); }
.locked-card .card-content svg { width: 30px; height: 30px; }
.locked-card .card-content b { color: var(--text); font-weight: 600; }
.empty { text-align: center; color: var(--muted); margin-top: 12vh; font-size: 19px; padding: 0 16px; }
.empty svg { width: 104px; height: 104px; margin: 0 auto 18px; stroke-width: 1; opacity: .35; }
.empty small { display: block; font-size: 14px; margin-top: 8px; }
.trash-note { text-align: center; color: var(--muted); margin: -8px 0 28px; font-size: 14px; }

/* ============================== colors ============================== */
.card[data-color], .editor[data-color] { background: var(--surface); }
[data-color="red"] { background: var(--n-red) !important; } [data-color="orange"] { background: var(--n-orange) !important; }
[data-color="yellow"] { background: var(--n-yellow) !important; } [data-color="green"] { background: var(--n-green) !important; }
[data-color="teal"] { background: var(--n-teal) !important; } [data-color="blue"] { background: var(--n-blue) !important; }
[data-color="purple"] { background: var(--n-purple) !important; } [data-color="pink"] { background: var(--n-pink) !important; }
[data-color="brown"] { background: var(--n-brown) !important; } [data-color="gray"] { background: var(--n-gray) !important; }
.color-menu { display: grid; grid-template-columns: repeat(6, 32px); gap: 6px; padding: 10px; min-width: 0; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(0,0,0,.06); transition: transform .1s; }
.swatch.default { border-color: var(--border); background: var(--surface); }
.swatch.sel { border-color: var(--primary); }
.swatch:hover { transform: scale(1.1); }

/* ============================== overlays ============================== */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(15,16,18,.5); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out; }
.editor { width: 100%; max-width: 620px; max-height: 90vh; display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; animation: pop .18s ease-out; }
.ed-head { display: flex; align-items: center; padding-right: 6px; }
.ed-head input { font-size: 21px; padding: 18px 18px 4px; }
.ed-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
#eBody { flex: 1 0 auto; min-height: 140px; }
.ed-meta { text-align: right; font-size: 12px; color: var(--muted); padding: 2px 18px; }
.dialog { width: 100%; max-width: 420px; background: var(--raised); border-radius: 18px; padding: 22px 24px 16px; box-shadow: var(--shadow); display: grid; gap: 12px; animation: pop .16s ease-out; max-height: 90vh; overflow-y: auto; }
.dialog h3 { margin: 0; font-size: 18px; font-weight: 700; }
.dialog p { margin: 0; color: var(--muted); font-size: 14px; }
#dlgFields { display: grid; gap: 10px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 4px; }
.toast { position: fixed; left: 24px; bottom: calc(24px + var(--safe-bottom)); z-index: 70; background: #2b2d31; color: #fff; border-radius: 12px; padding: 6px 8px 6px 18px; display: flex; align-items: center; gap: 18px; font-size: 14px; box-shadow: var(--shadow); min-height: 46px; animation: up .2s ease-out; }
.toast .btn { color: #f6c33f; }

/* settings */
.set-row { display: grid; gap: 6px; }
.set-row > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.seg { display: flex; background: var(--search); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 7px 6px; border-radius: 8px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.keys { font-size: 13px; color: var(--muted); display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; }
kbd { font: 600 12px/1 ui-monospace, monospace; background: var(--search); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 3px 6px; color: var(--text); }

/* floating new-note button (phones) */
.fab { position: fixed; right: 18px; bottom: calc(20px + var(--safe-bottom)); z-index: 25; width: 60px; height: 60px; border-radius: 20px; background: linear-gradient(160deg, #ffd45c, #f2b705); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(242,183,5,.45), var(--shadow-sm); display: inline-flex; align-items: center; justify-content: center; transition: transform .12s; }
.fab svg { width: 28px; height: 28px; stroke-width: 2.4; }
.fab:active { transform: scale(.92); }

@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 760px) {
  .topbar { gap: 4px; padding: var(--safe-top) 6px 0; }
  .brand #viewTitle { display: none; }
  .search { margin-left: 4px; height: 42px; }
  #layoutBtn, #sortBtn { display: none; }
  .conn { font-size: 0; padding: 5px; }
  .conn::before { margin: 0; }
  .sidebar { position: fixed; left: 0; top: calc(64px + var(--safe-top)); z-index: 30; background: var(--bg); width: 272px; height: calc(100vh - 64px - var(--safe-top)); box-shadow: var(--shadow); transform: translateX(-110%); transition: transform .22s ease; border-radius: 0 18px 18px 0; }
  .sidebar.mobile-open { transform: none; }
  .sidebar.collapsed { width: 272px; }
  .sidebar.collapsed .nav-item span:not(:first-child) { display: inline; }
  .sidebar.collapsed .nav-item { width: calc(100% - 12px); margin-left: 0; padding-left: 24px; border-radius: 0 999px 999px 0; }
  .main { padding: 14px 10px calc(100px + var(--safe-bottom)); }
  .composer { display: none; }
  .fab { display: inline-flex; }
  .grid { column-width: 150px; column-gap: 10px; }
  .card { margin-bottom: 10px; }
  .card-content { padding: 12px 14px 10px; }
  .card-body { max-height: calc(1.5em * 10); }
  .overlay { padding: 0; }
  .editor { max-height: 100vh; height: 100%; max-width: none; border-radius: 0; padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
  .toast { left: 12px; right: 12px; bottom: calc(92px + var(--safe-bottom)); }
}

/* ============================== new note types & extras ============================== */
.editor.wide { max-width: 1040px; height: 92vh; max-height: 92vh; }
.ed-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.adv-btn { display: inline-flex; align-items: center; gap: 6px; border-color: transparent; background: var(--active); font-weight: 700; }
.adv-btn svg { width: 16px; height: 16px; }
.pop-title { padding: 18px; font-size: 18px; }

/* formatted (Advanced) notes */
.rich-bar { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, var(--text)); }
.rb { min-width: 32px; height: 32px; padding: 0 7px; border-radius: 8px; font-weight: 700; font-size: 14px; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.rb:hover, .rb.on { background: var(--hover); }
.rb.on { outline: 2px solid var(--primary); outline-offset: -2px; }
.rb svg { width: 17px; height: 17px; }
.rb-sel { height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 0 6px; font-size: 13px; max-width: 120px; }
.rb-color { text-decoration: underline; text-decoration-color: #d93025; text-decoration-thickness: 3px; }
.rb-hi { color: #f2b705; }
.swatch-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 10px; max-width: 250px; }
.rich { flex: 1 0 auto; min-height: 200px; padding: 12px 18px 24px; outline: none; font-size: 15px; line-height: 1.6; word-wrap: break-word; }
.rich:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rich h1, .rich-preview h1 { font-size: 1.7em; margin: .4em 0; }
.rich h2, .rich-preview h2 { font-size: 1.35em; margin: .4em 0; }
.rich h3, .rich-preview h3 { font-size: 1.15em; margin: .4em 0; }
.rich p, .rich-preview p { margin: .3em 0; }
.rich blockquote, .rich-preview blockquote { border-inline-start: 4px solid var(--accent); margin: .5em 0; padding: .2em .9em; color: var(--muted); }
.rich pre, .rich-preview pre { background: var(--search); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: .9em; }
.rich table, .rich-preview table { border-collapse: collapse; margin: .6em 0; min-width: 50%; }
.rich td, .rich th, .rich-preview td, .rich-preview th { border: 1px solid var(--border); padding: 6px 10px; min-width: 60px; vertical-align: top; }
.rich a { color: var(--primary); }
.rich hr { border: 0; border-top: 2px solid var(--border); margin: 1em 0; }
.rich-preview { white-space: normal; }
.rich-preview > :first-child { margin-top: 0; }

/* spreadsheets */
.sheet-box { flex: 1 0 auto; display: flex; flex-direction: column; min-height: 0; }
.sheet-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--surface); }
.sheet-ref { font: 700 12px/1 ui-monospace, monospace; background: var(--search); border-radius: 6px; padding: 7px 8px; min-width: 42px; text-align: center; }
.sheet-fx { flex: 1 1 220px; min-width: 120px; height: 32px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; background: var(--bg); font: 13px ui-monospace, monospace; }
.sheet-wrap { overflow: auto; padding: 0 0 8px; max-height: 64vh; }
table.sheet { border-collapse: collapse; font-size: 13.5px; }
table.sheet th { background: var(--search); color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px 6px; border: 1px solid var(--border); position: sticky; top: 0; z-index: 1; min-width: 36px; }
table.sheet tbody th { position: sticky; left: 0; top: auto; }
table.sheet th.corner { left: 0; z-index: 2; }
table.sheet td { border: 1px solid var(--border); padding: 0; }
table.sheet td.sel { outline: 2px solid var(--primary); outline-offset: -2px; }
table.sheet input { width: 110px; border: 0; background: none; padding: 6px 7px; font: inherit; outline: none; }
table.sheet input.num { text-align: right; font-variant-numeric: tabular-nums; }
table.sheet input.err { color: var(--danger); }
table.sheet input.bold { font-weight: 700; }
.sheet-help { font-size: 12px; color: var(--muted); padding: 6px 12px; }
table.mini-sheet { border-collapse: collapse; font-size: 12px; width: 100%; table-layout: fixed; }
table.mini-sheet td { border: 1px solid var(--border); padding: 3px 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* drawings */
.draw-box, .draw-pop { flex: 1 0 auto; display: flex; flex-direction: column; min-height: 0; }
.draw-pop { overflow-y: auto; }
.draw-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--surface); }
.draw-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.swatch.sm { width: 24px; height: 24px; }
.draw-wrap { padding: 10px; }
.draw-canvas { display: block; touch-action: none; background: var(--bg); border-radius: 12px; cursor: crosshair; box-shadow: inset 0 0 0 1px var(--border); }
canvas.mini-draw { width: 100%; height: auto; display: block; border-radius: 8px; background: var(--bg); }

/* attachments */
.att-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 8px 18px 14px; }
.att { position: relative; border-radius: 12px; overflow: hidden; background: var(--search); min-height: 60px; }
.att.img img { width: 100%; height: 100%; max-height: 260px; object-fit: cover; display: block; cursor: zoom-in; background: var(--search); }
.att video { width: 100%; display: block; max-height: 300px; background: #000; }
.att.audio, .att.doc { grid-column: 1 / -1; padding: 10px 44px 10px 12px; display: grid; gap: 8px; }
.att audio { width: 100%; }
.att-name { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; min-width: 0; }
.att-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-name small { color: var(--muted); font-weight: 500; margin-left: auto; }
.att-name svg { width: 16px; height: 16px; flex: none; }
.att.doc .btn { justify-self: start; display: inline-flex; align-items: center; gap: 6px; }
.att.doc .btn svg { width: 15px; height: 15px; }
.att-rm { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.55); color: #fff !important; }
.att-err { font-size: 12px; color: var(--danger); padding: 8px; }
.viewer { background: rgba(0,0,0,.92); z-index: 80; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 86vh; object-fit: contain; }
.viewer-bar { position: fixed; bottom: calc(20px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.viewer-bar .btn { display: inline-flex; gap: 6px; align-items: center; background: #fff; color: #1f2328; }
.card-thumb { display: block; width: calc(100% + 36px); margin: -14px -18px 10px; max-height: 260px; object-fit: cover; background: var(--search); }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgba(0,0,0,.07); }
:root[data-theme="dark"] .file-chip { background: rgba(255,255,255,.1); }
.file-chip svg { width: 13px; height: 13px; }

/* audio recording */
.rec-box { display: grid; justify-items: center; gap: 8px; padding: 16px 0 6px; }
.rec-dot { width: 64px; height: 64px; border-radius: 50%; background: #d93025; animation: recPulse 1.4s ease-out infinite; }
.rec-timer { font: 700 30px/1 ui-monospace, monospace; }
.rec-box small { color: var(--muted); }
@keyframes recPulse { 0% { box-shadow: 0 0 0 0 rgba(217,48,37,.45); } 100% { box-shadow: 0 0 0 22px rgba(217,48,37,0); } }

/* lists: drag handle, sub-items, progress */
.ck-grip { width: 18px; flex: none; margin-top: 9px; color: var(--muted); cursor: grab; touch-action: none; opacity: .55; }
.ck-grip svg { width: 18px; height: 18px; }
.ck.dragging { background: var(--hover); box-shadow: var(--shadow-sm); }
.ck .ck-ind { display: none; }
.ck:focus-within .ck-ind { display: inline-flex; opacity: 1; }
.progress { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin: 4px 6px 8px 10px; }
.card .progress { margin: 2px 0 8px; }
.progress-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--search); overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: #188038; border-radius: inherit; transition: width .2s; }
.done-links { display: inline-flex; gap: 14px; }

@media (max-width: 760px) {
  .editor.wide { height: 100%; max-height: 100vh; }
  .rich-bar, .sheet-bar, .draw-bar { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .rich-bar::-webkit-scrollbar, .sheet-bar::-webkit-scrollbar, .draw-bar::-webkit-scrollbar { display: none; }
  .rb, .rb-sel, .swatch.sm { flex: none; }
  .rb-sel { max-width: 96px; }
  .adv-btn { padding: 6px 10px; }
  .card-thumb { width: calc(100% + 28px); margin: -12px -14px 8px; }
  .att-strip { padding: 8px 12px 14px; }
}

/* use without an account / link devices */
.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or-line::before, .or-line::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.guest-btn { background: var(--search); font-weight: 600; }
.guest-btn:hover { background: var(--hover); }
.menu .primary-item { color: var(--primary); font-weight: 700; }
.link-code { display: grid; justify-items: center; gap: 8px; padding: 10px 0; }
.link-code .code { font: 700 34px/1 ui-monospace, monospace; letter-spacing: .12em; padding: 14px 18px; border-radius: 14px; background: var(--search); user-select: all; }
.link-code small { color: var(--muted); }
