:root {
  --paper: #fffbea; --paper2: #fff3c7; --card: #ffffff; --chat: #f3eedf;
  --strip: #ffd65c; --strip2: #f7be3c;
  --ink: #2b2416; --muted: #5c5240; --muted2: #6b604a; --line: #efe3bb; --line2: #f1e8cc;
  --tag: #9a6b00; --red: #a83232; --redbg: #fde4e1; --blue: #2457c5; --bluebg: #e6eefc; --green: #237a46; --greenbg: #e3f3e8; --orange: #8a4513; --orangebg: #fde8d6;
  --hero: #3a3226;
  --shadow: 0 1px 2px rgba(80,60,10,.06), 0 6px 16px rgba(80,60,10,.07);
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --font: Inter, -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --head: Manrope, Inter, -apple-system, "Segoe UI", system-ui, sans-serif;
}
[data-theme="dark"] {
  --paper: #17140f; --paper2: #2a2418; --card: #221d15; --chat: #1d1913;
  --strip: #e9b93a; --strip2: #d39e1c;
  --ink: #f3ead6; --muted: #c4b597; --muted2: #a39578; --line: rgba(255,220,140,.1); --line2: rgba(255,220,140,.08);
  --tag: #f0b52a; --red: #ff7b7b; --redbg: rgba(255,107,107,.15); --blue: #8ab0ff; --bluebg: rgba(122,167,255,.15); --green: #5ccf8a; --greenbg: rgba(60,192,115,.15); --orange: #ffb07a; --orangebg: rgba(255,150,80,.15);
  --hero: #0f0d09;
  --shadow: 0 1px 0 rgba(255,255,255,.03), 0 6px 18px rgba(0,0,0,.35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font: 15px/1.4 var(--font); overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { flex-shrink: 0; }
.h { font-family: var(--head); }
.muted { color: var(--muted); }

/* ---------- телефон ---------- */
#app { min-height: 100%; }
.screen { min-height: var(--tg-viewport-height, 100dvh); display: flex; flex-direction: column; padding-bottom: calc(84px + var(--safe-bottom)); }
.top { padding: calc(var(--safe-top) + 18px) 18px 16px; background: var(--strip); color: #2b2416; border-radius: 0 0 26px 26px; }
.top .sub { font-size: 13px; color: #4a3a10; margin-top: 2px; }
.top .ttl { font-family: var(--head); font-size: 30px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.top .row { display: flex; align-items: center; gap: 10px; }
.top .grow { flex: 1; min-width: 0; }
.rbtn { width: 44px; height: 44px; border-radius: 22px; background: rgba(255,255,255,.5); display: flex; align-items: center; justify-content: center; color: #2b2416; flex-shrink: 0; }
.pbtn { height: 40px; padding: 0 14px; border-radius: 20px; background: rgba(255,255,255,.55); font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; color: #2b2416; }
.search { margin-top: 12px; height: 44px; border-radius: 14px; background: rgba(255,255,255,.8); display: flex; align-items: center; gap: 8px; padding: 0 12px; color: #5c5240; }
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; color: #2b2416; min-width: 0; }
.body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.sec { font-size: 11.5px; font-weight: 700; letter-spacing: .5px; color: var(--muted2); text-transform: uppercase; margin: 6px 2px 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; line-height: 1.6; }
.empty .big { font-size: 40px; margin-bottom: 4px; }

/* плитки */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--card); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); text-align: left; min-width: 0; }
.tile.wide { grid-column: 1 / -1; }
.tile.dark { background: #2b2416; color: #fffbea; }
.tile .lbl { font-size: 11.5px; font-weight: 700; letter-spacing: .5px; color: var(--muted2); text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.tile.dark .lbl { color: #ffd65c; }
.tile .lbl.red { color: var(--red); }
.tile .big { font-size: 15px; font-weight: 600; line-height: 1.3; word-break: break-word; }
.tile .tg { font-size: 12px; color: var(--tag); font-weight: 600; }
.tile .top2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.count { font-family: var(--head); font-size: 26px; font-weight: 800; color: #ffd65c; white-space: nowrap; font-variant-numeric: tabular-nums; }
.prog { height: 6px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
.prog > div { height: 6px; border-radius: 3px; background: #ffd65c; }
.ck { width: 30px; height: 30px; border-radius: 9px; border: 2px solid #b3a57e; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.ck.on { background: var(--green); border-color: var(--green); }
.ck.sm { width: 22px; height: 22px; border-radius: 7px; }
.irow { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 7px 0; border-top: 1px solid var(--line2); width: 100%; text-align: left; }
.irow:first-of-type { border-top: 0; }
.irow .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 9px; background: var(--paper2); color: var(--muted); white-space: nowrap; }
.chip.red { background: var(--redbg); color: var(--red); }
.chip.blue { background: var(--bluebg); color: var(--blue); }
.chip.green { background: var(--greenbg); color: var(--green); }
.chip.orange { background: var(--orangebg); color: var(--orange); }
.mini { height: 72px; border-radius: 14px; background: var(--hero); position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.mini img, .thumb img, .hero img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.playb { width: 30px; height: 30px; border-radius: 15px; background: rgba(255,255,255,.9); display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.dur { position: absolute; right: 6px; bottom: 6px; font-size: 10.5px; font-weight: 600; color: #fff; background: rgba(0,0,0,.5); padding: 1px 6px; border-radius: 7px; z-index: 1; }

/* папки */
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fcard { background: var(--card); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); text-align: left; }
.fic { width: 44px; height: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.fn { font-size: 15px; font-weight: 700; line-height: 1.2; }
.fc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.fresh { font-size: 11.5px; font-weight: 700; color: var(--green); background: var(--greenbg); padding: 2px 7px; border-radius: 8px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px; background: #2b2416; color: #fffbea; text-align: left; width: 100%; }
.banner b { color: #fffbea; }
.banner .go { color: #ffd65c; font-weight: 700; font-size: 13px; margin-left: auto; white-space: nowrap; }
.banner.warn { background: var(--redbg); color: var(--red); }
.srcs { display: flex; flex-wrap: wrap; gap: 6px; }
.src { font-size: 12.5px; font-weight: 600; padding: 7px 11px; border-radius: 12px; background: var(--card); box-shadow: 0 1px 2px rgba(80,60,10,.08); }
.src b { color: var(--muted2); font-weight: 600; margin-left: 4px; }

/* фильтры */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 12px 0 0; margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.chips::-webkit-scrollbar { display: none; }
.fchip { flex-shrink: 0; font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 14px; background: rgba(255,255,255,.55); white-space: nowrap; color: #2b2416; }
.fchip.on { background: #2b2416; color: #fff; }
.fchip b { font-weight: 600; opacity: .65; margin-left: 3px; }

/* карточки записей */
.card { background: var(--card); border-radius: 18px; padding: 10px; display: flex; gap: 11px; box-shadow: var(--shadow); text-align: left; width: 100%; align-items: flex-start; }
.card.done { opacity: .55; }
.card.done .ct { text-decoration: line-through; }
.thumb { width: 64px; height: 84px; border-radius: 12px; flex-shrink: 0; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb.sq { height: 64px; }
.ct { font-size: 14.5px; font-weight: 700; line-height: 1.25; word-break: break-word; }
.cm { font-size: 12px; color: var(--muted); margin-top: 3px; }
.cs { font-size: 12.5px; color: var(--muted); line-height: 1.35; margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ctags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.ctags .tg { font-size: 12px; color: var(--tag); font-weight: 600; }
.cbody { flex: 1; min-width: 0; }

/* теги */
.cloud { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tagb { font-weight: 700; padding: 6px 11px; border-radius: 13px; background: var(--card); color: var(--tag); box-shadow: 0 1px 2px rgba(80,60,10,.08); white-space: nowrap; }
.tagb b { font-weight: 600; color: var(--muted2); margin-left: 3px; font-size: 11.5px; }
.tagb.on { background: #2b2416; color: #ffd65c; }
.tagb.on b { color: #e6dcc2; }
.box { background: var(--card); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); }
.bar { display: grid; grid-template-columns: minmax(0, 130px) minmax(0, 1fr) 28px; gap: 8px; align-items: center; font-size: 13px; padding: 4px 0; }
.bar .tr { height: 8px; border-radius: 4px; background: var(--chat); }
.bar .fl { height: 8px; border-radius: 4px; background: var(--strip2); }
.pill { font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 11px; background: var(--paper2); color: var(--tag); }

/* нижняя навигация */
.nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-around; padding: 8px 8px calc(var(--safe-bottom) + 10px); background: var(--paper); border-top: 1px solid var(--line); z-index: 5; }
.nb { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted2); width: 64px; }
.nb.on { color: var(--ink); }
.plus { width: 56px; height: 56px; border-radius: 28px; background: #2b2416; display: flex; align-items: center; justify-content: center; margin-top: -26px; box-shadow: 0 8px 20px rgba(43,36,22,.35); color: #ffd65c; }

/* шторка */
.veil { position: fixed; inset: 0; background: rgba(20,15,5,.45); z-index: 10; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; background: var(--paper); border-radius: 24px 24px 0 0; max-height: calc(var(--tg-viewport-height, 100dvh) - var(--safe-top) - 24px); overflow-y: auto; animation: up .25s cubic-bezier(.2,.9,.3,1); box-shadow: 0 -10px 40px rgba(0,0,0,.2); padding-bottom: calc(var(--safe-bottom) + 14px); }
@keyframes up { from { transform: translateY(100%); } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--muted2) 40%, transparent); margin: 8px auto 6px; }
.sp { padding: 6px 16px 0; display: flex; flex-direction: column; gap: 14px; }
.sp h3 { margin: 4px 0 0; font-family: var(--head); font-size: 20px; }

/* карточка записи */
.hero { height: 220px; background: var(--hero); position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.hero .bigplay { width: 60px; height: 60px; border-radius: 30px; background: rgba(255,255,255,.92); display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.hero .lab { position: absolute; left: 14px; bottom: 14px; font-size: 12px; font-weight: 600; color: #fff; background: rgba(0,0,0,.5); padding: 3px 9px; border-radius: 9px; z-index: 1; }
.sheet .hero { border-radius: 24px 24px 0 0; }
.dsec { font-size: 11.5px; font-weight: 700; letter-spacing: .5px; color: var(--muted2); text-transform: uppercase; margin-bottom: 6px; }
.fld { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px; background: var(--card); outline: none; font-size: 16px; }
.fld:focus { border-color: var(--strip2); }
textarea.fld { min-height: 90px; resize: vertical; line-height: 1.45; }
.ttlin { font-family: var(--head); font-size: 20px; font-weight: 800; border: 0; background: transparent; padding: 0; width: 100%; outline: none; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick button { padding: 8px 12px; border-radius: 14px; background: var(--paper2); font-size: 13.5px; font-weight: 600; }
.quick button:active { background: var(--strip); color: #2b2416; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.two label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted2); }
.rel { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line2); font-size: 13.5px; width: 100%; text-align: left; }
.rel:first-child { border-top: 0; }
.acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.acts button { min-height: 48px; border-radius: 14px; background: var(--paper2); font-weight: 600; font-size: 14px; padding: 0 6px; }
.acts .pri { background: #2b2416; color: #fff; }
.acts .dng { background: var(--redbg); color: var(--red); }
.acts .wide { grid-column: 1 / -1; }
.stamp { font-size: 12.5px; color: var(--muted); }
.sel { appearance: none; -webkit-appearance: none; border: 0; background: var(--card); box-shadow: 0 1px 2px rgba(80,60,10,.1); border-radius: 12px; padding: 8px 12px; font-size: 13.5px; font-weight: 600; max-width: 100%; }

/* добавление */
.opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 16px; background: var(--card); font-size: 12.5px; font-weight: 600; box-shadow: 0 1px 2px rgba(80,60,10,.08); }
.opt.on { background: #2b2416; color: #fff; }
.rec { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); }
.recb { width: 64px; height: 64px; border-radius: 32px; background: #2b2416; color: #ffd65c; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.recb.on { background: #c23b3b; color: #fff; box-shadow: 0 0 0 7px rgba(194,59,59,.18); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(194,59,59,.08); } }
.prop { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line2); align-items: flex-start; text-align: left; width: 100%; }
.prop:first-child { border-top: 0; }
.primary { width: 100%; min-height: 52px; border-radius: 16px; background: #2b2416; color: #fff; font-weight: 700; font-size: 15px; }
.primary:disabled { opacity: .45; }
.ghost { min-height: 52px; border-radius: 16px; background: var(--paper2); font-weight: 600; font-size: 15px; padding: 0 18px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 96px); transform: translateX(-50%); background: #2b2416; color: #fffbea; padding: 10px 16px; border-radius: 14px; font-size: 14px; z-index: 30; max-width: 88%; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: fade .2s; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .lc { width: 100%; max-width: 340px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.dropcover { position: fixed; inset: 10px; border: 3px dashed var(--strip2); border-radius: 22px; background: rgba(255,214,92,.18); z-index: 40; display: grid; place-items: center; font-size: 20px; font-weight: 700; color: var(--ink); pointer-events: none; }

/* ---------- десктоп ---------- */
body.desk .screen { padding-bottom: 0; min-height: 0; }
.dk { display: flex; flex-direction: column; height: 100vh; }
.dk-top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 18px; background: var(--strip); color: #2b2416; }
.dk-top .search { margin: 0; flex: 1 1 280px; max-width: 560px; height: 40px; }
.dk-top .tb { height: 40px; padding: 0 14px; border-radius: 12px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.6); color: #2b2416; }
.dk-top .tb.pri { background: #2b2416; color: #fff; }
.dk-body { flex: 1; display: flex; min-height: 0; }
.dk-side { width: 250px; flex-shrink: 0; background: var(--paper2); padding: 14px 10px; overflow-y: auto; }
.sb { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; font-size: 14px; font-weight: 500; width: 100%; text-align: left; }
.sb b { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.sb.on { background: #2b2416; color: #fff; }
.sb.on b { color: #e6dcc2; }
.sb .fi { font-size: 16px; width: 20px; text-align: center; }
.sbt { font-size: 11.5px; font-weight: 700; letter-spacing: .5px; color: var(--muted2); text-transform: uppercase; margin: 16px 12px 6px; display: flex; align-items: center; justify-content: space-between; }
.sbt button { font-size: 18px; color: var(--muted2); width: 28px; height: 28px; border-radius: 8px; }
.dk-main { flex: 1; min-width: 0; overflow-y: auto; }
.dk-main .top { border-radius: 0; background: transparent; color: var(--ink); padding: 18px 22px 4px; }
.dk-main .top .sub { color: var(--muted); }
.dk-main .top .fchip { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(80,60,10,.08); }
.dk-main .top .fchip.on { background: #2b2416; color: #fff; }
.dk-main .top .chips { margin: 0; padding-left: 0; padding-right: 0; flex-wrap: wrap; }
.dk-main .top .rbtn, .dk-main .top .pbtn { background: var(--card); box-shadow: 0 1px 2px rgba(80,60,10,.1); color: var(--ink); }
.dk-main .body { padding: 14px 22px 30px; }
.dk-main .tiles { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.dk-main .fgrid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.dk-pane { width: 420px; flex-shrink: 0; background: var(--card); border-left: 1px solid var(--line); overflow-y: auto; }
.dk-pane .hero { border-radius: 0; }
.dk-pane .empty { padding-top: 120px; }
.modal { position: fixed; inset: 0; background: rgba(20,15,5,.45); z-index: 20; display: grid; place-items: center; }
.modal .mc { width: min(560px, 92vw); max-height: 90vh; overflow-y: auto; background: var(--paper); border-radius: 22px; padding: 10px 0 18px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
@media (max-width: 900px) { .dk-pane { display: none; } .dk-side { width: 200px; } }
@media (max-width: 640px) { .dk-side { display: none; } }

/* ---------- плитки на рабочем столе ---------- */
body.tilesmode { background: transparent; }
body.tilesmode html, html.tilesmode { background: transparent; }
.tb-wrap { padding: 8px; display: grid; grid-template-columns: 410px 200px; gap: 12px; align-items: start; }
.tbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 14px; background: rgba(43,36,22,.82); color: #ffd65c; -webkit-app-region: drag; font-weight: 700; font-size: 13px; }
.tbar button { -webkit-app-region: no-drag; color: #fffbea; width: 30px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.tbar button:hover { background: rgba(255,255,255,.12); }
.wt { background: #fffbea; color: #2b2416; border-radius: 20px; padding: 16px; box-shadow: 0 10px 28px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 10px; }
.wt.dark { background: #2b2416; color: #fffbea; }
.wt .lbl { font-size: 11.5px; font-weight: 700; letter-spacing: .5px; color: #6b604a; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.wt.dark .lbl { color: #ffd65c; }
.wt .row { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 6px 0; border-top: 1px dashed #efe3bb; text-align: left; width: 100%; }
.wt .row:first-child { border-top: 0; }
.wt .row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wt .fd { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 12px; padding: 8px 10px; font-size: 13px; font-weight: 600; width: 100%; text-align: left; }
.wt .fd b { margin-left: auto; font-size: 12px; color: #5c5240; font-weight: 600; }
.dz { border: 2px dashed rgba(255,214,92,.9); border-radius: 20px; background: rgba(43,36,22,.55); color: #ffe9a8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 18px; text-align: center; min-height: 130px; }
.dz.over { background: rgba(255,214,92,.3); color: #2b2416; }

.card.on { box-shadow: 0 0 0 2px var(--strip2), var(--shadow); }
.tile[role=button] { cursor: pointer; }
.wt .thumb { width: 42px; height: 42px; border-radius: 10px; }
.wt .row .t b { display: block; overflow: hidden; text-overflow: ellipsis; }
