:root {
  --bg: #0f1115; --panel: #171a21; --ink: #e7ecf3; --muted: #93a0b3;
  --accent: #7cc4ff; --accent2: #b48cff; --line: #232833; --danger: #ff6b7a;
  --sel: rgba(124,196,255,.22);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
header { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: rgba(15,17,21,.85); backdrop-filter: blur(6px); z-index: 5; }
.brand { display: inline-flex; align-items: center; color: var(--ink); }
.logo { height: 40px; width: auto; display: block; }
nav a { margin-left: 16px; color: var(--muted); }
nav a:hover { color: var(--ink); }
main { max-width: 960px; margin: 0 auto; padding: 24px 20px 60px; }
h1 { font-size: 28px; margin: 8px 0 20px; }
h2 { margin: 0 0 6px; }
.hero p { color: var(--muted); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; display: block; transition: transform .1s, border-color .1s; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card p { color: var(--muted); margin: 4px 0 0; }

.drop { display: flex; align-items: center; justify-content: center; height: 130px;
  border: 2px dashed var(--line); border-radius: 14px; color: var(--muted);
  cursor: pointer; background: var(--panel); }
.drop.hover { border-color: var(--accent); color: var(--ink); }
.drop input { display: none; }

.stage { position: relative; margin: 16px auto 0; border-radius: 12px; overflow: hidden; background: #000; width: fit-content; max-width: 100%; }
.stage video { display: block; max-width: 100%; max-height: 60vh; height: auto; width: auto; }
.crophost { position: absolute; inset: 0; pointer-events: none; }
.cropbox { position: absolute; border: 2px solid var(--accent); background: rgba(124,196,255,.08);
  cursor: move; pointer-events: auto; box-shadow: 0 0 0 9999px rgba(0,0,0,.3); }
.chandle { position: absolute; width: 14px; height: 14px; background: var(--accent);
  border-radius: 3px; pointer-events: auto; }
.c-nw { left: -7px; top: -7px; cursor: nwse-resize; }
.c-ne { right: -7px; top: -7px; cursor: nesw-resize; }
.c-sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.c-se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.cropbox.end { border-color: var(--accent2); background: rgba(180,140,255,.08); }
.cropbox.end .chandle { background: var(--accent2); }
.cropbox.start { box-shadow: none; }
.cropbox.end { box-shadow: none; }
.cropbox-tag { position: absolute; top: 2px; left: 4px; font-size: 10px; font-weight: 700;
  letter-spacing: .5px; color: var(--ink); background: rgba(0,0,0,.55); padding: 1px 5px; border-radius: 3px; pointer-events: none; }
button.kb-on { border-color: var(--accent2); color: var(--accent2); }

.kb-bar { margin-top: 10px; padding: 10px 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.kb-hint { color: var(--muted); font-size: 13px; }
.kb-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-presets button { padding: 4px 10px; font-size: 12px; }
.pill { display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px; color: #0b0d12; }
.pill.blue { background: var(--accent); }
.pill.purple { background: var(--accent2); }

.doc { line-height: 1.6; }
.doc h2 { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 18px; }
.doc h3 { margin-top: 18px; color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: .5px; }
.doc ul { padding-left: 20px; }
.doc li { margin: 4px 0; }
.doc strong { color: var(--ink); }

.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(15,17,21,.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); }
.bb-inner { max-width: 960px; margin: 0 auto; padding: 12px 20px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; }
.bb-settings { display: flex; gap: 12px; flex-wrap: wrap; }
.bb-settings label { display: flex; flex-direction: column; font-size: 11px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.bb-settings select { margin-top: 3px; }
.bb-status { min-width: 0; }
.bb-status .status { margin-top: 0; font-size: 13px; }
.bb-status .progress { margin-top: 0; height: 20px; }
button.big { padding: 12px 22px; font-size: 15px; }
@media (max-width: 700px) {
  .bb-inner { grid-template-columns: 1fr; }
  button.big { width: 100%; }
}
main { padding-bottom: 120px; }

.logout-form { display: inline; margin: 0 0 0 16px; }
button.linkish { background: none; border: none; padding: 0; color: var(--muted);
  cursor: pointer; font: inherit; }
button.linkish:hover { color: var(--ink); border: none; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(124,196,255,.10), transparent 60%),
              radial-gradient(900px 500px at 100% 110%, rgba(180,140,255,.10), transparent 60%),
              var(--bg); }
.login-wrap { width: 100%; max-width: 400px; padding: 24px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-mark { height: 64px; width: auto; display: block; }
.login-wordmark { height: 32px; width: auto; display: block; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.login-form input { margin-top: 6px; background: #0f1218; border: 1px solid var(--line);
  color: var(--ink); padding: 12px 14px; border-radius: 8px; font: inherit;
  transition: border-color .12s, box-shadow .12s; }
.login-form input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,196,255,.18); }
.login-form button { margin-top: 4px; }
.login-err { color: var(--danger); font-size: 13px; padding: 8px 10px;
  background: rgba(255,107,122,.08); border: 1px solid rgba(255,107,122,.3); border-radius: 8px; }

.tl { margin-top: 14px; }
.tl-track { position: relative; height: 36px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; user-select: none; }
.tl-sel { position: absolute; top: 0; bottom: 0; background: var(--sel);
  border-left: 2px solid var(--accent); border-right: 2px solid var(--accent); }
.tl-h { position: absolute; top: -4px; width: 12px; height: 44px; margin-left: -6px;
  background: var(--accent); border-radius: 3px; cursor: ew-resize; touch-action: none; }
.tl-play { position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: #fff; pointer-events: none; }
.tl-times { display: flex; justify-content: space-between; color: var(--muted);
  font-size: 12px; font-variant-numeric: tabular-nums; padding: 4px 2px 0; }
.tl-tp { color: var(--ink); }
.tl-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tl-btns button { padding: 5px 10px; font-size: 13px; }
.tl-btns button.toggle.on { border-color: var(--accent); color: var(--accent); }

.controls { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; align-items: end; }
.controls label, .clip-controls label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.controls input, .clip-controls input {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  padding: 8px 10px; border-radius: 8px; margin-top: 4px; }

select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-color: var(--panel);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%237cc4ff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 8px;
  border: 1px solid var(--line); color: var(--ink);
  padding: 8px 32px 8px 12px; border-radius: 8px; margin-top: 4px;
  font: inherit; line-height: 1.2; cursor: pointer;
  transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease;
}
select:hover { border-color: var(--accent); background-color: #1c2029; }
select:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,196,255,.18); }
select:disabled { opacity: .5; cursor: not-allowed; }
select::-ms-expand { display: none; }
option { background: #171a21; color: var(--ink); padding: 6px; }
.controls input { width: 110px; }
button { background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 8px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: linear-gradient(180deg, var(--accent), var(--accent2));
  color: #0b0d12; border: none; font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }

.status { margin-top: 14px; color: var(--muted); min-height: 1.5em; }
.status.err { color: var(--danger); }
#result img, #result video { margin-top: 16px; max-width: 100%; border-radius: 12px; }

.progress { margin-top: 14px; height: 22px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; position: relative; overflow: hidden; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s ease; }
.progress .msg { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 12px; color: var(--ink); mix-blend-mode: difference; }

.clips { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-direction: column; gap: 16px; }
.clip { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.clip-head { display: flex; align-items: center; gap: 10px; }
.clip-i { color: var(--muted); font-weight: 600; }
.clip-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-dur { color: var(--muted); font-size: 13px; }
.clip-actions { display: flex; gap: 6px; }
.clip-actions button { padding: 4px 10px; font-size: 13px; }
.clip .stage video { max-height: 40vh; }
.clip .stage { margin-left: 0; margin-right: 0; }
.clip-controls { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; align-items: end; }
.clip-controls .chk { flex-direction: row; align-items: center; gap: 6px; margin-top: 20px; }
