:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1c1b19; --muted: #6d6a64; --line: #e4e1da;
  --accent: #ff5a36; --accent-ink: #ffffff; --soft: #fff1ec; --ok: #1f8a4c; --warn: #b54708; --bad: #c0362c;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #131211; --panel: #1d1c1a; --ink: #f2efe9; --muted: #a29e96; --line: #33312d;
          --soft: #3a1f17; --shadow: none; color-scheme: dark; }
}
* { 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: inherit; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 15px; margin: 0 0 10px; }
h4 { font-size: 13px; margin: 14px 0 4px; color: var(--muted); }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.right { text-align: right; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
       padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent);
       backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top nav { display: flex; align-items: center; gap: 18px; }
.top nav a:not(.btn) { text-decoration: none; color: var(--muted); }
.top nav a.on { color: var(--ink); font-weight: 600; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; text-decoration: none; }
.brand.big { font-size: 22px; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
        background: var(--accent); color: #fff; font-size: 12px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 10px; font-size: 14px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.alert { background: var(--soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
         padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px;
       border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
       font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.big { padding: 13px 26px; font-size: 16px; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .7; cursor: progress; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }

label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 0; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; font-weight: 400;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
input[type=file] { display: block; margin-top: 8px; font: inherit; font-weight: 400; }
.search { max-width: 280px; margin: 0 !important; }

.login { width: 100%; max-width: 380px; padding: 30px; }
.login .btn { margin-top: 20px; }

/* library */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
        text-decoration: none; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--muted); }
.thumb { position: relative; aspect-ratio: 16/9; background: var(--soft); display: grid; place-items: center; font-size: 34px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.meta { padding: 12px 14px; display: grid; gap: 2px; }
.meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--panel);
         border: 1px solid var(--line); text-transform: capitalize; }
.thumb .badge { position: absolute; top: 10px; left: 10px; }
.len { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px;
       padding: 2px 7px; border-radius: 6px; }
.badge.done { color: var(--ok); } .badge.running, .badge.queued { color: var(--warn); }
.badge.failed { color: var(--bad); } .badge.cancelled { color: var(--muted); }
.empty { text-align: center; padding: 56px 24px; }
.empty-icon { font-size: 44px; }
.empty p { max-width: 440px; margin: 8px auto 22px; }

/* new video */
.new { max-width: 780px; }
.new h1, h1 + .new { margin-bottom: 18px; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
        background: var(--accent); color: #fff; font-size: 13px; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: inline-block; padding: 9px 16px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--bg); }
.seg input:checked + span { border-color: var(--accent); background: var(--soft); color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.drop { display: grid; justify-items: center; gap: 4px; padding: 30px 16px; margin: 0; border: 2px dashed var(--line);
        border-radius: var(--radius); cursor: pointer; text-align: center; background: var(--bg); transition: border-color .15s, background .15s; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { font-size: 26px; color: var(--accent); }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 14px; }
.previews.small { grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.previews img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.pv { position: relative; }
.pv .num { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.7); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.pv .ctl { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; }
.pv .ctl button { width: 24px; height: 24px; border-radius: 6px; border: 0; background: rgba(0,0,0,.7); color: #fff; cursor: pointer; font-size: 12px; }
.pv .name { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.actions.center-row { justify-content: center; margin: 0; }
.alert.warn { background: #fff4e5; border-color: #f5c27a; color: #6b3d00; }
@media (prefers-color-scheme: dark) { .alert.warn { background: #3a2a10; border-color: #7a5520; color: #f6d9a8; } }
.actions.left { justify-content: flex-start; margin: 14px 0 16px; }
[data-when] { display: none; }

/* video page */
#title { cursor: text; border-radius: 6px; }
#title:hover { outline: 1px dashed var(--line); outline-offset: 4px; }
.video-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.player { width: 100%; border-radius: var(--radius); background: #000; display: block; max-height: 78vh; }
.player.vertical { max-width: 440px; margin: 0 auto; }
.player.square { max-width: 640px; margin: 0 auto; }
.making { text-align: center; padding: 48px 24px; }
.making p { margin: 6px 0 20px; }
.spinner { width: 42px; height: 42px; margin: 0 auto 16px; border-radius: 50%; border: 4px solid var(--line);
           border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.log summary { cursor: pointer; font-weight: 600; }
.log pre { max-height: 360px; overflow: auto; margin: 12px 0 0; font: 12.5px/1.55 ui-monospace, Consolas, monospace;
           white-space: pre-wrap; word-break: break-word; color: var(--muted); }
.share { white-space: pre-wrap; font: inherit; font-size: 14px; margin: 0 0 10px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
dt { color: var(--muted); } dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 820px) {
  .video-layout { grid-template-columns: 1fr; }
  .top { padding: 10px 16px; }
  .top nav { gap: 12px; }
  .wrap { padding: 20px 16px 48px; }
  .search { max-width: none; width: 100%; }
}
@media (max-width: 480px) {
  .top nav a:not(.btn) { display: none; }
  .brand { font-size: 15px; }
  .actions .btn { flex: 1; }
}
