:root {
  --bg: #0F1113;
  --bar: #15181B;
  --card: #181B1F;
  --card-2: #22262B;
  --line: #262A2F;
  --line-2: #3A3F46;
  --text: #F3F1EC;
  --text-2: #DADDE1;
  --muted: #A3A8AE;
  --accent: #C8F560;
  --accent-ink: #0F1113;
  --accent-text: #C8F560;
  --accent-soft: #2A3318;
  --warn: #FF9B6B;
  --link: #7FB2FF;
  --radius: 20px;
  --display: "Unbounded", "Manrope", system-ui, sans-serif;
  --body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme="light"] {
  --bg: #F4F3EF;
  --bar: #FFFFFF;
  --card: #FFFFFF;
  --card-2: #EEEDE8;
  --line: #E4E2DC;
  --line-2: #CFCCC4;
  --text: #16181B;
  --text-2: #33373C;
  --muted: #62676E;
  --accent: #C8F560;
  --accent-ink: #16181B;
  --accent-text: #3F6400;
  --accent-soft: #EAF7C9;
  --warn: #B4471B;
  --link: #1F63C7;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); }
body { min-height: 100vh; }
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
a { color: var(--accent-text); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#screen { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* заголовки */
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 4px; }
h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 26px; letter-spacing: -0.01em; }
.sub { font-size: 14px; color: var(--muted); line-height: 1.45; }
.kicker { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.count b { color: var(--accent-text); }
.count { font-size: 14px; font-weight: 700; color: var(--muted); }

/* сегменты */
.seg { display: flex; gap: 4px; background: var(--card); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* карточка */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-top { display: flex; align-items: center; gap: 10px; }
.ava { width: 34px; height: 34px; border-radius: 50%; color: #0F1113; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ava.lg { width: 38px; height: 38px; }
.card-src { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-src b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-src span { font-size: 12px; color: var(--muted); }
.chip { font-size: 12px; font-weight: 700; border-radius: 8px; padding: 4px 8px; background: var(--card-2); color: var(--text-2); white-space: nowrap; }
.card h2 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.3; }
.bullets { display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.45; color: var(--text-2); }
.bullets div { display: flex; gap: 10px; }
.bullets .lbl { color: var(--accent-text); font-weight: 700; width: 92px; flex-shrink: 0; }
.plain { font-size: 14px; line-height: 1.5; color: var(--text-2); white-space: pre-line; }
.media { width: 100%; max-height: 260px; object-fit: cover; border-radius: 14px; background: var(--card-2); display: block; }
.meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.meta button { border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; text-decoration: underline; }
.dups { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.actions { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
.icon-btn.down svg { transform: rotate(180deg); }
.icon-btn.saved svg { fill: currentColor; }
.grow { flex: 1; }
.ghost { height: 40px; border: 1px solid var(--line-2); border-radius: 12px; background: transparent; font-weight: 600; font-size: 13px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; }
.ghost svg { width: 14px; height: 14px; }
.why { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.why svg { width: 14px; height: 14px; }

.btn { height: 46px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.secondary { background: var(--card-2); color: var(--text); font-weight: 600; }
.btn.danger { background: var(--warn); color: #0F1113; }
.btn:disabled { opacity: 0.5; }
.btn.wide { width: 100%; }
.link-btn { border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: underline; min-height: 44px; align-self: center; }

/* пустые состояния и загрузка */
.empty { text-align: center; padding: 40px 16px; display: flex; flex-direction: column; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; line-height: 1.5; }
.empty b { color: var(--text); font-size: 17px; font-family: var(--display); }
.skeleton { height: 180px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card) 0%, var(--card-2) 50%, var(--card) 100%); background-size: 200% 100%; animation: sh 1.2s infinite linear; }
@keyframes sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* списки */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px; display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 10px; min-height: 64px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-main b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main span { font-size: 12px; color: var(--muted); }
.row-main .warn { color: var(--warn); }
.row-main.wrap b { white-space: normal; }
.bar { width: 44px; height: 4px; border-radius: 2px; background: var(--line-2); display: inline-flex; vertical-align: middle; margin-right: 6px; }
.bar i { height: 4px; border-radius: 2px; background: var(--accent); display: block; }
.paused b { color: var(--muted); }

.switch { width: 50px; height: 30px; border: 0; border-radius: 15px; background: var(--line-2); padding: 3px; display: flex; justify-content: flex-start; flex-shrink: 0; }
.switch span { width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] span { background: var(--accent-ink); transform: translateX(20px); }

.progress { height: 6px; border-radius: 3px; background: var(--card-2); }
.progress i { display: block; height: 6px; border-radius: 3px; background: var(--accent); }

.add-box { background: var(--card); border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.add-box label { font-size: 14px; font-weight: 600; }
.input-row { display: flex; gap: 8px; }
.input { flex: 1; min-width: 0; height: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg); padding: 0 12px; font-size: 15px; }
.input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.tile b { font-family: var(--display); font-size: 22px; }
.tile span { font-size: 13px; color: var(--muted); }
.cat { border: 1px solid var(--line); border-radius: 16px; background: var(--card); min-height: 64px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; }
.cat b { font-size: 14px; display: block; }
.cat span { font-size: 12px; color: var(--muted); }

.hero { background: var(--accent); color: #0F1113; border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.hero .big { font-family: var(--display); font-weight: 700; font-size: 40px; line-height: 1; }
.hero .lbl { font-size: 14px; font-weight: 700; }
.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: end; height: 80px; }
.bars div { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; font-size: 11px; font-weight: 700; }
.bars i { display: block; width: 100%; border-radius: 6px; background: rgba(15,17,19,.85); min-height: 4px; }

.top-row { display: flex; gap: 12px; align-items: center; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--text); min-height: 32px; }
.top-row .n { font-family: var(--display); color: var(--accent-text); width: 16px; }
.top-row .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-row small { color: var(--muted); font-weight: 500; }

.more { align-self: center; }

/* нижнее меню */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); background: var(--bar); border-top: 1px solid var(--line); z-index: 10; }
.tab { height: 52px; border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--accent-text); font-weight: 700; }

/* нижний лист */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--bar); border-radius: 22px 22px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0; font-family: var(--display); font-size: 18px; }
.grabber { width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); align-self: center; }
textarea { width: 100%; min-height: 96px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--bg); padding: 12px; font-size: 15px; resize: vertical; }
.bubble-me { align-self: flex-end; max-width: 85%; background: var(--accent-soft); border-radius: 16px 16px 6px 16px; padding: 10px 14px; font-size: 15px; }
.bubble-bot { max-width: 92%; background: var(--card-2); border-radius: 16px 16px 16px 6px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.rule-line { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--accent); }
.dot.lower, .dot.hide { background: var(--warn); }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.check-row { display: flex; align-items: center; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--line); }
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); }

#toast { position: fixed; left: 50%; width: max-content; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s; z-index: 30; display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
#toast button { border: 0; background: none; color: #3F6400; font-weight: 700; font-size: 14px; padding: 4px; }
:root[data-theme="light"] #toast button { color: #C8F560; }
