/* Мини-приложение «Память». Основной экран 360 px; цвета из темы Telegram (переменные ставит tg.ts). */
:root {
  --bg: #ffffff; --bg2: #f1f1f4; --section: #ffffff; --text: #111111; --hint: #7d7d85; --link: #2678b6;
  --btn: #2481cc; --btn-text: #ffffff; --danger: #d33b3b; --accent: #2481cc;
  --e-low: #9a9aa2; --e-mid: #3b82f6; --e-high: #22a559; --line: rgba(127, 127, 135, 0.25);
  --tabbar: 56px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

.screen { max-width: 720px; margin: 0 auto; padding: 12px 12px calc(var(--tabbar) + 24px); min-height: 100vh; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar); display: flex; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11px; color: var(--hint); text-align: center; }
.tab.on { color: var(--accent); }
.tab-icon { font-size: 18px; line-height: 1; }

.banner { position: sticky; top: 0; z-index: 6; background: #f5c542; color: #3a2d00; text-align: center; padding: 6px 12px; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px); transform: translateX(-50%); background: rgba(0, 0, 0, 0.85); color: #fff; padding: 8px 14px; border-radius: 18px; z-index: 20; font-size: 13px; }

.splash { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; background: var(--bg); }
.splash h1 { font-size: 20px; }
.splash p { color: var(--hint); }

.section { margin-top: 18px; }
.section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--hint); font-weight: 600; margin: 0 4px 8px; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.card { display: flex; gap: 10px; align-items: flex-start; width: 100%; background: var(--section); border-radius: 12px; padding: 10px 12px; }
.card.static { cursor: default; }
.card.overdue .card-title { color: var(--danger); }
.card-emoji { font-size: 20px; line-height: 1.2; flex: none; }
.card-body { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.card-title { font-weight: 500; overflow-wrap: anywhere; }
.card-snippet { color: var(--hint); font-size: 13px; overflow-wrap: anywhere; }
.card-meta, .meta { color: var(--hint); font-size: 12px; }
mark { background: rgba(255, 210, 0, 0.45); color: inherit; border-radius: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; background: var(--section); border-radius: 16px; padding: 6px 12px; font-size: 13px; white-space: nowrap; }
.chip.on { background: var(--btn); color: var(--btn-text); }
.filterbar { margin: 4px 0 10px; }

.btn { display: inline-block; background: var(--btn); color: var(--btn-text); border-radius: 10px; padding: 9px 16px; text-align: center; }
.btn.ghost { background: var(--section); color: var(--text); }
.btn.wide { display: block; width: 100%; margin-top: 20px; }
.input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--section); color: var(--text); font: inherit; }
.searchbar { margin-bottom: 10px; }
.row2 { display: flex; gap: 8px; margin-top: 10px; }
.row2 > * { flex: 1; }

.empty, .error { text-align: center; color: var(--hint); padding: 28px 12px; }
.error { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.skeleton { display: flex; flex-direction: column; gap: 10px; }
.sk-block { background: var(--section); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.sk-line { height: 10px; border-radius: 5px; background: var(--line); animation: pulse 1.2s ease-in-out infinite; }
.w60 { width: 60%; } .w90 { width: 90%; }
@keyframes pulse { 50% { opacity: 0.4; } }
.sentinel { height: 1px; }

.entry-title { font-size: 20px; margin: 4px 0 6px; overflow-wrap: anywhere; }
.md { margin-top: 12px; background: var(--section); border-radius: 12px; padding: 12px; overflow-wrap: anywhere; }
.md p { margin: 0 0 10px; } .md p:last-child { margin-bottom: 0; }
.md a { color: var(--link); }
.md pre { overflow-x: auto; background: var(--bg2); padding: 8px; border-radius: 8px; }
.md code { background: var(--bg2); padding: 1px 4px; border-radius: 4px; }
.md pre code { padding: 0; background: none; }
.md ul, .md ol { padding-left: 22px; margin: 0 0 10px; }
.md blockquote { margin: 0 0 10px; padding-left: 10px; border-left: 3px solid var(--line); color: var(--hint); }
.md .img-ph { color: var(--hint); font-style: italic; }

.tasks { display: flex; flex-direction: column; }
.task { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.task[data-depth="1"] { padding-left: 28px; } .task[data-depth="2"] { padding-left: 52px; } .task[data-depth="3"] { padding-left: 76px; }
.check { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2px solid var(--hint); position: relative; }
.check.on { background: var(--e-high); border-color: var(--e-high); }
.check.on::after { content: "✓"; position: absolute; inset: 0; color: #fff; font-size: 14px; line-height: 20px; text-align: center; }
.task-title.done { text-decoration: line-through; color: var(--hint); }
.task-due { margin-left: auto; color: var(--hint); font-size: 12px; }

.monthnav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.month-title { font-weight: 600; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; background: var(--section); border-radius: 12px; padding: 8px; }
.wd { text-align: center; font-size: 11px; color: var(--hint); }
.day { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 8px; position: relative; text-align: center; }
.day.blank { pointer-events: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.dot.e-low { background: var(--e-low); } .dot.e-mid { background: var(--e-mid); } .dot.e-high { background: var(--e-high); }
.tick { position: absolute; top: 1px; right: 4px; font-size: 10px; color: var(--e-high); }
.stats { display: flex; gap: 8px; margin: 8px 0; }
.stat { flex: 1; background: var(--section); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; align-items: center; }
.stat b { font-size: 20px; } .stat span { font-size: 11px; color: var(--hint); }

.fold { margin-top: 12px; } .fold summary { color: var(--hint); padding: 6px 4px; }
.chart { width: 100%; height: auto; background: var(--section); border-radius: 12px; }
.chart .grid { stroke: var(--line); stroke-width: 0.5; }
.chart .axis { fill: var(--hint); font-size: 8px; }
.ln { stroke-width: 1.6; } .ln.energy { stroke: var(--e-mid); } .ln.mood { stroke: #e8903a; }
.pt.energy { fill: var(--e-mid); } .pt.mood { fill: #e8903a; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 4px 6px; font-size: 12px; color: var(--hint); }
.lg::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; background: currentColor; }
.lg.energy { color: var(--e-mid); } .lg.mood { color: #e8903a; }
.t-idea { fill: #f0b429; color: #f0b429; } .t-decision { fill: #7c5cd6; color: #7c5cd6; } .t-promise { fill: #e0594a; color: #e0594a; }
.t-note { fill: #3b82f6; color: #3b82f6; } .t-lesson { fill: #22a559; color: #22a559; } .t-material { fill: #8a8a93; color: #8a8a93; }
.t-person { fill: #d6579a; color: #d6579a; } .t-inbox { fill: #b0916a; color: #b0916a; } .t-task { fill: #2aa5a5; color: #2aa5a5; }
.t-journal { fill: #6a7fd6; color: #6a7fd6; } .t-project { fill: #5c6bc0; color: #5c6bc0; } .t-goal { fill: #c27c2c; color: #c27c2c; }
.t-area { fill: #6f9f4a; color: #6f9f4a; } .t-rule { fill: #a05cc2; color: #a05cc2; }
.legend .lg[class*="t-"] { fill: none; }

.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); display: flex; align-items: flex-end; z-index: 30; }
.sheet { width: 100%; max-width: 720px; margin: 0 auto; background: var(--bg); border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet h3 { font-size: 13px; color: var(--hint); margin: 12px 0 6px; text-transform: uppercase; }

@media (min-width: 640px) { .screen { padding-top: 20px; } .tabs { max-width: 720px; margin: 0 auto; } }
