/* ============ Конспект — светлая тема ============ */
:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e76;
  --line: #e7e6e1;
  --line-strong: #d6d5cf;
  --accent: #5b5bd6;
  --accent-soft: #eeeefc;
  --danger: #d6455b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .04), 0 4px 16px rgba(20, 20, 40, .04);
  --shadow-hover: 0 2px 4px rgba(20, 20, 40, .06), 0 10px 28px rgba(20, 20, 40, .08);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --c: var(--accent);
  --c-soft: var(--accent-soft);
}

/* цвета категорий / проектов */
.c-indigo  { --c: #5b5bd6; --c-soft: #eeeefc; }
.c-emerald { --c: #12a372; --c-soft: #e3f6ee; }
.c-amber   { --c: #d98a0b; --c-soft: #fdf1dc; }
.c-rose    { --c: #e0466e; --c-soft: #fde8ee; }
.c-sky     { --c: #1d8fd6; --c-soft: #e2f1fb; }
.c-violet  { --c: #8b4fd8; --c-soft: #f2e9fc; }
.c-slate   { --c: #5d6779; --c-soft: #eceef2; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.02em; margin: 0; }
h1 { font-size: 30px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
kbd { font: 12px var(--mono); background: var(--panel); border: 1px solid var(--line-strong); border-bottom-width: 2px; padding: 1px 6px; border-radius: 6px; }

/* ============ Layout ============ */
.layout { display: grid; grid-template-columns: 268px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 14px;
}
.main { padding: 36px 48px 80px; max-width: 1180px; width: 100%; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; padding: 0 6px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6d6df0, #a26cf2); color: #fff; font-size: 15px;
}
.brand-lg { font-size: 24px; justify-content: center; }
.brand-lg .brand-mark { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; }

.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; color: var(--muted); }
.search input { padding-left: 34px; background: var(--bg); border-color: transparent; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600;
  color: var(--muted); padding: 14px 8px 6px;
}
.nav-add { font-size: 15px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; }
.nav-add:hover { background: var(--bg); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px;
  font-size: 14px; font-weight: 500; color: #3a3a40;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--c-soft); color: var(--c); }
.nav-ico { width: 20px; text-align: center; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count { font-size: 12px; color: var(--muted); }
.nav-muted { color: var(--muted); font-size: 13px; }
.nav-empty { font-size: 13px; color: var(--muted); padding: 4px 8px; margin: 0; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; display: inline-block; margin: 0 5px; }
.dot-lg { width: 14px; height: 14px; vertical-align: middle; margin: 0 4px 4px 0; }

.sidebar-foot { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.who { flex: 1; font-size: 14px; font-weight: 500; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: 13px; }
.link-btn:hover { color: var(--danger); }

.burger { display: none; }

/* ============ Buttons & forms ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; font: 500 14px var(--font);
  background: var(--panel); color: var(--text); border: 1px solid var(--line-strong);
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #bdbcb5; color: var(--text); box-shadow: var(--shadow); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #4b4bc4; border-color: #4b4bc4; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { background: transparent; color: var(--danger); border-color: #f1c4cc; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

input, select, textarea {
  width: 100%; padding: 9px 12px; font: 14px var(--font); color: var(--text);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
label { font-size: 13px; font-weight: 500; color: #45454c; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-check label { display: flex; align-items: center; gap: 8px; cursor: pointer; padding-top: 26px; }
.err { color: var(--danger); font-size: 13px; }
.alert { background: #fdecef; color: var(--danger); padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }

/* ============ Page parts ============ */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 .h-ico { margin-right: 4px; }
.eyebrow { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.eyebrow a:hover { color: var(--c); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin: 32px 0 12px; }
.page-head + section > .section-title, .two-col > section > .section-title { margin-top: 0; }
.two-col { margin-top: 32px !important; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.grid-cats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.cat-card { padding: 18px; display: flex; flex-direction: column; gap: 4px; transition: .18s; position: relative; overflow: hidden; }
.cat-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c); }
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); color: var(--text); }
.cat-ico { font-size: 26px; width: 46px; height: 46px; display: grid; place-items: center; background: var(--c-soft); border-radius: 12px; margin-bottom: 8px; }
.cat-name { font-weight: 600; }
.cat-new { border-style: dashed; box-shadow: none; background: transparent; color: var(--muted); }
.cat-new::before { display: none; }
.cat-new .cat-ico { background: var(--bg); }

.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px; margin-top: 8px; }
.two-col-tasks { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* list rows */
.list { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list:has(> .empty:only-child) { background: transparent; box-shadow: none; border: 0; }
.row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line); transition: background .12s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: #fafaf8; color: var(--text); }
.row:hover b { color: var(--c); }
.row-ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--c-soft); font-size: 16px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-main b { font-weight: 600; transition: color .12s; }
.row-main .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: flex; gap: 6px; align-items: center; flex: none; }

.tag { display: inline-block; font-size: 12px; font-weight: 500; color: var(--c); background: var(--c-soft); padding: 2px 8px; border-radius: 99px; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill-red { background: #fdecef; color: var(--danger); border-color: #f6d0d7; }

.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty a { color: var(--accent); font-weight: 500; }

/* ============ Document view ============ */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 40px; }
.doc { max-width: 820px; }
.doc-head { padding-bottom: 22px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.doc-head h1 { font-size: 36px; margin-bottom: 12px; }
.doc-head .eyebrow a { color: var(--c); font-weight: 600; }
.doc-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.doc-side { position: sticky; top: 36px; align-self: start; padding-top: 8px; }
.side-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin: 0 0 10px; }
.side-link { display: block; font-size: 14px; padding: 5px 10px; border-left: 2px solid var(--line); color: #55555c; }
.side-link:hover { border-color: var(--accent); }

/* rendered CKEditor content */
.prose { font-size: 16px; line-height: 1.75; }
.prose h2 { font-size: 24px; margin: 1.8em 0 .5em; }
.prose h3 { font-size: 19px; margin: 1.5em 0 .4em; }
.prose h4 { font-size: 16px; margin: 1.3em 0 .3em; }
.prose p { margin: 0 0 1em; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .25em 0; }
.prose blockquote { margin: 1.2em 0; padding: 12px 18px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; color: #3d3d58; }
.prose blockquote p:last-child { margin: 0; }
.prose code { font: 13.5px var(--mono); background: #f0efeb; padding: 2px 6px; border-radius: 6px; color: #c03a5c; }
.prose pre { position: relative; margin: 1.2em 0; background: #fbfbfa; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; color: inherit; font-size: 13.5px; line-height: 1.6; }
.prose pre[data-language]::before { content: attr(data-language); position: absolute; top: 8px; right: 60px; font: 11px var(--mono); color: var(--muted); text-transform: uppercase; }
.copy-btn { position: absolute; top: 8px; right: 8px; font: 11px var(--mono); padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--muted); cursor: pointer; opacity: 0; transition: .15s; }
.prose pre:hover .copy-btn { opacity: 1; }
.prose img { max-width: 100%; height: auto; border-radius: 10px; }
.prose figure { margin: 1.4em 0; }
.prose figure.image { display: table; margin-left: auto; margin-right: auto; }
.prose figure.image img { display: block; border: 1px solid var(--line); }
.prose figure.image-style-align-left { float: left; margin: .3em 1.4em 1em 0; max-width: 50%; }
.prose figure.image-style-align-right { float: right; margin: .3em 0 1em 1.4em; max-width: 50%; }
.prose figcaption { font-size: 13px; color: var(--muted); text-align: center; padding-top: 6px; display: table-caption; caption-side: bottom; }
.prose figure.table { margin: 1.2em 0; overflow-x: auto; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
.prose th { background: #f5f5f2; font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose mark { background: #fff1b8; padding: 0 2px; border-radius: 3px; }
.prose .todo-list { list-style: none; padding-left: .2em; }
.prose .todo-list input { width: auto; margin-right: 8px; }
.prose::after { content: ""; display: block; clear: both; }

/* ============ Editor ============ */
.editor-fields { display: grid; grid-template-columns: minmax(0, 1fr) 180px auto; gap: 0 14px; align-items: start; }
.editor-fields .field-title, .editor-fields .field-tags { grid-column: 1 / -1; }
.editor-fields:not(:has(.field-topic)) { grid-template-columns: 1fr; }
.input-title { font-size: 17px !important; font-weight: 600; }

.editor-body .ck.ck-editor { border-radius: var(--radius); box-shadow: var(--shadow); }
.editor-body .ck.ck-editor__top .ck-sticky-panel .ck-toolbar {
  border-radius: var(--radius) var(--radius) 0 0 !important; border-color: var(--line) !important; background: #fbfbfa;
}
.editor-body .ck.ck-editor__main > .ck-editor__editable {
  min-height: 60vh; padding: 20px 32px !important; font-size: 16px; line-height: 1.7;
  border-radius: 0 0 var(--radius) var(--radius) !important; border-color: var(--line) !important;
}
.editor-body .ck.ck-editor__main > .ck-editor__editable.ck-focused { border-color: var(--accent) !important; box-shadow: none !important; }
.ck-content pre { background: #fbfbfa !important; border: 1px solid var(--line) !important; border-radius: 10px !important; }
.ck-content code { font-family: var(--mono) !important; }
:root { --ck-color-focus-border: var(--accent); --ck-border-radius: 8px; --ck-font-face: var(--font); }

.danger-zone { margin-top: 28px; padding-top: 20px; border-top: 1px dashed var(--line-strong); }

.narrow { max-width: 560px; }
.form-card { padding: 24px; }
.form-card .actions { justify-content: flex-end; margin-top: 8px; }

/* ============ Projects ============ */
.grid-projects { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.project-card { padding: 20px; display: flex; flex-direction: column; gap: 8px; transition: .18s; }
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); color: var(--text); }
.project-card h3 { font-size: 18px; }
.project-card p { margin: 0; flex: 1; }
.project-card.is-dim { opacity: .65; }
.project-top { display: flex; justify-content: space-between; align-items: center; }
.project-top .dot { margin: 0; width: 12px; height: 12px; }
.project-stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.bar { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.bar span { display: block; height: 100%; background: var(--c); border-radius: 99px; transition: width .3s; }

.status { font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 99px; }
.status-active { background: #e3f6ee; color: #12895f; }
.status-paused { background: #fdf1dc; color: #b06f05; }
.status-done   { background: #eceef2; color: #5d6779; }

.task-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; padding: 10px; margin-bottom: 14px; }
.task-add input[name=title] { grid-column: 1 / -1; }
.tasks { display: flex; flex-direction: column; gap: 6px; }
.task {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; transition: .12s;
}
.task:hover { border-color: var(--line-strong); }
.task form { margin: 0; display: flex; }
.task-title { flex: 1; font-size: 14.5px; }
.check {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line-strong); background: var(--panel);
  cursor: pointer; display: grid; place-items: center; font-size: 12px; color: #fff; padding: 0; transition: .12s;
}
.check:hover { border-color: var(--accent); }
.prio-1 .check { border-color: #ef9aab; }
.task.is-done .check { background: var(--accent); border-color: var(--accent); }
.task.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-del button { background: none; border: 0; color: var(--muted); cursor: pointer; opacity: 0; font-size: 13px; }
.task:hover .task-del button { opacity: 1; }
.task-del button:hover { color: var(--danger); }
.done-block { margin-top: 16px; }
.done-block summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 8px; }

/* ============ Auth ============ */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% 0%, #ecebfd 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #f6e9fb 0%, transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 36px 32px; box-shadow: var(--shadow-hover); display: flex; flex-direction: column; gap: 14px; }
.auth-card > p { text-align: center; margin: -6px 0 8px; font-size: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; }

/* ============ Toast ============ */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 50; }
.toast { background: #1d1d1f; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-hover); animation: pop .2s ease-out; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ============ Mobile ============ */
@media (max-width: 960px) {
  .two-col, .two-col-tasks, .doc-layout { grid-template-columns: 1fr; }
  .doc-side { display: none; }
  .editor-fields { grid-template-columns: 1fr; }
  .editor-fields .field-title, .editor-fields .field-tags { grid-column: auto; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; width: 280px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-hover); }
  .sidebar.open { transform: none; }
  .main { padding: 64px 16px 60px; }
  .burger { display: block; position: fixed; top: 12px; left: 12px; z-index: 41; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; }
  h1, .doc-head h1 { font-size: 26px; }
  .task-add { grid-template-columns: 1fr 1fr; }
  .task-add input[name=title] { grid-column: 1 / -1; }
  .row-meta .tag { display: none; }
  .editor-body .ck.ck-editor__main > .ck-editor__editable { padding: 14px 16px !important; }
}

/* ============ Дерево категорий/тем в сайдбаре ============ */
.tree > summary { list-style: none; cursor: pointer; }
.tree > summary::-webkit-details-marker { display: none; }
.caret { width: 12px; color: var(--muted); font-size: 15px; transition: transform .15s; display: inline-block; text-align: center; }
.tree[open] > summary .caret { transform: rotate(90deg); }
.tree > summary .nav-label:hover { color: var(--c); }
.tree-children { display: flex; flex-direction: column; margin: 2px 0 6px 21px; padding-left: 12px; border-left: 1px solid var(--line); }
.tree-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; font-size: 13.5px; color: #4a4a52; }
.tree-item:hover { background: var(--bg); color: var(--text); }
.tree-item.active { background: var(--c-soft); color: var(--c); font-weight: 500; }
.tree-add { color: var(--muted); font-size: 13px; }

/* ============ Темы ============ */
.grid-topics { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.topic-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; border-left: 3px solid var(--c); transition: .18s; }
.topic-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); color: var(--text); }
.topic-card h3 { font-size: 17px; }
.topic-card p { margin: 0; }
.topic-stats { display: flex; gap: 14px; font-size: 13px; margin-top: auto; padding-top: 8px; }
.topic-new { border: 1px dashed var(--line-strong); background: transparent; box-shadow: none; color: var(--muted); }
.crumbs a { color: var(--c); font-weight: 600; }
.crumbs a + a, .crumbs a:nth-child(2) { color: var(--muted); font-weight: 500; }

.kind { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; }
.kind-konspekt { background: var(--accent-soft); color: var(--accent); }
.kind-note { background: #fdf1dc; color: #b06f05; }

/* строка записи + быстрая кнопка редактирования */
.row-wrap { position: relative; border-bottom: 1px solid var(--line); }
.row-wrap:last-child { border-bottom: 0; }
.row-wrap .row { border-bottom: 0; padding-right: 52px; }
.row-edit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); opacity: 0; transition: .12s; }
.row-wrap:hover .row-edit { opacity: 1; }
.row-edit:hover { background: var(--c-soft); color: var(--c); }
.list + .section-title { margin-top: 32px; }

.side-link.active { border-color: var(--c, var(--accent)); color: var(--text); font-weight: 500; }
.side-add { color: var(--muted); }
@media (hover: none) { .row-edit { opacity: 1; } }
