﻿:root {
  --bg: #0b0d12;
  --panel: #141822;
  --panel-2: #1b2030;
  --border: #262d40;
  --text: #e6e9f0;
  --muted: #8a93a6;
  --primary: #6ea8ff;
  --primary-hover: #8fbcff;
  --danger: #ff6b6b;
  --warn: #ffb86b;
  --ok: #5dd39e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(110,168,255,0.06), transparent);
}
.brand { font-weight: 600; font-size: 18px; }
.status { color: var(--muted); font-size: 13px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--danger); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 24px 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
  background: rgba(110, 168, 255, 0.06);
}

main { padding: 24px; max-width: 1280px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

.grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 20px;
}
@media (max-width: 880px) {
  .grid { grid-template-columns: 1fr; }
}

.form, .result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.row { margin-bottom: 16px; }
.row > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input[type=text], textarea, select {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
input[type=text]:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.seg {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.seg-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--primary); color: #0b0d12; }

.actions { display: flex; align-items: center; gap: 12px; }
button.primary {
  background: var(--primary);
  color: #0b0d12;
  border: 0;
  padding: 10px 22px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
button.primary:hover { background: var(--primary-hover); }
button.primary:disabled { opacity: 0.5; cursor: wait; }
.hint { color: var(--muted); font-size: 12px; }
.hint + .hint { margin-left: 4px; }

.i2i-inputs { display: flex; flex-direction: column; gap: 8px; }
.preview { margin-top: 8px; min-height: 0; }
.preview img { max-width: 100%; max-height: 160px; border-radius: 8px; border: 1px solid var(--border); }

.result-empty {
  color: var(--muted);
  text-align: center;
  padding: 60px 0;
  font-size: 14px;
}
.result-content { display: flex; flex-direction: column; gap: 12px; }
.result-content img, .result-content video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #000;
}
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.result-actions a, .result-actions button {
  color: var(--primary);
  text-decoration: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.result-actions button { color: var(--text); }

.raw {
  background: #0a0d14;
  color: #cbd5e1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  overflow: auto;
  max-height: 240px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

.warn {
  background: rgba(255, 184, 107, 0.08);
  border: 1px solid rgba(255, 184, 107, 0.3);
  color: #ffd9a3;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.7;
}
.warn b { color: #ffe1b8; }
.warn code { background: rgba(0,0,0,0.4); padding: 2px 6px; border-radius: 4px; color: #fff; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  z-index: 100;
  max-width: 80vw;
  white-space: pre-wrap;
}
.toast.error { border-color: var(--danger); color: #ffb8b8; }
.toast.ok { border-color: var(--ok); color: #b8f0d4; }
/* ===== Video panel additions ===== */
.inline-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.inline-row input {
  width: auto;
  flex: 1 1 120px;
  min-width: 0;
}
.inline-row input[type=number] {
  flex: 0 0 auto;
  width: 140px;
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
button.ghost:hover {
  background: rgba(110, 168, 255, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}
button.ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.sep {
  color: var(--muted);
  font-size: 14px;
  user-select: none;
}

/* ===== Status pill ===== */
.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.status-pill.queued {
  background: rgba(138, 147, 166, 0.15);
  color: #b8bfcf;
  border-color: rgba(138, 147, 166, 0.4);
}
.status-pill.in_progress {
  background: rgba(110, 168, 255, 0.15);
  color: #b8d4ff;
  border-color: rgba(110, 168, 255, 0.45);
  animation: pill-pulse 1.6s ease-in-out infinite;
}
.status-pill.completed {
  background: rgba(93, 211, 158, 0.15);
  color: #b8f0d4;
  border-color: rgba(93, 211, 158, 0.45);
}
.status-pill.failed {
  background: rgba(255, 107, 107, 0.15);
  color: #ffb8b8;
  border-color: rgba(255, 107, 107, 0.45);
}
@keyframes pill-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* ===== Progress bar ===== */
.progress {
  height: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0 10px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.35s ease;
}
.progress-bar.indeterminate {
  width: 100% !important;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--primary) 40%,
    var(--primary-hover) 60%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: progress-slide 1.4s linear infinite;
  transition: none;
}
@keyframes progress-slide {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Task head + meta ===== */
.task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.task-time {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.task-meta {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  word-break: break-all;
  margin-bottom: 6px;
  min-height: 1.2em;
}
.task-error {
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: #ffb8b8;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

/* ===== Advanced <details> ===== */
.advanced { margin-bottom: 16px; }
.advanced > summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  padding: 6px 0;
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::before {
  content: '▸';
  display: inline-block;
  font-size: 10px;
  transition: transform 0.15s;
}
.advanced[open] > summary::before { transform: rotate(90deg); }
.advanced-body { padding: 10px 0 0; }
.advanced-body label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.advanced-body label + input,
.advanced-body label + textarea,
.advanced-body label + .inline-row { margin-bottom: 10px; }
.advanced code {
  background: rgba(0,0,0,0.4);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* raw <details> (in result panel) */
.result-content details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0;
  user-select: none;
}
.result-content details > summary:hover { color: var(--text); }

/* Toast: warn variant */
.toast.warn { border-color: var(--warn); color: #ffe1b8; }
/* Multi-image preview row (for video multi / keyframes) */
.preview-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  min-height: 0;
}
.preview-row:empty { display: none; }
.preview-row img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #000;
}
.preview-row .preview-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  width: 100%;
}
/* ===== Auth (login/register) ===== */
.auth-wrap { display:flex; align-items:center; justify-content:center; min-height: calc(100vh - 60px); padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 28px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.auth-tabs { display:flex; gap:4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-tab { flex:1; background:none; border:none; color: var(--muted); padding: 10px; font-size: 15px; cursor:pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.auth-tab.active { color: var(--fg); border-bottom-color: var(--primary); }
.auth-form { display:flex; flex-direction:column; gap: 6px; }
.auth-form label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.auth-form input { padding: 10px 12px; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.auth-form input:focus { outline: none; border-color: var(--primary); }
.auth-form .hint { font-size: 12px; color: var(--muted); margin-top: -2px; margin-bottom: 4px; }
.auth-form button[type=submit] { margin-top: 16px; padding: 10px; }

/* ===== User bar (top right) ===== */
.user-bar { display:flex; align-items:center; gap: 12px; }
.ub-user { font-size: 14px; color: var(--fg); }
.ub-credits { background: var(--primary); color: #fff; padding: 4px 10px; border-radius: 12px; font-size: 13px; font-weight: 500; }
.ub-logout { background: transparent; color: var(--muted); border: 1px solid var(--border); padding: 4px 10px; border-radius: 6px; font-size: 13px; cursor:pointer; }
.ub-logout:hover { color: var(--fg); border-color: var(--fg); }

/* ===== Cost row ===== */
.cost-row { display:flex; justify-content:space-between; align-items:center; padding: 8px 12px; background: var(--bg); border-radius: 6px; border: 1px solid var(--border); }
.cost-row .balance { color: var(--muted); font-size: 13px; }
.cost-row b { color: var(--primary); font-size: 16px; }

/* ===== Profile ===== */
.profile-wrap { max-width: 760px; }
.profile-head { display:flex; justify-content:space-between; align-items:center; padding: 20px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 20px; }
.profile-username { font-size: 22px; font-weight: 500; }
.profile-role { color: var(--muted); font-size: 13px; margin-top: 4px; }
.profile-credits-card { text-align:right; }
.credits-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.credits-value { font-size: 32px; font-weight: 600; color: var(--primary); }

/* ===== Tables (tx + users) ===== */
.tx-table, .user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tx-table th, .tx-table td, .user-table th, .user-table td { padding: 8px 10px; text-align:left; border-bottom: 1px solid var(--border); }
.tx-table th, .user-table th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
.tx-amount.pos { color: #4ade80; }
.tx-amount.neg { color: #f87171; }

/* ===== Admin ===== */
.admin-wrap { display:flex; flex-direction:column; gap: 24px; }
.admin-section { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.admin-section h3 { margin: 0 0 16px 0; font-size: 16px; font-weight: 500; color: var(--fg); }
.admin-toolbar { display:flex; gap: 8px; margin-bottom: 12px; }
.admin-toolbar input { flex:1; max-width: 240px; padding: 6px 10px; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.admin-toolbar button { padding: 6px 12px; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; cursor:pointer; font-size: 13px; }
.admin-toolbar button:hover { border-color: var(--primary); }
.actions-cell { white-space: nowrap; }
.actions-cell button + button { margin-left: 4px; }
.badge { display:inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge.ok { background: rgba(74,222,128,0.15); color: #4ade80; }
.badge.bad { background: rgba(248,113,113,0.15); color: #f87171; }
.mini { padding: 3px 8px; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 4px; cursor:pointer; font-size: 12px; }
.mini:hover { border-color: var(--primary); }
.pager { display:flex; align-items:center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--muted); }

[hidden] { display: none !important; }

/* ===== Change password modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; text-align: center; }
.cpw-actions { display: flex; gap: 10px; margin-top: 20px; }
.cpw-actions .secondary { flex: 1; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 10px; border-radius: var(--radius); font-size: 14px; cursor: pointer; transition: border-color 0.15s; }
.cpw-actions .secondary:hover { border-color: var(--primary); }
.cpw-actions .primary { flex: 1; background: var(--primary); color: #0b0d12; border: none; padding: 10px; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.cpw-actions .primary:hover { background: var(--primary-hover); }
.cpw-actions .primary:disabled { opacity: 0.6; cursor: not-allowed; }
.cpw-err.error { color: var(--danger); }
.ub-change-pw { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; transition: all 0.15s; }
.ub-change-pw:hover { border-color: var(--primary); color: var(--primary); }
