:root {
  --bg-solid: #F2EFE8;
  --bg-grad-1: #EAE4D8;
  --bg-grad-2: #E4E9DC;
  --glass: rgba(255, 255, 255, .55);
  --glass-strong: rgba(255, 255, 255, .8);
  --glass-border: rgba(255, 255, 255, .75);
  --panel-solid: #FBF9F4;
  --card: #FAF7F1;
  --card-border: rgba(60, 50, 30, .05);
  --input-bg: rgba(255, 255, 255, .7);
  --border: rgba(90, 80, 60, .14);
  --text: #2E2A24;
  --muted: #8B8478;
  --primary: #7D8F69;
  --on-primary: #FFFFFF;
  --primary-soft: #E6EBDD;
  --danger: #C4453C;
  --shadow: 0 16px 40px rgba(90, 80, 60, .12);
  --shadow-soft: 0 8px 24px rgba(90, 80, 60, .08);
  --r-xl: 30px;
  --r-lg: 24px;
  --r-md: 16px;
  --serif: Georgia, 'Times New Roman', 'Playfair Display', serif;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg-solid: #14120E;
  --bg-grad-1: #1D1913;
  --bg-grad-2: #171A12;
  --glass: rgba(30, 27, 22, .6);
  --glass-strong: rgba(32, 29, 24, .86);
  --glass-border: rgba(255, 255, 255, .07);
  --panel-solid: #1D1A15;
  --card: #201D17;
  --card-border: rgba(255, 255, 255, .05);
  --input-bg: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .08);
  --text: #ECE7DD;
  --muted: #A29A8C;
  --primary: #A3B18A;
  --on-primary: #1A1D14;
  --primary-soft: rgba(163, 177, 138, .16);
  --danger: #E5837B;
  --shadow: 0 16px 44px rgba(0, 0, 0, .5);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI Variable', 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
  background: var(--bg-solid);
  color: var(--text);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 480px at 85% -100px, var(--bg-grad-1), transparent 70%),
    radial-gradient(760px 420px at -120px 35%, var(--bg-grad-2), transparent 70%);
}

button, input, textarea { font: inherit; }

h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: .2px; margin: 0; }
h3 { margin: 0; font-weight: 700; }
h1 { font-size: 30px; }
h2 { font-size: 26px; }
h3 { font-size: 16px; }

[hidden] { display: none !important; }

.app { min-height: 100vh; position: relative; z-index: 1; }

/* ---------- Верхняя панель ---------- */
.top-app-bar {
  position: sticky;
  top: 10px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 14px 0;
  padding: 10px 18px;
  border-radius: var(--r-xl);
  background: var(--glass-strong);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
}

.title {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .4px;
}

.actions { display: flex; align-items: center; gap: 6px; }

.icon {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}

.icon:hover { background: var(--primary-soft); color: var(--primary); transform: scale(1.05); }

/* ---------- Навигация ---------- */
.nav-tabs {
  display: flex;
  gap: 6px;
  padding: 8px;
  margin: 12px 14px;
  border-radius: var(--r-xl);
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  overflow: auto;
}

.tab {
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}

.tab:hover { background: var(--primary-soft); color: var(--primary); }

.tab.active {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 35%, transparent);
}

@media (min-width: 900px) {
  .app { padding-left: 216px; }

  .nav-tabs {
    position: fixed;
    left: 14px;
    top: 86px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    width: 188px;
    max-height: calc(100vh - 110px);
    margin: 0;
    overflow: auto;
  }

  .tab { text-align: left; }
}

/* ---------- Контент ---------- */
.content {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 4px 20px 120px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 20px 0 14px;
}

.header-tools { display: flex; align-items: center; gap: 10px; }

.fab-header {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--on-primary);
  cursor: pointer;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 40%, transparent);
  transition: transform .18s;
}

.fab-header:hover { transform: translateY(-2px) scale(1.05); }
.fab-header svg { transition: transform .18s; }
.fab-header.open svg { transform: rotate(90deg); }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
}

.seg button {
  width: 38px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.seg button svg { width: 18px; height: 18px; }
.seg button.active { background: var(--primary); color: var(--on-primary); }

.cats-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }

.chip {
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 700;
  width: max-content;
}

.cat-chip { display: inline-flex; align-items: center; gap: 6px; }

.cat-x {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: .7;
}

.cat-x:hover { opacity: 1; color: var(--danger); }

/* ---------- Карточки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.list { display: grid; gap: 16px; margin-top: 12px; }

.list.mode-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.list.mode-rows { grid-template-columns: 1fr; }

.list .item {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: rise .3s ease both;
  transition: transform .18s, box-shadow .18s;
}

.list .item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.item-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; flex: 1; }

.list .item.row { flex-direction: row; align-items: center; }
.list .item.row .item-main { flex-direction: row; align-items: center; gap: 14px; }
.list .item.row .card-body { flex: 1; min-width: 0; }
.list .item.row .card-actions { margin-left: 0; flex: none; }

.list .item.tile .card-actions { margin-top: auto; padding-top: 4px; }

.list.masonry { display: block; columns: 3 260px; column-gap: 16px; }
.list.masonry .item { break-inside: avoid; margin-bottom: 16px; }

/* Иконки-плашки в шалфейном стиле */
.icon-tile {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: linear-gradient(135deg, #AEC09A, #7D8F69) !important;
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, .10), 0 6px 14px rgba(125, 143, 105, .30);
  flex: none;
}

:root[data-theme='dark'] .icon-tile {
  background: linear-gradient(135deg, #55603F, #3A4229) !important;
}

.icon-tile.small { width: 42px; height: 42px; font-size: 20px; border-radius: 14px; }
.list .item.tile .icon-tile { width: 58px; height: 58px; font-size: 28px; border-radius: 20px; }
.list .item.row .icon-tile { width: 46px; height: 46px; font-size: 22px; border-radius: 15px; }

.ext-tile {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  letter-spacing: 1px;
  flex: none;
  filter: saturate(.55) brightness(1.02);
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, .12), 0 6px 14px rgba(0, 0, 0, .12);
}

.list .item.tile .ext-tile { width: 58px; height: 58px; font-size: 14px; border-radius: 20px; }
.list .item.row .ext-tile { width: 46px; height: 46px; font-size: 12px; border-radius: 15px; }

.tile-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.opt-img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.icon-opt { overflow: hidden; }

/* Картинка, растворяющаяся в карточке — как в референсе */
.visual-thumb {
  width: calc(100% + 40px);
  margin: 6px -20px -20px;
  height: 160px;
  object-fit: cover;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 45%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 45%);
}

.list .item.row .visual-thumb {
  width: 46px;
  height: 46px;
  margin: 0;
  border-radius: 14px;
  -webkit-mask-image: none;
  mask-image: none;
  flex: none;
}

.card-body { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.card-body p { margin: 0; line-height: 1.6; }
.card-body h3 { font-size: 16px; }

.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Кнопки ---------- */
.filled, .tonal, .text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, filter .15s, box-shadow .15s, background .15s;
}

.filled {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 35%, transparent);
}

.filled:hover { transform: translateY(-1px); filter: brightness(1.05); }

.tonal {
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  color: var(--text);
  backdrop-filter: blur(10px);
}

.tonal:hover { filter: brightness(1.02); }
.tonal svg { width: 18px; height: 18px; }

.text { background: transparent; color: var(--primary); }
.danger-text { color: var(--danger); }

.danger-filled {
  background: linear-gradient(135deg, #C4453C, #E5837B);
  color: #fff;
  box-shadow: 0 8px 20px rgba(196, 69, 60, .35);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}

.icon-btn:hover { background: var(--primary-soft); color: var(--primary); transform: scale(1.06); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn svg { width: 20px; height: 20px; }

.check {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 10px;
  border: 2px solid color-mix(in srgb, var(--muted) 45%, transparent);
  background: transparent;
  color: var(--on-primary);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s, border-color .15s;
}

.task.done .check { border-color: transparent; background: var(--primary); }
.task.done .task-text { text-decoration: line-through; color: var(--muted); }
.task-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Пустое состояние ---------- */
.empty-drop {
  margin-top: 12px;
  border: 2px dashed color-mix(in srgb, var(--muted) 40%, transparent);
  border-radius: var(--r-xl);
  padding: 64px 24px;
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
  cursor: pointer;
  background: var(--card);
  transition: border-color .2s, background .2s, transform .2s;
  animation: rise .3s ease both;
}

.empty-drop:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-2px);
}

.empty-drop p { margin: 0; }
.empty-icon { font-size: 46px; }

/* ---------- Модалки ---------- */
.dialog-scrim, .add-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: color-mix(in srgb, var(--bg-solid) 55%, rgba(30, 25, 15, .45));
  backdrop-filter: blur(10px);
  animation: fadeIn .2s ease both;
}

.dialog {
  width: min(440px, 100%);
  border-radius: var(--r-xl);
  background: var(--panel-solid);
  border: 1px solid var(--card-border);
  padding: 26px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
  animation: pop .25s cubic-bezier(.2, .9, .3, 1.15) both;
}

.dialog-wide { width: min(560px, 100%); max-height: calc(100vh - 60px); overflow: auto; }
.dialog h3 { font-size: 19px; }
.dialog p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.dialog-input { width: 100%; }

.add-panel { width: auto; max-height: none; overflow: visible; }

.add-panel .card {
  width: min(560px, 100%);
  max-height: calc(100vh - 60px);
  overflow: auto;
  background: var(--panel-solid);
  border-radius: var(--r-xl);
  padding: 26px;
  box-shadow: var(--shadow);
  animation: pop .25s cubic-bezier(.2, .9, .3, 1.15) both;
}

.settings-body { display: grid; gap: 6px; }
.settings-sep { height: 1px; margin: 12px 0; background: var(--border); }
.totp-secret { cursor: pointer; word-break: break-all; }
.totp-url { word-break: break-all; }

/* ---------- Формы ---------- */
.form { display: grid; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

label, .field-label {
  display: grid;
  gap: 8px;
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
}

input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
  transition: outline-color .15s, border-color .15s;
}

textarea { min-height: 110px; resize: vertical; }

input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }

input[type='file'] { padding: 10px; }

input[type='file']::file-selector-button {
  border: 0;
  margin-right: 10px;
  border-radius: 999px;
  padding: 7px 14px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.icon-field { display: grid; gap: 10px; }

.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 8px;
}

.icon-opt {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  font-size: 20px;
  cursor: pointer;
  transition: transform .12s, background .12s;
}

.icon-opt:hover { transform: scale(1.08); }
.icon-opt.selected { background: var(--primary-soft); outline: 2px solid var(--primary); }
.icon-custom { grid-column: 1 / -1; }

/* ---------- Редактор ---------- */
.editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--bg-solid);
  animation: rise .2s ease both;
}

.editor-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(800px 400px at 90% -80px, var(--bg-grad-1), transparent 70%),
    radial-gradient(640px 360px at -80px 30%, var(--bg-grad-2), transparent 70%);
}

.editor-top {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  margin: 12px 14px 0;
  padding: 10px 14px;
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
}

.editor-title { min-width: 140px; flex: 1; }
.editor-category { width: 200px; flex: none; }

.editor-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  font-size: 20px;
  overflow: hidden;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--text);
  cursor: pointer;
}

.editor-icons {
  position: relative;
  margin: 10px 14px 0;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  max-height: 240px;
  overflow: auto;
}

.editor-toolbar { position: relative; display: flex; gap: 6px; padding: 10px 16px; overflow: auto; }

.md-btn {
  min-width: 38px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, color .12s;
}

.md-btn:hover { background: var(--primary-soft); color: var(--primary); }

.editor-main { position: relative; flex: 1; display: flex; min-height: 0; }

.editor-main textarea {
  flex: 1;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 18px 24px;
  resize: none;
  min-height: 0;
  line-height: 1.7;
  color: var(--text);
}

.editor-main textarea:focus { outline: none; }

.editor-preview {
  display: none;
  flex: 1;
  overflow: auto;
  padding: 18px 28px;
  border-left: 1px solid var(--border);
}

@media (min-width: 900px) { .editor-preview { display: block; } }
.editor-overlay.solo-preview .editor-preview { display: block; }
.editor-overlay.solo-preview .editor-main textarea { display: none; }

/* ---------- Режим чтения ---------- */
.reader-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  overflow-y: auto;
  background: var(--bg-solid);
  animation: rise .2s ease both;
}

.reader-top { display: flex; align-items: center; gap: 12px; padding: 16px 20px; }
.reader-title { flex: 1; min-width: 0; }
.reader-title h2 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-body { padding: 16px 20px 90px; }
.reader-doc { max-width: 860px; margin: 0 auto; }

/* ---------- Markdown ---------- */
.markdown { overflow-wrap: break-word; }

.markdown h1 { font-family: var(--serif); font-size: 28px; margin: 20px 0 12px; }
.markdown h2 { font-family: var(--serif); font-size: 23px; margin: 24px 0 10px; }
.markdown h3 { font-size: 18px; margin: 20px 0 8px; }
.markdown p { line-height: 1.75; margin: 10px 0; }
.markdown ul, .markdown ol { line-height: 1.7; padding-left: 24px; }

.markdown blockquote {
  border-left: 4px solid var(--primary);
  margin: 14px 0;
  padding: 10px 18px;
  background: var(--primary-soft);
  border-radius: 0 16px 16px 0;
}

.markdown table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 8px 12px; }

.markdown img { max-width: 100%; border-radius: var(--r-md); box-shadow: var(--shadow-soft); }

.markdown pre {
  overflow: auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
}

.markdown code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.markdown hr { border: 0; height: 1px; margin: 24px 0; background: linear-gradient(90deg, transparent, var(--muted), transparent); }

.note-full { display: none; margin-top: 8px; }
.item.expanded .note-full { display: block; animation: rise .25s ease both; }
.item.expanded .clamp-preview { display: none; }

.clickable { cursor: pointer; }

.cred-pass { margin-top: 2px; }

.pass-value {
  letter-spacing: 2px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
}

/* ---------- Вход ---------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 12px;
  border-radius: var(--r-xl);
  padding: 32px;
  background: var(--glass-strong);
  backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  animation: rise .3s ease both;
}

.login-card h1 { font-family: var(--serif); }

.login-brand {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #AEC09A, #7D8F69);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(125, 143, 105, .4);
}

/* ---------- Разное ---------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(10px);
  z-index: 300;
  background: var(--text);
  color: var(--bg-solid);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pop {
  from { opacity: 0; transform: scale(.92) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Мобильные ---------- */
@media (max-width: 900px) {
  .editor-top { flex-wrap: wrap; }
  .editor-category { width: 100%; }
}

@media (max-width: 640px) {
  .top-app-bar { margin: 10px 10px 0; padding: 8px 14px; }
  .nav-tabs { margin: 10px; }
  .content { padding: 4px 12px 120px; }
  .list .item.row { flex-wrap: wrap; align-items: flex-start; }
  .list .item.row .item-main { flex: 1 1 auto; }
  .list .item.row .card-actions { width: 100%; justify-content: flex-end; }
  .section-header h2 { font-size: 22px; }
}
/* ---------- Акцентные пресеты ---------- */
:root { --primary-soft: color-mix(in srgb, var(--primary) 16%, transparent); }
:root[data-theme='dark'] { --primary-soft: color-mix(in srgb, var(--primary) 22%, transparent); }

:root[data-accent='indigo'] { --primary: #4F46E5; }
:root[data-accent='indigo'][data-theme='dark'] { --primary: #8B93FF; }

:root[data-accent='violet'] { --primary: #7C3AED; }
:root[data-accent='violet'][data-theme='dark'] { --primary: #B39DFF; }

:root[data-accent='blue'] { --primary: #2563EB; }
:root[data-accent='blue'][data-theme='dark'] { --primary: #6FA5FF; }

:root[data-accent='teal'] { --primary: #0D9488; }
:root[data-accent='teal'][data-theme='dark'] { --primary: #34D3BF; }

:root[data-accent='rose'] { --primary: #DB2777; }
:root[data-accent='rose'][data-theme='dark'] { --primary: #F9A8D4; }

:root[data-accent='amber'] { --primary: #B45309; }
:root[data-accent='amber'][data-theme='dark'] { --primary: #FBBF24; }

/* ---------- Контрастные элементы ---------- */
.section-header h2 {
  position: relative;
  padding-bottom: 12px;
}

.section-header h2::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 52px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 30%, transparent));
}

.title::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 4px;
  margin-right: 10px;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 45%, #fff));
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 45%, transparent);
}

.filled {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 68%, #1F2937));
}

.fab-header {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 62%, #1F2937));
}

.task.done .check {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 68%, #1F2937));
}

.login-brand {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #fff));
}

.chip {
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
}

.icon-tile {
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 72%, #fff), var(--primary)) !important;
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, .10), 0 6px 14px color-mix(in srgb, var(--primary) 30%, transparent);
}

:root[data-theme='dark'] .icon-tile {
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 55%, #000), var(--primary)) !important;
}

.tab.active {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #1F2937));
}

/* ---------- Выбор акцента в настройках ---------- */
.accent-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.accent-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, .18);
}

.accent-dot:hover { transform: scale(1.12); }

.accent-dot.selected {
  outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent);
  outline-offset: 3px;
}
/* ---------- Режим чтения: сайдбар со списком ---------- */
.reader-overlay {
  display: flex;
  overflow: hidden;
}

.reader-overlay::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 85% -100px, var(--bg-grad-1), transparent 70%),
    radial-gradient(760px 420px at -120px 35%, var(--bg-grad-2), transparent 70%);
}

.reader-side {
  width: 300px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  z-index: 2;
}

.reader-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 12px 8px 18px;
}

.reader-side-head h3 {
  font-family: var(--serif);
  font-size: 19px;
}

.reader-list {
  overflow: auto;
  padding: 6px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reader-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s, box-shadow .15s;
  animation: rise .25s ease both;
}

.reader-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.reader-item.active {
  background: var(--card);
  border-color: var(--card-border);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.reader-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  font-size: 17px;
  flex: none;
  overflow: hidden;
}

.reader-item.active .reader-item-icon {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 60%, #fff));
}

img.reader-item-icon { object-fit: cover; }

.reader-item-title {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.reader-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 14px 0;
  padding: 10px 14px;
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
}

.reader-side-open { display: none; }

.reader-body {
  flex: 1;
  overflow: auto;
  padding: 22px 26px 90px;
}

.doc-anim { animation: docIn .32s ease both; }

@keyframes docIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 900px) {
  .reader-side {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 85vw);
    transform: translateX(-105%);
    transition: transform .28s cubic-bezier(.2, .8, .3, 1);
    box-shadow: var(--shadow);
  }

  .reader-overlay.side-open .reader-side { transform: translateX(0); }

  .reader-side-open { display: grid; }

  .reader-top { margin: 10px 10px 0; }
  .reader-body { padding: 16px 14px 80px; }
}

@media (min-width: 901px) {
  [data-reader-action='close-side'] { display: none; }
}
/* ---------- Современный шрифт вместо серифа ---------- */
:root {
  --serif: 'Manrope', 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
}

body {
  font-family: 'Manrope', 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
}

h1, h2, h3, .title {
  font-weight: 800;
  letter-spacing: -.2px;
}

/* ---------- Анимации читалки ---------- */
.reader-overlay { animation: readerIn .3s ease both; }

@keyframes readerIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.reader-overlay.reader-closing {
  animation: readerOut .24s ease both;
  pointer-events: none;
}

@keyframes readerOut {
  to { opacity: 0; transform: scale(.97); }
}

.reader-side {
  position: relative;
  width: var(--side-w, 300px);
  transition: width .38s cubic-bezier(.2, .8, .2, 1), opacity .3s;
  animation: sideIn .5s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes sideIn {
  from { opacity: 0; transform: translateX(-32px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.reader-main {
  animation: mainIn .5s cubic-bezier(.2, .8, .2, 1) both;
  transition: transform .38s cubic-bezier(.2, .8, .2, 1);
}

@keyframes mainIn {
  from { opacity: 0; transform: scale(1.045); }
  to { opacity: 1; transform: scale(1); }
}

.reader-overlay.side-anim .reader-main { transform: scale(.985); }

.reader-overlay.resizing .reader-side { transition: none; }

/* ---------- Сворачивание списка (десктоп) ---------- */
@media (min-width: 901px) {
  .reader-overlay.side-collapsed .reader-side {
    width: 0;
    opacity: 0;
    border-right-width: 0;
    overflow: hidden;
  }

  .reader-side-open { display: none; }
  .reader-overlay.side-collapsed .reader-side-open { display: grid; }

  [data-reader-action='close-side'] { display: grid; }
}

/* ---------- Изменение ширины списка ---------- */
.reader-resize {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -4px;
  width: 9px;
  cursor: col-resize;
  z-index: 6;
  background: transparent;
  touch-action: none;
}

.reader-resize::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 3px;
  transform: translateY(-50%);
  width: 3px;
  height: 46px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  opacity: 0;
  transition: opacity .2s, background .2s;
}

.reader-resize:hover::after,
.reader-overlay.resizing .reader-resize::after {
  opacity: 1;
  background: var(--primary);
}

@media (max-width: 900px) {
  .reader-resize { display: none; }
  .reader-side { width: min(320px, 85vw); }
}
/* ---------- Шапка читалки: скрытие при скролле ---------- */
.reader-top {
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .3s, margin-top .35s cubic-bezier(.2, .8, .2, 1);
}

.reader-overlay.top-hidden .reader-top {
  transform: translateY(-110%);
  opacity: 0;
  margin-top: -160px;
  pointer-events: none;
}

/* ---------- Мобильная читалка: фикс сайдбара и оптимизация ---------- */
@media (max-width: 900px) {
  .reader-side {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 85vw);
    animation: none;
    transform: translateX(-105%);
    opacity: 1;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1);
    box-shadow: var(--shadow);
    z-index: 10;
  }

  .reader-overlay.side-open .reader-side { transform: translateX(0); }

  .reader-top { margin: 10px 10px 0; padding: 8px 10px; gap: 6px; }
  .reader-title h2 { font-size: 16px; }
  .reader-body { padding: 14px 12px 90px; }

  .reader-doc { font-size: 15px; }
  .reader-doc h1 { font-size: 23px; }
  .reader-doc h2 { font-size: 20px; }
  .reader-doc h3 { font-size: 17px; }
  .reader-doc pre { font-size: 12px; }

  .reader-item { padding: 8px 10px; }
}
.users-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 12px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* ---------- Оглавление инструкции ---------- */
.reader-toc {
  max-width: 860px;
  margin: 0 auto 18px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-soft);
}

.reader-toc h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 10px;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.toc-item {
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  transition: background .15s, color .15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.toc-level-h2 { padding-left: 28px; font-weight: 500; color: var(--muted); }
.toc-level-h3 { padding-left: 44px; font-weight: 500; color: var(--muted); font-size: 13px; }

.reader-doc h1, .reader-doc h2, .reader-doc h3 { scroll-margin-top: 18px; }

@media (max-width: 900px) {
  .reader-toc { margin-bottom: 14px; padding: 12px 14px; }
  .toc-level-h2 { padding-left: 20px; }
  .toc-level-h3 { padding-left: 32px; }
}
/* ---------- Правая панель оглавления ---------- */
.reader-toc {
  width: 270px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 0;
  border-left: 1px solid var(--glass-border);
  border-radius: 0;
  margin: 0;
  max-width: none;
  padding: 0;
  box-shadow: none;
}

.reader-toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 10px 8px 16px;
}

.reader-toc-head h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
}

.reader-toc .toc-list {
  overflow: auto;
  padding: 6px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.reader-overlay.toc-hidden .reader-toc { display: none; }

.reader-overlay.no-toc .reader-toc,
.reader-overlay.no-toc [data-reader-action='toc-toggle'] { display: none; }

@media (max-width: 900px) {
  .reader-toc {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 85vw);
    transform: translateX(105%);
    transition: transform .3s cubic-bezier(.2, .8, .2, 1);
    z-index: 10;
    box-shadow: var(--shadow);
    border-left: 0;
    display: flex;
  }

  .reader-overlay.toc-open .reader-toc { transform: translateX(0); }
  .reader-overlay.toc-hidden .reader-toc { display: flex; }
}
/* ---------- Анимированное скрытие и ресайз оглавления ---------- */
.reader-toc {
  position: relative;
  width: var(--toc-w, 270px);
  transition: width .38s cubic-bezier(.2, .8, .2, 1), opacity .3s;
  overflow: hidden;
}

.reader-toc > * { min-width: 200px; }

.reader-overlay.toc-hidden .reader-toc {
  display: flex;
  width: 0;
  opacity: 0;
  border-left-width: 0;
}

.reader-overlay.resizing .reader-toc { transition: none; }

.reader-resize-toc {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  width: 9px;
  cursor: col-resize;
  z-index: 6;
  touch-action: none;
}

.reader-resize-toc::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  width: 3px;
  height: 46px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  opacity: 0;
  transition: opacity .2s, background .2s;
}

.reader-resize-toc:hover::after,
.reader-overlay.resizing .reader-resize-toc::after {
  opacity: 1;
  background: var(--primary);
}

@media (max-width: 900px) {
  .reader-resize-toc { display: none; }

  .reader-toc { width: min(300px, 85vw); }

  .reader-overlay.toc-hidden .reader-toc {
    width: min(300px, 85vw);
    opacity: 1;
  }
}