@font-face { font-family: "Cinzel"; src: url("/brand-fonts/Cinzel-Regular.ttf") format("truetype"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("/brand-fonts/EBGaramond-Regular.ttf") format("truetype"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("/brand-fonts/EBGaramond-Italic.ttf") format("truetype"); font-weight: 400 800; font-style: italic; font-display: swap; }

:root {
  --bg: #0c0a08;
  --bg-2: #120f0b;
  --panel: #17130e;
  --panel-2: #1f1912;
  --line: #3b2f20;
  --line-2: #574630;
  --gold: #c9a24a;
  --gold-2: #e6c778;
  --gold-dim: #8c7133;
  --text: #ece1c8;
  --muted: #a4957a;
  --faint: #6f624d;
  --danger: #cf6a4f;
  --ok: #8fae68;
  --flag: #f0923a;
  --flag-bg: rgba(240, 146, 58, .14);
  --sel: rgba(201, 162, 74, .22);
  --radius: 6px;
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --body: "EB Garamond", Garamond, Georgia, serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(ellipse at top, #1a140d 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font: 18px/1.45 var(--body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .06em; color: var(--gold); margin: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .12em; }
h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .12em; color: var(--gold-dim); margin: 1.1rem 0 .5rem; }
small, .muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .82em; }
[hidden] { display: none !important; }

/* ------------------------------------------------ chrome */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .7rem 1.25rem;
  border-bottom: 1px solid var(--line); background: linear-gradient(#17120c, #110d09);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--gold); font-family: var(--display); letter-spacing: .1em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b { font-weight: 600; font-size: 1.05rem; }
.brand span { color: var(--muted); font-size: .72rem; letter-spacing: .18em; display: block; line-height: 1; }
.topbar .grow { flex: 1; min-width: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.25rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-pad { padding: 1rem 1.1rem; }
.rule { height: 1px; background: linear-gradient(90deg, transparent, var(--line-2), transparent); border: 0; margin: 1rem 0; }

/* ------------------------------------------------ controls */
button, .btn {
  font: inherit; font-size: .9rem; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: var(--radius); padding: .38rem .75rem;
  cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; line-height: 1.2;
  white-space: nowrap; touch-action: manipulation;
}
button:hover, .btn:hover { border-color: var(--gold-dim); background: #271f16; text-decoration: none; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
button:disabled { opacity: .45; cursor: default; }
button.primary, .btn.primary { background: linear-gradient(#d4ae55, #b18a36); color: #1a1208; border-color: #e3c476; font-weight: 600; }
button.primary:hover { background: linear-gradient(#e0bb62, #bf9640); }
button.danger { color: #f1b3a3; border-color: #6b3325; }
button.danger:hover { background: #3a1a12; border-color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: .3rem .45rem; }
button.ghost:hover { color: var(--text); border-color: var(--line-2); }
button.icon { padding: .3rem .45rem; min-width: 2rem; justify-content: center; }
button.on { border-color: var(--gold); color: var(--gold-2); background: #2a2014; }

input, select, textarea {
  font: inherit; font-size: .95rem; color: var(--text); background: #0f0c09; border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: .35rem .5rem; min-width: 0;
}
textarea { resize: vertical; line-height: 1.35; }
input[type=number] { width: 6rem; }
input[type=color] { padding: 0; width: 2.4rem; height: 2rem; border-radius: var(--radius); cursor: pointer; }
input[type=range] { accent-color: var(--gold); padding: 0; background: none; border: 0; }
input[type=checkbox] { accent-color: var(--gold); width: 1.05rem; height: 1.05rem; margin: 0; }
label { color: var(--muted); font-size: .9rem; }
.field { display: flex; flex-direction: column; gap: .2rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.tight { gap: .3rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; color: var(--text); cursor: pointer; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem .8rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem .8rem; }
.grid2 > .field > input, .grid2 > .field > select, .grid3 > .field > input, .grid3 > .field > select { width: 100%; }
.hint { font-size: .85rem; color: var(--muted); margin: .35rem 0 0; }
.warn { color: var(--flag); }

.badge {
  font-family: var(--display); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase;
  padding: .18rem .5rem; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap;
}
.badge.processing, .badge.rendering { color: var(--gold-2); border-color: var(--gold-dim); }
.badge.ready { color: var(--text); }
.badge.rendered { color: var(--ok); border-color: #4e6238; }
.badge.error { color: var(--danger); border-color: #6b3325; }
.badge.flag { color: var(--flag); border-color: #7a4a1f; background: var(--flag-bg); }

.bar { height: 6px; background: #0a0806; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-dim), var(--gold-2)); transition: width .4s; }

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 100;
  background: #231b12; border: 1px solid var(--gold-dim); padding: .6rem 1rem; border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.5); max-width: calc(100vw - 2rem);
}
.toast.error { border-color: var(--danger); }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--gold-dim); border-radius: 8px;
  padding: 1.2rem 1.3rem; max-width: min(520px, calc(100vw - 2rem)); box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(0,0,0,.65); }
dialog h2 { margin-bottom: .8rem; }
dialog .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; }

/* ------------------------------------------------ login */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 1rem;
}
.login form { width: min(380px, 100%); text-align: center; padding: 2rem 1.6rem; }
.login svg { width: 88px; height: 88px; margin-bottom: .6rem; }
.login h1 { font-size: 1.6rem; }
.login p { color: var(--muted); margin: .2rem 0 1.4rem; letter-spacing: .08em; font-size: .9rem; }
.login input { width: 100%; font-size: 1.05rem; padding: .6rem .7rem; text-align: center; }
.login button { width: 100%; justify-content: center; margin-top: .8rem; padding: .6rem; font-size: 1rem; }
.login .err { color: var(--danger); min-height: 1.4em; margin-top: .7rem; font-size: .95rem; }

/* ------------------------------------------------ library */
.drop {
  border: 1.5px dashed var(--line-2); border-radius: 8px; padding: 1.6rem 1rem; text-align: center;
  background: repeating-linear-gradient(135deg, rgba(201,162,74,.02) 0 12px, transparent 12px 24px);
  transition: border-color .15s, background-color .15s; cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--gold); background-color: rgba(201,162,74,.05); }
.drop strong { font-family: var(--display); color: var(--gold); letter-spacing: .08em; font-weight: 600; }
.drop p { margin: .3rem 0 0; color: var(--muted); font-size: .92rem; }
.step { font-family: var(--display); color: var(--gold-2); letter-spacing: .05em; margin: 1rem 0 .5rem; font-size: .95rem; }
.formats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.fmt { flex-direction: column; align-items: center; gap: .3rem; padding: .7rem .5rem; white-space: normal; text-align: center; }
.fmt .shape { display: block; border: 1.5px solid var(--gold-dim); border-radius: 2px; margin-bottom: .2rem; }
.fmt .fmt-name { font-size: .95rem; }
.fmt small { font-size: .75rem; }
.fmt.on { border-color: var(--gold); background: #2a2014; box-shadow: 0 0 0 1px var(--gold) inset; }
.fmt.on .shape { border-color: var(--gold-2); background: rgba(201,162,74,.2); }

.uploads { display: grid; gap: .5rem; margin-top: .9rem; }
.upload-item { display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem; align-items: center; padding: .6rem .8rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); }
.upload-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .bar { grid-column: 1 / -1; }
.upload-item .info { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); }

.lib-head { margin: 1.6rem 0 .6rem; }
.clips { width: 100%; border-collapse: collapse; }
.clips th { text-align: left; font-family: var(--display); font-weight: 600; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-dim); padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
.clips td { padding: .6rem .7rem; border-bottom: 1px solid #231c14; vertical-align: middle; }
.clips tr:hover td { background: rgba(201,162,74,.035); }
.clips .name a { color: var(--text); font-size: 1.05rem; }
.clips .name a:hover { color: var(--gold-2); }
.clips .status { min-width: 9rem; }
.clips td.len, .clips td.date { white-space: nowrap; }
.clips .status small.warn { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 28rem; }
.clips .status .bar { margin-top: .3rem; }
.clips .status small { display: block; margin-top: .15rem; font-size: .78rem; }
.clips .act { text-align: right; white-space: nowrap; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty svg { width: 54px; opacity: .45; }

@media (max-width: 720px) {
  .clips thead { display: none; }
  .clips tr { display: grid; grid-template-columns: 1fr auto; padding: .6rem 0; border-bottom: 1px solid var(--line); }
  .clips td { border: 0; padding: .15rem .3rem; }
  .clips td.len, .clips td.date { font-size: .85rem; color: var(--muted); }
  .clips td.status { grid-column: 1 / -1; }
  .clips td.act { grid-column: 1 / -1; text-align: left; }
  .topbar { padding: .6rem .8rem; gap: .6rem; }
  .brand div { display: none; }
  .wrap { padding: .8rem; }
}

/* ------------------------------------------------ editor */
.banners { max-width: 1500px; margin: 0 auto; padding: 0 1.25rem; display: grid; gap: .5rem; }
.banners:has(> :not([hidden])) { padding-top: 1rem; }
.editor {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 520px); gap: 1rem; padding: 1rem 1.25rem;
  max-width: 1500px; margin: 0 auto; align-items: start;
}
.editor .left { display: grid; gap: 1rem; min-width: 0; }
.editor .right { position: sticky; top: 4.4rem; max-height: calc(100vh - 5.4rem); display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 1000px) {
  .editor { grid-template-columns: minmax(0, 1fr); padding: .7rem; }
  .editor .right { position: static; max-height: none; }
  .banners { padding: 0 .7rem; }
}
.row.between { justify-content: space-between; }

.name-input { font-family: var(--display); font-size: 1.05rem; letter-spacing: .05em; color: var(--gold-2); background: transparent; border-color: transparent; width: 100%; max-width: 32rem; }
.name-input:hover, .name-input:focus { border-color: var(--line-2); background: #0f0c09; }
.savestate { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.savestate.dirty { color: var(--gold-2); }
.savestate.bad { color: var(--danger); }

.jobbar { display: flex; align-items: center; gap: .8rem; padding: .55rem .8rem; }
.jobbar .bar { flex: 1; }
.jobbar .msg { font-size: .9rem; color: var(--gold-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.banner { padding: .6rem .8rem; border-radius: var(--radius); border: 1px solid; display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.banner.conflict, .banner.error { border-color: var(--danger); background: rgba(207,106,79,.1); }

/* preview */
.stage-wrap { display: flex; justify-content: center; margin: .8rem 0; width: 100%; }
.stage {
  position: relative; flex: none; overflow: hidden; border: 1px solid var(--gold-dim); border-radius: 4px;
  min-height: 90px; box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 6px 24px rgba(0,0,0,.45);
  user-select: none; touch-action: none; cursor: grab;
}
.stage:active { cursor: grabbing; }
.stage img { position: absolute; max-width: none; pointer-events: none; }
.stage-empty { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: grid; place-items: start center; padding-top: 18% !important; color: var(--muted); font-size: .95rem; cursor: default; text-align: center; padding: .5rem; }
.stage .cap {
  position: absolute; text-align: center; paint-order: stroke fill; text-wrap: balance; cursor: move;
}
.stage .cap span { outline: 1px dashed transparent; outline-offset: 4px; }
.stage .cap:hover span, .stage .cap.dragging span { outline-color: rgba(230,199,120,.7); }
.stage .cap.sample { opacity: .55; }
.cap-style { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .2rem; display: grid; gap: .6rem; }
.cap-style h3 { margin: .6rem 0 0; }
.auto-cap { margin-top: .7rem; flex-wrap: wrap; }
.auto-cap small { width: 100%; padding-left: 1.5rem; }
.bg-tools { display: grid; gap: .6rem; justify-items: start; }
.zoom { display: flex; align-items: center; gap: .6rem; width: 100%; max-width: 32rem; }
.zoom input { flex: 1; }
audio { width: 100%; margin-top: .9rem; }
button.big { font-size: 1.05rem; padding: .6rem 1.4rem; }

/* captions */
.cap-head { padding: 1rem 1rem .7rem; border-bottom: 1px solid var(--line); flex: none; }
.cap-list { overflow-y: auto; padding: .6rem .7rem 1rem; flex: 1; min-height: 150px; }
@media (max-width: 1000px) { .cap-list { max-height: 80vh; } }
.flagnote { font-size: .88rem; background: var(--flag-bg); border: 1px solid #6b431c; border-radius: var(--radius); padding: .45rem .6rem; color: #f4c79b; margin: .7rem 0 0; }

.seg { border: 1px solid var(--line); border-left: 3px solid var(--line-2); border-radius: 5px; padding: .5rem .6rem .6rem; margin-bottom: .5rem; background: var(--bg-2); }
.seg.check { border-left-color: var(--flag); }
.seg.active { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(201,162,74,.25) inset; }
.seg .top { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.seg .top .t { width: 5.4rem; font-family: var(--mono); font-size: .8rem; padding: .22rem .35rem; }
.seg .top .sp { flex: 1; }
.seg .play { width: 2rem; justify-content: center; padding: .25rem; }
.seg .del { font-size: .82rem; }
.seg textarea { width: 100%; margin-top: .45rem; font-size: 1.08rem; min-height: 2.5rem; padding: .4rem .55rem; }
.seg textarea:hover { border-color: var(--gold-dim); }
.checkrow { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .4rem; }
.checkrow small { flex: 1; font-size: .82rem; }

.export-video { width: 100%; max-height: 60vh; border: 1px solid var(--line-2); border-radius: 4px; background: #000; margin: .8rem 0; }
