:root {
  --sidebar: #f4f4f2;
  --main: #eaf4e6;
  --ink: #22231f;
  --muted: #777a70;
  --line: rgba(34,35,31,.12);
  --card: #f9faf7;
  --accent: #5f795c;
  --accent-soft: #dbe9d5;
  --danger: #a74646;
  --shadow: 0 18px 55px rgba(52, 65, 48, .11);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--main); color: var(--ink); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

/* AUTH */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 50% 15%, #f8fbf6 0, var(--main) 48%, #dfead9 100%); }
.auth-card { width: min(430px, 100%); background: rgba(255,255,255,.84); backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 28px; padding: 34px; box-shadow: var(--shadow); }
.auth-brand { font-family: Literata, serif; font-size: 29px; margin-bottom: 8px; }
.auth-note { margin: 0 0 28px; color: var(--muted); line-height: 1.55; font-size: 14px; }
.field { display: grid; gap: 8px; margin: 16px 0; }
.field label { font-size: 13px; font-weight: 600; color: #55584f; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); background: white; border-radius: 13px; padding: 13px 14px; outline: none; }
.field input:focus, .field textarea:focus { border-color: rgba(95,121,92,.65); box-shadow: 0 0 0 4px rgba(95,121,92,.10); }
.primary-btn { border: 0; background: var(--ink); color: white; border-radius: 13px; padding: 13px 18px; cursor: pointer; font-weight: 600; }
.primary-btn:hover { opacity: .9; }
.auth-error { min-height: 20px; color: var(--danger); margin-top: 12px; font-size: 13px; }
.pin-row { display: flex; justify-content: center; gap: 9px; margin: 22px 0; }
.pin-box { width: 43px; height: 50px; border-radius: 12px; border: 1px solid var(--line); background: white; text-align: center; font-size: 23px; }

/* APP LAYOUT */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 290px 1fr; }
.sidebar { min-height: 100vh; background: var(--sidebar); border-right: 1px solid var(--line); padding: 36px 25px 22px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { font-family: Literata, serif; font-size: 22px; font-weight: 600; padding: 7px 8px 36px; }
.sidebar-nav { display: grid; gap: 4px; }
.nav-title { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: #85887e; padding: 8px 10px; margin-top: 5px; }
.nav-tree-group { display: grid; gap: 2px; }
.nav-parent-row { display: grid; grid-template-columns: 28px 1fr; align-items: center; border-radius: 10px; }
.nav-parent-row:hover { background: rgba(0,0,0,.04); }
.nav-parent-row.active { background: rgba(95,121,92,.12); }
.tree-toggle { width: 28px; height: 38px; border: 0; background: transparent; cursor: pointer; color: #757970; font-size: 21px; display:flex; align-items:center; justify-content:center; padding:0; border-radius:9px; }
.tree-toggle:hover { background: rgba(0,0,0,.04); }
.nav-parent { width: 100%; border: 0; background: transparent; text-align: left; padding: 10px 11px 10px 2px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.section-icon { font-size: 15px; }
.nav-children { display: grid; gap: 2px; margin-left: 28px; padding-left: 9px; border-left: 1px solid rgba(40,45,38,.11); }
.tree-bullet { width: 12px; color: #858b80; font-size: 17px; line-height: 1; text-align:center; }
.tree-plus { width: 12px; color: #6d7268; font-size: 15px; line-height: 1; text-align:center; }
.nav-item { width: 100%; border: 0; background: transparent; text-align: left; border-radius: 10px; padding: 10px 11px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.nav-item:hover { background: rgba(0,0,0,.04); }
.nav-item.active { background: rgba(95,121,92,.12); font-weight: 600; }
.nav-item.sub { padding: 8px 10px 8px 8px; font-size: 14px; }
.nav-add { color: #575b52; font-weight: 600; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 4px; }
.demo-badge { margin: 10px 8px 2px; font-size: 11px; line-height: 1.4; color: #876f36; background: #fff7dc; border: 1px solid #ead99d; padding: 9px 10px; border-radius: 10px; }

.main { min-width: 0; min-height: 100vh; background: var(--main); }
.topbar { height: 72px; display: flex; align-items: center; gap: 12px; padding: 0 30px; border-bottom: 1px solid transparent; }
.mobile-menu { display: none; }
.breadcrumbs { color: #74776e; font-size: 14px; }
.content { padding: 30px clamp(24px, 5vw, 78px) 70px; max-width: 1440px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.page-title { font-family: Literata, serif; font-size: clamp(32px, 4vw, 52px); line-height: 1.1; margin: 0; }
.page-subtitle { color: var(--muted); margin: 8px 0 0; }

/* CARDS */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px; }
.note-card { min-height: 190px; border: 1px solid var(--line); background: rgba(255,255,255,.74); border-radius: 18px; padding: 18px; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 8px 24px rgba(50,64,46,.05); transition: transform .18s ease, box-shadow .18s ease; text-align: left; }
.note-card:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(50,64,46,.09); }
.note-title { font-family: Literata, serif; font-size: 21px; line-height: 1.25; }
.note-meta { font-size: 12px; color: var(--muted); }
.note-preview { font-size: 13px; line-height: 1.5; color: #6b6e66; margin-top: 10px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.create-card { border: 1px dashed rgba(34,35,31,.25); background: rgba(255,255,255,.34); align-items: center; justify-content: center; text-align: center; gap: 10px; }
.create-plus { font-size: 38px; line-height: 1; font-weight: 300; }
.empty-state { max-width: 560px; margin: 16vh auto 0; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--ink); font-family: Literata, serif; font-size: 32px; margin-bottom: 10px; }

/* EDITOR */
.editor-wrap { max-width: 900px; margin: 0 auto; }
.editor-title { width: 100%; border: 0; background: transparent; outline: none; font-family: Literata, serif; font-size: clamp(34px,5vw,58px); line-height: 1.12; color: var(--ink); padding: 8px 0 12px; }
.editor-meta { font-size: 12px; color: var(--muted); margin-bottom: 24px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 14px; position: sticky; top: 12px; z-index: 5; backdrop-filter: blur(12px); }
.tool-btn { border: 0; background: transparent; border-radius: 9px; min-width: 34px; height: 34px; cursor: pointer; }
.tool-btn:hover { background: rgba(0,0,0,.06); }
.editor-body { margin-top: 18px; min-height: 54vh; background: rgba(255,255,255,.58); border: 1px solid rgba(34,35,31,.08); border-radius: 18px; padding: 28px; outline: none; line-height: 1.72; font-size: 16px; }
.editor-body:empty:before { content: "Начните конспект…"; color: #9b9e95; }
.editor-body h2 { font-family: Literata, serif; font-size: 26px; }
.back-btn { border: 0; background: transparent; padding: 8px 0; cursor: pointer; color: #5e625a; margin-bottom: 18px; }
.save-state { font-size: 12px; color: var(--muted); margin-left: auto; align-self: center; }

/* SETTINGS */
.settings-grid { display: grid; gap: 18px; max-width: 780px; }
.panel { background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 20px; padding: 22px; }
.panel h3 { margin: 0 0 6px; font-family: Literata, serif; font-size: 21px; }
.panel p { margin: 0 0 15px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.color-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.color-field input { height: 46px; padding: 4px; }
.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.secondary-btn { border: 1px solid var(--line); background: rgba(255,255,255,.6); border-radius: 12px; padding: 11px 15px; cursor: pointer; }
.danger-btn { color: var(--danger); }
.codebox { min-height: 180px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.55; }

/* MODAL */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,22,18,.28); display: grid; place-items: center; padding: 20px; z-index: 40; }
.modal { width: min(440px,100%); background: #fbfcf8; border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 16px; font-family: Literata, serif; font-size: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(315px, 88vw); z-index: 30; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 18px 0 50px rgba(0,0,0,.13); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.18); z-index: 20; }
  .mobile-menu { display: inline-flex; border: 0; background: rgba(255,255,255,.65); width: 40px; height: 40px; border-radius: 11px; align-items: center; justify-content: center; cursor: pointer; }
  .topbar { height: 62px; padding: 0 15px; }
  .content { padding: 22px 16px 56px; }
  .page-head { align-items: flex-start; }
  .notes-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .note-card { min-height: 156px; padding: 15px; border-radius: 15px; }
  .note-title { font-size: 17px; }
  .editor-body { padding: 20px 17px; border-radius: 14px; }
  .color-row { grid-template-columns: 1fr; }
}
@media (max-width: 390px) {
  .notes-grid { grid-template-columns: 1fr; }
}

/* PHOTOS */
.visually-hidden { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; margin:-1px!important; overflow:hidden!important; clip:rect(0,0,0,0)!important; white-space:nowrap!important; border:0!important; }
.photo-btn { padding: 0 10px; width:auto; display:inline-flex; align-items:center; gap:6px; }
.editor-body .note-image { display:block; max-width:100%; width:auto; max-height:780px; object-fit:contain; margin:22px auto; border-radius:14px; box-shadow:0 8px 28px rgba(36,42,34,.08); }
.editor-body.is-dragging { outline:2px dashed var(--accent); outline-offset:4px; background:rgba(255,255,255,.78); }
@media (max-width:760px){ .photo-btn span{display:none;} .editor-body .note-image{margin:16px auto;border-radius:10px;} }

/* CHECKLISTS */
.section-link { margin-top: 4px; font-size: 14px; }
.checklist-card-meta { margin-top: 13px; color: var(--muted); font-size: 13px; }
.progress-track { height: 6px; margin-top: 12px; border-radius: 999px; background: rgba(34,35,31,.09); overflow: hidden; }
.progress-track span { display:block; height:100%; background: var(--accent); border-radius: inherit; transition: width .2s ease; }
.checklist-page { max-width: 820px; margin: 0 auto; }
.checklist-title-input { margin-bottom: 2px; }
.checklist-summary { color: var(--muted); font-size: 13px; margin: 2px 0 26px; }
.checklist-list { display: grid; gap: 8px; }
.checklist-row { display: grid; grid-template-columns: 34px 1fr 34px; gap: 10px; align-items: center; min-height: 52px; background: rgba(255,255,255,.66); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; }
.checklist-row.done .check-text { color: #92968d; text-decoration: line-through; }
.check-control { width: 30px; height: 30px; display:grid; place-items:center; cursor:pointer; position:relative; }
.check-control input { position:absolute; opacity:0; pointer-events:none; }
.fake-check { width: 21px; height: 21px; border: 1.5px solid #a7aba2; border-radius: 7px; display:grid; place-items:center; color: transparent; font-size: 13px; font-weight:700; background:white; }
.check-control input:checked + .fake-check { background: var(--accent); color:white; border-color:var(--accent); }
.check-text { min-width:0; line-height:1.45; }
.check-delete { width:30px; height:30px; border:0; background:transparent; border-radius:8px; cursor:pointer; color:#9a706d; font-size:21px; opacity:.35; }
.checklist-row:hover .check-delete { opacity:1; }
.check-delete:hover { background:rgba(167,70,70,.08); }
.check-add { display:grid; grid-template-columns: 24px 1fr auto; gap:10px; align-items:center; margin-top:12px; padding: 10px 12px; border:1px dashed rgba(34,35,31,.2); background:rgba(255,255,255,.33); border-radius:14px; }
.check-add > span { color:var(--muted); font-size:19px; }
.check-add input { border:0; background:transparent; outline:none; min-width:0; padding:8px 0; }
.check-add button { border:0; background:transparent; color:var(--accent); font-weight:700; cursor:pointer; padding:7px 8px; }
@media (max-width:760px){ .checklist-row{grid-template-columns:30px 1fr 30px}.check-add{grid-template-columns:22px 1fr}.check-add button{display:none}.check-delete{opacity:.65} }
