/* ──────────────────────────────────────────────────
   Token 系统
   ────────────────────────────────────────────────── */
:root {
  --bg:        #0e0e12;
  --surface:   #16161d;
  --surface2:  #1e1e28;
  --border:    #2a2a38;
  --border-hover: #3d3d52;
  --text:      #e4e4ed;
  --text-dim:  #8888a0;
  --accent:    #6c5ce7;
  --accent2:   #a29bfe;
  --success:   #00cec9;
  --warning:   #fdcb6e;
  --danger:    #ff7675;
  --radius:    8px;
  --radius-lg: 12px;
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  --transition: 180ms ease;
}

/* ── Reset & Base ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Topbar ─────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.topbar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 6px;
  font-size: 13px;
  color: #fff;
}
.topbar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ── 顶栏用户区（共享用户系统） ─────────────────── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-user__name {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-user__logout {
  font-size: 12px;
  font-family: inherit;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
  transition: var(--transition);
}
.topbar-user__logout:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.connected { background: var(--success); }

/* ── Layout ─────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 52px - 40px);
}

/* ── Panel ──────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Fields ─────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.hint { font-weight: 400; color: var(--text-dim); opacity: 0.6; }
input[type="text"], input[type="url"], select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  transition: border-color var(--transition);
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }

/* ── Upload Area ────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  overflow: hidden;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.05);
}
.upload-area--small { padding: 14px; }
.upload-hint { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-dim); }
.preview-img {
  max-width: 100%;
  max-height: 180px;
  border-radius: var(--radius);
  display: block;
  margin: 0 auto;
}
.remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,.7);
  border: none;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Micro status ───────────────────────────────── */
.micro-status { font-size: 11px; color: var(--text-dim); min-height: 16px; }
.micro-status.busy  { color: var(--warning); }
.micro-status.ok    { color: var(--success); }
.micro-status.err   { color: var(--danger); }

/* ── Divider ────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ── Details (Advanced) ─────────────────────────── */
.details { border-top: 1px solid var(--border); padding-top: 12px; }
.details-summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.details-summary::before { content: "▸"; transition: transform var(--transition); display: inline-block; }
.details[open] .details-summary::before { transform: rotate(90deg); }
.details-body { padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.hint-text { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover:not(:disabled) { background: #5a4bd6; border-color: #5a4bd6; }
.btn--block { width: 100%; padding: 12px; font-size: 14px; }
.btn-icon { font-size: 12px; }
.btn-copy, .btn-download {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
}
.btn-copy:hover, .btn-download:hover { border-color: var(--accent); color: var(--text); }

/* ── Status Card ────────────────────────────────── */
.status-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.status-card__icon { font-size: 28px; }
.status-card__label { font-size: 15px; font-weight: 600; }
.status-card__sub   { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ── Task ID Bar ────────────────────────────────── */
.task-id-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
}
.task-id-label { color: var(--text-dim); }
.task-id-bar code {
  font-family: var(--font-mono);
  color: var(--accent2);
  word-break: break-all;
  flex: 1;
}

/* ── Progress ───────────────────────────────────── */
.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
}
.progress-label { font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* ── Result Area ────────────────────────────────── */
.result-area { display: flex; flex-direction: column; gap: 12px; }
#resultVideo, #resultImage {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
}
#resultVideoWrap, #resultImageWrap { position: relative; }
.btn-download { margin-top: 8px; }
.error-box {
  background: rgba(255,118,117,0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
  color: var(--danger);
}

/* ── History ────────────────────────────────────── */
.history-section { margin-top: 8px; }
.history-title { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.history-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--transition);
}
.history-item:hover { border-color: var(--accent); }
.history-item__dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.history-item__dot.queued   { background: var(--warning); }
.history-item__dot.running  { background: var(--accent2); animation: pulse 1s infinite; }
.history-item__dot.success  { background: var(--success); }
.history-item__dot.failed   { background: var(--danger); }
.history-item__dot.timeout  { background: var(--text-dim); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.history-item__id { font-family: var(--font-mono); color: var(--text-dim); flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.history-item__time { color: var(--text-dim); opacity:0.6; }
.empty-hint { font-size: 12px; color: var(--text-dim); opacity:0.5; text-align:center; padding: 12px; }

/* ── Footer ─────────────────────────────────────── */
.footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.5;
  padding: 16px;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}
