:root {
  --bg: #0b0f17;
  --surface: #151b27;
  --surface-2: #1e2636;
  --line: #2a3447;
  --text: #eef2f8;
  --muted: #93a0b5;
  --accent: #5b8cff;
  --ok: #34c77b;
  --warn: #f5b84a;
  --danger: #ef5d6b;
  --radius: 14px;
  --tabs-h: 60px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* Author display rules (.row, .btn) would otherwise override the hidden attribute. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: .8rem; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 6px 0; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: .88rem; }
.hint { color: var(--warn); font-size: .85rem; }
.error, .errorlist { color: var(--danger); font-size: .88rem; }
.errorlist { list-style: none; padding: 0; margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 48px 0; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 640px; margin: 0 auto; padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--bg);
}
.banner { padding: 10px 16px; margin: 0 0 12px; border-radius: var(--radius); background: var(--surface-2); font-size: .92rem; }
body > .banner { border-radius: 0; margin: 0; text-align: center; }
.banner-warn, .banner-warning { background: #4a3a12; color: #ffe0a3; }
.banner-error { background: #4a1820; color: #ffc4ca; }
.banner-success { background: #123d27; color: #b6f0d0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 0 0 12px;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1 1 0; min-width: 0; }
.wrap-anywhere { overflow-wrap: anywhere; }

label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 1rem; flex-wrap: wrap; }
input[type=text], input[type=password], input[type=url], input[type=number], select, textarea {
  width: 100%; padding: 12px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 16px; font: inherit; font-weight: 600; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #062213; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-tiktok { background: #111; border-color: #25f4ee; }
.btn-instagram { background: #c13584; border-color: #c13584; }
.btn-youtube { background: #d91f1f; border-color: #d91f1f; }
.btn.is-done { background: transparent; border-color: var(--ok); color: var(--ok); }

.toggles { margin-top: 10px; }
.toggle {
  min-height: 40px; padding: 0 14px; font: inherit; font-size: .9rem; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.toggle.on { color: #062213; background: var(--ok); border-color: var(--ok); font-weight: 600; }
.logout { margin-top: 24px; text-align: center; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill-done, .pill-rendered, .pill-approved, .pill-posted { background: #123d27; color: #8fe6b8; }
.pill-failed, .pill-rejected { background: #4a1820; color: #ffb3bb; }
.pill-needs_upload { background: #4a3a12; color: #ffe0a3; }
.pill-queued, .pill-downloading, .pill-transcribing, .pill-selecting, .pill-rendering, .pill-pending { background: #16305e; color: #b3ccff; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }

.clip video, .clip .thumb {
  display: block; width: 100%; max-height: 62vh; aspect-ratio: 9 / 16; object-fit: contain;
  background: #000; border-radius: 10px; margin-bottom: 10px;
}
.clip details { margin-top: 10px; }
.clip summary { color: var(--accent); cursor: pointer; padding: 6px 0; }
.caption-text { white-space: pre-wrap; font-size: .92rem; background: var(--surface-2); border-radius: 10px; padding: 10px; }
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.share-status { min-height: 1.3em; font-size: .88rem; color: var(--muted); }
.posted-form { margin-top: 8px; }

progress { width: 100%; height: 10px; accent-color: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.tile b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .82rem; }
.meter { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.full i { background: var(--danger); }
.views-input { width: 96px !important; padding: 8px !important; text-align: right; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  position: relative; display: flex; align-items: center; justify-content: center;
  color: var(--muted); text-decoration: none; font-size: .8rem; font-weight: 600;
}
.tabs a[aria-current=page] { color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.badge {
  position: absolute; top: 8px; right: 14%; min-width: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: .7rem; line-height: 18px; text-align: center;
}
.htmx-request { opacity: .6; }
