:root {
  --bg: #f6f4ef; --panel: #ffffff; --ink: #1d1b18; --muted: #6f6a62; --line: #e4dfd5;
  --accent: #e2522f; --accent-ink: #fff; --ok: #2f8f5b; --warn: #c98a12; --bad: #c0392b;
  --radius: 12px;
  --yt: #ff0033; --fb: #1877f2; --ig: #c13584; --tt: #111; --sp: #1db954;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151412; --panel: #1f1d1a; --ink: #f1ede6; --muted: #a39d93; --line: #34312c; --tt: #eee; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
code { background: var(--line); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
h1 { font-size: 1.7rem; margin: .2rem 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 2rem 0 .8rem; display: flex; gap: .5rem; align-items: center; }
main { max-width: 1180px; margin: 0 auto; padding: 1.2rem 1.25rem 4rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: .5rem; }
.brand em { font-style: normal; color: var(--muted); font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
nav { display: flex; gap: 1rem; align-items: center; }
nav a { color: var(--ink); text-decoration: none; }
.banner { background: #fff4d6; color: #6b4e00; text-align: center; padding: .45rem 1rem; font-size: .9rem; border-bottom: 1px solid #f0dc9e; }
@media (prefers-color-scheme: dark) { .banner { background: #3a2f12; color: #f3d98c; border-color: #5a4a1c; } }

.btn { display: inline-block; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: .5rem .95rem; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.05); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .3rem .7rem; font-size: .85rem; }
form.inline { display: inline; }

.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid var(--line); background: var(--panel); }
.flash-ok { border-color: var(--ok); }
.flash-error { border-color: var(--bad); color: var(--bad); }
.flash-working { border-color: var(--warn); }
.flash-info { border-color: var(--muted); }

.panel, .card, .conn, .clip { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel { padding: 1.3rem; max-width: 760px; }
label { display: block; font-weight: 600; font-size: .85rem; margin: .9rem 0 .25rem; }
input, textarea { width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
input[readonly], textarea[readonly] { opacity: .75; }
textarea { resize: vertical; }
.hint { font-size: .82rem; color: var(--muted); margin: .3rem 0 0; }
.form .btn-primary { margin-top: 1.4rem; }
.fields2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: .8rem; }
.fields3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem; }
.span2 { grid-column: span 2; }

.muted { color: var(--muted); }
.small { font-size: .84rem; }
.error-text { color: var(--bad); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.count { background: var(--accent); color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 .5rem; }

.chip { font-size: .78rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; color: #fff; white-space: nowrap; }
.chip-youtube { background: var(--yt); } .chip-facebook { background: var(--fb); } .chip-instagram { background: var(--ig); }
.chip-tiktok { background: var(--tt); color: var(--bg); } .chip-spotify { background: var(--sp); }
.pill { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--line); }
.pill-working { background: #fff0c2; color: #6b4e00; }
.status { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--muted); }
.status-approved { color: var(--fb); } .status-posted { color: var(--ok); } .status-failed { color: var(--bad); }
.status-manual { color: var(--warn); } .status-posting { color: var(--warn); }

.card { padding: 1rem 1.1rem; margin-bottom: .8rem; }
.card-failed { border-left: 4px solid var(--bad); }
.card-manual { border-left: 4px solid var(--warn); }
.copyrow { display: flex; gap: .5rem; align-items: flex-start; }
.copyrow .btn { flex-shrink: 0; }
.card .btn, .card form { margin-top: .5rem; margin-right: .3rem; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list td, table.list th { padding: .6rem .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list th { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.when { white-space: nowrap; font-variant-numeric: tabular-nums; }

.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 1.5rem 1.8rem; }
.empty li { margin: .35rem 0; }

.sticky-actions { position: sticky; top: 58px; z-index: 5; background: var(--bg); padding: .7rem 0; display: flex; gap: .5rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.clip { display: grid; grid-template-columns: 260px 1fr; gap: 1.2rem; padding: 1.1rem; margin-bottom: 1.2rem; }
.clip-media video { width: 100%; border-radius: 10px; background: #000; }
.clip-media video.vertical { max-height: 420px; aspect-ratio: 9/16; object-fit: contain; }
.clip-media .filename { word-break: break-all; margin: .35rem 0; }
.clip-media .btn { margin-top: .6rem; }
.transcript { white-space: pre-wrap; max-height: 220px; overflow: auto; }
.clip-posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: .9rem; }
.post { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; background: var(--bg); }
.post label { margin-top: .6rem; }
.post-posted, .post-skipped { opacity: .7; }
.post-actions { display: flex; gap: .4rem; align-items: center; margin-top: .6rem; flex-wrap: wrap; }

.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-top: 1rem; }
.conn { padding: 1rem; }
.conn-ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }

@media (max-width: 800px) {
  .grid2, .clip, .fields2, .fields3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  nav { gap: .6rem; }
}

/* ---------- PHP version additions ---------- */
h3 { font-size: .95rem; margin: 1.6rem 0 .2rem; }
select { width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
.hidden { display: none !important; }
.narrow { max-width: 520px; }
.wide-panel { max-width: none; margin-bottom: 1.4rem; }
.wide-panel h2 { margin-top: 0; }
.banner-bad { background: #fde3df; color: #7a1c10; border-color: #f2b8ae; }
.banner a { color: inherit; font-weight: 600; }
@media (prefers-color-scheme: dark) { .banner-bad { background: #43201b; color: #f6c1b8; border-color: #6b2f26; } }
.fields5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: .6rem; }
.align-end { align-items: end; margin-top: .6rem; }
.right { text-align: right; }
.checkrow { display: flex; gap: 1.2rem; flex-wrap: wrap; }
label.check { display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; margin: .4rem 0; }
label.check input { width: auto; }
label.check.big { font-size: 1rem; }
.subnav { display: flex; gap: 1rem; flex-wrap: wrap; margin: .2rem 0 1.2rem; font-size: .9rem; }
.subnav a { color: var(--muted); }
.sticky-save { position: sticky; bottom: 0; background: var(--bg); padding: .8rem 0; border-top: 1px solid var(--line); margin-bottom: 1.4rem; }
ul.checks { list-style: none; padding: 0; }
ul.checks li { padding: .45rem 0 .45rem 1.8rem; position: relative; }
ul.checks li::before { position: absolute; left: 0; font-weight: 700; }
ul.checks li.ok::before { content: "\2713"; color: var(--ok); }
ul.checks li.bad::before { content: "!"; color: var(--bad); }
.drops { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.2rem; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1rem; background: var(--bg); transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg)); }
.drop input[type=file] { display: none; }
.drop p { margin: .2rem 0 .7rem; }
.files { list-style: none; padding: 0; margin: .8rem 0 0; font-size: .85rem; }
.files li { display: flex; justify-content: space-between; gap: .6rem; padding: .35rem 0; border-top: 1px solid var(--line); }
.files li .name { word-break: break-all; }
.files li .size { color: var(--muted); white-space: nowrap; }
.files li.done .size { color: var(--ok); }
.files li .x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0 .2rem; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 1.2rem; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.deleted { aspect-ratio: 9/16; display: grid; place-items: center; text-align: center; padding: 1rem; border: 1px dashed var(--line); border-radius: 10px; }
.wide-panel .copyrow { margin-bottom: .4rem; }
@media (max-width: 800px) { .drops, .fields5 { grid-template-columns: 1fr 1fr; } }

/* ---------- clip maker ---------- */
.drop-vertical { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.waiting { display: flex; gap: 1rem; align-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem; margin-bottom: .6rem; }
.style-card { display: flex; flex-direction: column; gap: .3rem; padding: .6rem; border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer; background: var(--bg); font-weight: 500; margin: 0; }
.style-card:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--bg)); }
.style-card input { position: absolute; opacity: 0; pointer-events: none; }
.style-card canvas { width: 100%; aspect-ratio: 9/16; border-radius: 8px; display: block; }
input[type=color], label.check input[type=color] { width: 48px; height: 34px; padding: 2px; cursor: pointer; }
.clipper-grid { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
.idea { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .8rem; }
.idea.off { opacity: .55; }
.idea.made { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.idea-top { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.idea-top label.check { margin: 0; }
.idea-top .idea-status { margin-left: auto; }
.idea-title { font-weight: 700; margin: .5rem 0 .1rem; }
.idea p.small { margin: .1rem 0 .3rem; }
.idea label { margin-top: .5rem; }
.idea-actions { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.idea-actions .small { margin-left: .4rem; }
.score { font-weight: 800; font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; color: #fff; }
.score-hi { background: var(--ok); } .score-mid { background: var(--warn); } .score-lo { background: var(--muted); }
.stage-wrap { position: sticky; top: 72px; display: flex; flex-direction: column; gap: .5rem; }
#stage { width: 100%; aspect-ratio: 9/16; background: #111; border-radius: 12px; }
#makeProgress { font-weight: 600; min-height: 1.2em; }
body.rendering .idea-actions, body.rendering [data-restart] { pointer-events: none; opacity: .5; }
@media (max-width: 900px) { .clipper-grid { grid-template-columns: 1fr; } .styles { grid-template-columns: 1fr 1fr; } .stage-wrap { position: static; } .drops { grid-template-columns: 1fr; } }
