:root {
  --bg: #0f1115;
  --card: #171a21;
  --line: #2a3140;
  --text: #e8ecf4;
  --muted: #9aa6bd;
  --accent: #6ea8ff;
  --accent2: #3dd6c6;
  --danger: #ff6b7a;
  --ok: #5ddea0;
  --warn: #ffcc66;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(110, 168, 255, 0.12), transparent 45%),
    radial-gradient(ellipse at 80% 90%, rgba(61, 214, 198, 0.1), transparent 40%),
    var(--bg);
}
.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.login-form input {
  width: 100%;
  background: #0c0e13;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
}
.login-form .btn { width: 100%; padding: 12px; }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 18px;
}
h1 { margin: 0 0 4px; font-size: 1.6rem; letter-spacing: 0.02em; }
h2 { margin: 0 0 12px; font-size: 1.15rem; }
.sub { margin: 0; color: var(--muted); font-size: 0.92rem; }

.token-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.token-box label { color: var(--muted); font-size: 0.85rem; }
.token-box input {
  width: min(260px, 60vw);
  background: #0c0e13;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}
.tab.active {
  color: #0b1020;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  font-weight: 600;
}

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.hint { color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.msg { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); margin-top: 10px; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86rem; word-break: break-all; }

.dropzone {
  border: 1.5px dashed #3a455c;
  border-radius: 14px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  background: #12151c;
  transition: border-color .15s, background .15s;
  margin: 12px 0 14px;
}
.dropzone.drag {
  border-color: var(--accent);
  background: #141b2a;
}
.drop-inner { display: grid; gap: 6px; color: var(--muted); }
.drop-inner strong { color: var(--text); font-size: 1.05rem; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.row.between { justify-content: space-between; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 600;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #7b6cff);
  color: #081018;
}
.btn.secondary {
  background: #232a38;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger {
  background: rgba(255, 107, 122, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 122, 0.35);
}

.preview-wrap {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}
.preview-wrap img {
  max-width: 100%;
  max-height: 420px;
  border-radius: 12px;
  border: 1px solid var(--line);
  object-fit: contain;
  background: #0c0e13;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.stat {
  background: #12151c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 6px;
}
.stat.wide { grid-column: 1 / -1; }
.stat .label { color: var(--muted); font-size: 0.8rem; }
.stat .value { font-size: 1rem; }

.pill {
  display: inline-flex;
  width: fit-content;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}
.pill.idle { background: #2a3140; color: #c9d3e7; }
.pill.running { background: rgba(255, 204, 102, 0.18); color: var(--warn); }
.pill.done { background: rgba(93, 222, 160, 0.16); color: var(--ok); }
.pill.error { background: rgba(255, 107, 122, 0.16); color: var(--danger); }

.history-list { display: grid; gap: 10px; }
.hist-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #12151c;
}
.hist-item h3 { margin: 0 0 4px; font-size: 0.98rem; }
.hist-item .desc { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.hist-actions { display: flex; gap: 8px; flex-wrap: wrap; }

video#player {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 12px;
  border: 1px solid var(--line);
}

footer {
  margin-top: 22px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

@media (max-width: 640px) {
  .status-grid { grid-template-columns: 1fr; }
  .hist-item { grid-template-columns: 1fr; }
}
