/* iOS/Apple-оформление (28.10.2026). Бэкап: _versions/static_pre-apple_2026-10-28/ */
:root {
  --bg: #f2f2f7; --panel: #fff; --side: #f2f2f7; --panel2: #f2f2f7; --text: #1d1d1f; --muted: #6e6e73;
  --line: #e5e5ea; --accent: #0071e3; --gold: #b85c00; --gold-soft: rgba(0, 113, 227, .10); --mark: rgba(255, 159, 10, .35);
  --code: #f2f2f7; --danger: #d70015; --ok: #248a3d; --onaccent: #fff;
  --glass: rgba(255, 255, 255, .72); --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  --scrim: rgba(0, 0, 0, .35); --toast-bg: #1d1d1f; --toast-fg: #fff; --r: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000; --panel: #1c1c1e; --side: #000; --panel2: #2c2c2e; --text: #f5f5f7; --muted: #a1a1a6;
    --line: #38383a; --accent: #0a84ff; --gold: #ff9f0a; --gold-soft: rgba(10, 132, 255, .16); --mark: rgba(255, 159, 10, .38);
    --code: #2c2c2e; --danger: #ff453a; --ok: #30d158;
    --glass: rgba(28, 28, 30, .72); --shadow: none; --scrim: rgba(0, 0, 0, .55); --toast-bg: #2c2c2e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000; --panel: #1c1c1e; --side: #000; --panel2: #2c2c2e; --text: #f5f5f7; --muted: #a1a1a6;
  --line: #38383a; --accent: #0a84ff; --gold: #ff9f0a; --gold-soft: rgba(10, 132, 255, .16); --mark: rgba(255, 159, 10, .38);
  --code: #2c2c2e; --danger: #ff453a; --ok: #30d158;
  --glass: rgba(28, 28, 30, .72); --shadow: none; --scrim: rgba(0, 0, 0, .55); --toast-bg: #2c2c2e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--font); letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; opacity: .85; }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: var(--panel2); border-radius: 99px;
  padding: 8px 16px; cursor: pointer; font-weight: 600; font-size: 15px; white-space: nowrap;
  color: var(--text); text-decoration: none !important;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--onaccent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 12px; font-size: 14px; }
.btn.wide { width: 100%; padding: 13px; border-radius: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 50%;
  font-size: 20px; cursor: pointer; flex: none; color: var(--text);
}
.icon-btn:hover { background: var(--gold-soft); }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px 0; font-size: 14px; text-align: left; }
.link-btn:hover { color: var(--accent); }
.pill { font-size: 12px; background: var(--gold-soft); color: var(--accent); border-radius: 99px; padding: 0 8px; font-weight: 600; }
.pill:empty { display: none; }

/* ---------- вход ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%); background: var(--panel); border: 0;
  border-radius: 28px; padding: 28px; box-shadow: var(--shadow);
}
.login-card label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0; }
.login-card input {
  display: block; width: 100%; margin-top: 6px; padding: 12px; border-radius: 10px;
  border: 0; background: var(--panel2); font-size: 16px; outline: none;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; color: var(--text); font-weight: 700; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 28px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(145deg, #ff9f0a, #ffd60a); color: #fff; font-weight: 800; font-size: 19px;
}
.brand.big .brand-mark { width: 44px; height: 44px; font-size: 26px; }

/* ---------- каркас ---------- */
.app { display: flex; height: 100%; }
.side {
  width: 290px; flex: none; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
  padding-top: env(safe-area-inset-top);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.side-nav { padding: 6px 8px; }
.side-link { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px; color: var(--text); font-weight: 500; }
.side-link:hover, .side-link.active { background: var(--gold-soft); text-decoration: none; opacity: 1; }
.side-link.active { color: var(--accent); }
.side-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12.5px; letter-spacing: .01em; color: var(--muted);
  padding: 12px 18px 4px; font-weight: 600;
}
.tree-filter {
  width: 120px; border: 0; background: var(--panel2); border-radius: 99px;
  padding: 3px 10px; font-size: 13px; text-transform: none; letter-spacing: 0;
}
.fav-list { padding: 0 8px; max-height: 28vh; overflow: auto; }
.fav-list:empty::after { content: "Нажмите ☆ у заметки"; display: block; color: var(--muted); font-size: 13px; padding: 4px 10px; }
.tree { flex: 1; overflow: auto; padding: 0 8px 12px; font-size: 14.5px; }
.tree details > summary { list-style: none; }
.tree details > summary::-webkit-details-marker { display: none; }
.t-row {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 10px; cursor: pointer;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.45;
}
.t-row:hover { background: var(--gold-soft); text-decoration: none; opacity: 1; }
.t-row.active { background: var(--gold-soft); color: var(--accent); font-weight: 600; }
.t-row .t-name { overflow: hidden; text-overflow: ellipsis; }
.t-row .t-ico { flex: none; width: 14px; text-align: center; color: var(--muted); font-size: 11px; transition: transform .15s; }
.tree details[open] > summary .t-ico { transform: rotate(90deg); }
.t-row .t-cnt { margin-left: auto; color: var(--muted); font-size: 12px; }
.t-children { padding-left: 14px; border-left: 1px solid var(--line); margin-left: 14px; }
.side-foot { display: flex; gap: 14px; padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex-wrap: wrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.top {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  position: sticky; top: 0; z-index: 5;
}
.search-wrap { flex: 1; position: relative; display: flex; align-items: center; max-width: 720px; }
.search-ico { position: absolute; left: 12px; color: var(--muted); font-size: 18px; pointer-events: none; }
#q {
  width: 100%; padding: 9px 40px 9px 36px; border-radius: 99px; border: 0;
  background: var(--panel2); font-size: 16px; outline: none;
}
#q:focus { box-shadow: 0 0 0 3px var(--gold-soft); }
.search-wrap kbd { position: absolute; right: 10px; font-size: 12px; color: var(--muted); border: 0; background: var(--panel); border-radius: 6px; padding: 0 6px; }
.add-btn { margin-left: auto; }
.view { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.page { max-width: 860px; margin: 0 auto; padding: 18px 24px 96px; }
.page.wide { max-width: 1100px; }

.scrim { display: none; }
.only-mobile { display: none; }

/* ---------- главная ---------- */
.h-title { font-size: clamp(26px, 6vw, 34px); margin: 2px 0 14px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.h-title i { color: var(--accent); font-style: normal; }
.card { background: var(--panel); border: 0; border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 8px; font-size: 13.5px; letter-spacing: .01em; color: var(--muted); font-weight: 600; }
.capture textarea {
  width: 100%; min-height: 72px; resize: vertical; border: 0; border-radius: 14px;
  background: var(--panel2); padding: 12px; font-size: 16px; line-height: 1.5; outline: none;
}
.capture textarea:focus { box-shadow: 0 0 0 3px var(--gold-soft); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.list { display: flex; flex-direction: column; }
.li {
  display: block; padding: 10px 6px; border-bottom: 1px solid var(--line); color: var(--text);
}
.li:last-child { border-bottom: 0; }
.li:hover { text-decoration: none; background: var(--gold-soft); border-radius: 12px; opacity: 1; }
.li-title { font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.li-title .when { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 13px; white-space: nowrap; }
.li-path { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-snip { color: var(--muted); font-size: 14px; margin-top: 3px; overflow-wrap: anywhere; }
.li-snip mark, .li-title mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile {
  display: block; padding: 10px 14px; border-radius: 16px; background: var(--panel2); border: 0; color: var(--text);
}
.tile:hover { text-decoration: none; filter: brightness(.96); opacity: 1; }
.tile b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile span { font-size: 13px; color: var(--muted); }

/* ---------- заметка ---------- */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; overflow-wrap: anywhere; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.note-head { display: flex; align-items: flex-start; gap: 10px; }
.note-title { font-size: clamp(25px, 6vw, 34px); line-height: 1.15; margin: 0 0 6px; font-weight: 800; letter-spacing: -.03em; flex: 1; overflow-wrap: anywhere; }
.note-actions { display: flex; gap: 6px; flex: none; padding-top: 4px; }
.meta { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.fm { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 18px; }
.fm .kv { font-size: 13px; background: var(--code); border: 0; border-radius: 99px; padding: 2px 10px; }
.fm .kv b { color: var(--muted); font-weight: 500; margin-right: 4px; }
.tag { display: inline-block; font-size: .86em; background: var(--gold-soft); color: var(--accent); border-radius: 99px; padding: 0 8px; margin: 0 1px; font-weight: 500; }
.tag:hover { text-decoration: none; filter: brightness(1.15); }

.md { overflow-wrap: anywhere; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin: 1.5em 0 .5em; }
.md h1 { font-size: 1.6em; } .md h2 { font-size: 1.35em; border-bottom: 1px solid var(--line); padding-bottom: .2em; }
.md h3 { font-size: 1.15em; } .md h4 { font-size: 1em; }
.md > :first-child { margin-top: 0; }
.md p, .md ul, .md ol { margin: .6em 0; }
.md ul, .md ol { padding-left: 1.5em; }
.md li { margin: .2em 0; }
.md li.task { list-style: none; margin-left: -1.4em; }
.md li.task > input { width: 18px; height: 18px; vertical-align: -3px; margin: 0 8px 0 0; accent-color: var(--accent); cursor: pointer; }
.md li.task.done { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.md blockquote { margin: .8em 0; padding: .5em 1em; border-left: 3px solid var(--accent); background: var(--gold-soft); border-radius: 0 14px 14px 0; }
.md blockquote > :first-child { margin-top: 0; } .md blockquote > :last-child { margin-bottom: 0; }
.md code { background: var(--code); border-radius: 5px; padding: .1em .35em; font-size: .9em; font-family: var(--mono); }
.md pre { background: var(--code); border: 0; border-radius: 14px; padding: 12px 14px; overflow: auto; font-size: 14px; line-height: 1.5; }
.md pre code { background: none; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.md img, .md video { max-width: 100%; border-radius: 14px; height: auto; }
.md .tbl { overflow-x: auto; margin: .8em 0; border: 0; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.md table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--code); font-weight: 600; white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }
.md td + td, .md th + th { border-left: 1px solid var(--line); }
.md a.wl { border-bottom: 1px dashed currentColor; }
.md a.wl:hover { text-decoration: none; border-bottom-style: solid; }
.md a.wl.missing { color: var(--muted); }
.md a.ext::after { content: "↗"; font-size: .75em; margin-left: 2px; }
.md mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.md .embed-file { display: inline-flex; gap: 6px; padding: 6px 12px; border: 0; border-radius: 99px; background: var(--code); }
.md .callout { border-left-width: 3px; }
.md .callout-title { font-weight: 700; margin-bottom: .3em; }
.backlinks { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 16px; }
.backlinks h3 { font-size: 13.5px; letter-spacing: .01em; color: var(--muted); margin: 0 0 6px; }

/* ---------- редактор ---------- */
.editor { display: flex; flex-direction: column; height: 100%; }
.ed-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--line);
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); flex-wrap: wrap; position: sticky; top: 0; z-index: 3;
}
.ed-bar .ed-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 160px; }
.ed-bar .ed-name small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.ed-tools { display: flex; gap: 2px; overflow-x: auto; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--panel); scrollbar-width: none; }
.ed-tools button {
  flex: none; border: 1px solid transparent; background: none; border-radius: 12px; min-width: 38px; height: 36px;
  cursor: pointer; font-weight: 600; padding: 0 8px; color: var(--text);
}
.ed-tools button:hover { background: var(--panel2); }
.ed-wrap { flex: 1; position: relative; display: flex; min-height: 0; }
.ed-wrap textarea {
  flex: 1; width: 100%; border: 0; outline: none; resize: none; background: var(--bg);
  padding: 20px max(20px, calc((100% - 860px) / 2)) 50vh; font: 16.5px/1.65 var(--font);
  tab-size: 2;
}
.ed-wrap .ed-preview { flex: 1; overflow: auto; padding: 20px 28px 120px; border-left: 1px solid var(--line); display: none; }
.editor.split .ed-preview { display: block; }
.editor.split textarea { padding: 20px 24px 50vh; }
.ed-status { font-size: 13px; color: var(--muted); }
.ed-status.dirty { color: var(--gold); }
.ac {
  position: fixed; z-index: 30; background: var(--panel); border: 0; border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.28); width: min(420px, calc(100vw - 32px)); max-height: 280px; overflow: auto;
}
.ac div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac div:last-child { border-bottom: 0; }
.ac div.sel, .ac div:hover { background: var(--gold-soft); }
.ac small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- формы / модалки ---------- */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; border: 0; border-radius: 14px; background: var(--panel2); font-size: 16px; outline: none;
}
.field input:focus, .field select:focus { box-shadow: 0 0 0 3px var(--gold-soft); }
.modal { position: fixed; inset: 0; background: var(--scrim); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--panel); border: 0; border-radius: 26px; padding: 20px; width: min(520px, 100%); box-shadow: var(--shadow); max-height: 90vh; overflow: auto; }
.modal-card h3 { margin: 0 0 14px; }
.menu-list { display: flex; flex-direction: column; gap: 4px; }
.menu-list button { text-align: left; border: 0; background: none; padding: 11px 12px; border-radius: 14px; cursor: pointer; font-size: 16px; }
.menu-list button:hover { background: var(--gold-soft); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%);
  background: var(--toast-bg); color: var(--toast-fg); padding: 10px 18px; border-radius: 99px; box-shadow: 0 8px 28px rgba(0,0,0,.28);
  transition: transform .25s, visibility .25s; visibility: hidden; z-index: 70; max-width: calc(100vw - 32px); font-size: 15px;
}
.toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- круглая кнопка темы ---------- */
.themebtn { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--panel2); cursor: pointer; font-size: 16px; color: var(--text); }
.themebtn:active { transform: scale(.94); }
.side-head .brand { font-size: 17px; }

/* ---------- нижний док (телефон) ---------- */
.dock { display: none; }
.dock-fade { display: none; }
.dock a, .dock button {
  flex: 1 1 0; min-width: 0; display: grid; justify-items: center; gap: 1px; padding: 6px 2px 5px; border: 0; border-radius: 22px;
  background: transparent; color: var(--muted); font: 600 10.5px var(--font); cursor: pointer; text-decoration: none; position: relative;
}
.dock i { font-style: normal; font-size: 20px; line-height: 1.15; filter: grayscale(.55); transition: filter .2s, transform .2s; }
.dock .on { background: var(--gold-soft); color: var(--accent); opacity: 1; }
.dock .on i { filter: none; transform: translateY(-1px) scale(1.06); }
.dock a:active, .dock button:active { transform: scale(.95); }
.dock .pill { position: absolute; top: 2px; right: 18%; font-size: 10px; padding: 0 5px; background: var(--accent); color: var(--onaccent); }

/* ---------- телефон ---------- */
@media (max-width: 899px) {
  .only-desktop { display: none !important; }
  .only-mobile { display: inline-grid; place-items: center; }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; width: min(330px, 88vw);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: 0 10px 40px rgba(0,0,0,.3);
    background: var(--panel); border-right: 0; border-radius: 0 24px 24px 0;
  }
  .app.side-open .side { transform: none; }
  .app.side-open .scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 55; }
  .top { padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); gap: 8px; }
  .top > .icon-btn.only-mobile { display: none; }
  .add-btn { display: none; }
  .page { padding: 12px 14px 120px; }
  .note-title { font-size: 26px; }
  .card { padding: 12px 14px; margin-bottom: 12px; }
  .ed-wrap textarea { padding: 14px 16px 50vh; font-size: 16px; }
  .editor.split .ed-preview { display: none; }
  .ed-bar { padding: 8px 12px; }
  .md table { font-size: 13.5px; }
  .dock-fade { display: block; position: fixed; left: 0; right: 0; bottom: 0; height: calc(env(safe-area-inset-bottom) + 84px); background: linear-gradient(transparent, var(--bg) 70%); pointer-events: none; z-index: 45; }
  .dock {
    display: flex; position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 10px); transform: translateX(-50%); z-index: 50;
    width: calc(100vw - 16px); max-width: 560px; gap: 2px; padding: 6px; border-radius: 30px;
    background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(28px); backdrop-filter: saturate(180%) blur(28px);
    box-shadow: 0 10px 40px rgba(0,0,0,.28), 0 0 0 .5px color-mix(in srgb, var(--text) 14%, transparent);
  }
  body.in-editor .dock, body.in-editor .dock-fade { display: none; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (min-width: 900px) {
  .only-mobile { display: none !important; }
}
