:root {
  --bg: #0E0E0E; --surface: #1A1A1A; --surface-2: #2A2A2A; --border: #2E2E2E;
  --text: #EDEDED; --muted: #8A8A8A; --accent: #FFB020; --on-accent: #241600; --danger: #FF5A5A;
  --safe-top: var(--tg-content-safe-area-inset-top, 0px);
  --safe-bottom: max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 400 14px/1.45 -apple-system, BlinkMacSystemFont, Roboto, "Noto Sans", sans-serif;
  min-height: 100vh; overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { flex: none; }

/* заставка «Собирается» */
.splash { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; background: var(--bg); z-index: 50; transition: opacity .3s; }
.splash.out { opacity: 0; pointer-events: none; }
.splash-g { stroke-dasharray: 150; stroke-dashoffset: 150; animation: draw 1.1s cubic-bezier(.3,.7,.3,1) .1s forwards; }
.splash-block { transform-origin: 67px 84.5px; transform: scaleY(0); animation: rise .5s cubic-bezier(.3,.7,.3,1) 1s forwards; }
.wordmark { font-weight: 700; font-size: 24px; letter-spacing: -.3px; opacity: 0; animation: fade .5s 1.4s forwards; }
.wordmark span { color: var(--accent); }
.splash-error { color: var(--muted); text-align: center; max-width: 280px; margin: 8px 0 0; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes rise { to { transform: scaleY(1); } }
@keyframes fade { to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* каркас */
main { max-width: 480px; margin: 0 auto; padding: calc(12px + var(--safe-top)) 16px calc(84px + var(--safe-bottom)); }
.head { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; min-height: 32px; }
.head h1 { font-size: 20px; font-weight: 600; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head .brand { font-size: 17px; font-weight: 700; flex: 1; }
.head .brand span { color: var(--accent); }
.pill { font-size: 12px; color: var(--muted); background: var(--surface); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.pro { color: var(--on-accent); background: var(--accent); font-weight: 600; }
.card { background: var(--surface); border-radius: 14px; padding: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: rgba(14,14,14,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: .5px solid var(--border); padding: 6px 8px calc(6px + var(--safe-bottom)); z-index: 20; }
.nav button { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; color: var(--muted); padding: 4px 0; }
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.nav button.on { color: var(--accent); }

/* главная */
.grab { display: flex; gap: 8px; background: var(--surface); border-radius: 14px; padding: 6px; }
.grab input { flex: 1; min-width: 0; background: transparent; border: 0; padding: 10px 8px; outline: none; }
.grab input::placeholder { color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px;
  padding: 11px 16px; font-weight: 600; background: var(--surface-2); min-height: 44px; }
.btn.accent { background: var(--accent); color: var(--on-accent); }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.now { display: flex; align-items: center; gap: 14px; }
.ring { width: 52px; height: 52px; position: relative; }
.ring svg { width: 52px; height: 52px; }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--surface-2); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .4s;
  transform-origin: 50px 50px; transform: rotate(-90deg); }
.ring.spin .bar { animation: orbit 1.1s linear infinite; }
@keyframes orbit { from { transform: rotate(-90deg); } to { transform: rotate(270deg); } }
.thumb-btn { display: block; width: 100%; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface); border-radius: 14px; padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 6px; min-height: 92px; }
.tile svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tile b { font-weight: 600; font-size: 15px; }

/* галерея */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin: 0 -16px 10px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 999px; background: var(--surface); color: var(--text); font-size: 13px; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.chips.sub .chip { background: transparent; border: .5px solid var(--border); color: var(--muted); padding: 5px 11px; font-size: 12px; }
.chips.sub .chip.on { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.thumb { position: relative; aspect-ratio: 9 / 14; border-radius: 10px; overflow: hidden; background: var(--surface); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.thumb .ph svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.badge { position: absolute; right: 5px; bottom: 5px; font-size: 11px; background: rgba(14,14,14,.82); padding: 1px 5px; border-radius: 5px; }
.badge.left { left: 5px; right: auto; }
.lockbar { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.lockbar p { flex: 1; margin: 0; color: var(--muted); }
.empty { text-align: center; padding: 40px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty h2 { font-size: 16px; font-weight: 600; margin: 4px 0 0; }
.empty p { color: var(--muted); margin: 0 0 8px; max-width: 280px; }
.skeleton { background: var(--surface); border-radius: 10px; aspect-ratio: 9 / 14; animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .55; } to { opacity: 1; } }

/* списки: папки, профиль */
.row { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 14px; padding: 12px 14px; text-align: left; width: 100%; min-height: 56px; }
.row .emoji { font-size: 24px; width: 32px; text-align: center; }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .val { color: var(--muted); white-space: nowrap; }
.row .val.accent { color: var(--accent); }
.row.danger { color: var(--danger); }
.chev { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; }
.locked { color: var(--muted); }
.item { display: flex; gap: 12px; background: var(--surface); border-radius: 14px; padding: 10px; text-align: left; width: 100%; }
.item .thumb { width: 64px; flex: none; }
.item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item .title { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.item .note { color: var(--accent); font-size: 13px; word-break: break-word; }
.who { display: flex; align-items: center; gap: 12px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 18px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.section { margin: 18px 0 8px; color: var(--muted); font-size: 12px; text-transform: none; }

/* нижний лист */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-back { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto; background: var(--surface);
  border-radius: 18px 18px 0 0; padding: 10px 16px calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px;
  max-height: 85vh; overflow-y: auto; animation: up .22s cubic-bezier(.3,.7,.3,1); }
.sheet-body::before { content: ""; width: 36px; height: 4px; border-radius: 2px; background: var(--surface-2); margin: 0 auto 6px; }
.sheet-body h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; word-break: break-word; }
.sheet-body .row { background: var(--surface-2); }
.field { width: 100%; background: var(--surface-2); border: 0; border-radius: 10px; padding: 12px; outline: none; resize: vertical; }
.field:focus { outline: 2px solid var(--accent); }
.emojis { display: flex; flex-wrap: wrap; gap: 6px; }
.emojis button { font-size: 22px; width: 42px; height: 42px; border-radius: 10px; background: var(--surface-2); }
.emojis button.on { outline: 2px solid var(--accent); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; z-index: 60; max-width: calc(100% - 32px); text-align: center; font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation-duration: .01ms !important; animation-delay: 0s !important; transition: none !important; }
}
