/* Заметки — тёплая бумага, тонкие линии, спокойные цвета. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f5f1e8;
  --bg-deep: #efe9dd;
  --surface: #fffdf8;
  --surface-2: #faf6ee;
  --surface-3: #f0eadd;
  --text: #1c1a16;
  --muted: #7a7468;
  --faint: #a39b8d;
  --line: #e3dccf;
  --line-strong: #d2c8b7;
  --accent: #b7792f;
  --accent-strong: #8f5a1c;
  --accent-soft: #f2e3ca;
  --green: #3e7a5c;
  --red: #a8473f;
  --amber: #b7792f;
  --shadow-soft: 0 1px 2px rgba(48, 38, 22, .04), 0 10px 30px rgba(48, 38, 22, .05);
  --shadow-pop: 0 18px 50px rgba(38, 30, 18, .16), 0 2px 8px rgba(38, 30, 18, .08);
  --c-default: #fffdf8;
  --c-sand: #f8eed4;
  --c-blush: #f7e3df;
  --c-sage: #e4ede0;
  --c-sky: #e0ebf4;
  --c-lavender: #e9e3f3;
  --c-peach: #f9e7d6;
  --c-mint: #e0efe9;
  --note-line: rgba(74, 60, 38, .12);
  --hover: rgba(74, 60, 38, .05);
  --radius: 16px;
  --font: "Inter", "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --topbar-h: 68px;
  --sidebar-w: 246px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #14120f;
  --bg-deep: #100e0c;
  --surface: #1d1a16;
  --surface-2: #231f1a;
  --surface-3: #2b261f;
  --text: #f3eee4;
  --muted: #a9a093;
  --faint: #7f7669;
  --line: #332e27;
  --line-strong: #453e34;
  --accent: #e0a45a;
  --accent-strong: #efbd7d;
  --accent-soft: #3a2b18;
  --green: #6ea985;
  --red: #d27a70;
  --amber: #e0a45a;
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, .2), 0 12px 34px rgba(0, 0, 0, .24);
  --shadow-pop: 0 22px 60px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
  --c-default: #211e19;
  --c-sand: #2c2517;
  --c-blush: #2d201f;
  --c-sage: #1f2a21;
  --c-sky: #1b2530;
  --c-lavender: #272130;
  --c-peach: #2c2118;
  --c-mint: #1b2923;
  --note-line: rgba(255, 244, 220, .09);
  --hover: rgba(255, 244, 220, .06);
  color-scheme: dark;
}

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-locked { overflow: hidden; }

[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip-link {
  position: fixed; top: -60px; left: 16px; z-index: 200;
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg);
  text-decoration: none; transition: top .15s;
}
.skip-link:focus { top: 12px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

.only-mobile { display: none !important; }
.muted { color: var(--muted); }
.fineprint { color: var(--faint); font-size: 12px; line-height: 1.5; margin: 0; }
.eyebrow {
  margin: 0 0 8px; color: var(--muted); font-size: 10.5px; font-weight: 650;
  letter-spacing: .13em; text-transform: uppercase;
}

/* ---------- boot ---------- */

.boot {
  position: fixed; inset: 0; z-index: 150;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--bg); color: var(--muted); font-size: 13px;
  transition: opacity .25s, visibility .25s;
}
.boot.is-gone { opacity: 0; visibility: hidden; }
.boot-mark { display: flex; gap: 7px; align-items: flex-end; height: 30px; }
.boot-mark span { width: 7px; border-radius: 4px; background: var(--accent); animation: boot 1s ease-in-out infinite; }
.boot-mark span:nth-child(1) { height: 14px; animation-delay: 0s; }
.boot-mark span:nth-child(2) { height: 25px; animation-delay: .12s; }
.boot-mark span:nth-child(3) { height: 18px; animation-delay: .24s; }
@keyframes boot { 0%, 100% { transform: scaleY(.6); opacity: .5; } 50% { transform: scaleY(1); opacity: 1; } }

/* ---------- shared controls ---------- */

.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; line-height: 1; text-decoration: none;
  transition: transform .15s, background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { transform: translateY(-1px); background: #000; }
[data-theme="dark"] .btn-primary:hover { background: #fff8ea; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(168, 71, 63, .3); }
.btn-danger:hover { background: rgba(168, 71, 63, .08); }
.btn-wide { width: 100%; }
.btn-primary .icon, .btn-secondary .icon, .btn-danger .icon { width: 18px; height: 18px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  padding: 0; border: 1px solid transparent; border-radius: 50%;
  background: transparent; color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.small .icon { width: 16px; height: 16px; }
.icon-btn.is-active { color: var(--accent-strong); background: var(--accent-soft); }

.text-btn, .link-btn {
  border: 0; background: transparent; color: var(--accent-strong);
  padding: 4px 2px; font-size: 13.5px; font-weight: 600; border-radius: 6px;
}
.text-btn:hover, .link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-btn:disabled { color: var(--faint); cursor: default; text-decoration: none; }
.text-btn-quiet { color: var(--muted); font-weight: 500; }
.link-btn { padding: 0; font-size: 12.5px; }

.text-input {
  width: 100%; height: 44px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
  outline: none;
}
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2);
  color: var(--muted); font: 11px/1 var(--mono);
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot-green { background: var(--green); }

/* ---------- login ---------- */

.login {
  min-height: 100dvh; padding: 40px 24px;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 12% 8%, rgba(183, 121, 47, .08), transparent 38%),
    radial-gradient(circle at 92% 90%, rgba(91, 127, 103, .08), transparent 34%),
    var(--bg);
}
.login-inner {
  width: min(1120px, 100%);
  display: grid; grid-template-columns: 1.08fr .92fr; gap: 64px; align-items: center;
}
.login-story { position: relative; padding: 10px 0 20px; }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 44px; font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 1px solid rgba(143, 90, 28, .28); border-radius: 10px;
  background: #f4d58c; color: #6e4414;
}
[data-theme="dark"] .brand-mark { background: #e3b463; color: #3c2508; border-color: rgba(255, 226, 165, .2); }
.brand-mark svg { width: 21px; height: 21px; }
.login-story h1 { margin: 0 0 20px; font-size: clamp(36px, 4.4vw, 58px); line-height: 1.04; letter-spacing: -.045em; font-weight: 600; }
.login-lead { margin: 0 0 26px; max-width: 44ch; color: var(--muted); font-size: 15.5px; line-height: 1.62; }
.login-points { list-style: none; margin: 0 0 46px; padding: 0; display: grid; gap: 10px; color: var(--muted); font-size: 14px; }
.login-points li { display: flex; align-items: center; gap: 10px; }
.point-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex: none; }

.login-stack { position: relative; height: 214px; margin-left: 8px; max-width: 390px; }
.stack-card {
  position: absolute; overflow: hidden; display: flex; flex-direction: column; gap: 5px;
  padding: 16px 18px; border: 1px solid var(--note-line); border-radius: 14px;
  background: var(--surface); color: var(--muted); font-size: 12.5px; line-height: 1.45;
  box-shadow: var(--shadow-soft);
}
.stack-card strong { color: var(--text); font-size: 14px; font-weight: 600; }
.stack-card em { color: var(--faint); font-style: normal; font-size: 11px; margin-top: 4px; }
.stack-a { width: 230px; left: 0; top: 6px; transform: rotate(-3.2deg); background: var(--c-sand); }
.stack-b { width: 250px; left: 116px; top: 40px; transform: rotate(2.4deg); z-index: 2; background: var(--c-sky); }
.stack-c { width: 190px; left: 58px; top: 142px; transform: rotate(-1.2deg); background: var(--c-default); flex-direction: row; align-items: center; gap: 9px; }
.stack-pin { position: absolute; right: 13px; top: 12px; width: 13px; height: 13px; border: 1.6px solid var(--accent); border-radius: 50% 50% 50% 2px; transform: rotate(45deg); }
.stack-check { color: var(--green); font-weight: 700; }

.login-panel { display: flex; flex-direction: column; gap: 18px; }
.login-card {
  padding: 32px; border: 1px solid var(--line); border-radius: 22px;
  background: var(--surface); box-shadow: var(--shadow-soft);
}
.login-card h2 { margin: 0 0 10px; font-size: 26px; line-height: 1.15; letter-spacing: -.03em; font-weight: 600; }
.login-card > .muted { margin: 0 0 22px; font-size: 14px; }
.login-card .btn-primary { min-height: 48px; }
.code-step { margin-top: 20px; display: grid; gap: 9px; }
.code-step label, .key-step label { font-size: 11px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.code-input {
  width: 100%; height: 58px; padding: 0 14px; text-align: center;
  border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface-2);
  font: 26px/1 var(--mono); letter-spacing: .32em; outline: none;
}
.code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.code-actions { display: flex; gap: 10px; align-items: center; }
.code-actions .btn-primary { flex: 1; }
.key-step { margin-top: 16px; display: grid; gap: 9px; }
.login-error {
  margin: 14px 0 0; padding: 10px 12px; border-radius: 9px;
  background: rgba(168, 71, 63, .09); border: 1px solid rgba(168, 71, 63, .18);
  color: var(--red); font-size: 13px; line-height: 1.45;
}
.login-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 12px; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.login-divider::before, .login-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.login-local-link { margin-top: 18px; text-align: center; }
.login-foot { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12px; padding-left: 6px; }
.login-card.is-shaking { animation: shake .35s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- app shell ---------- */

.app { min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h); padding: 0 26px;
  display: grid; grid-template-columns: auto minmax(220px, 620px) auto; align-items: center; gap: 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 16.5px; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; }
.brand .brand-mark { width: 31px; height: 31px; border-radius: 9px; }
.brand .brand-mark svg { width: 19px; height: 19px; }

.search-wrap { position: relative; display: flex; align-items: center; justify-self: stretch; }
.search-wrap .search-icon { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
#searchInput {
  width: 100%; height: 42px; padding: 0 78px 0 42px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  outline: none; font-size: 14px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#searchInput::placeholder { color: var(--faint); }
#searchInput:focus { border-color: var(--line-strong); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-kbd { position: absolute; right: 12px; }
.search-clear { position: absolute; right: 8px; width: 28px; height: 28px; }
.search-clear .icon { width: 16px; height: 16px; }

.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.sync { display: inline-flex; align-items: center; gap: 7px; margin-right: 6px; color: var(--faint); font-size: 11.5px; white-space: nowrap; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(62, 122, 92, .12); transition: background .2s, box-shadow .2s; }
.sync.is-saving .sync-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(183, 121, 47, .14); animation: pulse 1s infinite; }
.sync.is-offline .sync-dot { background: var(--red); box-shadow: 0 0 0 3px rgba(168, 71, 63, .12); }
.sync.is-error .sync-dot { background: var(--red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

.new-btn { height: 42px; padding: 0 17px 0 14px; }
.new-btn .icon { width: 18px; height: 18px; }

.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }

/* ---------- sidebar ---------- */

.sidebar {
  position: sticky; top: var(--topbar-h); align-self: start;
  height: calc(100dvh - var(--topbar-h));
  padding: 22px 14px 18px;
  display: flex; flex-direction: column; gap: 26px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, var(--surface));
  overflow-y: auto;
}
.side-nav { display: grid; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  height: 40px; padding: 0 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); text-align: left;
  font-size: 13.5px; font-weight: 500;
  transition: background .13s, color .13s;
}
.nav-item .icon { width: 18px; height: 18px; }
.nav-item span { flex: 1; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.is-active { background: var(--surface); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.nav-item.is-active .icon { color: var(--accent-strong); }
.nav-count { font: 11px/1 var(--mono); color: var(--faint); font-weight: 500; }
.nav-item.is-active .nav-count { color: var(--muted); }
.nav-item-quiet { margin-top: auto; }

.side-section { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 10px; }
.side-head > span { color: var(--muted); font-size: 10.5px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; }
.label-list { display: grid; gap: 2px; }
.label-item {
  display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  font-size: 13px; text-align: left; min-width: 0;
}
.label-item:hover { background: var(--hover); color: var(--text); }
.label-item.is-active { background: var(--surface); color: var(--text); font-weight: 600; }
.label-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.label-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-count { font: 10.5px/1 var(--mono); color: var(--faint); }
.side-empty { margin: 2px 10px; color: var(--faint); font-size: 12px; }

.side-foot { margin-top: auto; display: grid; gap: 14px; }
.side-note {
  display: flex; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--muted); font-size: 11.8px; line-height: 1.45;
}
.side-note p { margin: 0; }
.spark { color: var(--accent); flex: none; }
.spark .icon { width: 16px; height: 16px; }

.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(20, 16, 10, .38); backdrop-filter: blur(2px); }

/* ---------- main ---------- */

.main { min-width: 0; padding: 30px 34px 120px; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.view-head h1 { margin: 0; font-size: 33px; line-height: 1.1; letter-spacing: -.035em; font-weight: 600; }
.view-head .eyebrow { margin-bottom: 6px; }
.view-tools { display: flex; align-items: center; gap: 14px; padding-bottom: 3px; }
.result-count { color: var(--muted); font-size: 12px; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--muted); font-size: 12.5px;
}
.sort-btn:hover { border-color: var(--line); background: var(--surface); color: var(--text); }
.sort-btn .icon { width: 14px; height: 14px; }

.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 20px; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 12.8px;
}
.banner.is-warn { border-color: rgba(183, 121, 47, .3); background: rgba(183, 121, 47, .07); color: var(--accent-strong); }
.banner .icon { width: 16px; height: 16px; }
.banner strong { color: var(--text); }
.banner-actions { display: flex; gap: 8px; margin-left: auto; }

.section-label { margin: 0 0 12px; color: var(--muted); font-size: 10.5px; font-weight: 650; letter-spacing: .13em; text-transform: uppercase; }
.notes-section + .notes-section { margin-top: 30px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 18px; align-items: start; }
.grid.masonry { display: block; position: relative; }
.grid.masonry > .note { position: absolute; top: 0; left: 0; margin: 0; }
.grid.is-animated > .note { transition: transform .2s ease, opacity .2s ease; }

/* ---------- note cards ---------- */

.note {
  --note-bg: var(--c-default);
  position: relative; display: flex; flex-direction: column;
  min-width: 0; padding: 16px 16px 11px;
  border: 1px solid var(--note-line); border-radius: 15px;
  background: var(--note-bg); color: var(--text);
  box-shadow: 0 1px 0 rgba(50, 40, 22, .02);
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.note:hover { border-color: rgba(74, 60, 38, .24); box-shadow: 0 6px 22px rgba(48, 38, 22, .07); transform: translateY(-2px); }
[data-theme="dark"] .note:hover { border-color: rgba(255, 244, 220, .16); box-shadow: 0 8px 26px rgba(0, 0, 0, .32); }
.note:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.note[data-color="sand"] { --note-bg: var(--c-sand); }
.note[data-color="blush"] { --note-bg: var(--c-blush); }
.note[data-color="sage"] { --note-bg: var(--c-sage); }
.note[data-color="sky"] { --note-bg: var(--c-sky); }
.note[data-color="lavender"] { --note-bg: var(--c-lavender); }
.note[data-color="peach"] { --note-bg: var(--c-peach); }
.note[data-color="mint"] { --note-bg: var(--c-mint); }

.note-top { position: absolute; top: 9px; right: 9px; display: flex; gap: 2px; z-index: 2; }
.note-pin, .note-menu {
  display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  opacity: 0; transition: opacity .13s, background .13s, color .13s;
}
.note:hover .note-pin, .note:hover .note-menu, .note:focus-within .note-pin, .note:focus-within .note-menu { opacity: 1; }
.note-pin:hover, .note-menu:hover { background: rgba(74, 60, 38, .08); color: var(--text); }
[data-theme="dark"] .note-pin:hover, [data-theme="dark"] .note-menu:hover { background: rgba(255, 244, 220, .08); }
.note-pin .icon, .note-menu .icon { width: 17px; height: 17px; }
.note.is-pinned .note-pin {
  opacity: 1;
  color: var(--accent-strong);
  background: var(--accent-soft);
}
.note.is-pinned .note-pin .icon {
  fill: currentColor;
  stroke: currentColor;
}
.note.is-pinned .note-pin:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.note.is-trashed .note-menu { opacity: 1; }

.note-title {
  margin: 0 34px 6px 0; font-size: 15.5px; line-height: 1.35; font-weight: 650;
  letter-spacing: -.01em; overflow-wrap: anywhere;
}
.note-title:empty { display: none; }

.note-body {
  position: relative; max-height: 330px; overflow: hidden;
  color: color-mix(in srgb, var(--text) 86%, var(--muted));
  font-size: 13.7px; line-height: 1.52; overflow-wrap: anywhere;
}
.note-body.is-clipped::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 48px;
  background: linear-gradient(to bottom, transparent, var(--note-bg));
  pointer-events: none;
}
.note-body p { margin: 0 0 8px; }
.note-body p:last-child { margin-bottom: 0; }
.note-body h1, .note-body h2, .note-body h3 { margin: 4px 0 6px; font-size: 14.5px; line-height: 1.3; }
.note-body ul, .note-body ol { margin: 0 0 8px; padding-left: 18px; }
.note-body blockquote { margin: 0 0 8px; padding-left: 10px; border-left: 2px solid var(--line-strong); color: var(--muted); }
.note-body code { padding: 1px 4px; border-radius: 4px; background: rgba(74, 60, 38, .08); font: 12px/1.4 var(--mono); }
.note-body pre { margin: 0 0 8px; padding: 9px 10px; border-radius: 8px; background: rgba(74, 60, 38, .07); overflow-x: auto; }
.note-body pre code { padding: 0; background: none; }
.note-body a { color: var(--accent-strong); text-underline-offset: 2px; }
.note-body mark, .note-title mark { background: #f4d58c; color: #3a2708; border-radius: 3px; padding: 0 1px; }
[data-theme="dark"] .note-body mark, [data-theme="dark"] .note-title mark { background: #8a6428; color: #fff4dc; }

.note-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin: 10px 0 4px; }
.note-images img { width: 100%; height: 96px; object-fit: cover; border-radius: 8px; display: block; background: var(--surface-3); }
.note-images.is-single img { height: 170px; }

.note-checklist { display: grid; gap: 3px; margin: -2px 0 2px; }
.check-row { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.check-box {
  width: 16px; height: 16px; margin-top: 2px; flex: none; border: 1.4px solid var(--line-strong);
  border-radius: 4px; background: transparent; display: grid; place-items: center; padding: 0;
  color: transparent; transition: background .13s, border-color .13s, color .13s;
}
.check-box .icon { width: 11px; height: 11px; stroke-width: 2.4; }
.check-box[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #fff8ea; }
.check-text { font-size: 13.6px; line-height: 1.45; overflow-wrap: anywhere; }
.check-row.is-done .check-text { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.check-more { margin: 4px 0 0 24px; color: var(--faint); font-size: 11.5px; }

.note-labels { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 7px; border: 1px solid var(--note-line); border-radius: 999px;
  background: rgba(255, 255, 255, .32); color: var(--muted);
  font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; line-height: 1.3;
}
[data-theme="dark"] .chip { background: rgba(255, 244, 220, .04); }
.chip-dot { width: 5px; height: 5px; border-radius: 50%; }

.note-foot { display: flex; align-items: center; gap: 6px; margin-top: 11px; color: var(--faint); font-size: 10.8px; min-height: 20px; }
.note-foot time { white-space: nowrap; }
.note-author { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-strong); font-weight: 600; }
.note-author::after { content: "·"; color: var(--faint); font-weight: 400; margin-left: 2px; }
.note-author .mini-avatar {
  display: grid; place-items: center; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong); font-size: 8px; font-weight: 700;
}
.note-foot-spacer { flex: 1; }
.note-trash-date { color: var(--red); }

/* ---------- empty ---------- */

.empty { display: grid; justify-items: center; text-align: center; padding: 70px 20px; }
.empty-art { position: relative; width: 150px; height: 100px; margin-bottom: 22px; }
.empty-page { position: absolute; width: 82px; height: 96px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.empty-page.page-a { left: 12px; top: 8px; transform: rotate(-8deg); background: var(--c-sand); }
.empty-page.page-b { left: 50px; top: 0; transform: rotate(6deg); background: var(--c-sky); }
.empty-page.page-c { left: 32px; top: 10px; transform: rotate(-1deg); display: grid; place-items: center; color: var(--faint); }
.empty-page.page-c svg { width: 46px; height: 46px; }
.empty h2 { margin: 0 0 7px; font-size: 21px; letter-spacing: -.02em; font-weight: 600; }
.empty p { margin: 0 0 20px; max-width: 44ch; color: var(--muted); font-size: 13.5px; }
.empty-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }

/* ---------- mobile nav ---------- */

.mobile-nav { display: none; }

/* ---------- dialogs ---------- */

dialog { color: var(--text); }
dialog::backdrop { background: rgba(24, 19, 12, .42); backdrop-filter: blur(3px); }

.editor {
  padding: 0; border: 0; background: transparent;
  width: min(820px, calc(100vw - 32px)); max-width: 820px; max-height: calc(100dvh - 32px);
  margin: auto; overflow: visible;
}
.editor[open] { animation: dialog-in .18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

.editor-card {
  --note-bg: var(--c-default);
  display: flex; flex-direction: column; max-height: calc(100dvh - 32px);
  border: 1px solid var(--note-line); border-radius: 20px;
  background: var(--note-bg); box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.editor-card[data-color="sand"] { --note-bg: var(--c-sand); }
.editor-card[data-color="blush"] { --note-bg: var(--c-blush); }
.editor-card[data-color="sage"] { --note-bg: var(--c-sage); }
.editor-card[data-color="sky"] { --note-bg: var(--c-sky); }
.editor-card[data-color="lavender"] { --note-bg: var(--c-lavender); }
.editor-card[data-color="peach"] { --note-bg: var(--c-peach); }
.editor-card[data-color="mint"] { --note-bg: var(--c-mint); }

.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 4px; }
.editor-head-left, .editor-head-right { display: flex; align-items: center; gap: 2px; }
.editor-head .icon-btn:hover { background: rgba(74, 60, 38, .08); }
[data-theme="dark"] .editor-head .icon-btn:hover { background: rgba(255, 244, 220, .08); }

.editor-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 2px 18px 0; padding: 8px 11px; border-radius: 9px;
  background: rgba(183, 121, 47, .12); border: 1px solid rgba(183, 121, 47, .24);
  color: var(--accent-strong); font-size: 12px;
}
.editor-banner .text-btn { margin-left: auto; font-size: 12px; }

.editor-body { padding: 8px 22px 4px; overflow-y: auto; min-height: 160px; }
.editor-title {
  width: 100%; padding: 8px 0; border: 0; background: transparent; outline: none;
  font-size: 22px; line-height: 1.3; font-weight: 650; letter-spacing: -.025em;
}
.editor-title::placeholder { color: var(--faint); }
.editor-text {
  width: 100%; min-height: 190px; padding: 4px 0 10px; border: 0; background: transparent;
  outline: none; resize: none; font-size: 14.6px; line-height: 1.62; overflow: hidden;
}
.editor-text::placeholder { color: var(--faint); }

.editor-images { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0 10px; }
.editor-image { position: relative; width: 112px; height: 90px; border-radius: 9px; overflow: hidden; border: 1px solid var(--note-line); background: var(--surface-3); }
.editor-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.editor-image-remove {
  position: absolute; top: 4px; right: 4px; width: 23px; height: 23px;
  display: grid; place-items: center; border: 0; border-radius: 50%;
  background: rgba(20, 16, 10, .62); color: #fff; opacity: 0; transition: opacity .13s;
}
.editor-image:hover .editor-image-remove, .editor-image-remove:focus-visible { opacity: 1; }
.editor-image-remove .icon { width: 13px; height: 13px; }
.editor-image.is-loading { display: grid; place-items: center; color: var(--muted); }
.editor-image.is-loading::after { content: ""; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.editor-checklist { display: grid; gap: 2px; padding: 2px 0 4px; }
.edit-check-row { display: flex; align-items: flex-start; gap: 7px; padding: 1px 0; border-radius: 6px; }
.edit-check-row.is-dragging { opacity: .4; }
.check-handle {
  width: 20px; height: 30px; display: grid; place-items: center; padding: 0;
  border: 0; background: transparent; color: var(--faint); cursor: grab; opacity: 0;
}
.edit-check-row:hover .check-handle, .check-handle:focus-visible { opacity: 1; }
.check-handle .icon { width: 14px; height: 14px; }
.edit-check-row .check-box { margin-top: 7px; }
.check-input {
  flex: 1; min-width: 0; padding: 5px 2px; border: 0; background: transparent;
  outline: none; resize: none; font-size: 14.3px; line-height: 1.5; overflow: hidden;
}
.check-input:focus { box-shadow: inset 0 -1px 0 var(--line-strong); }
.edit-check-row.is-done .check-input { color: var(--faint); text-decoration: line-through; }
.check-remove { width: 26px; height: 28px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--faint); opacity: 0; border-radius: 6px; }
.edit-check-row:hover .check-remove, .check-remove:focus-visible { opacity: 1; }
.check-remove:hover { background: rgba(74, 60, 38, .07); color: var(--red); }
.check-remove .icon { width: 14px; height: 14px; }

.add-item {
  display: inline-flex; align-items: center; gap: 7px; margin: 3px 0 10px 27px; padding: 4px 2px;
  border: 0; background: transparent; color: var(--muted); font-size: 13px;
}
.add-item:hover { color: var(--text); }
.add-item .icon { width: 15px; height: 15px; }

.editor-labels { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 0 8px; }
.editor-labels .chip { background: rgba(74, 60, 38, .06); }
[data-theme="dark"] .editor-labels .chip { background: rgba(255, 244, 220, .06); }
.chip-remove { border: 0; background: transparent; color: var(--muted); padding: 0; display: grid; place-items: center; }
.chip-remove .icon { width: 11px; height: 11px; }

.editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px 12px 22px; border-top: 1px solid var(--note-line); }
.editor-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.editor-status { color: var(--faint); font-size: 11.5px; }
.editor-status.is-error { color: var(--red); }
.editor-author { color: var(--accent-strong); font-size: 11px; }
.editor-foot-actions { display: flex; align-items: center; gap: 8px; }
.editor-foot .btn-primary { min-height: 38px; padding: 0 20px; }
.type-toggle { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ---------- settings ---------- */

.settings {
  padding: 0; border: 0; background: transparent;
  width: min(660px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto;
}
.settings-card {
  display: flex; flex-direction: column; max-height: calc(100dvh - 32px);
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface);
  box-shadow: var(--shadow-pop); overflow: hidden;
}
.settings-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 24px 16px; border-bottom: 1px solid var(--line); }
.settings-head h2 { margin: 0; font-size: 23px; letter-spacing: -.03em; font-weight: 600; }
.settings-body { overflow-y: auto; padding: 4px 24px 26px; }
.settings-section { padding: 20px 0; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: 0; padding-bottom: 4px; }
.settings-section h3 { margin: 0 0 12px; font-size: 13px; font-weight: 650; }
.settings-section > .muted { margin: -4px 0 12px; font-size: 12.5px; }
.settings-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 5px 0; color: var(--muted); font-size: 13px; }
.settings-row strong { color: var(--text); font-weight: 600; font-size: 12.5px; text-align: right; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.settings-actions .btn-secondary { min-height: 38px; padding: 0 14px; font-size: 12.5px; }
.settings-shortcuts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 18px; margin-bottom: 14px; }
.settings-shortcuts > div { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.settings-about { display: flex; gap: 12px; align-items: flex-start; }
.about-mark { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 10px; background: #f4d58c; color: #6e4414; }
.about-mark svg { width: 23px; height: 23px; }
.settings-about strong { display: block; font-size: 13px; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px;
}
.segmented button .icon { width: 15px; height: 15px; }
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(40, 30, 16, .08); font-weight: 600; }

/* ---------- history ---------- */

.history {
  padding: 0; border: 0; background: transparent;
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto;
}
.history-card { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-pop); overflow: hidden; }
.history-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 22px 14px; border-bottom: 1px solid var(--line); }
.history-head h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; font-weight: 600; }
.history-list { overflow-y: auto; padding: 8px 14px 18px; }
.history-item { padding: 12px 8px; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: 0; }
.history-item.is-current { background: var(--surface-2); border-radius: 10px; border-bottom-color: transparent; }
.history-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; color: var(--faint); font-size: 11px; }
.history-author { color: var(--accent-strong); font-weight: 650; }
.history-title { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; overflow-wrap: anywhere; }
.history-preview { color: var(--muted); font-size: 12px; line-height: 1.45; max-height: 54px; overflow: hidden; overflow-wrap: anywhere; }
.history-actions { margin-top: 7px; }
.history-empty { padding: 34px 10px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- popovers ---------- */

.popover-layer { position: fixed; inset: 0; z-index: 90; }
.popover {
  position: fixed; z-index: 91; min-width: 190px; max-width: 300px;
  padding: 6px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow-pop);
  animation: pop-in .12s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.popover-title { padding: 7px 10px 5px; color: var(--faint); font-size: 10px; font-weight: 650; letter-spacing: .11em; text-transform: uppercase; }
.popover-item {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 0 9px;
  border: 0; border-radius: 7px; background: transparent; color: var(--text); text-align: left; font-size: 12.8px;
}
.popover-item:hover { background: var(--surface-2); }
.popover-item.is-active { background: var(--surface-2); color: var(--accent-strong); font-weight: 600; }
.popover-item.is-active .icon { color: var(--accent-strong); }
.popover-item .icon { width: 16px; height: 16px; color: var(--muted); }
.popover-item.is-danger { color: var(--red); }
.popover-item.is-danger .icon { color: var(--red); }
.popover-sep { height: 1px; margin: 5px 7px; background: var(--line); }
.popover-hint { padding: 5px 10px 7px; color: var(--faint); font-size: 10.5px; }

.color-grid { display: grid; grid-template-columns: repeat(4, 34px); gap: 7px; padding: 7px; }
.color-swatch {
  width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--c-default); position: relative;
}
.color-swatch[data-color="sand"] { background: var(--c-sand); }
.color-swatch[data-color="blush"] { background: var(--c-blush); }
.color-swatch[data-color="sage"] { background: var(--c-sage); }
.color-swatch[data-color="sky"] { background: var(--c-sky); }
.color-swatch[data-color="lavender"] { background: var(--c-lavender); }
.color-swatch[data-color="peach"] { background: var(--c-peach); }
.color-swatch[data-color="mint"] { background: var(--c-mint); }
.color-swatch.is-active::after { content: ""; position: absolute; inset: -3px; border: 1.5px solid var(--accent); border-radius: 50%; }
.color-swatch .icon { position: absolute; inset: 0; margin: auto; width: 15px; height: 15px; color: var(--text); opacity: 0; }
.color-swatch.is-active .icon { opacity: 1; }

.label-picker { width: 260px; }
.label-picker-list { max-height: 230px; overflow-y: auto; padding: 2px 0; }
.label-check { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 9px; border-radius: 7px; font-size: 12.8px; cursor: pointer; }
.label-check:hover { background: var(--surface-2); }
.label-check input { accent-color: var(--accent); width: 14px; height: 14px; }
.label-check .label-dot { width: 7px; height: 7px; }
.label-check span { flex: 1; }
.label-create { display: flex; gap: 6px; padding: 8px 7px 4px; border-top: 1px solid var(--line); margin-top: 4px; }
.label-create input { flex: 1; min-width: 0; height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); font-size: 12px; outline: none; }
.label-create button { height: 32px; padding: 0 11px; border: 0; border-radius: 7px; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600; }
.label-manage { display: flex; align-items: center; gap: 4px; padding: 0 4px 0 9px; }
.label-manage .label-check { flex: 1; padding: 0; }
.label-manage-actions { display: flex; gap: 1px; opacity: 0; }
.label-manage:hover .label-manage-actions { opacity: 1; }
.label-manage-actions button { width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: transparent; color: var(--faint); border-radius: 5px; }
.label-manage-actions button:hover { background: var(--surface-3); color: var(--text); }
.label-manage-actions .icon { width: 13px; height: 13px; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed; left: 50%; bottom: 22px; z-index: 120;
  display: flex; flex-direction: column-reverse; align-items: center; gap: 8px;
  transform: translateX(-50%); pointer-events: none; width: min(520px, calc(100vw - 28px));
}
.toast {
  display: flex; align-items: center; gap: 11px; max-width: 100%;
  padding: 10px 12px 10px 15px; border: 1px solid var(--line-strong); border-radius: 11px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-pop);
  font-size: 12.5px; line-height: 1.4; pointer-events: auto;
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.toast.is-leaving { opacity: 0; transform: translateY(4px); transition: opacity .18s, transform .18s; }
.toast-message { flex: 1; min-width: 0; }
.toast-action { border: 0; background: transparent; color: #f4d58c; font-weight: 650; font-size: 12px; padding: 2px; white-space: nowrap; }
[data-theme="dark"] .toast-action { color: #3a2708; }
.toast-close { border: 0; background: transparent; color: currentColor; opacity: .55; width: 22px; height: 22px; padding: 0; display: grid; place-items: center; }
.toast-close .icon { width: 13px; height: 13px; }

.drop-overlay { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; background: rgba(24, 19, 12, .45); backdrop-filter: blur(3px); pointer-events: none; }
.drop-overlay > div { display: grid; justify-items: center; gap: 7px; padding: 28px 40px; border: 2px dashed rgba(255, 248, 234, .6); border-radius: 18px; color: #fff8ea; }
.drop-overlay .icon { width: 34px; height: 34px; }
.drop-overlay strong { font-size: 17px; }
.drop-overlay span { font-size: 12.5px; opacity: .8; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; padding: 30px; background: var(--bg); text-align: center; }

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .login-inner { gap: 38px; }
  .login-story h1 { font-size: 44px; }
  .stack-b { left: 80px; }
  .stack-c { left: 26px; }
}

@media (max-width: 920px) {
  :root { --topbar-h: 62px; }
  .topbar { padding: 0 16px; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; }
  .brand-text { display: none; }
  .sync-text { display: none; }
  .sync { margin-right: 0; }
  .only-desktop { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 46;
    width: min(310px, 84vw); height: 100dvh; padding-top: 22px;
    transform: translateX(-104%); transition: transform .22s ease;
    background: var(--bg); border-right: 1px solid var(--line);
    box-shadow: 12px 0 40px rgba(30, 24, 14, .12);
  }
  .sidebar.is-open { transform: none; }
  .main { padding: 22px 18px 110px; }
  .view-head h1 { font-size: 28px; }
  .view-head { margin-bottom: 18px; }
  .mobile-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 42;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    height: calc(60px + env(safe-area-inset-bottom)); padding: 5px 8px env(safe-area-inset-bottom);
    border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(14px);
  }
  .mobile-nav-item {
    display: grid; justify-items: center; gap: 3px; padding: 5px 0;
    border: 0; background: transparent; color: var(--faint); font-size: 9.5px; letter-spacing: .02em;
  }
  .mobile-nav-item .icon { width: 20px; height: 20px; }
  .mobile-nav-item.is-active { color: var(--accent-strong); }
  .mobile-new {
    justify-self: center; width: 50px; height: 50px; margin-bottom: 8px;
    display: grid; place-items: center; border: 0; border-radius: 50%;
    background: var(--text); color: var(--bg); box-shadow: 0 6px 18px rgba(30, 24, 14, .2);
  }
  .mobile-new .icon { width: 23px; height: 23px; }
  .editor { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; }
  .editor-card { height: 100dvh; max-height: none; border-radius: 0; border: 0; }
  .editor-body { padding: 4px 18px; }
  .editor-title { font-size: 21px; }
  .editor-text { min-height: 44vh; }
  .editor-foot { padding: 9px 12px calc(10px + env(safe-area-inset-bottom)) 18px; }
  .settings, .history { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; }
  .settings-card, .history-card { height: 100dvh; max-height: none; border-radius: 0; border: 0; }
  .settings-body { padding-bottom: 40px; }
  .only-mobile { display: inline-grid !important; }
}

@media (max-width: 700px) {
  .login { padding: 24px 18px 34px; align-items: start; }
  .login-inner { grid-template-columns: 1fr; gap: 28px; }
  .login-story { padding-top: 6px; }
  .login-brand { margin-bottom: 26px; }
  .login-story h1 { font-size: clamp(34px, 10vw, 44px); }
  .login-lead { font-size: 14px; margin-bottom: 16px; }
  .login-points, .login-stack { display: none; }
  .login-card { padding: 24px 20px; border-radius: 18px; }
  .login-card h2 { font-size: 23px; }
  .login-foot { justify-content: center; }
  .topbar { grid-template-columns: auto 1fr auto; }
  .search-wrap { grid-column: 1 / -1; grid-row: 2; margin: 0 -2px 9px; }
  .topbar { height: auto; padding-top: 10px; padding-bottom: 0; }
  .search-wrap { display: none; }
  .app.is-searching .search-wrap { display: flex; }
  .new-btn span { display: none; }
  .new-btn { width: 40px; height: 40px; padding: 0; }
  .main { padding: 18px 14px 100px; }
  .view-head { align-items: center; }
  .view-head h1 { font-size: 26px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .note { padding: 14px 14px 10px; }
  .note-body { max-height: 300px; }
  .note-pin, .note-menu { opacity: 1; }
  .toasts { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .settings-shortcuts { grid-template-columns: 1fr; }
  .color-grid { grid-template-columns: repeat(4, 40px); }
  .color-swatch { width: 40px; height: 40px; }
  .popover { max-width: calc(100vw - 24px); }
}

@media (min-width: 921px) {
  .only-mobile { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
  .topbar, .sidebar, .mobile-nav, .toasts, .view-tools, .note-menu, .note-pin { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  .note { break-inside: avoid; box-shadow: none; }
}

/* ярлыки: строка + меню */
.label-row { display: flex; align-items: center; gap: 1px; min-width: 0; }
.label-row .label-item { flex: 1; min-width: 0; }
.label-menu-btn {
  width: 24px; height: 24px; display: grid; place-items: center; flex: none;
  padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--faint);
  opacity: 0; transition: opacity .13s, background .13s, color .13s;
}
.label-row:hover .label-menu-btn, .label-menu-btn:focus-visible { opacity: 1; }
.label-menu-btn:hover { background: var(--hover); color: var(--text); }
.label-menu-btn .icon { width: 14px; height: 14px; }

@media (max-width: 920px) {
  .editor-body { flex: 1; }
  .editor-card { overflow: hidden; }
}
@media (max-width: 700px) {
  .editor-foot { gap: 8px; }
  .editor-meta { max-width: 42%; }
  .editor-author { display: none; }
  .editor-foot-actions { gap: 4px; }
  .type-toggle { font-size: 11.5px; }
}

@media (hover: none) {
  .note-pin, .note-menu, .label-menu-btn, .check-remove, .check-handle, .editor-image-remove { opacity: 1; }
}
.label-check .label-dot, .label-manage .label-dot { flex: none; width: 7px; height: 7px; }
.label-check span:not(.label-dot) { flex: 1; }

/* ---------- журнальная типографика ---------- */

:root {
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
}

.note-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.012em;
  line-height: 1.3;
  text-wrap: balance;
}
.note-body {
  font-family: var(--serif);
  font-size: 14.4px;
  line-height: 1.62;
  font-feature-settings: "onum" 1, "kern" 1;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-wrap: pretty;
}
.note-body p { margin: 0 0 .72em; }
.note-body p:last-child { margin-bottom: 0; }
.note-body h1, .note-body h2, .note-body h3, .note-body h4 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -.012em;
  line-height: 1.28;
}
.note-body h1 { font-size: 19px; margin: 2px 0 8px; }
.note-body h2 { font-size: 17px; margin: 4px 0 7px; }
.note-body h3 { font-size: 15.5px; margin: 3px 0 6px; }
.note-body blockquote {
  margin: 0 0 9px;
  padding: 1px 0 1px 12px;
  border-left: 2px solid var(--line-strong);
  color: var(--muted);
  font-style: italic;
}
.note-body ul, .note-body ol { margin: 0 0 .8em; padding-left: 18px; }
.note-body li { margin: 0 0 3px; }
.note-body hr { border: 0; border-top: 1px solid var(--note-line); margin: 12px 0; }
.note-body strong { font-weight: 700; }
.note-body em { font-style: italic; }
.note-body code, .note-body pre { font-family: var(--mono); }
.note-body code { font-size: 12.2px; }
.note-body pre { font-size: 12px; line-height: 1.5; }
.note-body a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.check-text { font-family: var(--serif); font-size: 14px; line-height: 1.5; }
.chip, .note-foot { font-family: var(--font); }

.editor-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.02em;
}
.editor-text {
  font-family: var(--serif);
  font-size: 16.2px;
  line-height: 1.7;
  font-feature-settings: "onum" 1, "kern" 1;
}
.check-input { font-family: var(--serif); font-size: 14.8px; line-height: 1.55; }

/* панель форматирования */
.format-bar {
  display: flex; align-items: center; gap: 1px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--note-line);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.format-bar::-webkit-scrollbar { display: none; }
.format-btn {
  display: inline-grid; place-items: center;
  min-width: 32px; height: 32px; padding: 0 6px;
  border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-family: var(--font); font-size: 13.5px; line-height: 1;
  flex: none;
  transition: background .13s, color .13s;
}
.format-btn:hover { background: rgba(74, 60, 38, .08); color: var(--text); }
[data-theme="dark"] .format-btn:hover { background: rgba(255, 244, 220, .08); }
.format-btn .icon { width: 16px; height: 16px; }
.format-bold { font-weight: 800; font-size: 15px; }
.format-italic { font-family: var(--serif); font-style: italic; font-size: 16px; font-weight: 600; }
.format-strike { text-decoration: line-through; font-weight: 600; }
.format-quote { font-family: var(--serif); font-size: 20px; line-height: .8; padding-top: 5px; }
.format-ol, .format-code { font-family: var(--mono); font-size: 10.5px; letter-spacing: -.04em; }
.format-code { font-size: 11px; }
.format-break { font-size: 16px; }
.format-sep { width: 1px; height: 18px; margin: 0 5px; background: var(--note-line); flex: none; }

.preview-btn {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--muted); font-size: 12.5px; white-space: nowrap;
}
.preview-btn .icon { width: 15px; height: 15px; }
.preview-btn:hover { color: var(--text); }
.preview-btn.is-active { color: var(--accent-strong); }

/* предпросмотр в редакторе */
.editor-preview {
  max-width: 620px;
  padding: 4px 0 22px;
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.7;
  font-feature-settings: "onum" 1, "kern" 1;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-wrap: pretty;
}
.editor-preview p { margin: 0 0 1em; }
.editor-preview p.has-dropcap::first-letter {
  float: left; font-size: 2.9em; line-height: .82; font-weight: 500;
  padding: .02em .09em 0 0; color: var(--accent-strong);
}
.editor-preview h1, .editor-preview h2, .editor-preview h3 {
  font-family: var(--serif); font-weight: 600; letter-spacing: -.015em; line-height: 1.25;
}
.editor-preview h1 { font-size: 24px; margin: 8px 0 12px; }
.editor-preview h2 { font-size: 20px; margin: 18px 0 8px; }
.editor-preview h3 { font-size: 17px; margin: 14px 0 6px; }
.editor-preview blockquote {
  margin: 0 0 1em; padding: 2px 0 2px 16px;
  border-left: 2px solid var(--line-strong); color: var(--muted); font-style: italic;
}
.editor-preview ul, .editor-preview ol { margin: 0 0 1em; padding-left: 22px; }
.editor-preview li { margin-bottom: 4px; }
.editor-preview a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.editor-preview code { font-family: var(--mono); font-size: 13px; background: rgba(74, 60, 38, .07); padding: 1px 4px; border-radius: 4px; }
.editor-preview pre { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: rgba(74, 60, 38, .07); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.editor-preview hr { border: 0; border-top: 1px solid var(--note-line); margin: 18px 0; }

/* ---------- режим чтения ---------- */

.reader {
  padding: 0; border: 0; background: transparent; margin: auto;
  width: min(940px, calc(100vw - 32px)); max-width: 940px; max-height: calc(100dvh - 32px);
  overflow: visible;
}
.reader-card {
  display: flex; flex-direction: column;
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow-pop);
  overflow-y: auto;
}
.reader-head {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 18px 12px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px);
}
.reader-meta { color: var(--faint); font-size: 10.5px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; }
.reader-actions { display: flex; align-items: center; gap: 6px; }
.reader-edit { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.reader-edit .icon { width: 15px; height: 15px; }
.reader-edit:hover { color: var(--text); }
.reader-inner { width: min(680px, 100%); margin: 0 auto; padding: 40px 44px 54px; }
.reader-title {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: clamp(32px, 4.4vw, 46px);
  line-height: 1.06;
  letter-spacing: -.035em;
  font-weight: 600;
  text-wrap: balance;
}
.reader-labels { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 26px; }
.reader-labels .chip { font-family: var(--font); font-size: 10px; }
.reader-body {
  font-family: var(--serif);
  font-size: 17.5px;
  line-height: 1.74;
  font-feature-settings: "onum" 1, "kern" 1;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-wrap: pretty;
  color: var(--text);
}
.reader-body p { margin: 0 0 1.05em; }
.reader-body p.has-dropcap::first-letter {
  float: left; font-size: 3.15em; line-height: .82; font-weight: 500;
  padding: .02em .1em 0 0; color: var(--accent-strong);
}
.reader-body h1, .reader-body h2, .reader-body h3 {
  font-family: var(--serif); font-weight: 600; letter-spacing: -.02em; line-height: 1.2;
}
.reader-body h1 { font-size: 30px; margin: 30px 0 12px; }
.reader-body h2 { font-size: 25px; margin: 28px 0 10px; }
.reader-body h3 { font-size: 20px; margin: 22px 0 8px; }
.reader-body blockquote {
  position: relative;
  isolation: isolate;
  margin: 26px 0 26px;
  padding: 2px 0 2px 26px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
  font-size: 19px;
  line-height: 1.55;
}
.reader-body blockquote::before {
  content: "“";
  position: absolute; left: -2px; top: -26px;
  font-family: var(--serif); font-size: 54px; line-height: 1;
  color: var(--accent-soft); z-index: -1;
}
.reader-body ul, .reader-body ol { margin: 0 0 1.1em; padding-left: 24px; }
.reader-body li { margin: 0 0 6px; }
.reader-body hr { border: 0; border-top: 1px solid var(--line); margin: 30px 0; }
.reader-body a { color: var(--accent-strong); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.reader-body code { font-family: var(--mono); font-size: 13.5px; background: rgba(74, 60, 38, .07); padding: 1px 5px; border-radius: 4px; }
.reader-body pre { font-family: var(--mono); font-size: 13px; line-height: 1.55; background: rgba(74, 60, 38, .07); padding: 14px 16px; border-radius: 8px; overflow-x: auto; }
.reader-figures { display: grid; gap: 12px; margin: 0 0 28px; }
.reader-figures img { width: 100%; max-height: 520px; object-fit: cover; border-radius: 8px; display: block; background: var(--surface-3); }
.reader-check { display: grid; gap: 9px; margin: 4px 0 8px; }
.reader-check-row { display: flex; align-items: flex-start; gap: 11px; font-size: 16.5px; line-height: 1.5; }
.reader-check-mark { width: 18px; height: 18px; flex: none; margin-top: 4px; border: 1.5px solid var(--line-strong); border-radius: 5px; display: grid; place-items: center; color: var(--accent); font-size: 12px; font-weight: 700; }
.reader-check-row.is-done .reader-check-mark { background: var(--accent); border-color: var(--accent); color: #fff8ea; }
.reader-check-row.is-done .reader-check-text { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.reader-empty { color: var(--muted); font-style: italic; }
.reader-foot {
  margin-top: 34px; padding-top: 15px; border-top: 1px solid var(--line);
  color: var(--faint); font-family: var(--font); font-size: 10.5px;
  letter-spacing: .08em; text-transform: uppercase;
  display: flex; justify-content: space-between; gap: 12px;
}

@media (max-width: 700px) {
  .reader { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; }
  .reader-card { height: 100dvh; max-height: none; border-radius: 0; border: 0; }
  .reader-inner { padding: 28px 20px 44px; }
  .reader-title { font-size: 32px; }
  .reader-body { font-size: 17px; line-height: 1.7; }
  .reader-head { padding: 10px 12px 10px 18px; }
  .reader-meta { max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .reader-edit span { display: none; }
  .preview-btn span { display: none; }
  .format-bar { padding: 4px 10px; }
  .format-btn { min-width: 30px; height: 30px; }
}

@media (max-width: 700px) {
  .editor-title { font-size: 22px; }
  .editor-text { font-size: 16px; }
  .note-title { font-size: 16.5px; }
  .note-body { font-size: 14.2px; }
  .editor-preview { font-size: 16px; }
}

.reader-check-mark.is-clickable {
  padding: 0; background: transparent; cursor: pointer;
  font-family: var(--font);
}
.reader-check-mark.is-clickable:hover { border-color: var(--accent); }
.reader-check-mark.is-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.reader-card { border-top: 3px solid var(--line-strong); }
.reader-card[data-color="sand"] { border-top-color: #d9b65a; }
.reader-card[data-color="blush"] { border-top-color: #cf8a82; }
.reader-card[data-color="sage"] { border-top-color: #7f9b77; }
.reader-card[data-color="sky"] { border-top-color: #7ea1bd; }
.reader-card[data-color="lavender"] { border-top-color: #9b8bbd; }
.reader-card[data-color="peach"] { border-top-color: #d69a6a; }
.reader-card[data-color="mint"] { border-top-color: #79a996; }

/* ---------- перетаскивание ---------- */

.note {
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: pan-y;
}
.note img { -webkit-user-drag: none; user-drag: none; }

.note-placeholder {
  box-sizing: border-box;
  border: 1.5px dashed var(--accent);
  border-radius: 15px;
  background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
  opacity: .55;
  pointer-events: none;
}
.grid.masonry > .note-placeholder { position: absolute; top: 0; left: 0; }

.drag-ghost {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  z-index: 200;
  margin: 0 !important;
  pointer-events: none;
  opacity: .97;
  transform-origin: top left;
  will-change: transform;
  transition: none !important;
  animation: none !important;
  box-shadow: 0 22px 55px rgba(38, 30, 18, .28), 0 2px 8px rgba(38, 30, 18, .12);
}
body.is-dragging { user-select: none; -webkit-user-select: none; touch-action: none; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
.grid.is-dragging > .note,
.grid.is-dragging > .note-placeholder,
.grid.is-animated.is-dragging > .note { transition: none !important; }

/* подсказка в меню сортировки */
.popover-hint-drag { padding: 5px 10px 7px; color: var(--faint); font-size: 10.5px; line-height: 1.4; }

.note.is-drag-source {
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
