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

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --border: #2a2a3a;
  --accent: #53fc18;
  --accent-dim: #3ab810;
  --text: #e8e8f0;
  --text-muted: #888;
  --red: #ff4444;
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

header .logo { font-size: 1.5rem; }

main { max-width: 900px; margin: 2rem auto; padding: 0 1.5rem; }

/* Add channel form */
.add-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.add-form input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.6rem 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.add-form input:focus { border-color: var(--accent); }

.btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #000;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover { background: var(--accent-dim); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.btn-danger:hover { background: var(--red); color: #fff; }

.btn-watch {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.btn-watch:hover { background: var(--accent); color: #000; }

.btn-viewer {
  background: transparent;
  border: 1px solid #555;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.btn-viewer:hover { background: #2a2a3a; color: var(--text); border-color: var(--text-muted); }

.btn-stats {
  background: transparent;
  border: 1px solid #4fc3f7;
  color: #4fc3f7;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.btn-stats:hover { background: #4fc3f7; color: #000; }

.btn-transcribe {
  background: transparent;
  border: 1px solid #f9a825;
  color: #f9a825;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}
.btn-transcribe:hover:not(:disabled) { background: #f9a825; color: #000; }
.btn-transcribe:disabled { opacity: 0.5; cursor: default; }
.btn-transcribe-done { border-color: var(--accent); color: var(--accent); }

.btn-delete-transcript {
  font-size: 0.95rem;
  padding: 0.25rem 0.55rem;
  line-height: 1;
}

.btn-history {
  background: transparent;
  border: 1px solid #ab47bc;
  color: #ab47bc;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.btn-history:hover { background: #ab47bc; color: #fff; }

.btn-vod-upload {
  background: transparent;
  border: 1px solid #4fc3f7;
  color: #4fc3f7;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.btn-vod-upload:hover { background: #4fc3f7; color: #000; }

.btn-vod-upload-fast {
  background: transparent;
  border: 1px solid #66bb6a;
  color: #66bb6a;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.btn-vod-upload-fast:hover { background: #66bb6a; color: #000; }

.btn-vod-toggle {
  background: transparent;
  border: 1px solid #555;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.btn-vod-toggle:hover { background: #2a2a3a; color: var(--text); border-color: var(--text-muted); }
.btn-vod-toggle.btn-vod-on { border-color: var(--accent); color: var(--accent); }
.btn-vod-toggle.btn-vod-on:hover { background: var(--accent); color: #000; }

.badge-vod-progress { background: #1a3a4a; color: #4fc3f7; animation: pulse 2s infinite; }
.badge-vod-done { background: #1a3a1a; color: var(--accent); }
.badge-vod-error { background: #3a1a1a; color: var(--red); }

/* Auto-transcribe + auto-clip per-channel toggles (mirror .btn-vod-toggle) */
.btn-tx-toggle,
.btn-clip-toggle,
.btn-words {
  background: transparent;
  border: 1px solid #555;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}
.btn-tx-toggle:hover,
.btn-clip-toggle:hover,
.btn-words:hover { background: #2a2a3a; color: var(--text); border-color: var(--text-muted); }
.btn-tx-toggle.btn-tx-on { border-color: #f9a825; color: #f9a825; }
.btn-tx-toggle.btn-tx-on:hover { background: #f9a825; color: #000; }
.btn-clip-toggle.btn-clip-on { border-color: #ce93d8; color: #ce93d8; }
.btn-clip-toggle.btn-clip-on:hover { background: #ce93d8; color: #000; }

.btn-social {
  background: transparent;
  border: 1px solid #555;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}
.btn-social:hover { background: #2a2a3a; color: var(--text); border-color: var(--text-muted); }

/* Auto-clip status in the recordings list */
.btn-clip-run {
  background: transparent;
  border: 1px solid #ce93d8;
  color: #ce93d8;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}
.btn-clip-run:hover { background: #ce93d8; color: #000; }
.badge-clip-progress { background: #2e1a3a; color: #ce93d8; animation: pulse 2s infinite; }
.badge-clip-done { background: #1a3a1a; color: var(--accent); }
.badge-clip-error { background: #3a1a1a; color: var(--red); }

/* Channel cards */
#channel-list { display: flex; flex-direction: column; gap: 0.75rem; }

.channel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color 0.2s;
}

.channel-card.recording { border-color: var(--accent); }

.channel-info { flex: 1; min-width: 0; }
.channel-info .name { font-weight: 600; font-size: 1rem; }
.channel-info .meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.badge-offline { background: #2a2a3a; color: var(--text-muted); }
.badge-recording { background: var(--accent); color: #000; animation: pulse 2s infinite; }
.badge-error { background: var(--red); color: #fff; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.card-actions { display: flex; gap: 0.5rem; align-items: center; }

/* Player modal */
#player-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
}

#player-modal.open { display: flex; }

#player-modal video {
  width: 100%;
  max-width: 1100px;
  max-height: 80vh;
  border-radius: var(--radius);
  background: #000;
}

#player-modal .close-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1100px;
}

#player-modal .close-bar span { font-weight: 600; font-size: 1rem; }

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 0;
}

.error-msg {
  background: #2a1a1a;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  padding: 0.6rem 1rem;
}

/* Past recordings */
.recordings-section { margin-top: 2.5rem; }

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.count-badge {
  background: var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  text-transform: none;
  letter-spacing: 0;
}

.rec-group { margin-bottom: 1.25rem; }

.rec-group-header {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.rec-group-header { cursor: pointer; user-select: none; }

.rec-group-chevron {
  display: inline-block;
  transition: transform 0.15s;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.rec-group.collapsed .rec-group-chevron { transform: rotate(0deg); }
.rec-group:not(.collapsed) .rec-group-chevron { transform: rotate(90deg); }
.rec-group.collapsed .rec-row { display: none; }

.rec-group-name { font-weight: 600; font-size: 0.95rem; }
.rec-group-count { font-size: 0.78rem; color: var(--text-muted); }

.rec-group-recent {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(83, 252, 24, 0.1);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.rec-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.4rem;
  transition: border-color 0.15s;
}

.rec-row:hover { border-color: #3a3a50; }

.rec-info { flex: 1; min-width: 0; }
.rec-title { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }

/* Word Clip Compiler */
header { justify-content: space-between; }
header h1 { flex: 1; }

.btn-clip-tool {
  background: transparent;
  border: 1px solid #ff7043;
  color: #ff7043;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}
.btn-clip-tool:hover { background: #ff7043; color: #000; }

.btn-search-tool {
  background: transparent;
  border: 1px solid #4fc3f7;
  color: #4fc3f7;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}
.btn-search-tool:hover { background: #4fc3f7; color: #000; }

.btn-followers-tool {
  background: transparent;
  border: 1px solid #ab47bc;
  color: #ab47bc;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}
.btn-followers-tool:hover { background: #ab47bc; color: #fff; }

.btn-ads-tool {
  background: transparent;
  border: 1px solid #ffd740;
  color: #ffd740;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}
.btn-ads-tool:hover { background: #ffd740; color: #000; }

.btn-restream-tool {
  background: transparent;
  border: 1px solid #e040fb;
  color: #e040fb;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}
.btn-restream-tool:hover { background: #e040fb; color: #000; }

/* Past VODs per-channel button */
.btn-vod-browse {
  background: transparent;
  border: 1px solid #ff9800;
  color: #ff9800;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}
.btn-vod-browse:hover { background: #ff9800; color: #000; }

/* VOD download badges in recordings list */
.badge-vod-dl { background: #3a2a00; color: #ff9800; animation: pulse 2s infinite; }
.badge-vod-dl-err { background: #3a1a1a; color: var(--red); }

/* Past VOD browser modal */
#vod-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem 2rem;
  overflow-y: auto;
}
#vod-modal.open { display: flex; }
#vod-modal .modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
#vod-modal .modal-header {
  display: flex; justify-content: space-between; align-items: center;
}
#vod-modal h2 { font-size: 1.1rem; font-weight: 600; }

.vod-loading, .vod-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.vod-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.vod-row:hover { border-color: #3a3a50; }

.vod-row-info { flex: 1; min-width: 0; }
.vod-row-title { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vod-row-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }

.vod-dl-btn {
  background: transparent;
  border: 1px solid #ff9800;
  color: #ff9800;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}
.vod-dl-btn:hover:not(:disabled) { background: #ff9800; color: #000; }
.vod-dl-btn:disabled { opacity: 0.5; cursor: default; }

#word-search-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem 2rem;
  overflow-y: auto;
}
#word-search-modal.open { display: flex; }
#word-search-modal .modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
#word-search-modal .modal-header {
  display: flex; justify-content: space-between; align-items: center;
}
#word-search-modal h2 { font-size: 1.1rem; font-weight: 600; }
#word-search-modal .form-row { display: flex; flex-direction: column; gap: 0.4rem; }
#word-search-modal .form-row > label {
  font-size: 0.8rem; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
#word-search-modal .form-row small { font-size: 0.75rem; color: var(--text-muted); }
#word-search-modal input[type="text"],
#word-search-modal input[type="datetime-local"],
#word-search-modal select {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.9rem; padding: 0.55rem 0.8rem; outline: none; width: 100%;
}
#word-search-modal input:focus, #word-search-modal select:focus { border-color: var(--accent); }
#word-search-modal input[type="range"] { width: 100%; accent-color: var(--accent); }

#ws-status { font-size: 0.9rem; color: var(--text-muted); min-height: 1.2rem; }

.ws-summary {
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ws-section-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 0.5rem;
}

.ws-list { display: flex; flex-direction: column; gap: 0.35rem; }

.ws-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.ws-label {
  flex: 0 0 9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.ws-bar-wrap {
  flex: 1;
  height: 0.5rem;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}

.ws-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.ws-count {
  flex: 0 0 3rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.ws-meta {
  flex: 0 0 8rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ws-empty {
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.ws-row-empty { opacity: 0.45; }

#word-clip-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem 2rem;
  overflow-y: auto;
}

#word-clip-modal.open { display: flex; }

#word-clip-modal .modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

#word-clip-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#word-clip-modal h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

#word-clip-modal .form-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#word-clip-modal .form-row > label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#word-clip-modal .form-row small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

#word-clip-modal input[type="text"],
#word-clip-modal input[type="datetime-local"],
#word-clip-modal select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.55rem 0.8rem;
  outline: none;
  width: 100%;
}

#word-clip-modal input:focus,
#word-clip-modal select:focus { border-color: var(--accent); }

#word-clip-modal input[type="range"] { width: 100%; accent-color: var(--accent); }

.wc-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-preset {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}

.btn-preset:hover { border-color: var(--accent); color: var(--accent); }

.wc-dates {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.wc-dates span { color: var(--text-muted); font-size: 0.85rem; }

.wc-actions {
  display: flex;
  gap: 0.6rem;
}

#wc-preview-result {
  font-size: 0.9rem;
  color: var(--text);
  min-height: 1.2rem;
}

#wc-status {
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

