/* Заметки — интерфейс в духе Obsidian.
   Вариант акцента задаётся --accent (фиолетовый Obsidian или индиго панели). */
:root {
  --bg: #1e1e1e;            /* редактор */
  --bg-side: #1a1a1a;       /* сайдбар */
  --bg-ribbon: #151515;     /* лента */
  --bg-hover: #2a2a2a;
  --bg-active: #313131;
  --border: #2b2b2b;
  --text: #dadada;
  --text-soft: #b0b0b0;
  --muted: #7f7f7f;
  --accent: #a882ff;        /* фиолетовый Obsidian */
  --accent-dim: rgba(168, 130, 255, .16);
  --ok: #48b784;
  --danger: #e35c55;
  --radius: 8px;
  --side-w: 288px;
  --ribbon-w: 48px;
  --col-w: 720px;           /* «читаемая ширина», как в Obsidian */
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.55; -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; }

/* ---------- каркас ---------- */
.app { display: flex; height: 100vh; height: 100dvh; }

/* лента слева */
.ribbon {
  flex: none; width: var(--ribbon-w);
  background: var(--bg-ribbon); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding-top: 10px; gap: 6px;
}
.rb-btn {
  width: 34px; height: 34px; border: none; border-radius: var(--radius);
  background: none; color: var(--muted); font-size: 19px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.rb-btn:hover { background: var(--bg-hover); color: var(--text); }
.rb-btn.primary { color: var(--accent); font-size: 24px; }
.rb-btn.primary:hover { background: var(--accent-dim); }

/* сайдбар */
.sidebar {
  flex: none; width: var(--side-w);
  background: var(--bg-side); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 14px 14px 8px;
  font-size: 11px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted);
}
.side-head .count { margin-left: auto; }
.side-search { padding: 0 10px 10px; }
.side-search input {
  width: 100%; padding: 8px 12px; font-size: 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); outline: none;
}
.side-search input:focus { border-color: var(--accent); }
.side-search input::placeholder { color: var(--muted); }
.note-list { flex: 1; overflow-y: auto; padding: 2px 6px 12px; }
.note-item {
  padding: 7px 10px 8px; margin: 1px 0; border-radius: var(--radius);
  cursor: pointer; position: relative;
}
.note-item:hover { background: var(--bg-hover); }
.note-item.active { background: var(--bg-active); }
.note-item.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px; background: var(--accent);
}
.note-item .t {
  font-size: 14px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-item .m { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.side-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 16px; }

/* ---------- основная область ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-top {
  flex: none; display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.main-top .crumb {
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-btn {
  flex: none; border: none; background: none; color: var(--muted);
  font-size: 18px; width: 32px; height: 32px; border-radius: var(--radius); cursor: pointer;
  display: none; align-items: center; justify-content: center;
}
.top-btn:hover { background: var(--bg-hover); color: var(--text); }
.main-top #del { display: flex; } /* удаление доступно и на десктопе */
.sync-dot { margin-left: auto; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync-dot.on { background: var(--ok); }

/* редактор */
.editor-scroll { flex: 1; overflow-y: auto; }
.editor-col { max-width: var(--col-w); margin: 0 auto; padding: 26px 28px 45vh; }
#title {
  font-size: 30px; font-weight: 700; color: var(--text);
  line-height: 1.25; outline: none; margin-bottom: 6px;
  overflow-wrap: break-word;
}
#title:empty::before { content: "Без названия"; color: var(--muted); }
.meta-line {
  font-size: 12px; color: var(--muted); margin-bottom: 22px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
#ta {
  width: 100%; min-height: 55vh; resize: none; border: none; outline: none;
  background: transparent; color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 16.5px; line-height: 1.75;
}
#ta::placeholder { color: var(--muted); }

/* статус-бар */
.statusbar {
  flex: none; display: flex; align-items: center; gap: 14px;
  height: 26px; padding: 0 14px;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-ribbon); border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted);
}
.statusbar .right { margin-left: auto; }
.statusbar .saved { color: var(--ok); }
.statusbar .pending { color: #d9a848; }

/* ---------- вход ---------- */
.login-wrap {
  height: 100vh; height: 100dvh;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  width: 100%; max-width: 340px;
  background: var(--bg-side); border: 1px solid var(--border);
  border-radius: 14px; padding: 30px 26px;
}
.login-card .logo {
  width: 52px; height: 52px; border-radius: 14px; margin-bottom: 16px;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.login-card h1 { font-size: 19px; margin-bottom: 2px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 11px 14px; font-size: 16px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  outline: none; margin-bottom: 10px;
}
.login-card input:focus { border-color: var(--accent); }
.btn {
  border: none; cursor: pointer; width: 100%;
  background: var(--accent); color: #1b1330;
  font-weight: 700; font-size: 15px;
  padding: 11px 18px; border-radius: var(--radius);
}
.btn:hover { filter: brightness(1.1); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }

/* ---------- мобильный (<860px) ---------- */
.backdrop {
  display: none; position: fixed; inset: 0; z-index: 8;
  background: rgba(0,0,0,.45);
}
@media (max-width: 860px) {
  .ribbon { display: none; }
  .sidebar {
    position: fixed; z-index: 9; top: 0; bottom: 0; left: 0;
    padding-top: env(safe-area-inset-top);
    transform: translateX(-102%); transition: transform .18s ease;
    width: min(82vw, 320px); box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  body.side-open .sidebar { transform: translateX(0); }
  body.side-open .backdrop { display: block; }
  .top-btn { display: flex; }
  .editor-col { padding: 18px 16px 40vh; }
  #title { font-size: 25px; }
  .main-top .crumb { display: none; }
}
