:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #141820;
  --muted: #6a7282;
  --accent: #3b6cf6;
  --accent-hover: #2f5ce0;
  --accent-soft: #e8eefe;
  --on-accent: #ffffff;
  --ok: #15803d;
  --ok-soft: #e3f5e9;
  --warn: #b45309;
  --warn-soft: #fdf1df;
  --err: #c81e1e;
  --err-soft: #fde8e8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .05);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --border: #2a2f39;
    --text: #e8eaf0;
    --muted: #8d95a5;
    --accent: #6b8fff;
    --accent-hover: #86a3ff;
    --accent-soft: #1e2840;
    --on-accent: #0b0e14;
    --ok: #4ade80;
    --ok-soft: #13291c;
    --warn: #f5b04a;
    --warn-soft: #2e2312;
    --err: #f87171;
    --err-soft: #321718;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --surface-2: #1f232b;
  --border: #2a2f39;
  --text: #e8eaf0;
  --muted: #8d95a5;
  --accent: #6b8fff;
  --accent-hover: #86a3ff;
  --accent-soft: #1e2840;
  --on-accent: #0b0e14;
  --ok: #4ade80;
  --ok-soft: #13291c;
  --warn: #f5b04a;
  --warn-soft: #2e2312;
  --err: #f87171;
  --err-soft: #321718;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 24px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 6px; }
p { margin: 4px 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--accent) url("/static/favicon.svg") center / cover;
  flex: none;
}
.brand-mark.big { width: 48px; height: 48px; border-radius: 14px; }

.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 9px;
  padding: 0;
  flex: none;
  line-height: 0;
  cursor: pointer;
}
.icon-btn svg { display: block; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .15);
  padding: 6px;
  display: grid;
}
.menu-pop a, .menu-pop button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  font: inherit;
  color: var(--text);
  background: none;
  border: 0;
  cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop form { margin: 0; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  flex: none;
}
.avatar.sm { width: 30px; height: 30px; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.container.narrow { max-width: 680px; }
.container.wide { max-width: 1240px; }
.container.center { min-height: 100vh; display: grid; place-items: center; align-content: center; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head > .status, .page-head > .live { white-space: nowrap; }
.back { display: inline-block; margin-bottom: 6px; font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card-title { margin-bottom: 12px; }
.table-card { padding: 0; overflow: hidden; }

.empty { text-align: center; padding: 40px 20px; }
.empty-icon { color: var(--muted); margin-bottom: 8px; }
.empty .btn { margin-top: 14px; }
.error-code { font-size: 54px; font-weight: 800; color: var(--muted); line-height: 1; margin-bottom: 8px; }

.flash {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }

.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-weight: 500; font-size: 14px; }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-width: 0;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 0; border-color: var(--accent); }

.row-form { display: flex; gap: 8px; flex-wrap: wrap; }
.row-form input { flex: 1 1 220px; width: auto; }
.row-form select { flex: 0 0 auto; width: auto; }
.hint { font-size: 13px; margin-top: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--err); }
.btn-danger:hover { background: var(--err-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 11px; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-err { background: var(--err-soft); color: var(--err); }

.login-card { width: min(400px, 100%); padding: 28px; position: relative; }
.login-head { text-align: center; margin-bottom: 20px; display: grid; justify-items: center; gap: 6px; }
.login-head h1 { margin-top: 8px; }
.login-theme { position: absolute; top: 12px; right: 12px; }

.bot-list { display: grid; gap: 12px; }
.bot-card { margin: 0; }
.bot-main { display: flex; gap: 14px; align-items: flex-start; }
.bot-avatar {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 19px;
  flex: none;
}
.bot-info { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bot-name { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.bot-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; margin-top: 4px; align-items: center; }
.bot-detail {
  margin-top: 8px;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  overflow-wrap: anywhere;
}
.bot-detail-warn { background: var(--warn-soft); color: var(--warn); }
.bot-users {
  display: grid;
  justify-items: end;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.bot-users b { color: var(--text); font-size: 16px; }
.bot-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); align-items: flex-start; }
.bot-actions form { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
summary:focus:not(:focus-visible), button:focus:not(:focus-visible) { outline: none; }

.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-running { color: var(--ok); }
.status-running .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-starting { color: var(--warn); }
.status-starting .dot { background: var(--warn); animation: pulse 1.2s infinite; }
.status-error { color: var(--err); }
.status-error .dot { background: var(--err); }
.status-stopped { color: var(--muted); }

@keyframes pulse { 50% { opacity: .3; } }

.inline-details > summary { list-style: none; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] { flex-basis: 100%; }
.inline-details[open] > summary { margin-bottom: 8px; background: var(--surface-2); }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs a {
  padding: 9px 14px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); font-size: 12px; text-align: center; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
  padding: 11px 16px;
  background: var(--surface-2);
}
.table td { padding: 12px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.table td.actions { text-align: right; }
.table td.actions, .table td.actions > * { white-space: nowrap; }
.table td.actions form, .table td.actions details { display: inline-block; margin: 2px 0 2px 4px; vertical-align: middle; }
.table td.actions .inline-details[open] { display: block; }
.table td.actions .inline-details .row-form { flex-wrap: nowrap; }
.row-alert td { background: color-mix(in srgb, var(--err-soft) 55%, transparent); }
.user-cell { display: flex; gap: 10px; align-items: center; }
.kv { display: inline-block; margin-right: 10px; overflow-wrap: anywhere; }

.count-warn { background: var(--warn-soft); color: var(--warn); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 2px;
}
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; hyphens: auto; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.chip:hover { color: var(--text); text-decoration: none; }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.bulk-bar {
  position: sticky;
  top: 58px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.bulk-channels { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; flex-basis: 100%; }
.bulk-note { flex-basis: 100%; margin: 0; }
.chip-check { padding: 3px 10px 3px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; min-width: 0; }
.chip-check span { overflow-wrap: anywhere; }
.chip-check:has(input:checked) { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.channels-cell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; max-width: 360px; }
.channel-list { display: grid; gap: 12px; }
.channel-card { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; justify-content: space-between; }
.channel-info { min-width: 0; flex: 1 1 320px; }
.channel-info strong { overflow-wrap: anywhere; }
.channel-rights { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.channel-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.post-summary { overflow-wrap: anywhere; max-width: 360px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.col-check { width: 44px; padding-right: 0 !important; }
tr.selected td { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.attempts b { font-size: 18px; }
.preview-cell { max-width: 340px; }
.preview {
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 720px) {
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 12px; }
  .bot-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bot-actions > form, .bot-actions > a, .bot-actions > details { min-width: 0; }
  .bot-actions .btn, .bot-actions summary.btn { width: 100%; }
  .bot-actions .inline-details[open] { grid-column: 1 / -1; }
  .bulk-bar { top: 96px; }
  .bulk-actions { margin-left: 0; }
  .col-check { width: auto; }
  .preview-cell { max-width: none; }
  .channels-cell { max-width: none; }
  .channel-actions { width: 100%; }
  .topbar-inner { flex-wrap: wrap; gap: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; gap: 2px; }
  .nav a { padding: 6px 9px; }
  .topbar-right { margin-left: auto; }
  .menu-login { display: none; }
  .user-menu > summary { padding: 3px; }
  h1 { font-size: 21px; }
  .bot-main { flex-wrap: wrap; }
  .bot-users { justify-items: start; flex-basis: 100%; grid-auto-flow: column; justify-content: start; align-items: center; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-top: 1px solid var(--border); padding: 10px 0; }
  .table td { border: 0; padding: 4px 16px; }
  .table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .table td.actions { text-align: left; white-space: normal; }
  .table td.actions form, .table td.actions details { margin: 4px 4px 0 0; }
  .table td.actions .inline-details .row-form { flex-wrap: wrap; }
}

.container.feed-wrap { max-width: 720px; }
.feed-head { align-items: center; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ok); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: pulse 2s infinite; }
.live.is-off { color: var(--muted); }
.live.is-off .live-dot { background: var(--muted); box-shadow: none; animation: none; }

.new-posts {
  position: sticky;
  top: 66px;
  z-index: 8;
  display: block;
  margin: 0 auto 12px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.new-posts[hidden] { display: none; }

.feed { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

.post {
  position: relative;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scroll-margin-top: 80px;
  transition: box-shadow .6s, border-color .6s;
}
.post:has(details[open]) { z-index: 20; }
.post.is-new { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.post.is-hidden { border-style: dashed; background: color-mix(in srgb, var(--surface) 70%, var(--bg)); }
.post.is-hidden .gallery, .post.is-hidden .post-text, .post.is-hidden .voice { opacity: .5; filter: grayscale(.6); }
.post-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.post-head .avatar { width: 38px; height: 38px; font-size: 15px; }
.post-who { flex: 1; min-width: 0; }
.post-author { display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; overflow-wrap: anywhere; }
.post-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.post-meta a.muted:hover { color: var(--text); }
.post-menu { flex: none; }
.post-menu > summary.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border-color: transparent;
  background: transparent;
}
.post-menu > summary.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.post-menu > summary.icon-btn svg { display: block; }
.post-menu[open] > summary.icon-btn { border-color: var(--border); background: var(--surface-2); color: var(--text); }
.post-menu .menu-pop { z-index: 30; min-width: 210px; }
.post-menu .menu-pop button.danger { color: var(--err); }

.post-origins { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.origin { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); overflow-wrap: anywhere; }

.gallery { display: grid; gap: 3px; background: var(--surface); overflow: hidden; }
.post > .gallery:last-child { border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px); }
.gallery .tile { position: relative; margin: 0; overflow: hidden; background: var(--surface-2); min-width: 0; min-height: 0; }
.gallery .tile > img, .gallery .tile > video { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery.g1 .tile > img, .gallery.g1 .tile > video { height: auto; max-height: 640px; object-fit: contain; }
.gallery.g1 .tile-video, .gallery.g1 .tile-animation { background: #000; }
.gallery.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gallery.g2 .tile { aspect-ratio: 3 / 4; }
.gallery.g3 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); aspect-ratio: 4 / 3; }
.gallery.g3 .tile:first-child { grid-row: span 2; }
.gallery.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gallery.g4 .tile { aspect-ratio: 4 / 3; }
.gallery.grid6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.gallery.grid6 .tile.s3 { grid-column: span 3; aspect-ratio: 4 / 3; }
.gallery.grid6 .tile.s2 { grid-column: span 2; aspect-ratio: 1; }
.tile img[data-open], .tile video[data-open] { cursor: zoom-in; }
.tile-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding-left: 3px;
  background: rgba(15, 17, 21, .6);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform .15s, background .15s;
}
.tile-play:hover { background: rgba(15, 17, 21, .8); transform: translate(-50%, -50%) scale(1.06); }
.tile-video_note { display: grid; place-items: center; background: var(--surface-2); }
.gallery .tile-video_note video { width: min(320px, 80%); height: auto; aspect-ratio: 1; border-radius: 50%; object-fit: cover; margin: 12px auto; }

.tile-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}
.gallery.g1 .tile-video .tile-badge { display: none; }
.tile-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: rgba(15, 17, 21, .62);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .15s;
}
.tile:hover .tile-actions, .tile:focus-within .tile-actions { opacity: 1; }
@media (hover: none) { .tile-actions { opacity: 1; } }
.tile-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.tile-btn:hover { background: rgba(255, 255, 255, .16); text-decoration: none; }
.gallery.g1 .tile-video .tile-actions { top: 8px; }

.voice { margin: 10px 16px 0; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.voice-row { display: flex; align-items: center; gap: 10px; }
.voice-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.voice audio { flex: 1; min-width: 0; height: 38px; }
.voice-len { flex: none; font-variant-numeric: tabular-nums; }
.transcript { margin-top: 10px; }
.transcript-text { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.transcript-pending { display: inline-flex; align-items: center; gap: 8px; }
.spinner { width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.post-text { padding: 12px 16px 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.post-text a { word-break: break-all; }
.post-text pre, .post-text code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface-2); border-radius: 6px; }
.post-text code { padding: 1px 5px; }
.post-text pre { padding: 10px 12px; overflow-x: auto; white-space: pre; }
.post-text pre code { padding: 0; background: none; }
.post-text blockquote { margin: 4px 0; padding: 4px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; }
.spoiler { background: var(--muted); color: transparent; border-radius: 4px; cursor: pointer; transition: color .2s, background .2s; }
.spoiler.revealed { background: var(--surface-2); color: inherit; cursor: auto; }
.post-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 14px; }
.post-actions .btn { color: var(--text); }
.post > :last-child:not(.post-actions) { margin-bottom: 14px; }
.post > .gallery:last-child { margin-bottom: 0; }
.feed-more { display: grid; place-items: center; padding: 8px 0 20px; }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(5, 6, 8, .97); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: grid; grid-template-rows: auto 1fr; }
.lightbox[hidden] { display: none; }
.lb-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; color: #fff; }
.lb-counter { font-size: 14px; opacity: .8; }
.lb-actions { display: flex; gap: 8px; }
.lb-btn { padding: 7px 12px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 8px; background: rgba(255, 255, 255, .08); color: #fff; font: inherit; font-size: 14px; cursor: pointer; }
.lb-btn:hover { background: rgba(255, 255, 255, .18); text-decoration: none; }
.lb-btn[hidden] { display: none; }
.lb-stage { display: grid; place-items: center; min-height: 0; padding: 0 56px 24px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: calc(100vh - 90px); object-fit: contain; border-radius: 4px; }
.lb-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .08); color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
.lb-nav:hover { background: rgba(255, 255, 255, .18); }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }
.lightbox.single .lb-nav { display: none; }
body.no-scroll { overflow: hidden; }

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 120; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: calc(100% - 32px); }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); transition: opacity .35s, transform .35s; max-width: 100%; text-align: center; }
.toast-err { background: var(--err); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

@media (max-width: 720px) {
  .new-posts { top: 104px; }
  .post-actions .btn { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; }
  .post-head { padding: 12px 12px 8px; }
  .post-origins { padding: 0 12px 8px; }
  .post-text { padding: 10px 12px 0; }
  .post-actions { padding: 10px 12px 12px; }
  .voice { margin: 8px 12px 0; }
  .voice-len { display: none; }
  .tile-actions { top: 6px; right: 6px; }
  .tile-play { width: 44px; height: 44px; }
  .post { border-radius: 12px; }
  .lb-stage { padding: 0 8px 16px; }
  .lb-nav { display: none; }
}

.studio-live-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.studio-preview { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); background: #0b0d11; overflow: hidden; display: grid; place-items: center; }
.studio-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.studio-preview img[hidden], .studio-preview-empty[hidden], .studio-fps[hidden] { display: none; }
.studio-preview-empty { display: grid; justify-items: center; gap: 8px; color: #8d95a5; font-size: 14px; text-align: center; padding: 16px; }
.studio-fps { position: absolute; top: 10px; left: 10px; padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; font-variant-numeric: tabular-nums; }
.studio-state { margin-bottom: 8px; }
.studio-detail { font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin: 0 0 12px; overflow-wrap: anywhere; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--radius-sm); background: var(--surface-2); }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 8px 6px; border-radius: 7px; font-size: 14px; font-weight: 500; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.segmented label.is-disabled { opacity: .45; cursor: not-allowed; }
.segmented label.is-disabled span { text-decoration: none; }
.segmented label.is-disabled input { pointer-events: none; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hint-box { margin-top: 14px; font-size: 14px; }
.hint-box summary { cursor: pointer; color: var(--accent); }
.hint-box ol { padding-left: 20px; margin: 8px 0; }
.studio-upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.studio-upload > input[name="name"] { flex: 1 1 200px; width: auto; }
.studio-upload select { flex: 0 1 220px; width: auto; }
.studio-upload .attest { flex-basis: 100%; }
.file-pick { position: relative; display: inline-flex; align-items: center; padding: 9px 14px; border: 1px dashed var(--border); border-radius: var(--radius-sm); cursor: pointer; color: var(--muted); font-size: 14px; max-width: 100%; }
.file-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pick:hover { border-color: var(--accent); color: var(--text); }
.file-pick.has-file { border-style: solid; color: var(--text); }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.char-card { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.char-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; background: var(--surface-2); aspect-ratio: 3 / 1; }
.char-thumbs.thumbs-1 { grid-template-columns: minmax(0, 1fr); aspect-ratio: 16 / 9; }
.char-thumbs.thumbs-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); aspect-ratio: 2 / 1; }
.char-thumbs.thumbs-1 img { object-position: center 30%; }
.char-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.char-thumbs img.no-face { opacity: .35; filter: grayscale(1); }
.char-body { padding: 10px 12px 12px; display: grid; gap: 8px; }
.char-name { display: flex; justify-content: space-between; gap: 8px; align-items: center; overflow-wrap: anywhere; }
.char-body form { margin: 0; }
.job-list { display: grid; gap: 12px; margin-top: 16px; }
.job { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }
.job-media video, .job-placeholder { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background: #0b0d11; display: block; }
.job-placeholder { display: grid; place-items: center; }
.job-body { display: grid; gap: 6px; align-content: start; min-width: 0; }
.job-title { overflow-wrap: anywhere; }
.job-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.progress { flex: 1 1 140px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; max-width: 260px; }
.progress[hidden] { display: none; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.job-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.job-actions form { margin: 0; }
.err-text { color: var(--err); margin: 0; }
@media (max-width: 860px) {
  .studio-live-grid { grid-template-columns: minmax(0, 1fr); }
  .job { grid-template-columns: minmax(0, 1fr); }
}

.segmented.segmented-3 { grid-template-columns: repeat(3, 1fr); }
[data-portrait-only][hidden], [data-faceswap-only][hidden], .takes-panel[hidden], [data-saved-panel][hidden] { display: none; }
.takes-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.takes-head form { margin: 0; }
.rec-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%;
  padding: 22px 16px; margin: 6px 0 6px; border-radius: var(--radius); border: 2px dashed var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 18px; font-weight: 600;
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none; transition: background .15s, border-color .15s;
}
.rec-btn:disabled { opacity: .5; cursor: not-allowed; }
.rec-btn:not(:disabled):hover { border-color: var(--err); }
.rec-btn.is-recording { background: var(--err-soft); border-color: var(--err); border-style: solid; color: var(--err); }
.rec-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--err); flex: none; }
.rec-btn.is-recording .rec-dot { animation: pulse 1s infinite; }
.rec-hint { margin-bottom: 14px; }
.takes-subtitle { font-size: 15px; margin: 6px 0 10px; }
.take-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.take-tile {
  position: relative; display: block; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2); cursor: pointer; text-align: left; font: inherit; color: var(--text);
}
.take-tile:hover { border-color: var(--accent); }
.take-tile img, .take-ph { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.take-ph { display: grid; place-items: center; }
.take-meta { padding: 6px 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.take-failed .take-meta { color: var(--err); }
.take-badge { position: absolute; top: 6px; left: 6px; padding: 1px 7px; border-radius: 6px; background: var(--ok); color: #fff; font-size: 11px; font-weight: 600; }
.take-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0, 0, 0, .2); }
.take-progress div { height: 100%; background: var(--accent); transition: width .4s; }
.take-dialog { width: min(720px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.take-dialog::backdrop { background: rgba(5, 6, 8, .7); backdrop-filter: blur(4px); }
.take-dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; }
.take-dialog video { display: block; width: 100%; max-height: 70vh; background: #000; }
.take-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 4px; }
.take-dialog [data-take-status] { padding: 0 14px 12px; margin: 0; min-height: 1em; }

.picked { display: flex; gap: 6px; flex-wrap: wrap; flex-basis: 100%; }
.picked[hidden] { display: none; }
.picked-chip { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.picked-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picked-chip button { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .65); color: #fff; font-size: 10px; line-height: 18px; padding: 0; cursor: pointer; }
.library-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); display: none; }
.library-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.library-dialog::backdrop { background: rgba(5, 6, 8, .7); backdrop-filter: blur(4px); }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; padding: 0 14px; overflow-y: auto; align-content: start; }
.lib-item { position: relative; padding: 0; border: 2px solid transparent; border-radius: 9px; overflow: hidden; background: var(--surface-2); cursor: pointer; aspect-ratio: 1; }
.lib-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-item.is-picked { border-color: var(--accent); }
.lib-item.is-picked::after { content: "✓"; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.lib-item:disabled { opacity: .45; cursor: not-allowed; }
.lib-tag { position: absolute; left: 6px; bottom: 6px; padding: 0 6px; border-radius: 5px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; }
.library-foot { display: flex; align-items: center; gap: 10px; padding: 12px 14px; flex-wrap: wrap; }
.library-foot [data-library-done] { margin-left: auto; }

.take-cancel { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: rgba(15, 17, 21, .7); color: #fff; font-size: 12px; cursor: pointer; }
.take-cancel:hover { background: var(--err); }

.section-title { font-size: 18px; margin: 28px 0 12px; }

.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }

/* Settings & access groups */
.settings-tabs { margin-bottom: 18px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }
.profile-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.profile-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 16px; font-size: 14px; }
.profile-kv dt { color: var(--muted); }
.profile-kv dd { margin: 0; font-weight: 600; }
.sub-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 6px 0 10px; }
.mt { margin-top: 14px; }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-soft { background: var(--surface-2); color: var(--text); font-weight: 500; }
.group-form { display: flex; gap: 6px; align-items: center; }
.group-form select { width: auto; min-width: 150px; padding: 6px 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head p { margin: 0; max-width: 720px; }
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.group-card { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.group-card .card-title { margin: 0; }
.group-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.group-card-head .chips, .group-card > .chips { margin: 0; }
.group-card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--border); }
.group-card-foot .actions { display: flex; gap: 6px; }
.back-link { display: inline-block; margin-bottom: 12px; font-size: 14px; }
.group-edit-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.group-edit-head .card-title { margin: 0; }
.group-fields { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; }
@media (max-width: 760px) { .group-fields { grid-template-columns: 1fr; } }
.perm-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
@media (max-width: 520px) { .perm-sections { grid-template-columns: 1fr; } }
.perm-section { margin: 0; border-left: 3px solid var(--border); transition: border-color .15s; }
.perm-section.is-on { border-left-color: var(--accent); }
.perm-section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.perm-section-head h3 { margin: 0 0 2px; font-size: 16px; }
.perm-root span { display: flex; flex-direction: column; gap: 2px; }
.perm-root b { font-size: 16px; }
.perm-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.perm-list .perm-list { margin: 6px 0 2px 26px; padding-left: 12px; border-left: 1px dashed var(--border); }
.perm-check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; line-height: 1.4; }
.perm-check input { width: 17px; height: 17px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.perm-check.is-disabled { cursor: default; opacity: .5; }
.perm-kind { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; margin-left: auto; }
.perm-kind.kind-sub { background: var(--accent-soft); color: var(--accent); }
.perm-kind.kind-block { background: var(--warn-soft); color: var(--warn); }
.perm-empty { margin: 10px 0 0; }
.form-bar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 14px 0; margin-top: 16px; background: linear-gradient(transparent, var(--bg) 35%); }

.perm-hidden { display: none !important; }

.scope-note { font-size: 12px; vertical-align: middle; margin-left: 8px; font-weight: 600; letter-spacing: 0; }

.acc-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .acc-fields { grid-template-columns: 1fr; } }
.account-form { display: grid; gap: 16px; }
.account-form .card { margin: 0; }
.acc-title { margin: 0 0 12px; font-size: 16px; }
.seg-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.seg-choice label { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; background: var(--surface); }
.seg-choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.seg-choice input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.seg-choice span { display: flex; flex-direction: column; gap: 2px; }
.seg-choice small { color: var(--muted); font-size: 12.5px; }
.seg-choice.compact label { padding: 8px 12px; }
.scope-box { display: grid; grid-template-columns: 1fr 1.6fr .8fr; gap: 14px; margin-top: 14px; transition: opacity .15s; }
.scope-box.is-off { opacity: .4; pointer-events: none; }
@media (max-width: 960px) { .scope-box { grid-template-columns: 1fr; } }
.scope-col { border: 1px solid var(--border); border-radius: 12px; padding: 12px; min-width: 0; background: var(--surface); }
.scope-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.scope-list { display: grid; gap: 8px; max-height: 300px; overflow: auto; padding-right: 4px; }
.scope-list small { display: block; }
.scope-search { margin-bottom: 10px; }
.scope-pairs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 10px; }
@media (max-width: 860px) { .scope-pairs, .seg-choice { grid-template-columns: 1fr; } }
.scope-pair { display: grid; gap: 8px; }
.acc-check { align-self: end; padding-bottom: 8px; }
.acc-check span { display: flex; flex-direction: column; gap: 2px; }
.acc-danger { margin-top: 16px; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.scope-sum { display: flex; flex-direction: column; gap: 2px; }
