:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --line: #272c37;
  --text: #e8eaf0;
  --muted: #98a0b3;
  --accent: #e1306c;
  --accent-soft: rgba(225, 48, 108, 0.14);
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 14px;
  --maxw: 760px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f6;
    --line: #e2e5ec;
    --text: #14161b;
    --muted: #666e80;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: 60px;
}

a { color: inherit; }
a:hover { color: var(--accent); }

/* ------------------------------------------------------------- шапка */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; text-decoration: none; }
.brand-mark {
  width: 20px; height: 20px; border-radius: 6px;
  background: linear-gradient(135deg, #f9ce34, #ee2a7b 50%, #6228d7);
}
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted);
  font-size: 14px;
}
.topbar nav a:hover { background: var(--surface-2); color: var(--text); }
.topbar nav a.active { background: var(--accent-soft); color: var(--accent); }
.pill {
  display: inline-block; min-width: 18px; padding: 0 6px;
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: 11px; line-height: 18px; text-align: center;
}

.accountstrip {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 20px;
  border-bottom: 1px solid var(--line); background: var(--surface);
  scrollbar-width: thin;
}
.chip {
  display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
  padding: 5px 12px 5px 5px; border: 1px solid var(--line); border-radius: 999px;
  text-decoration: none; font-size: 13px; background: var(--surface-2);
}
.chip img, .chip .avatar-stub { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.chip.muted { opacity: .45; }

main { max-width: var(--maxw); margin: 0 auto; padding: 20px 16px; }
.page.narrow { max-width: 640px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.warn { color: var(--warn); }
.notice {
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid var(--accent);
}

/* ------------------------------------------------------------- фильтры */

.filters { margin: 16px 0 20px; display: grid; gap: 10px; }
.filters input[type=search] {
  width: 100%; padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.kinds { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  padding: 5px 12px; border-radius: 999px; font-size: 13px; text-decoration: none;
  border: 1px solid var(--line); color: var(--muted); background: var(--surface);
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------- лента */

.feed { display: grid; gap: 18px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.card.unread { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }

.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.avatar-stub {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f9ce34, #ee2a7b 55%, #6228d7);
  color: #fff; font-weight: 600;
}
.card-head-text { flex: 1; min-width: 0; }
.headline { margin: 0; font-size: 15px; }
.headline .username { font-weight: 650; text-decoration: none; }
.headline .action { color: var(--muted); }
.meta { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.meta a { text-decoration: none; }
.dot { opacity: .5; }
.kind {
  padding: 1px 8px; border-radius: 999px; font-size: 11.5px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.kind-story { color: #f9ce34; }
.kind-reel { color: #7dd3fc; }
.kind-highlight { color: #c4b5fd; }
.edited { color: var(--warn); }
.card.deleted { border-color: var(--warn); }
.card.deleted .media { opacity: .72; }
.deleted-note {
  margin: 0; padding: 10px 16px; font-size: 13.5px;
  background: color-mix(in srgb, var(--warn) 12%, var(--surface-2));
  border-bottom: 1px solid var(--line);
}
.badge.gone { background: var(--warn); color: #1a1a1a; }
.badge {
  background: var(--accent); color: #fff; font-size: 11px;
  padding: 2px 9px; border-radius: 999px; flex: 0 0 auto;
}

.media { background: #000; }
.media.carousel {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 2px;
}
.media.carousel .media-cell { flex: 0 0 88%; scroll-snap-align: center; }
.media-cell { margin: 0; position: relative; }
.media-cell img, .media-cell video { display: block; width: 100%; max-height: 640px; object-fit: contain; }
.filename {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 12px; font-size: 11.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted); background: var(--surface-2); word-break: break-all;
}
.filename a { text-decoration: none; }
.empty-media { margin: 0; padding: 18px 16px; color: var(--muted); background: var(--surface-2); }

.repost {
  padding: 1px 8px; border-radius: 999px; font-size: 11.5px;
  background: var(--accent-soft); color: var(--accent);
}
.repost a { text-decoration: none; font-weight: 600; }
.repost-note {
  margin: 0; padding: 10px 16px; font-size: 13.5px;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.links { list-style: none; margin: 0; padding: 10px 16px; display: grid; gap: 6px; font-size: 13.5px; }
.links.bare { padding: 0; }
.links a { word-break: break-all; }

.caption { margin: 0; padding: 12px 16px; white-space: pre-wrap; word-wrap: break-word; }
.caption.big { padding: 16px 0; font-size: 15.5px; }

.card-foot {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.card-foot .spacer { flex: 1; }
.card-foot a { text-decoration: none; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 26px 0; }

/* ------------------------------------------------------------- профиль */

.profile-head { display: flex; gap: 18px; margin-bottom: 20px; flex-wrap: wrap; }
.profile-avatar { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; font-size: 32px; }
.profile-info { flex: 1; min-width: 240px; }
.profile-info h1 { display: flex; align-items: center; gap: 8px; }
.fullname { margin: 2px 0; font-weight: 600; }
.bio { margin: 6px 0; white-space: pre-wrap; }
.numbers { margin: 2px 0; font-size: 13px; }
.verified { color: #38bdf8; }
.breadcrumbs { font-size: 13px; color: var(--muted); }
.item-title { font-size: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.media-full { margin: 0 0 12px; background: #000; border-radius: var(--radius); overflow: hidden; }
.media-full img, .media-full video { display: block; width: 100%; }

/* ------------------------------------------------------------- таблицы */

.kv, .files, .runs { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kv th, .kv td, .files th, .files td, .runs th, .runs td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top;
}
.kv th, .files th, .runs th { color: var(--muted); font-weight: 500; width: 190px; }
.files th { width: auto; }
.runs .row-error td { background: color-mix(in srgb, var(--warn) 10%, transparent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; word-break: break-all; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 16px 0;
}
.panel summary { cursor: pointer; font-weight: 600; }

.timeline { list-style: none; padding: 0; margin: 10px 0; }
.timeline li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline time { color: var(--muted); flex: 0 0 165px; font-size: 12.5px; }

.comments { list-style: none; padding: 0; margin: 0; }
.comments li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.comments li.reply { padding-left: 28px; border-left: 2px solid var(--line); }
.comments li.deleted { opacity: .55; text-decoration: line-through; }
.comment-head { display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; color: var(--muted); }
.comment-head b { color: var(--text); font-size: 13.5px; }
.comments p { margin: 4px 0 0; white-space: pre-wrap; }

.likes { list-style: none; padding: 0; margin: 0; counter-reset: like; }
.likes li {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.likes li.gone { opacity: .5; }
.likes li.gone .like-body > a { text-decoration: line-through; }
.small-avatar { width: 30px; height: 30px; font-size: 13px; }
.like-body { min-width: 0; }
.like-body a { font-weight: 600; text-decoration: none; }

.events { list-style: none; padding: 0; margin: 0; }
.events li {
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 10px;
}
.events li.unread { border-color: var(--accent); }
/* Служебные тревоги — про поломку сервиса, а не про новый контент. */
.events li.alert {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, var(--surface));
}

/* ------------------------------------------------------------- аккаунты */

.add-form { display: flex; gap: 10px; margin: 16px 0 24px; }
.add-form input { flex: 1; }
.accounts { display: grid; gap: 12px; }
.account-row {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; display: grid; gap: 12px;
}
.account-main { display: flex; gap: 12px; align-items: center; }
.account-main .username { font-weight: 650; text-decoration: none; }
.flags { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.flags label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------- формы */

input[type=text], input[type=search], input[type=password], textarea {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; width: 100%;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.stacked { display: grid; gap: 10px; margin-top: 12px; }

.btn {
  display: inline-block; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 13.5px; text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { color: #fff; opacity: .9; }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: #ef4444; color: #ef4444; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.footer { text-align: center; padding: 24px; color: var(--muted); font-size: 12.5px; }

body.centered { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  display: grid; gap: 12px; width: min(340px, 90vw); padding: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}

@media (max-width: 640px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .kv th { width: 130px; }
  .timeline li { flex-direction: column; gap: 2px; }
  .timeline time { flex: none; }
}
