:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1c1c1c;
  --surface3: #242424;
  --border: #2a2a2a;
  --border-active: #404040;
  --accent: #ff0033;
  --accent-dim: rgba(255,0,51,0.12);
  --accent-hover: #e60030;
  --text: #f0f0f0;
  --text-muted: #888;
  --text-dim: #555;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.15s ease;
  --panel-left: 340px;
  --header-h: 52px;
  --bottombar-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* ── Header ──────────────────────────────────── */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}
#header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}
.logo {
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
#header-right { display: flex; align-items: center; gap: 10px; }
#account-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: 20px;
  font-size: 11px; color: var(--success);
}
#account-badge::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%; background: var(--success);
}

/* ── Layout ─────────────────────────────────── */
#main {
  display: flex;
  height: calc(100vh - var(--header-h) - var(--bottombar-h));
  margin-top: var(--header-h);
  overflow: hidden;
}

/* ── Left Panel ─────────────────────────────── */
#left-panel {
  width: var(--panel-left);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top action buttons ──────────────────────── */
.top-actions {
  display: flex;
  gap: 8px;
  padding: 12px;
  flex-shrink: 0;
}

/* 添加视频 — red, left */
.btn-add {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
}
.btn-add:hover { background: var(--accent-hover); }

/* 上传到R2 — blue, right */
.btn-r2 {
  flex: 1;
  background: var(--info);
  color: #fff;
  border: none;
  padding: 10px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
}
.btn-r2:hover { background: #2563eb; }
.btn-r2:disabled { opacity: 0.6; cursor: not-allowed; }
.r2-count {
  background: rgba(255,255,255,0.25);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 700;
}

/* ── Panel headers ───────────────────────────── */
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.count-badge {
  background: var(--surface3); color: var(--text-muted);
  font-size: 10px; padding: 1px 6px; border-radius: 10px;
}
.icon-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); padding: 3px 8px;
  border-radius: 5px; cursor: pointer; font-size: 11px; transition: var(--transition);
}
.icon-btn:hover { border-color: var(--border-active); color: var(--text); }

/* ── 待发布 scrollable list (takes all remaining space) ── */
#queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  min-height: 0;
}
#queue-list::-webkit-scrollbar { width: 4px; }
#queue-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.list-empty {
  padding: 20px; text-align: center; color: var(--text-dim); font-size: 12px;
}

/* ── Queue items ──────────────────────────────── */
.queue-item {
  padding: 9px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.queue-item:hover { background: var(--surface2); }
.queue-item.checked  { background: rgba(255,0,51,0.06); border-color: rgba(255,0,51,0.2); }
.queue-item.focused  { background: var(--accent-dim); border-color: rgba(255,0,51,0.35); }

.queue-item-top {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Checkbox — always visible */
.qi-checkbox {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
  padding: 2px;
}
.qi-checkbox input[type="checkbox"] { display: none; }
.qi-check-box {
  width: 16px; height: 16px;
  border: 2px solid var(--border-active);
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
  background: var(--surface2);
}
.qi-checkbox input:checked + .qi-check-box {
  background: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3.5 4L11 1' stroke='%23fff' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 9px;
}

.queue-item-icon {
  width: 34px; height: 26px;
  background: var(--surface3);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
}
.queue-item-icon img { width: 100%; height: 100%; object-fit: cover; }

.queue-item-info {
  flex: 1;
  min-width: 0;
}
.queue-item-name {
  font-size: 12px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.queue-item-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* Right side: status badge + delete button */
.queue-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.qi-del {
  opacity: 0;
  width: 20px; height: 20px;
  background: var(--surface3);
  border: none;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  transition: var(--transition);
}
.queue-item:hover .qi-del { opacity: 1; }
.qi-del:hover { background: var(--error); color: #fff; }

/* Staged items (waiting to upload) */
.staged-item { cursor: default; opacity: 0.9; }
.staged-item:hover { background: var(--surface2); }
.queue-item-actions { opacity: 0; transition: var(--transition); }
.queue-item:hover .queue-item-actions { opacity: 1; }
.qi-btn {
  width: 22px; height: 22px; background: var(--surface3);
  border: none; color: var(--text-muted); border-radius: 4px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 11px; transition: var(--transition);
}
.qi-btn:hover { background: var(--error); color: #fff; }

/* Status badges */
.status-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; padding: 2px 7px; border-radius: 10px; white-space: nowrap;
}
.status-staging   { background: rgba(136,136,136,0.15); color: var(--text-dim); }
.status-pending   { background: rgba(59,130,246,0.12);  color: var(--info); }
.status-ready     { background: rgba(245,158,11,0.15);  color: var(--warning); }
.status-publishing{ background: rgba(255,0,51,0.12);    color: var(--accent); }
.status-uploading { background: rgba(59,130,246,0.15);  color: var(--info); }
.status-uploaded  { background: rgba(34,197,94,0.15);   color: var(--success); }
.status-failed    { background: rgba(239,68,68,0.15);   color: var(--error); }

.qi-progress { height: 2px; background: var(--border); border-radius: 1px; margin-top: 5px; overflow: hidden; }
.qi-progress-fill { height: 100%; background: var(--info); border-radius: 1px; transition: width 0.3s; }

/* ── 待上传 staged section ────────────────────── */
#staged-section { border-top: 1px solid var(--border); flex-shrink: 0; }
#staged-list { padding: 0 8px 4px; max-height: 200px; overflow-y: auto; }

/* ── 已发布 history at bottom ────────────────── */
#history-section {
  border-top: 1px solid var(--border);
  max-height: 180px;
  overflow-y: auto;
  flex-shrink: 0;
}
.history-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; cursor: pointer; transition: var(--transition);
}
.history-item:hover { background: var(--surface2); }
.history-icon {
  width: 28px; height: 20px; background: var(--surface3);
  border-radius: 3px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; flex-shrink: 0; color: var(--success);
}
.history-info { flex: 1; min-width: 0; }
.history-name { font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-url { font-size: 10px; color: var(--info); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── 发布视频 bar at very bottom of left panel ── */
#left-publish-bar {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.btn-publish-left {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
.btn-publish-left:hover { background: var(--accent-hover); }
.btn-publish-left:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Right Panel ─────────────────────────────── */
#right-panel {
  flex: 1; overflow-y: auto;
  background: var(--bg); display: flex; flex-direction: column;
}
#right-panel::-webkit-scrollbar { width: 6px; }
#right-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

#empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-dim); gap: 12px;
}
.empty-icon { font-size: 48px; opacity: 0.3; }
#video-form { padding: 20px 24px; max-width: 760px; }

.form-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.form-header h2 { font-size: 15px; font-weight: 600; color: var(--text); }

/* Thumbnail */
.thumbnail-section {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 20px; padding: 16px;
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.thumbnail-preview {
  width: 160px; height: 90px; background: var(--surface3);
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--text-dim); overflow: hidden;
  flex-shrink: 0; border: 1px solid var(--border);
}
.thumbnail-preview img { width: 100%; height: 100%; object-fit: cover; }
.thumbnail-actions { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.thumbnail-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
label.field-label {
  display: block; font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px;
}
.field-wrap { position: relative; }

input[type="text"], input[type="datetime-local"], textarea, select {
  width: 100%; background: var(--surface);
  border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: var(--radius);
  font-size: 13px; font-family: inherit; transition: var(--transition); outline: none;
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
textarea { resize: vertical; min-height: 80px; }
select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
select option { background: var(--surface2); }

.char-count {
  position: absolute; right: 10px; bottom: 8px;
  font-size: 10px; color: var(--text-dim); pointer-events: none;
}
.char-count.warn { color: var(--warning); }

/* Tags */
.tags-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 4px;
  min-height: 40px; transition: var(--transition); cursor: text;
}
.tags-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface3); border: 1px solid var(--border-active);
  padding: 2px 8px 2px 10px; border-radius: 20px; font-size: 11px; color: var(--text);
}
.tag-chip button {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 0; font-size: 13px; transition: var(--transition);
}
.tag-chip button:hover { color: var(--error); }
#tag-input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: 13px; padding: 3px 4px; min-width: 120px; flex: 1;
}

/* Radio */
.radio-group { display: flex; gap: 6px; flex-wrap: wrap; }
.radio-card { position: relative; cursor: pointer; }
.radio-card input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.radio-card-label {
  display: block; padding: 6px 14px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px; color: var(--text-muted);
  cursor: pointer; transition: var(--transition);
}
.radio-card input:checked + .radio-card-label {
  border-color: var(--accent); background: var(--accent-dim); color: var(--accent);
}
.radio-card:hover .radio-card-label { border-color: var(--border-active); color: var(--text); }

/* Toggle */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 13px; color: var(--text); }
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0; background: var(--surface3);
  border-radius: 10px; cursor: pointer; transition: var(--transition);
  border: 1px solid var(--border);
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; background: #fff; border-radius: 50%;
  transition: var(--transition); pointer-events: none;
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(16px); }

/* Advanced */
details.advanced { margin-top: 4px; }
details.advanced > summary {
  cursor: pointer; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  list-style: none; display: flex; align-items: center; gap: 6px;
  transition: var(--transition); user-select: none;
}
details.advanced > summary::before { content: '›'; font-size: 16px; transition: transform 0.2s; }
details.advanced[open] > summary::before { transform: rotate(90deg); }
details.advanced > summary:hover { color: var(--text); border-color: var(--border-active); }
.advanced-body {
  background: var(--surface); border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 var(--radius) var(--radius);
  padding: 0 14px; margin-top: -1px;
}

/* Buttons */
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  padding: 8px 20px; border-radius: 7px; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 8px 16px; border-radius: 7px; cursor: pointer; font-size: 13px; transition: var(--transition);
}
.btn-ghost:hover { border-color: var(--border-active); color: var(--text); }
.btn-danger {
  background: none; border: 1px solid var(--border); color: var(--error);
  padding: 8px 16px; border-radius: 7px; cursor: pointer; font-size: 13px; transition: var(--transition);
}
.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: var(--error); }
.btn-outline {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: var(--transition);
  display: inline-block; text-align: center;
}
.btn-outline:hover { border-color: var(--border-active); color: var(--text); }

/* ── Bottom Bar ──────────────────────────────── */
#bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottombar-h); background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 16px; z-index: 100;
}
#progress-area { flex: 1; min-width: 0; }
#progress-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
#progress-filename { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
#progress-stats { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
#progress-bar-wrap { height: 4px; background: var(--surface3); border-radius: 2px; overflow: hidden; }
#progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #ff6688); border-radius: 2px; transition: width 0.3s; width: 0%; }
#progress-idle { font-size: 12px; color: var(--text-muted); }
#queue-controls { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Utilities ───────────────────────────────── */
.hidden { display: none !important; }
.hint { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.section-divider { height: 1px; background: var(--border); margin: 18px 0; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
.pulse { animation: pulse 1.5s ease-in-out infinite; }

@keyframes indeterminate-slide {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}
#progress-bar-fill.indeterminate {
  width: 100% !important;
  background: linear-gradient(90deg, var(--accent) 0%, #ff6666 40%, var(--accent) 60%, #ff6666 100%);
  background-size: 200% auto;
  animation: indeterminate-slide 1.5s linear infinite;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Toast ────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 90px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  white-space: nowrap;
  max-width: 90vw;
  text-overflow: ellipsis;
  overflow: hidden;
}
#toast.toast-error { background: var(--error); color: #fff; }
#toast.toast-ok { background: var(--success); color: #fff; }
