:root {
  --bg: #08090b;
  --bg-glow: #0c0e13;
  --panel: #0e1015;
  --panel-2: #12151c;
  --line: #1e2230;
  --line-soft: #171a24;
  --text: #eceef3;
  --dim: #8b93a3;
  --dim-2: #626a79;
  --accent: #f0c24b;
  --accent-ink: #1b1405;
  --blue: #6ea8fe;
  --ok: #58d6a0;
  --err: #ff7a7a;
  --radius: 14px;
  --radius-sm: 9px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 12% -10%, #141821 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #121017 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

::selection { background: #f0c24b33; }

/* ------------------------------ top bar ------------------------------ */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px clamp(16px, 3vw, 40px) 14px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, #08090be8, #08090bcc 60%, #08090b55);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { color: var(--accent); font-size: 15px; letter-spacing: -1px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }
.brand-sub { color: var(--dim-2); font-size: 12.5px; letter-spacing: 0.02em; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.chip {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--dim);
  font-family: var(--mono); letter-spacing: -0.01em; white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: #58d6a03a; background: #58d6a00f; }
.chip.bad { color: var(--err); border-color: #ff7a7a33; background: #ff7a7a0f; }

/* ------------------------------- layout ------------------------------ */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 18px;
  padding: 20px clamp(16px, 3vw, 40px) 60px;
  max-width: 1560px;
  margin: 0 auto;
  align-items: start;
}
.col-main, .col-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.col-side { position: sticky; top: 84px; }

@media (max-width: 1080px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .col-side { position: static; }
}

/* -------------------------------- card ------------------------------- */
.card {
  background: linear-gradient(180deg, #0f1117, #0c0e13);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 0 #ffffff05 inset, 0 18px 40px -30px #000;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2 {
  margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.01em;
  display: flex; align-items: center; gap: 9px;
}
.step {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 6px;
  background: #f0c24b1a; color: var(--accent);
  font-family: var(--mono); font-size: 11px;
}
.hint { color: var(--dim-2); font-size: 12px; }
.tiny { font-size: 11.5px; color: var(--dim-2); margin: 8px 0 0; line-height: 1.5; }
.note { color: var(--dim-2); }
.mono { font-family: var(--mono); }

/* ------------------------------- dropzone ---------------------------- */
.drop {
  border: 1.5px dashed #262c3a;
  border-radius: var(--radius-sm);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
  background: #0b0d12;
}
.drop:hover, .drop:focus-visible { border-color: #3a4357; outline: none; }
.drop.hot { border-color: var(--accent); background: #f0c24b08; }
.drop p { margin: 6px 0 0; color: var(--dim); font-size: 13.5px; }
.drop p b { color: var(--text); font-weight: 600; }
.drop .link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.drop svg { color: #3f4656; }

/* ------------------------------- url row ----------------------------- */
.url-row { display: flex; gap: 10px; margin-top: 12px; }
.url-row input { flex: 1; min-width: 0; }
.url-note { margin-top: 6px; }
.adv { margin-top: 10px; }
.adv summary { cursor: pointer; font-size: 12px; color: var(--dim-2); user-select: none; }
.adv summary:hover { color: var(--dim); }
.adv input { margin-top: 8px; }

.meta {
  margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px;
  font-family: var(--mono); font-size: 11.5px; color: var(--dim);
}
.meta span { border: 1px solid var(--line); background: var(--panel-2); padding: 3px 9px; border-radius: 7px; }

/* -------------------------------- inputs ----------------------------- */
input[type="text"], input[type="url"], input[type="number"], select, textarea {
  background: #0a0c11;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 11px;
  font-family: inherit;
  font-size: 13.5px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #46506a; box-shadow: 0 0 0 3px #f0c24b14; }
textarea { resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 49%, var(--dim) 50%), linear-gradient(-45deg, transparent 49%, var(--dim) 50%); background-position: calc(100% - 16px) 51%, calc(100% - 11px) 51%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--dim); margin-bottom: 6px; letter-spacing: 0.01em; }
.field > span em { color: var(--accent); font-style: normal; font-family: var(--mono); }
.check { display: flex; align-items: center; gap: 9px; margin: 4px 0 12px; font-size: 13px; color: var(--dim); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: #1c2130; border-radius: 99px; border: none; padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0a0c11; cursor: pointer;
  box-shadow: 0 0 0 1px #f0c24b55;
}

.glossary { margin-top: 4px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.glossary summary { cursor: pointer; font-size: 12.5px; color: var(--dim); user-select: none; }
.glossary summary:hover { color: var(--text); }
.glossary textarea { margin-top: 8px; }
code { font-family: var(--mono); font-size: 0.92em; background: #ffffff0a; padding: 1px 5px; border-radius: 5px; }

/* -------------------------------- buttons ---------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #12151c;
  color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .14s, border-color .14s, transform .1s, color .14s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #171b24; border-color: #2b3345; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid #f0c24b66; outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: #f0c24b; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #ffd166; border-color: #ffd166; }
.btn.accent { background: #f0c24b12; border-color: #f0c24b4d; color: var(--accent); font-weight: 600; }
.btn.accent:hover:not(:disabled) { background: #f0c24b1f; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.ghost:hover:not(:disabled) { color: var(--text); background: #ffffff08; }
.btn.tiny-btn { padding: 6px 11px; font-size: 12px; }

.actions .btn { width: 100%; margin-bottom: 9px; }
.actions .btn:last-of-type { margin-bottom: 0; }
.exports { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 9px; }

/* ------------------------------- progress ---------------------------- */
.progress { margin-top: 12px; }
.bar { height: 5px; background: #161a23; border-radius: 99px; overflow: hidden; }
.bar > span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #f0c24b, #ffd166);
  border-radius: 99px; transition: width .25s ease;
}
.progress-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; font-size: 11.5px; color: var(--dim); }
.progress-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------- player ----------------------------- */
.player {
  position: relative;
  background: #050608;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 260px;
}
#video {
  display: block; width: 100%; max-height: 58vh; background: #000;
}
.player-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #3f4656; font-size: 13px; background: #050608;
  pointer-events: none;
}
.player-empty[hidden] { display: none; }
.overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  padding: 0 6% 5.5%;
  pointer-events: none;
}
.sub-line {
  text-align: center;
  font-weight: 600;
  line-height: 1.32;
  color: #fff;
  max-width: 92%;
  font-size: var(--sub-size, 22px);
  text-shadow: 0 0 4px #000, 0 1px 2px #000, 0 2px 8px #000c;
  opacity: 0;
  transition: opacity .1s;
  white-space: pre-line;
  paint-order: stroke fill;
}
.sub-line.show { opacity: 1; }
.sub-line .src-line { display: block; font-weight: 500; font-size: .62em; color: #cfd3db; margin-top: .18em; }

.timeline-hint {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 9px; font-size: 11.5px; color: var(--dim-2);
}
.seg-group { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #0a0c11; }
.seg-group button {
  border: none; background: transparent; color: var(--dim);
  padding: 6px 11px; font-size: 12px; font-family: inherit; cursor: pointer;
  transition: background .14s, color .14s;
}
.seg-group button + button { border-left: 1px solid var(--line); }
.seg-group button:hover { color: var(--text); }
.seg-group button.active { background: #f0c24b14; color: var(--accent); font-weight: 600; }

/* -------------------------------- table ------------------------------ */
.table-wrap { max-height: 46vh; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: #0d1016; color: var(--dim-2);
  font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em;
  text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
tbody td { padding: 8px 12px; border-bottom: 1px solid #14171f; vertical-align: top; }
tbody tr:hover { background: #ffffff04; }
tbody tr.active { background: #f0c24b0a; }
.c-idx { width: 44px; color: var(--dim-2); font-family: var(--mono); font-size: 11.5px; }
.c-time { width: 132px; font-family: var(--mono); font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.c-time span { display: block; cursor: pointer; }
.c-time span:hover { color: var(--accent); }
td[contenteditable] { outline: none; border-radius: 6px; min-width: 120px; }
td[contenteditable]:focus { background: #ffffff06; box-shadow: 0 0 0 1px #f0c24b44 inset; }
td.tr-cell { color: #cfe3ff; }
td.empty-cell { color: #4a5263; font-style: italic; }
.empty { color: var(--dim-2); font-size: 13px; text-align: center; padding: 26px 12px 10px; }
.empty[hidden] { display: none; }

/* -------------------------------- toasts ----------------------------- */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: 9px; max-width: min(380px, 90vw);
}
.toast {
  background: #12151c; border: 1px solid var(--line); border-left: 3px solid var(--dim);
  color: var(--text); padding: 11px 14px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 12px 30px -12px #000;
  animation: toast-in .18s ease-out;
}
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
.toast.info { border-left-color: var(--blue); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* -------------------------------- dialog ----------------------------- */
dialog {
  background: #0e1015; color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; max-width: 620px; width: calc(100vw - 40px);
  box-shadow: 0 30px 80px -30px #000;
}
dialog::backdrop { background: #05060ac9; backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dlg-head h2 { margin: 0; font-size: 16px; }
dialog h3 { font-size: 13px; margin: 18px 0 6px; color: var(--accent); font-weight: 600; }
.help-list { margin: 0; padding-left: 20px; color: var(--dim); font-size: 13px; }
.help-list li { margin-bottom: 7px; }
.help-list b { color: var(--text); font-weight: 600; }
