:root {
  --bg: #0A100D;
  --surface: #121A16;
  --surface-2: #19241E;
  --edge: #1D2822;
  --line: #243129;
  --line-strong: #2E3F35;
  --text: #EEF3EE;
  --text-2: #D6DED8;
  --muted: #9DAEA3;
  --dim: #7E8F84;
  --accent: #C8F169;
  --accent-ink: #2C3A10;
  --green: #3DDC97;
  --deleted: #FF8F7E;
  --deleted-bg: #33201C;
  --edited: #F2C14E;
  --edited-bg: #33291A;
  --media: #C3A6FF;
  --media-bg: #261F38;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Manrope', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { min-height: 100vh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px calc(112px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#app.no-tabs { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.loader {
  width: 28px; height: 28px; margin: 40vh auto 0;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- типографика --- */
.serif { font-family: var(--serif); font-style: italic; font-weight: 600; letter-spacing: -0.01em; }
.h1 { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 46px; line-height: 1; letter-spacing: -0.02em; }
.h2 { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 28px; line-height: 1.05; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.lead { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.mono { font-family: var(--mono); }
.accent { color: var(--accent); }
.muted { color: var(--muted); }

/* --- шапка --- */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 12px; }
.wordmark { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 30px; letter-spacing: -0.01em; }
.wordmark span { color: var(--accent); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: 15px; border: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--muted);
  white-space: nowrap;
}
.dot { width: 6px; height: 6px; border-radius: 3px; background: var(--green); flex-shrink: 0; }
.dot.off { background: var(--deleted); }

/* --- карточки --- */
.card { background: var(--surface); border: 1px solid var(--edge); border-radius: 24px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card.tight { padding: 14px; gap: 10px; border-radius: 22px; }
.hero { background: var(--accent); color: var(--bg); border-radius: 28px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.hero .eyebrow, .hero .meta { color: var(--accent-ink); }
.hero .big { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 46px; line-height: .95; letter-spacing: -0.02em; }
.hero .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.meta { font-family: var(--mono); font-size: 12px; }
.bar { height: 4px; border-radius: 2px; background: rgba(10, 16, 13, .18); overflow: hidden; }
.bar > div { height: 4px; background: var(--bg); }

/* --- кнопки --- */
.btn {
  min-height: 52px; border-radius: 26px; border: 0; padding: 0 20px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; font-size: 16px; width: 100%;
}
.btn.primary { background: var(--accent); color: var(--bg); }
.btn.dark { background: var(--bg); color: var(--accent); min-height: 48px; font-size: 15px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line-strong); min-height: 46px; font-size: 14px; font-weight: 700; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: transparent;
  display: flex; align-items: center; justify-content: center; color: var(--text); flex-shrink: 0;
}
.chip-btn {
  height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line-strong); background: transparent;
  color: var(--accent); font-weight: 800; font-size: 12px; letter-spacing: .08em;
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.badge { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; padding: 6px 10px; border-radius: 999px; }
.badge.on { background: var(--accent); color: var(--bg); }
.badge.soon { border: 1px solid var(--line-strong); color: var(--muted); }

/* --- статистика --- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--edge); border-radius: 20px; padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.stat .num { font-family: var(--mono); font-size: 26px; }
.stat .lbl { display: flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; padding-top: 6px; gap: 8px; }

/* --- события --- */
.event-head { display: flex; align-items: center; gap: 10px; }
.event-icon { width: 34px; height: 34px; border-radius: 17px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.event-icon.deleted { background: var(--deleted-bg); color: var(--deleted); }
.event-icon.edited { background: var(--edited-bg); color: var(--edited); }
.event-who { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.event-who b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-who span { font-size: 12px; font-weight: 600; }
.event-who .deleted { color: var(--deleted); }
.event-who .edited { color: var(--edited); }
.event-time { font-family: var(--mono); font-size: 12px; color: var(--dim); flex-shrink: 0; }
.quote { font-size: 14px; line-height: 1.45; color: var(--text-2); background: var(--surface-2); border-radius: 14px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; }
.diff { display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.diff .was { color: var(--dim); text-decoration: line-through; }
.media-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--media); font-weight: 700; }

.empty { text-align: center; padding: 28px 18px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty .h2 { font-size: 26px; }

/* --- подключение --- */
.steps { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.steps li { display: flex; gap: 16px; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--line); }
.steps .n { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 28px; color: var(--accent); width: 22px; flex-shrink: 0; }
.steps .t { font-size: 15px; font-weight: 700; }
.steps .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.copy {
  margin-top: 8px; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line-strong); background: var(--surface);
  font-family: var(--mono); font-size: 13px; display: inline-flex; align-items: center; gap: 8px;
}
.note { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--edge); border-radius: 18px; padding: 12px 14px; font-size: 13px; line-height: 1.45; color: #B8D9C6; }
.note svg { flex-shrink: 0; margin-top: 1px; color: var(--green); }
.fine { text-align: center; font-size: 12px; color: var(--dim); line-height: 1.5; }

/* --- сервисы --- */
.svc-top { display: flex; align-items: center; justify-content: space-between; }
.svc-icon { width: 42px; height: 42px; border-radius: 21px; display: flex; align-items: center; justify-content: center; }
.svc-desc { font-size: 14px; color: var(--muted); line-height: 1.45; margin: 4px 0 0; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--edge); border-radius: 24px; padding: 16px; display: flex; flex-direction: column; gap: 18px; color: var(--text); text-align: left; }
.tile:disabled { cursor: default; }
.tile .h2 { font-size: 24px; }

/* --- списки --- */
.list { border-top: 1px solid var(--line); display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); min-height: 52px; }
.list-row .grow { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-row .name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .sub { font-size: 12px; color: var(--muted); }
button.list-row { background: transparent; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; color: var(--text); font-size: 15px; font-weight: 600; justify-content: space-between; }
.avatar { width: 46px; height: 46px; border-radius: 23px; flex-shrink: 0; color: var(--bg); display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 20px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.search { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line); color: var(--dim); }
.search input { flex-grow: 1; min-width: 0; background: transparent; border: 0; outline: none; font-size: 15px; color: var(--text); }
.search input::placeholder { color: var(--dim); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- тарифы --- */
.plans { display: flex; flex-direction: column; gap: 10px; }
.plan {
  display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 14px 18px; border-radius: 24px;
  background: var(--surface); border: 1.5px solid var(--edge); color: var(--text); text-align: left; width: 100%;
}
.plan[aria-checked="true"] { background: #17231C; border-color: var(--accent); }
.radio { width: 20px; height: 20px; border-radius: 10px; flex-shrink: 0; border: 1.5px solid #4A5A50; }
.plan[aria-checked="true"] .radio { border: 6px solid var(--accent); }
.plan .grow { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; }
.plan .title { display: flex; align-items: center; gap: 8px; }
.plan .title .serif { font-size: 24px; line-height: 1.1; }
.save { font-size: 11px; font-weight: 800; color: var(--bg); background: var(--green); padding: 3px 8px; border-radius: 999px; }
.plan .price { font-family: var(--mono); font-size: 16px; white-space: nowrap; }
.checks { margin: 0; padding: 4px 0 0; list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: var(--text-2); }
.checks li { display: flex; gap: 10px; align-items: center; }
.checks svg { color: var(--green); flex-shrink: 0; }

/* --- профиль --- */
.profile-head { display: flex; align-items: center; gap: 14px; padding: 8px 0; }
.profile-head .avatar { width: 60px; height: 60px; border-radius: 30px; font-size: 26px; background: var(--accent); }
.switch { width: 52px; height: 30px; flex-shrink: 0; border: 0; padding: 3px; border-radius: 15px; display: flex; background: #2A3830; justify-content: flex-start; transition: background .15s; }
.switch span { width: 24px; height: 24px; border-radius: 12px; background: var(--muted); }
.switch[aria-checked="true"] { background: var(--accent); justify-content: flex-end; }
.switch[aria-checked="true"] span { background: var(--bg); }

/* --- нижнее меню --- */
#tabs {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 528px; height: 64px; border-radius: 32px;
  background: rgba(22, 32, 27, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 6px; z-index: 10;
}
#tabs button {
  border: 0; border-radius: 26px; background: transparent; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 700;
}
#tabs button[aria-current="page"] { background: var(--accent); color: var(--bg); font-weight: 800; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 20px;
  font-size: 14px; font-weight: 700; z-index: 20; text-align: center;
}

@media (max-width: 360px) {
  .h1 { font-size: 38px; }
  .hero .big { font-size: 40px; }
  #tabs button svg { display: none; }
}
