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

:root {
  --bg: #0d0d0d;
  --surface: #181818;
  --surface2: #222;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --muted: #777;
  --accent: #7c3aed;
  --accent-h: #6d28d9;
  --success: #10b981;
  --error: #ef4444;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Login ────────────────────────────────────────── */
.login-body {
  justify-content: center;
  align-items: center;
  overflow: auto;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 44px 40px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-logo {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 10px;
}

.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 28px; }

/* ── Inputs / Buttons ────────────────────────────── */
input[type="text"],
input[type="password"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
input:focus { border-color: var(--accent); }

button { cursor: pointer; border: none; font-family: inherit; font-size: 14px; border-radius: 8px; transition: background .15s; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 12px;
  font-weight: 600;
  width: 100%;
  margin-top: 4px;
}
.btn-primary:hover { background: var(--accent-h); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 7px 12px;
  font-size: 13px;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-send {
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  font-weight: 500;
  flex-shrink: 0;
}
.btn-send:hover { background: var(--accent-h); }
.btn-send:disabled { opacity: .4; cursor: default; }

.btn-icon {
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  padding: 4px 8px;
  line-height: 1;
}
.btn-icon:hover { color: var(--text); }

.error { color: var(--error); font-size: 13px; margin-top: 10px; }
.hidden { display: none !important; }

/* ── Header ──────────────────────────────────────── */
header {
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { color: var(--accent); font-size: 16px; }
header h1 { font-size: 16px; font-weight: 700; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.yt-status { font-size: 12px; color: var(--muted); }
.yt-status.connected { color: var(--success); }

/* ── Main layout ─────────────────────────────────── */
main {
  display: grid;
  grid-template-columns: 300px 1fr;
  flex: 1;
  overflow: hidden;
}

/* ── Left panel ──────────────────────────────────── */
.left-panel {
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--accent);
  background: rgba(124,58,237,.05);
}
.upload-icon { font-size: 30px; display: block; margin-bottom: 10px; }
.upload-area p { font-size: 14px; color: var(--muted); line-height: 1.6; }
.upload-area strong { color: var(--text); }
.upload-hint { font-size: 11px !important; margin-top: 8px; }
.upload-area input[type="file"] { display: none; }

.progress-bar-wrap {
  background: var(--surface2);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}
.progress-bar {
  background: var(--accent);
  height: 100%;
  width: 0;
  transition: width .2s;
}
.progress-text { font-size: 13px; color: var(--muted); margin-top: 8px; }

.video-info {
  background: var(--surface2);
  border-radius: 10px;
  padding: 14px 16px;
}
.video-check { color: var(--success); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.video-name { font-size: 13px; word-break: break-all; margin-bottom: 3px; }
.video-size { font-size: 12px; color: var(--muted); }

.left-hint { font-size: 13px; color: var(--muted); text-align: center; padding: 8px 0; }

/* ── Right panel / Chat ──────────────────────────── */
.right-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chatContainer {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 10px;
}
.chat-empty-icon { font-size: 40px; }
.chat-empty p { font-size: 14px; }

/* ── Messages ────────────────────────────────────── */
.msg {
  display: flex;
  gap: 10px;
  max-width: 80%;
  animation: msgIn .15s ease;
}
@keyframes msgIn { from { opacity:0; transform:translateY(6px) } to { opacity:1; transform:none } }

.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }

.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}
.msg.assistant .msg-avatar { background: var(--accent); color: #fff; }
.msg.user .msg-avatar { background: var(--surface2); border: 1px solid var(--border); }

.msg-bubble {
  background: var(--surface2);
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .msg-bubble { background: var(--accent); color: #fff; }

/* ── Typing indicator ────────────────────────────── */
.typing { display: flex; gap: 5px; padding: 10px 4px; }
.typing span {
  width: 7px; height: 7px;
  background: var(--muted);
  border-radius: 50%;
  animation: dot 1.3s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%,80%,100%{transform:translateY(0);opacity:.35} 40%{transform:translateY(-5px);opacity:1} }

/* ── Caption review card ─────────────────────────── */
.review-card {
  align-self: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.review-card h3 { font-size: 15px; font-weight: 600; }

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}

.review-card textarea,
.review-card input[type="text"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  outline: none;
  margin-bottom: 0;
  resize: vertical;
}
.review-card textarea:focus,
.review-card input[type="text"]:focus { border-color: var(--accent); }
.review-card textarea { min-height: 110px; }

.platform-row { display: flex; gap: 10px; }

.platform-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.platform-chip input { display: none; }
.platform-chip.on { border-color: var(--accent); background: rgba(124,58,237,.1); }
.platform-chip.disabled { opacity: .45; cursor: default; }
.platform-chip-icon { font-size: 16px; }

.btn-publish {
  background: var(--accent);
  color: #fff;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  width: 100%;
}
.btn-publish:hover { background: var(--accent-h); }
.btn-publish:disabled { opacity: .5; cursor: default; }

/* ── Publish result ──────────────────────────────── */
.result-card {
  align-self: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.result-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.result-row:last-of-type { border-bottom: none; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  text-transform: uppercase;
}
.badge.published { background: rgba(16,185,129,.15); color: var(--success); }
.badge.failed { background: rgba(239,68,68,.15); color: var(--error); }
.badge.skipped { background: rgba(120,120,120,.12); color: var(--muted); }
.badge.pending { background: rgba(124,58,237,.12); color: var(--accent); }

.result-link { color: var(--accent); font-size: 12px; text-decoration: none; margin-left: auto; }
.result-link:hover { text-decoration: underline; }

.result-error { font-size: 12px; color: var(--error); margin-top: 8px; }

.btn-new {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px;
  font-size: 14px;
  margin-top: 16px;
}
.btn-new:hover { background: var(--border); }

/* ── Chat input ──────────────────────────────────── */
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.chat-input-area input {
  flex: 1;
  margin-bottom: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.chat-input-area input:focus { border-color: var(--accent); }

/* ── Spinner ─────────────────────────────────────── */
.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 7px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── History modal ───────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 90%; max-width: 860px;
  max-height: 80vh;
  display: flex; flex-direction: column;
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { font-size: 17px; }
.modal-body { overflow-y: auto; padding: 20px 22px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
td { padding: 11px 12px; border-bottom: 1px solid #1c1c1c; vertical-align: top; }
.caption-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  padding: 12px 20px;
  border-radius: 9px;
  font-size: 14px; font-weight: 500;
  color: #fff;
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity:0; transform:translateY(8px) } to { opacity:1; transform:none } }
