/* ──────────────────────────────────────────────────────────
   Anthropic / Claude warm-canvas design language.
   Cream canvas + coral accent + warm ink. Serif display for
   brand/headers (Tiempos/Garamond fallback), humanist sans body.
   ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=Inter:wght@400;500;600&display=swap');

:root {
  /* Surfaces — warm cream, light to strong */
  --bg: #faf9f5;            /* canvas */
  --surface: #ffffff;       /* cards/panels sit slightly brighter than canvas */
  --surface2: #f5f0e8;      /* soft cream */
  --surface3: #efe9de;      /* card cream */
  --border: #e6dfd8;        /* hairline */
  --border-active: #cbbfb0; /* stronger hairline */

  /* Brand — coral */
  --accent: #cc785c;
  --accent-dim: rgba(204,120,92,0.12);
  --accent-hover: #a9583e;

  /* Text — warm ink */
  --text: #141413;
  --text-muted: #6c6a64;
  --text-dim: #8e8b82;

  /* Semantic (kept close to Anthropic's warm palette) */
  --success: #5db872;
  --warning: #d4a017;
  --error: #c64545;
  --info: #5db8a6;          /* teal accent stands in for the old blue */

  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.15s ease;
  --panel-left: 300px;
  --panel-right: 260px;
  --header-h: 56px;
  --bottombar-h: 38px;

  --serif: 'Cormorant Garamond', 'Tiempos Headline', Garamond, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--sans);
  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(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}
#header-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: -0.3px;
  color: var(--text);
}
.logo {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; 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(--bg);
  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 items ────────────────────── */
.history-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; cursor: pointer; transition: var(--transition);
}
.history-item:hover { background: var(--surface2); }
/* Status dot — was a 28x20 ✓ block, now a small coloured dot (~1/3 width). */
.history-icon {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-dim);
  align-self: flex-start;
  margin-top: 4px;
}
.history-icon.dot-ok   { background: #34a853; }            /* 正常发布：绿 */
.history-icon.dot-bad  { background: var(--error); }       /* 版权/拒绝：红 */
.history-icon.dot-warn { background: var(--warning); }     /* 年龄限制等：黄 */
.history-icon.dot-mid  { background: var(--text-muted); }  /* 私享/不公开：灰 */
.history-icon.dot-none { background: var(--text-dim); }    /* 无数据 */
.history-info { flex: 1; min-width: 0; }
.history-del {
  flex-shrink: 0;
  width: 22px; height: 22px;
  background: var(--surface3);
  border: none;
  color: var(--text-muted, #888);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: var(--transition);
}
.history-item:hover .history-del { opacity: 1; }
.history-del:hover { background: var(--error, #ef4444); color: #fff; }
.history-item-wide .history-del { opacity: 1; }
.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; }

/* ── Middle Panel (form) ─────────────────────── */
#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; }

/* ── Resizer handle for the right column ─────────────────────── */
#right-resizer {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s ease;
}
#right-resizer:hover,
#right-resizer.dragging { background: var(--accent); }
body.col-resizing { cursor: col-resize; user-select: none; }

/* ── Right column (already-published + R2 library) ───────────── */
#right-column {
  width: var(--panel-right);
  flex-shrink: 0;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── History Panel ───────────── */
#history-panel {
  flex: 1 1 50%;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#history-panel #history-list {
  flex: 1;
  overflow-y: auto;
}
#history-panel #history-list::-webkit-scrollbar { width: 4px; }
#history-panel #history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
#history-panel .panel-header { border-top: none; }
#history-panel .list-empty { padding: 20px 14px; }

/* History stats row (views + avg view duration) */
.history-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}
.history-stats span { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }

/* Visibility + category badges under each published item. */
.history-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}
.history-badges span {
  font-size: 10px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 10px;
  white-space: nowrap;
}
.cat-badge {
  background: var(--surface3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.vis-badge { border: 1px solid transparent; }
.vis-ok   { background: rgba(52,168,83,0.15);  color: #5fd07a; }
.vis-mid  { background: rgba(120,120,120,0.18); color: var(--text-muted); }
.vis-warn { background: rgba(251,188,5,0.16);   color: #f5c451; }
.vis-bad  { background: rgba(234,67,53,0.16);    color: #f08a7e; }
.vis-none { background: var(--surface3);         color: var(--text-muted); }

/* ── R2 Library Panel ───────────── */
#r2-panel {
  flex: 1 1 50%;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--border);
}
#r2-list {
  flex: 1;
  overflow-y: auto;
}
#r2-list::-webkit-scrollbar { width: 4px; }
#r2-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
#r2-panel .list-empty { padding: 20px 14px; }

.r2-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  transition: var(--transition);
  border-bottom: 1px solid transparent;
}
.r2-item:hover { background: var(--surface2); }
.r2-info { flex: 1; min-width: 0; }
.r2-name {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.r2-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted);
}
.r2-size { color: var(--text-dim); }
.r2-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.r2-btn {
  width: 24px;
  height: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: var(--transition);
}
.r2-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border-active); }
.r2-btn-del:hover { color: var(--error); border-color: var(--error); background: rgba(239,68,68,0.08); }

/* Wider rows inside modals (mobile view) */
.r2-item-wide, .history-item-wide { padding: 10px 14px; }
.r2-item-wide .r2-name, .history-item-wide .history-name { font-size: 13px; }
.r2-item-wide .r2-meta, .history-item-wide .history-stats { font-size: 11px; }
.r2-item-wide .r2-btn { width: 30px; height: 30px; font-size: 13px; }
.history-item-wide { border-bottom: 1px solid var(--border); }
.history-item-wide:last-child { border-bottom: none; }
.r2-item-wide + .r2-item-wide { border-top: 1px solid var(--border); }

/* Mobile-only dropdown items — desktop hides them */
@media (min-width: 769px) {
  .dropdown-item.mobile-only { display: none !important; }
}

#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-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: -0.3px; 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); }

/* ── Confirm Dialog ──────────────────────────── */
#modal-confirm { z-index: 700; } /* above other modals */
.modal-confirm { width: 400px; }
.confirm-message {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
/* Primary button turns red when the action is destructive. */
#modal-confirm.danger #confirm-ok {
  background: var(--error);
}
#modal-confirm.danger #confirm-ok:hover {
  background: #d33;
}

/* ── Bottom Bar ──────────────────────────────── */
#bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
}
#bottom-progress-row {
  height: 38px;
  display: flex; align-items: center; padding: 0 16px; gap: 16px;
}

#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: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#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; }

/* ── Mobile back button (desktop: hidden) ────── */
.btn-mobile-back {
  display: none;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px 4px 0;
  flex-shrink: 0;
  transition: var(--transition);
  font-family: inherit;
}
.btn-mobile-back:hover { color: var(--text); }

/* ── Form footer: save + publish (both desktop & mobile) ── */
#mobile-form-footer {
  display: flex;
  gap: 10px;
  margin-top: 40px;
  padding: 20px 0 8px;
  border-top: 1px solid var(--border);
}

/* ── Settings button & dropdown ─────────────── */
.settings-wrap { position: relative; }
.btn-settings {
  padding: 5px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}
.btn-settings:hover { border-color: var(--border-active); color: var(--text); }

.settings-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 140px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(20,20,19,0.12);
  overflow: hidden;
}
.dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}
.dropdown-item:hover { background: var(--surface3); }

/* ── Modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,20,19,0.45);
  backdrop-filter: blur(2px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 460px;
  max-width: 95vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(20,20,19,0.2);
}
.modal-wide { width: 720px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -0.2px; }
.modal-close {
  width: 28px; height: 28px;
  background: none; border: none;
  color: var(--text-muted); font-size: 16px;
  cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--surface3); color: var(--text); }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Switch Channel cards ────────────────────── */
.channel-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}
.channel-card:hover { border-color: var(--border-active); background: var(--surface2); }
.channel-card.active { border-color: var(--accent); background: var(--accent-dim); }
.channel-avatar {
  width: 36px; height: 36px;
  background: var(--surface3);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.channel-name { font-size: 13px; font-weight: 500; flex: 1; }
.channel-active-mark { color: var(--accent); font-size: 16px; }
.channel-list-empty { color: var(--text-muted); font-size: 13px; padding: 12px 0; }

/* ── Settings modal two-pane layout ──────────── */
.settings-body {
  display: flex;
  gap: 0;
  padding: 0 !important;
  min-height: 420px;
}
.settings-sidebar {
  width: 180px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 4px;
}
.settings-ch-item {
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-ch-item:hover { background: var(--surface2); color: var(--text); }
.settings-ch-item.active { background: var(--accent-dim); color: var(--text); }
.settings-form {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
}
.settings-placeholder {
  color: var(--text-dim);
  font-size: 13px;
  padding-top: 40px;
  text-align: center;
}
.w-full { width: 100%; }

/* ── Settings form sections ──────────────────── */
.settings-section {
  margin-bottom: 20px;
}
.settings-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.settings-field label {
  font-size: 11px;
  color: var(--text-muted);
}
.settings-field input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  transition: var(--transition);
  width: 100%;
}
.settings-field input:focus {
  outline: none;
  border-color: var(--border-active);
}
.settings-form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.btn-danger-sm {
  padding: 7px 14px;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--error);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}
.btn-danger-sm:hover { background: rgba(239,68,68,0.22); }
.btn-save {
  padding: 7px 20px;
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}
.btn-save:hover { background: var(--accent-hover); }

/* ── Mobile layout ───────────────────────────── */
@media (max-width: 820px) {

  /* Left panel fills the entire screen */
  #left-panel { width: 100% !important; flex-shrink: 0; }

  /* Right panel completely hidden (removed from flex layout) */
  #right-panel { display: none !important; }

  /* Right panel opens as full-screen overlay from bottom */
  body.meta-open #right-panel {
    display: flex !important;
    flex-direction: column;
    position: fixed !important;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    overflow-y: auto;
    background: var(--bg);
    animation: slideUp 0.28s ease;
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  /* Empty state not needed on mobile */
  #empty-state { display: none !important; }

  /* Show mobile back button */
  .btn-mobile-back { display: flex !important; }

  /* Hide desktop-only controls */
  .btn-desktop-only { display: none !important; }

  /* Hide entire right column on mobile (accessed via settings menu instead) */
  #right-column { display: none !important; }
  #right-resizer { display: none !important; }

  /* Form footer — sticky at bottom of overlay on mobile */
  #mobile-form-footer {
    margin-top: 0;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    border-top: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    bottom: 0;
    flex-shrink: 0;
  }
  #mobile-form-footer button { flex: 1; padding: 12px; font-size: 14px; }

  /* Form padding on mobile */
  #video-form { padding: 16px 16px 0; }

  /* Bottom bar */
  #bottom-bar { padding: 0; }
  #bottom-progress-row { padding: 0 12px; }

  /* Toast position */
  #toast { bottom: 110px; }

  /* Larger touch targets */
  .queue-item { padding: 12px 8px; }
  .qi-check-box { width: 20px; height: 20px; }
  .qi-del { opacity: 1; width: 26px; height: 26px; font-size: 13px; }

  /* Thumbnail */
  .thumbnail-preview { width: 120px; height: 68px; }
  .thumbnail-section { gap: 12px; padding: 12px; }
}
