/* xRobot admin — design tokens --------------------------------------------- */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #14171c;
  --text-2: #4a5260;
  --muted: #7a8392;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --accent-text: #1d4ed8;
  --viral: #e5484d;
  --viral-soft: #fdecec;
  --rising: #d97706;
  --rising-soft: #fdf3e2;
  --ok: #16a34a;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fff4e0;
  --err: #dc2626;
  --err-soft: #fdeaea;
  --ai: #7c3aed;
  --ai-soft: #f1eafe;
  --tech: #0e7490;
  --tech-soft: #e3f4f8;
  --tips: #a16207;
  --tips-soft: #fbf3dc;
  --thread: #0f766e;
  --thread-soft: #e1f5f2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar: 236px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #161a21; --surface-2: #1d222b; --border: #262c37; --border-strong: #343c4a;
    --text: #e8ebf0; --text-2: #b4bcc8; --muted: #8590a0; --accent: #5b8cff; --accent-soft: #1b2741;
    --accent-text: #8fb0ff; --viral: #ff6b6f; --viral-soft: #3a1d20; --rising: #f0a43a; --rising-soft: #3a2a14;
    --ok: #3ccf6e; --ok-soft: #15301f; --warn: #f0a43a; --warn-soft: #3a2a14; --err: #ff6b6b; --err-soft: #3a1d1d;
    --ai: #b196ff; --ai-soft: #2a2145; --tech: #4cc3dc; --tech-soft: #142f37; --tips: #e1b94f; --tips-soft: #362c12;
    --thread: #43c9b7; --thread-soft: #12322e; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #161a21; --surface-2: #1d222b; --border: #262c37; --border-strong: #343c4a;
  --text: #e8ebf0; --text-2: #b4bcc8; --muted: #8590a0; --accent: #5b8cff; --accent-soft: #1b2741;
  --accent-text: #8fb0ff; --viral: #ff6b6f; --viral-soft: #3a1d20; --rising: #f0a43a; --rising-soft: #3a2a14;
  --ok: #3ccf6e; --ok-soft: #15301f; --warn: #f0a43a; --warn-soft: #3a2a14; --err: #ff6b6b; --err-soft: #3a1d1d;
  --ai: #b196ff; --ai-soft: #2a2145; --tech: #4cc3dc; --tech-soft: #142f37; --tips: #e1b94f; --tips-soft: #362c12;
  --thread: #43c9b7; --thread-soft: #12322e; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Layout -------------------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; position: sticky;
  top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #111827, #2563eb);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.brand-name { font-weight: 750; font-size: 16px; letter-spacing: -.02em; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -2px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  padding: 0 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 520; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.nav a .count { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 8px; display: flex;
  justify-content: space-between; align-items: center; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.topbar .chips { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.content { padding: 22px 28px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Surfaces ------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-halves { grid-template-columns: 1fr 1fr; }
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--text-2); }
.kpi.viral .value { color: var(--viral); }
.kpi.rising .value { color: var(--rising); }
.meter { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.warn > span { background: var(--warn); }
.meter.danger > span { background: var(--err); }

/* Chips / badges ------------------------------------------------------------ */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12.5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 520; white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.chip.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.chip.err .dot { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.chip.warn .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.chip.run .dot { background: var(--accent); animation: pulse 1.2s infinite; }
.chip.demo { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 650; }
.chip.live { background: var(--ok-soft); color: var(--ok); border-color: transparent; font-weight: 650; }
@keyframes pulse { 50% { opacity: .35; } }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 11.5px;
  font-weight: 650; line-height: 18px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge.viral { background: var(--viral-soft); color: var(--viral); }
.badge.rising { background: var(--rising-soft); color: var(--rising); }
.badge.candidate { background: var(--surface-2); color: var(--muted); }
.badge.thread { background: var(--thread-soft); color: var(--thread); }
.badge.single { background: var(--surface-2); color: var(--text-2); }
.badge.ai { background: var(--ai-soft); color: var(--ai); }
.badge.tech { background: var(--tech-soft); color: var(--tech); }
.badge.tips { background: var(--tips-soft); color: var(--tips); }
.badge.us { background: var(--accent-soft); color: var(--accent-text); }
.badge.non_us { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.badge.ok, .badge.success { background: var(--ok-soft); color: var(--ok); }
.badge.err, .badge.failed { background: var(--err-soft); color: var(--err); }
.badge.partial, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.running { background: var(--accent-soft); color: var(--accent-text); }
.badge.skipped { background: var(--surface-2); color: var(--muted); }
.badge.outline { background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 550; }

/* Buttons & forms ----------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 560;
  cursor: pointer; white-space: nowrap; line-height: 1.3; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.icon-only { padding: 5px 7px; }
.btn.on { color: var(--rising); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }
label { font-weight: 560; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field .help { font-size: 12px; color: var(--muted); font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=url], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 10px; width: 100%; min-width: 0; }
textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px 20px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px; }
.toolbar select, .toolbar input[type=search] { width: auto; padding: 6px 9px; font-size: 13px; }
.toolbar input[type=search] { min-width: 200px; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented a { padding: 6px 11px; font-size: 13px; color: var(--text-2); border-right: 1px solid var(--border); font-weight: 540; white-space: nowrap; }
.segmented a:last-child { border-right: 0; }
.segmented a.active { background: var(--accent-soft); color: var(--accent-text); }
.segmented a:hover { text-decoration: none; background: var(--surface-2); }

/* Flash / alerts ------------------------------------------------------------ */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  display: flex; gap: 10px; align-items: flex-start; }
.flash.success { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.flash.error { background: var(--err-soft); border-color: transparent; color: var(--err); }
.flash.info { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.flash.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.flash b { font-weight: 650; }

/* Tables -------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--surface); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td.num, th.num { text-align: right; white-space: nowrap; }

/* Post cards ---------------------------------------------------------------- */
.post-list { display: flex; flex-direction: column; }
.post { display: grid; grid-template-columns: 44px minmax(0, 1fr) 170px; gap: 12px 14px; padding: 16px 18px;
  border-bottom: 1px solid var(--border); }
.post:last-child { border-bottom: 0; }
.post.dismissed { opacity: .5; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); object-fit: cover;
  display: grid; place-items: center; font-weight: 700; color: var(--muted); font-size: 16px; overflow: hidden; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.post-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.post-head .name { font-weight: 650; color: var(--text); }
.post-head .handle, .post-head .meta { color: var(--muted); font-size: 13px; }
.verified { width: 15px; height: 15px; vertical-align: -2px; }
.verified.blue { fill: #1d9bf0; }
.verified.business { fill: #e2b719; }
.verified.government { fill: #829aab; }
.post-badges { display: flex; gap: 5px; flex-wrap: wrap; margin: 6px 0 0; }
.post-text { margin: 8px 0 0; color: var(--text); white-space: normal; overflow-wrap: anywhere; }
.post-text.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.post-metrics { display: flex; gap: 6px 16px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--text-2);
  font-variant-numeric: tabular-nums; }
.post-metrics span { display: inline-flex; align-items: center; gap: 5px; }
.post-metrics .icon { width: 14px; height: 14px; color: var(--muted); }
.post-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.post-side .big { font-size: 22px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.post-side .big.viral { color: var(--viral); }
.post-side .big.rising { color: var(--rising); }
.post-side .label { font-size: 11.5px; color: var(--muted); }
.post-actions { display: flex; gap: 4px; margin-top: auto; }
.sparkline { display: block; }
.sparkline polyline { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; }
.sparkline .spark-threshold { stroke: var(--viral); stroke-dasharray: 3 3; stroke-width: 1; opacity: .7; }
.compact .post { grid-template-columns: 36px minmax(0, 1fr) 120px; padding: 12px 16px; }
.compact .avatar { width: 36px; height: 36px; font-size: 14px; }
.compact .post-text.clamp { -webkit-line-clamp: 2; }
.compact .post-side .big { font-size: 18px; }

/* Charts -------------------------------------------------------------------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.chart .area { fill: var(--accent); opacity: .09; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 1.6; }
.chart .threshold { stroke: var(--viral); stroke-dasharray: 5 4; stroke-width: 1.3; }
.chart .threshold-label { fill: var(--viral); }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar.over { fill: var(--err); }

/* Misc ---------------------------------------------------------------------- */
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 28px; height: 28px; margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 8px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.querybox { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 8px 10px; overflow-wrap: anywhere; color: var(--text-2); }
.log { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; max-height: 460px; overflow: auto;
  font-family: var(--mono); font-size: 12px; white-space: pre-wrap; margin: 0; }
.thread-part { padding: 12px 18px; border-top: 1px solid var(--border); display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; }
.thread-part .pos { width: 26px; height: 26px; border-radius: 50%; background: var(--thread-soft); color: var(--thread);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 14px; }
.settings-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.settings-group { scroll-margin-top: 80px; }
.settings-group .form-grid { padding: 18px; }
.settings-group .card-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border);
  justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.field.wide { grid-column: 1 / -1; }
.cat-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); margin: 8px 0; }
.cat-bar span { display: block; height: 100%; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.trend-row { display: flex; align-items: center; gap: 10px; }
.trend-rank { width: 22px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* Inspirations ------------------------------------------------------------- */
.inspiration.done { opacity: .72; }
.rank { font-weight: 800; font-size: 16px; color: var(--accent-text); letter-spacing: -.02em; }
.hook { margin: 0; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 16px; font-weight: 600; line-height: 1.45; }
.reasons { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; }
.skeleton { margin: 8px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px;
  color: var(--text-2); }
.skeleton li::marker { color: var(--thread); font-weight: 700; }
.fulltext summary { cursor: pointer; font-weight: 600; color: var(--accent-text); }
.fulltext .post-text { margin-top: 10px; }
.fulltext .part { padding-top: 10px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.fulltext .part .pos { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--thread-soft);
  color: var(--thread); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; }

/* Media ---------------------------------------------------------------------- */
.french { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface); }
.french > summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fr-flag { display: inline-grid; place-items: center; height: 20px; padding: 0 6px; border-radius: 4px; font-size: 11px;
  font-weight: 750; letter-spacing: .04em; color: #fff; background: linear-gradient(90deg, #1f4fbf 0 33%, #9aa3b2 33% 66%, #d6293b 66%); }
.fr-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.fr-parts { display: flex; flex-direction: column; margin-top: 8px; }
.fr-part { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); align-items: start; }
.fr-part:first-child { border-top: 0; }
.fr-part .pos { width: 24px; height: 24px; border-radius: 50%; background: var(--thread-soft); color: var(--thread);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.fr-text { overflow-wrap: anywhere; line-height: 1.5; }
.fr-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.fr-over { color: var(--err); font-weight: 650; }
.fr-notes { margin: 8px 0 0; }
.btn.copied { color: var(--ok); }
.composer { display: flex; flex-direction: column; gap: 10px; }
.compose-part textarea { width: 100%; font-family: inherit; font-size: 14px; line-height: 1.5; }
.compose-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.compose-head .pos { width: 24px; height: 24px; border-radius: 50%; background: var(--thread-soft); color: var(--thread);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.compose-head [data-cost] { margin-left: auto; }
.compose-media { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.media-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; }
.media-pick img, .media-pick video { width: 96px; height: 64px; object-fit: cover; border-radius: 4px; background: var(--surface-2); }
.media-pick:has(input:checked) { border-color: var(--accent); background: var(--surface-2); }
.compose-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pub-done { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.xacc { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.media-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.media-head code { font-size: 11.5px; word-break: break-all; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 10px; }
.media-item { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.media-item img, .media-item video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); display: block; }

/* Login --------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }

.track-form { display: flex; gap: 6px; min-width: 0; }
.track-form input { width: 300px; min-width: 0; }

/* Responsive ---------------------------------------------------------------- */
@media (max-width: 1100px) {
  .grid-2, .grid-halves { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 16px;
    overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand-sub, .nav-label, .sidebar-foot .version { display: none; }
  .nav-group { flex-direction: row; }
  .nav a { padding: 6px 9px; }
  .nav a span.txt { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .post { grid-template-columns: 40px minmax(0, 1fr); }
  .post-side { grid-column: 2; align-items: flex-start; text-align: left; flex-direction: row; flex-wrap: wrap; gap: 10px; }
  .post-actions { margin-top: 0; }
  .page-head .actions { width: 100%; }
  .track-form { flex: 1 1 100%; }
  .track-form input { flex: 1; width: auto; }
  .toolbar select, .toolbar input[type=search] { flex: 1 1 140px; min-width: 0; }
}

/* Generated visuals (Gemini image + free local video) */
.media-item.mine img, .media-item.mine video { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: -2px; }
.gen-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.gen-pending { display: flex; align-items: center; justify-content: center; gap: 8px; aspect-ratio: 16 / 10;
  border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.gen-pending.failed { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.gen-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.gen-form input[type="text"] { flex: 1 1 260px; min-width: 0; }
.media-pick.mine { border-style: dashed; }
.visuals .compose-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }

/* Analytics: what works */
.works-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px 28px; }
.works h3 { margin: 0 0 8px; }
.works-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 8px; align-items: center; padding: 3px 0; }
.works-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.works-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.works-bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.works-val { white-space: nowrap; color: var(--text-2); }
