/* Card fonts match the ones the video renderer uses. */
@font-face { font-family: "RobotoCard"; font-weight: 500; src: url("/fonts/Roboto-Medium.ttf"); }
@font-face { font-family: "RobotoCard"; font-weight: 700; src: url("/fonts/Roboto-Bold.ttf"); }

:root {
  --bg: #0e1116; --panel: #161b22; --line: #2a313c; --text: #e6edf3; --muted: #8b949e;
  --accent: #2dd4bf; --accent-ink: #04201c; --err: #f87171;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* hidden must beat any display rule */
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.5 -apple-system, system-ui, "Segoe UI", sans-serif; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 32px 20px 48px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 24px; }

.grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; align-items: start; }
.side { position: sticky; top: 20px; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } .side { position: static; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.card + .card { margin-top: 20px; }

label, .lbl { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
label.first { margin-top: 0; }
input[type=text], textarea, select { width: 100%; background: var(--bg); color: var(--text);
       border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; }
textarea { min-height: 220px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 36px;
         background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238b949e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
         background-repeat: no-repeat; background-position: right 14px center; }
.meta { font-size: 12px; color: var(--muted); }
#count { margin-top: 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

button { cursor: pointer; border: 0; border-radius: 8px; padding: 11px 16px; font: inherit; font-weight: 600; }
.primary { background: var(--accent); color: var(--accent-ink); width: 100%; margin-top: 18px; }
.primary:disabled, .ghost:disabled { opacity: .5; cursor: default; }
.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.presets button { padding: 7px 12px; font-size: 13px; font-weight: 500; }

.ctl { display: flex; align-items: center; gap: 10px; }
.ctl.gap { gap: 16px; }
.ctl input[type=range] { flex: 1; accent-color: var(--accent); }
.ctl output { font-size: 12px; color: var(--muted); min-width: 38px; text-align: right; }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line);
                    border-radius: 8px; background: var(--bg); cursor: pointer; }
input[type=color]:disabled { opacity: .35; cursor: default; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 0; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 20px 0 0; padding: 14px 0 0; }
legend { font-size: 13px; font-weight: 600; padding: 0 8px 0 0; }

/* AI script writer */
.ai { border: 1px dashed var(--line); border-radius: 10px; padding: 14px; margin-bottom: 6px; }
.ai-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 10px; }
.ai-title { font-size: 14px; font-weight: 600; }
.ai-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 8px; }
.ai-row button { padding: 9px 14px; font-size: 14px; white-space: nowrap; }
.ai-row button:disabled { opacity: .5; cursor: default; }
.ai-status { margin: 10px 0 0; }
.ai-status.err { color: var(--err); }
@media (max-width: 560px) { .ai-row { grid-template-columns: 1fr 1fr; } .ai-row button { grid-column: span 2; } }

/* 9:16 preview */
.phone { position: relative; width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 9/16;
         border-radius: 18px; overflow: hidden; background: linear-gradient(160deg, #2b4a3a, #14263a 60%, #3a2a1a); }
.phone img { position: absolute; inset: -8%; width: 116%; height: 116%; object-fit: cover; }
.pdim { position: absolute; inset: 0; background: #000; pointer-events: none; }
.pcard { position: absolute; left: 50%; transform: translateX(-50%); text-align: center;
         font-family: "RobotoCard", sans-serif; line-height: 1.28; overflow-wrap: break-word; }
.note { font-size: 12px; color: var(--muted); text-align: center; margin: 10px 0 0; }

/* progress + results */
.bar { height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
.stage { display: flex; justify-content: space-between; font-size: 13px; margin: 8px 0 0; color: var(--muted); }
video { width: 100%; max-height: 460px; border-radius: 10px; background: #000; margin-top: 14px; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.actions a, .actions button { text-decoration: none; font-size: 14px; padding: 9px 14px; }
.actions a.primary { width: auto; margin: 0; }
.err { color: var(--err); }

ul.recent { list-style: none; margin: 0; padding: 0; }
ul.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0;
               border-bottom: 1px solid var(--line); font-size: 14px; }
ul.recent li:last-child { border-bottom: 0; }
ul.recent a { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ul.recent .meta { white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- top bar (signed-in pages) ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
          padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar .brand { color: var(--text); text-decoration: none; font-weight: 700; }
.topbar nav { display: flex; align-items: center; gap: 16px; font-size: 14px; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a[aria-current="page"], .topbar nav a:hover { color: var(--text); }
.who { color: var(--muted); font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap.narrow { max-width: 720px; }
.wrap.narrow h1 { margin-bottom: 20px; }

/* ---------- buttons ---------- */
button.small { padding: 7px 12px; font-size: 13px; }
.primary.small { width: auto; margin: 0; }
.danger { background: transparent; color: var(--err); border: 1px solid color-mix(in srgb, var(--err) 45%, transparent); }
button.icon { background: transparent; color: var(--muted); padding: 0 4px; font-size: 18px; line-height: 1; }
button.icon:hover { color: var(--err); }
a { color: var(--accent); }

/* ---------- sign-in page ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; }
.auth { width: 100%; max-width: 420px; padding: 32px 20px; }
.auth-brand h1 { font-size: 26px; }
.auth-card { margin-top: 8px; }
.forgot { text-align: right; margin: 8px 0 0; }
.subscription { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
                border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 14px 0 4px; }
.subscription.warn { border-color: color-mix(in srgb, var(--err) 60%, var(--line)); }
.subscription .meta { display: block; margin-top: 2px; }
.forgot a { color: var(--muted); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); padding: 4px;
        border-radius: 10px; border: 1px solid var(--line); margin-bottom: 18px; }
.tab { background: transparent; color: var(--muted); font-weight: 500; padding: 9px; }
.tab.active { background: var(--panel); color: var(--text); }
.google { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px;
          border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.google:hover { border-color: var(--muted); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 4px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
input[type=email], input[type=password] { width: 100%; background: var(--bg); color: var(--text);
       border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; }
#authError { margin: 12px 0 0; font-size: 14px; }

/* ---------- settings: AI providers ---------- */
.provider { border-top: 1px solid var(--line); padding: 16px 0 4px; }
.provider:first-child { border-top: 0; padding-top: 4px; }
.provider-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; white-space: nowrap; }
.badge.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.keyrow { display: flex; gap: 8px; }
.keyrow input { flex: 1; }
.status { margin: 10px 0 0; }
.status.err { color: var(--err); }
section.card h2 { margin-bottom: 6px; }
section.card > .meta { margin: 0 0 12px; }

/* ---------- my videos ---------- */
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.lib-head h1 { margin: 0; }
/* Studio: the scene editor (pages/studio/scene-list.ts) */
.script-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.script-head .linklike { font-size: 13px; }
.scenes { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 10px; }
.scene { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.scene-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.scene-head .meta { flex: 1; }
.scene-move { display: flex; gap: 4px; }
.scene-move button { padding: 4px 9px; }
.scene textarea { min-height: 0; }
.scene-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-start; margin: 8px 0; }
.scene-row > label { display: grid; gap: 4px; margin: 0; font-size: 13px; min-width: 0; flex: 1 1 180px; }
.scene-start input[type=range] { width: 100%; }
.scene-still { width: 54px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.scene-look { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.scene-look select { width: auto; }
.scene-look input[type=range] { flex: 1 1 100px; }
/* My videos: trim dialog */
.trim-range { display: grid; gap: 10px; margin: 12px 0 4px; }
.trim-range label { display: grid; grid-template-columns: 52px 64px 1fr; align-items: center; gap: 8px; margin: 0; font-size: 14px; }
.trim-range output { font-variant-numeric: tabular-nums; color: var(--muted); }
/* Studio: editing a finished video, and music volume */
.edit-banner { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 14px;
               margin-bottom: 14px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 10px; }
.edit-banner .meta { display: block; margin-top: 2px; }
.edit-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.edit-actions button { flex: 1 1 180px; width: auto; margin: 0; }
.music-volume { margin: 10px 0 4px; }
/* sign-up: "check your email" (pages/login) */
.confirm-sent h2 { margin: 0 0 8px; font-size: 18px; }
.confirm-sent p { margin: 0 0 10px; }
.confirm-sent .ghost { width: 100%; margin-top: 6px; }
/* Moderation (pages/moderation) */
#modSearch { width: 280px; max-width: 100%; }
.mod-tabs { max-width: 320px; margin: 14px 0; }
.mod-filter { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; font-size: 14px; }
.mod-script { white-space: pre-wrap; font-size: 14px; margin: 0; max-height: 30vh; overflow: auto; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer;
            text-align: left; overflow-wrap: anywhere; }
.linklike:hover { text-decoration: underline; }
@media (max-width: 640px) { .lib-head:has(#modSearch) { flex-wrap: wrap; } #modSearch { width: 100%; } }
.btnlink { display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
           border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; }
.btnlink.ghost { color: var(--text); border: 1px solid var(--line); }
.btnlink.primary { color: var(--accent-ink); }
#connNote { margin: 0 0 16px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 12px; }
.vcard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
         display: flex; flex-direction: column; }
.thumb { position: relative; aspect-ratio: 9/16; max-height: 320px; width: 100%; padding: 0; border-radius: 0;
         background: linear-gradient(160deg, #2b4a3a, #14263a 60%, #3a2a1a); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb::after { content: "▶"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px;
                color: #fff; opacity: 0; background: rgba(0,0,0,.35); transition: opacity .2s; }
.thumb:hover::after, .thumb:focus-visible::after { opacity: 1; }
.dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px;
       padding: 1px 6px; border-radius: 4px; }
.vbody { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.vbody h3 { font-size: 14px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbody .meta { margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; min-height: 0; }
.chip { font-size: 11px; border-radius: 99px; padding: 2px 8px; border: 1px solid var(--line); color: var(--muted);
        text-decoration: none; }
.chip.done { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.chip.error { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); cursor: help; }
.chip.busy { color: var(--text); }
.vactions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: auto; padding-top: 6px; }
.vactions .del { margin-left: auto; }
.thumb.gone { cursor: default; }
.thumb.gone::after { content: none; }
a.thumb { display: block; }
.side-note { margin: 16px 4px 0; }

/* ---------- dialogs ---------- */
.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
       padding: 20px; width: min(520px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(0,0,0,.6); }
.dlg video { width: 100%; max-height: 70vh; border-radius: 10px; background: #000; }
.dlg textarea { min-height: 0; }
.dlg h2 { margin-bottom: 4px; }
.dl-head { font-size: 14px; margin: 22px 0 6px; }
.dl-table td:first-child { white-space: normal; width: 100%; }
.dl-table td.num .badge + button, .dl-table td.num button + button { margin-left: 6px; }
.dlg .clear-choices { border: 0; margin: 14px 0 4px; padding: 0; display: grid; gap: 10px; }
/* the short wait with an ad, when the browser can't show a rewarded one (core/rewarded-ad.ts) */
.ad-wait h2 span { font-variant-numeric: tabular-nums; }
.ad-box { min-height: 250px; margin: 14px 0 4px; border-radius: 10px; overflow: hidden; }
.ad-box.empty { min-height: 0; margin: 0; }
.ad-wait .actions { justify-content: flex-end; }

/* ---------- admin ---------- */
.mono, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }
p.mono { margin: 0; }
.steps { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.55; }
.steps li { margin-bottom: 10px; }
.steps a { color: var(--accent); }
.copyrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0;
           padding: 6px 8px 6px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.provider-head h2 { margin: 0; }
.setup { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.setup summary { cursor: pointer; font-size: 14px; font-weight: 600; margin-bottom: 10px; }

/* ---------- stats (My videos, Admin) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
        display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card .stat { background: var(--bg); }
.stat-value { font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.stat-label { font-size: 13px; color: var(--text); }
.stat-note { font-size: 12px; color: var(--muted); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.chart { margin: 0; }
.chart figcaption { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding: 8px; background: var(--bg);
        border: 1px solid var(--line); border-radius: 10px; }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bar-fill { width: 100%; min-height: 2px; background: var(--accent); border-radius: 3px 3px 0 0; }
.bar-fill.zero { background: var(--line); }
.wrap > h1 { margin-bottom: 20px; }
#userFilter { width: 240px; min-width: 0; flex: 0 1 240px; }
input[type=search] { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
                     border-radius: 8px; padding: 8px 12px; font: inherit; font-size: 14px; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table.users { width: 100%; border-collapse: collapse; font-size: 13px; }
table.users th { text-align: left; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line);
                 white-space: nowrap; }
table.users td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
table.users tr:last-child td { border-bottom: 0; }
table.users .num { text-align: right; font-variant-numeric: tabular-nums; }
table.users .meta { margin-top: 2px; }
.who-cell { display: flex; gap: 6px; align-items: center; }
.chart figcaption { display: flex; justify-content: space-between; gap: 8px; }
.chart-total { color: var(--text); font-weight: 600; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
@media (max-width: 560px) { .stat { padding: 12px; } .stat-value { font-size: 19px; } }
.head-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex: 1; min-width: 0; }
.row-actions { text-align: right; }
.row-actions button + button { margin-left: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dlg select:disabled { opacity: .6; cursor: default; }
#cleanNote { margin: -4px 0 16px; }
.keyrow button { white-space: nowrap; }
.home-link { color: inherit; text-decoration: none; }

/* ---------- plan & billing (Settings) ---------- */
.usage-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin: 4px 0 8px; flex-wrap: wrap; }
.fill.full { background: var(--err); }
.billing-toggle { display: inline-flex; gap: 4px; padding: 4px; margin: 16px 0 6px; border-radius: 10px;
                  background: var(--bg); border: 1px solid var(--line); }
.billing-toggle button { background: none; color: var(--muted); padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.billing-toggle button.on { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.plan-list { display: grid; gap: 8px; margin: 10px 0 12px; }
.plan-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 12px 14px;
            border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.plan-row.current { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.plan-price { font-weight: 650; white-space: nowrap; }
.plan-action { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
@media (max-width: 560px) {
  .plan-row { grid-template-columns: 1fr auto; }
  .plan-action { grid-column: 1 / -1; justify-content: flex-start; }
}
.usage-line { text-align: center; margin: 10px 0 0; } .usage-line a, .err a { color: var(--accent); }
.plans-edit input[type=text], .plans-edit input[type=number] { width: 100%; min-width: 90px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 13px; }
.plans-edit input[type=number] { text-align: right; max-width: 120px; }
.plans-edit input:disabled { opacity: .5; }
#requestsCard .plan-row + .plan-row { margin-top: 8px; }

/* ---------- phone fixes ---------- */
fieldset { min-width: 0; }                  /* browsers default fieldsets to their content width */
.grid > *, .row > *, .row3 > * { min-width: 0; }
.table-wrap { position: relative; }         /* keeps the hidden table caption inside the scroll box */
.ctl { min-width: 0; } .ctl input[type=range] { min-width: 0; width: 100%; }

/* ---------- phones ---------- */
.menu-btn { display: none; }
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .menu-btn { display: inline-flex; }
  .topbar nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 0; padding-top: 6px; }
  .topbar.open nav { display: flex; }
  .topbar nav a { padding: 12px 2px; border-top: 1px solid var(--line); font-size: 15px; }
  .topbar nav .who { padding: 12px 2px 6px; border-top: 1px solid var(--line); max-width: none; }
  .topbar nav #signout { align-self: flex-start; margin: 6px 0 4px; }
  .wrap { padding: 20px 16px 40px; }
  .card { padding: 16px; }
  .row, .row3 { grid-template-columns: 1fr; }
  .ctl { flex-wrap: wrap; row-gap: 8px; }
  .ctl input[type=range] { flex: 1 1 120px; }
  .ai-row { grid-template-columns: 1fr; }
  .ai-row button { grid-column: auto; }
  .provider-head { flex-wrap: wrap; }
  .head-actions { flex: 1 1 100%; }
  #userFilter { flex: 1 1 auto; width: auto; }
  .plan-row > div:first-child { min-width: 0; overflow-wrap: anywhere; }
  .dlg { width: calc(100vw - 24px); max-width: none; }

  /* users table becomes one card per person */
  table.users.cards thead { display: none; }
  table.users.cards, table.users.cards tbody, table.users.cards tr, table.users.cards td { display: block; width: 100%; }
  table.users.cards tr { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--bg); }
  table.users.cards td { border: 0; padding: 4px 0; white-space: normal; text-align: left; display: flex; align-items: baseline; gap: 6px; }
  table.users.cards td[data-label]::before { content: attr(data-label); color: var(--muted); margin-right: auto; }
  table.users.cards td:first-child { display: block; padding-bottom: 8px; }
  table.users.cards td.row-actions { justify-content: flex-start; padding-top: 8px; }
  table.users.cards .num .meta { display: inline; margin-left: 6px; }
}

/* ---------- payment settings (Admin) ---------- */
.checkout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.checkout-grid label { margin-top: 6px; }
input[type=url] { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
                  border-radius: 8px; padding: 10px 12px; font: inherit; font-size: 14px; }
@media (max-width: 640px) { .checkout-grid { grid-template-columns: 1fr; } }

/* ---------- your footage (Studio) ---------- */
.footage-list { display: grid; gap: 8px; margin: 12px 0; max-height: 300px; overflow-y: auto; }
.footage-item { display: grid; grid-template-columns: 40px 1fr auto auto; gap: 10px; align-items: center;
                padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.footage-item img { width: 40px; height: 71px; object-fit: cover; border-radius: 6px; background: var(--panel); }
.footage-item strong { font-size: 14px; overflow-wrap: anywhere; }
.check.rights { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 14px; color: var(--text); }
input[type=file] { width: 100%; font: inherit; font-size: 14px; color: var(--muted); }
#footageBar { margin-top: 12px; }
.chip.scheduled { color: var(--accent-2, #818cf8); border-color: color-mix(in srgb, #818cf8 45%, transparent); }
.when { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.when .check { display: flex; gap: 6px; align-items: center; margin: 0; color: var(--text); font-size: 14px; }
input[type=datetime-local] { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
                             padding: 8px 10px; font: inherit; font-size: 14px; color-scheme: dark; }
.vcard.rendering .thumb { display: grid; place-items: center; }
.render-pct { font-size: 28px; font-weight: 800; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.vcard.rendering .bar { margin-top: auto; }
.topbar .brand { display: inline-flex; align-items: center; gap: 9px; }
.brand-icon { width: 24px; height: 24px; display: block; flex: none; }
.auth-logo { width: 56px; height: 56px; display: block; margin: 0 0 14px; }

/* ---------- admin sections ---------- */
.admin-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.admin-tabs { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 4px; }
.admin-tabs a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px;
                border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.admin-tabs a:hover { color: var(--text); background: var(--panel); }
.admin-tabs a.on { color: var(--text); background: var(--panel); box-shadow: inset 3px 0 0 var(--accent); }
.admin-tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tab-count { font-size: 12px; color: var(--muted); font-weight: 600; }
.tab-count.alert { color: var(--accent-ink); background: var(--accent); border-radius: 99px; padding: 1px 8px; }
.panel > * + *, #billingCards:not(:empty) { margin-top: 20px; }
#billingCards .card + .card { margin-top: 20px; }
@media (max-width: 820px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .admin-tabs { position: static; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px;
                scrollbar-width: none; }
  .admin-tabs::-webkit-scrollbar { display: none; }
  .admin-tabs a { flex: none; white-space: nowrap; border: 1px solid var(--line); }
  .admin-tabs a.on { box-shadow: none; border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
}
.admin-panels, .panel { min-width: 0; }
.remake { margin: 0; color: var(--accent); }

/* ---------- API tokens (Settings) ---------- */
.token-form { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 12px; }
.token-form input { width: 100%; }
.token-new { margin: 12px 0; padding: 12px; border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line));
             border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.token-new p { margin: 0 0 8px; font-size: 14px; }
#tokenList .plan-row + .plan-row { margin-top: 8px; }
@media (max-width: 640px) { .token-form { grid-template-columns: 1fr; } }

/* TikTok share dialog */
.tt-head { display: flex; gap: 14px; align-items: center; margin-top: 10px; }
.tt-head video { width: 72px; height: 128px; max-height: none; object-fit: cover; border-radius: 8px; flex: none; }
.tt-who { font-weight: 600; margin: 0; }
.tt-indent { margin: 6px 0 0 24px; }
.tt-indent .meta { margin: 2px 0 8px 24px; }
.tt-commercial { margin-top: 16px; align-items: flex-start; }
.tt-label { color: var(--text); }
.chip-x { background: none; border: 0; color: inherit; padding: 0 0 0 4px; font-size: 14px; line-height: 1; cursor: pointer; }
.legal-links { text-align: center; margin: 18px auto; }
.legal-links a { color: var(--muted); }
.share-err { color: var(--err); font-size: 12.5px; margin: 6px 0 0; line-height: 1.4; }
/* Admin → Activity */
table.act-table td { white-space: normal; }
table.act-table td.when { white-space: nowrap; color: var(--muted); }
.act-details { color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.act-via { font-size: 11px; }
@media (max-width: 640px) {
  /* Activity on phones: the time and what happened head each card; who and from below, labelled. */
  table.users.cards.act-table td.when, table.users.cards.act-table td.what { display: block; padding: 2px 0; }
  table.users.cards.act-table td.what { padding-bottom: 6px; }
  table.users.cards.act-table tr { display: flex; flex-direction: column; }
  table.users.cards.act-table td.when { order: -2; }
  table.users.cards.act-table td.what { order: -1; }
  #tab-activity .head-actions { flex-wrap: wrap; width: 100%; }
  #actSearch { flex: 1 1 100%; }
}
