/* =====================================================================
   AutoSu Studio — styles
   Vanilla CSS, no framework. Theme via CSS variables.
   ===================================================================== */

* { box-sizing: border-box; }

:root {
  /* Dark theme (default) */
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1f2530;
  --border: #30363d;
  --border-soft: #21262d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-faint: #6e7681;
  --primary: #ffd23f;
  --primary-fg: #161616;
  --primary-hover: #ffce1a;
  --danger: #f85149;
  --success: #3fb950;
  --warning: #d29922;
  --info: #58a6ff;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 4px 12px rgba(0,0,0,0.3);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #f6f8fa;
  --bg-elev-2: #eef1f4;
  --border: #d0d7de;
  --border-soft: #e6eaef;
  --text: #1f2328;
  --text-dim: #59636e;
  --text-faint: #818b98;
  --primary: #d4a017;
  --primary-fg: #1f2328;
  --primary-hover: #b88a0c;
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

[data-theme="accent"] {
  --bg: #0f111a;
  --bg-elev: #1a1d2b;
  --bg-elev-2: #252938;
  --border: #2d3344;
  --text: #e7eaf3;
  --primary: #ff5e8a;
  --primary-fg: #0f111a;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

.hidden { display: none !important; }

/* =====================================================================
   Loading screen
   ===================================================================== */
.app-loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 1000;
  gap: 1rem;
  color: var(--text-dim);
}
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   Auth screen
   ===================================================================== */
.auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 1rem;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-icon { font-size: 2.5rem; }
.auth-brand h1 { margin: 0.5rem 0 0.25rem; font-size: 1.5rem; }
.auth-tagline { color: var(--text-dim); margin: 0; font-size: 0.9rem; }
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.75rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1.25rem 0 0.5rem;
  color: var(--text-faint);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.brand-guest-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.6rem;
  padding: 0.15rem 0.55rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.auth-field { display: flex; flex-direction: column; gap: 0.35rem; }
.auth-field label { font-size: 0.85rem; color: var(--text-dim); }
.auth-field input {
  padding: 0.65rem 0.75rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.auth-field input:focus { outline: none; border-color: var(--primary); }
.auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}
.auth-footer { text-align: center; color: var(--text-faint); font-size: 0.8rem; margin-top: 1rem; }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.btn:hover { background: var(--border-soft); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg-elev-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-icon {
  background: none; border: none; padding: 0.4rem;
  cursor: pointer; font-size: 1.1rem;
}

/* =====================================================================
   App shell (header + main)
   ===================================================================== */
.app-shell {
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.app-header {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.app-brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.brand-icon { font-size: 1.3rem; }
.app-nav { display: flex; gap: 0.5rem; flex: 1; }
.nav-link {
  color: var(--text-dim);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.nav-link:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--bg-elev-2); color: var(--primary); }
.app-user { display: flex; align-items: center; gap: 0.5rem; }
.user-email { color: var(--text-dim); font-size: 0.9rem; }

.app-main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* =====================================================================
   Views
   ===================================================================== */
.view-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.view-header h2 { margin: 0; font-size: 1.4rem; }
.view-sub { color: var(--text-dim); margin: 0.25rem 0 0; font-size: 0.9rem; }

/* =====================================================================
   Panels
   ===================================================================== */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}
.panel-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
}
.panel-title { font-weight: 500; }
.panel-body { padding: 1rem; }

/* =====================================================================
   Dropzone
   ===================================================================== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-elev-2);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--bg-elev);
}
.dropzone-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.dropzone-text { font-size: 1rem; margin-bottom: 0.25rem; }
.dropzone-hint { color: var(--text-faint); font-size: 0.85rem; }

.upload-progress { margin-top: 1rem; }
.upload-progress-label {
  display: flex; justify-content: space-between;
  font-size: 0.85rem; color: var(--text-dim);
  margin-bottom: 0.4rem;
}

/* Progress bar */
.progress-bar {
  height: 6px;
  background: var(--bg-elev-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
}

/* =====================================================================
   Template picker
   ===================================================================== */
.template-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.template-card {
  border: 2px solid var(--border);
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.5rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.template-card:hover { border-color: var(--text-faint); }
.template-card.selected {
  border-color: var(--primary);
  background: var(--bg-elev);
}
.template-card .template-sample {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.4rem 0.3rem;
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.1;
  min-height: 2.4em;
  display: flex; align-items: center; justify-content: center;
}
.template-card .template-name {
  font-size: 0.85rem; color: var(--text);
  font-weight: 500;
}
.template-card .template-id {
  font-size: 0.7rem; color: var(--text-faint);
  font-family: var(--mono);
}

/* Subtitle style samples (visual approximation) */
.template-card .sample-default  { color: #fff; text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000; }
.template-card .sample-outline  { color: #fff; text-shadow: 2px 2px 0 #000; font-weight: 800; }
.template-card .sample-yellow   { color: #FFE84D; text-shadow: 1px 1px 0 #111; }
.template-card .sample-neon     { color: #0ff; text-shadow: 0 0 4px #0ff, 0 0 8px #0aa; }
.template-card .sample-blue     { color: #fff; text-shadow: 0 0 4px #58a6ff, 0 0 10px #1f6feb; }
.template-card .sample-box      { color: #fff; background: #000; padding: 4px 6px; border-radius: 3px; }
.template-card .sample-sticker  { color: #fff; background: linear-gradient(180deg, #ff8fb1, #ff5e8a); padding: 4px 6px; border-radius: 12px; }
.template-card .sample-green    { color: #3fb950; text-shadow: 1px 1px 0 #000; }
.template-card .sample-karaoke  { color: #ff5e8a; text-shadow: 1px 1px 0 #000; font-weight: 800; }
.template-card .sample-gold     { color: #ffd23f; text-shadow: 1px 1px 0 #6b4f00, 2px 2px 0 #6b4f00; font-weight: 800; }
.template-card .sample-comic    { color: #ff0; text-shadow: 2px 2px 0 #000; font-size: 1rem; }
.template-card .sample-red      { color: #f85149; background: rgba(0,0,0,0.6); padding: 4px 6px; }
.template-card .sample-purple   { color: #c084fc; text-shadow: 1px 1px 0 #000; }
.template-card .sample-ice      { color: #a5f3fc; text-shadow: 0 0 4px #06b6d4; }
.template-card .sample-orange   { color: #fb923c; background: rgba(0,0,0,0.5); padding: 4px 6px; }
.template-card .sample-white-shadow { color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.6); }
.template-card .sample-black-label { color: #fff; background: #000; padding: 4px 8px; font-weight: 800; }
.template-card .sample-pixel    { color: #0f0; font-family: monospace; background: #000; padding: 4px; }
.template-card .sample-pastel   { color: #fbcfe8; text-shadow: 1px 1px 0 rgba(0,0,0,0.3); }
.template-card .sample-lime     { color: #bef264; text-shadow: 1px 1px 0 #000; font-weight: 800; }
.template-card .sample-random   { background: linear-gradient(45deg, #ff5e8a, #ffd23f); color: #fff; padding: 4px; }

/* =====================================================================
   Advanced settings (collapsible)
   ===================================================================== */
.advanced-toggle {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
}
.advanced-toggle summary {
  cursor: pointer; color: var(--text-dim);
  font-size: 0.9rem;
}
.advanced-toggle[open] summary { margin-bottom: 0.75rem; }
.advanced-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.advanced-grid label {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.85rem; color: var(--text-dim);
}
.advanced-grid input, .advanced-grid select {
  padding: 0.4rem 0.5rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.form-hint { color: var(--text-faint); font-size: 0.8rem; margin-top: 0.5rem; }

/* =====================================================================
   Developer / API tokens / code snippets
   ===================================================================== */
.code-inline {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  margin: 0 0.5rem;
  word-break: break-all;
}
.token-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.token-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.token-item-meta { flex: 1; }
.token-item-name { font-weight: 600; }
.token-item-prefix {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 0.15rem;
}
.token-item-time {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 0.15rem;
}
.token-item-actions { display: flex; gap: 0.4rem; }
.snippet-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}
.snippet-tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-faint);
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.snippet-tab:hover { color: var(--text); }
.snippet-tab.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
.snippet-frame {
  position: relative;
  background: #0a0d12;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: auto;
}

/* =====================================================================
   History (filter + search + bulk actions)
   ===================================================================== */
.history-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 720px) {
  .history-layout { grid-template-columns: 1fr; }
}
.history-filters {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  position: sticky;
  top: 1rem;
}
.filter-group { margin-bottom: 0.9rem; }
.filter-group:last-child { margin-bottom: 0; }
.filter-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-bottom: 0.4rem;
  font-weight: 700;
}
.radio-row, .check-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  padding: 0.18rem 0;
  cursor: pointer;
  color: var(--text);
}
.radio-row input, .check-row input { cursor: pointer; }
.filter-group input[type="search"],
.filter-group input[type="date"],
.filter-group select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  font-family: inherit;
}
.filter-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.history-results {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}
.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
  gap: 0.5rem;
}
.hist-count {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-right: 0.7rem;
}
.bulk-row { font-size: 0.85rem; color: var(--text-faint); }
.bulk-actions { display: flex; gap: 0.4rem; }
.hist-table {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 200px;
}
.hist-row {
  display: grid;
  grid-template-columns: 32px 110px 80px 1fr 100px 100px 110px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.1s;
}
.hist-row:hover { background: var(--bg); }
.hist-row.selected { background: rgba(255, 215, 0, 0.08); }
.hist-row:last-child { border-bottom: none; }
.hist-row.hist-head {
  background: var(--bg);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  font-weight: 700;
  cursor: default;
}
.hist-row.hist-head:hover { background: var(--bg); }
.hist-row.hist-empty {
  cursor: default;
  color: var(--text-faint);
  text-align: center;
  padding: 1.5rem 0.75rem;
  display: block;
}
.hist-row.hist-empty:hover { background: var(--bg-elev); }
.hist-when { color: var(--text-faint); font-size: 0.78rem; }
.hist-file {
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-badge { font-size: 0.72rem; padding: 0.18rem 0.45rem; }
.hist-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-faint);
}
input[type="date"].hidden { display: none; }

/* =====================================================================
   Cues editor (job detail)
   ===================================================================== */
.cues-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 480px;
  overflow-y: auto;
}
.cue-row {
  display: grid;
  grid-template-columns: 40px 110px 1fr 60px;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}
.cue-row:hover { background: var(--bg-elev); }
.cue-row.cue-editing { background: rgba(255,215,0,0.06); border-color: var(--accent); }
.cue-idx { color: var(--text-faint); font-family: var(--mono); }
.cue-time { font-family: var(--mono); font-size: 0.78rem; color: var(--text-faint); }
.cue-text {
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}
.cue-text textarea {
  width: 100%;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.88rem;
  resize: vertical;
  min-height: 2.4rem;
}
.cue-actions { display: flex; gap: 0.2rem; }
.cue-actions .btn { padding: 0.2rem 0.5rem; font-size: 0.78rem; }

/* =====================================================================
   Connection indicator (job detail live status)
   ===================================================================== */
.conn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}
.conn-live {
  border-color: #3ecf8e;
  color: #3ecf8e;
  animation: live-pulse 2s ease-in-out infinite;
}
.conn-polling {
  border-color: #f0b54c;
  color: #f0b54c;
}
.conn-idle {
  border-color: var(--border);
  color: var(--text-faint);
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.view-header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* =====================================================================
   Drag and drop upload
   ===================================================================== */
.upload-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text-faint);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 0.5rem 0;
}
.upload-dropzone:hover {
  border-color: var(--accent);
  color: var(--text);
}
.upload-dropzone.is-dragover {
  border-color: var(--primary);
  background: rgba(255, 215, 102, 0.05);
  color: var(--primary);
  transform: scale(1.01);
}
.upload-dropzone .dz-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.upload-dropzone .dz-text {
  font-size: 0.95rem;
  font-weight: 600;
}
.upload-dropzone .dz-hint {
  font-size: 0.75rem;
  margin-top: 0.3rem;
  color: var(--text-faint);
}
.upload-dropzone .dz-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.upload-queue {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.upload-queue-row {
  display: grid;
  grid-template-columns: 1fr 70px 90px 30px;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.upload-queue-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
}
.upload-queue-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.upload-queue-bar > div {
  height: 100%;
  background: var(--primary);
  transition: width 0.2s;
}
.upload-queue-pct {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
}
.upload-queue-remove {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
}
.upload-queue-remove:hover {
  color: #ff6b6b;
}

/* =====================================================================
   Landing hero + Public Gallery grid
   ===================================================================== */
.landing-hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
  background: linear-gradient(180deg, rgba(255,215,102,0.04) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.landing-hero h1 {
  font-size: 2.5rem;
  margin: 0 0 0.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, #ff9966 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.landing-tagline {
  font-size: 1.2rem;
  color: var(--text);
  margin: 0 0 0.5rem;
}
.landing-desc {
  color: var(--text-faint);
  margin: 0 auto 1.5rem;
  max-width: 540px;
  line-height: 1.5;
}
.landing-cta {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}
.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}
.landing-feature {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  text-align: center;
}
.landing-feature-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}
.landing-feature h3 {
  font-size: 1rem;
  margin: 0 0 0.4rem;
  color: var(--text);
}
.landing-feature p {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin: 0;
  line-height: 1.4;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem;
}
.gallery-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
  cursor: pointer;
}
.gallery-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}
.gallery-card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.gallery-card-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-card-thumb .play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 2rem;
  color: white;
}
.gallery-card:hover .play-overlay {
  opacity: 1;
}
.gallery-card-info {
  padding: 0.6rem 0.7rem;
}
.gallery-card-title {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 0.3rem;
}
.gallery-card-template {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.05rem 0.45rem;
  font-size: 0.7rem;
  color: var(--accent);
}
.gallery-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.5rem;
}
.gallery-actions .btn {
  flex: 1;
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
}

/* =====================================================================
   Dashboard
   ===================================================================== */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}
.dash-kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  position: relative;
  overflow: hidden;
}
.dash-kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.dash-kpi.kpi-ok::before { background: #3ecf8e; }
.dash-kpi.kpi-err::before { background: #ff6b6b; }
.dash-kpi.kpi-info::before { background: #5aa9ff; }
.dash-kpi-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.dash-kpi-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  font-family: var(--mono);
}
.dash-kpi-sub {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.2rem;
}
.dash-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.8rem;
}
.dash-grid > .panel:nth-child(3) { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
}
.dash-recent { display: flex; flex-direction: column; gap: 0.4rem; }
.dash-recent-row {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.1s;
}
.dash-recent-row:hover { background: var(--bg-elev); }
.dash-recent-time { color: var(--text-faint); font-size: 0.78rem; font-family: var(--mono); }
.dash-recent-file { font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-recent-status { text-align: right; }
.dash-template-card {
  text-align: center;
  padding: 1.2rem 0.5rem;
}
.dash-template-card .big-template {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0.3rem 0;
}
.dash-template-card .preview-box {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background: #0a0d12;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 1.05rem;
  margin: 0.4rem 0 0.8rem 0;
  color: #ffd866;
}
.dash-windows {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.dash-window {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.dash-window-label {
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dash-window-value {
  font-size: 1.4rem;
  font-weight: 600;
  font-family: var(--mono);
}
.dash-admin {
  margin-top: 1rem;
}
.admin-top-users {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.admin-top-user {
  display: grid;
  grid-template-columns: 1fr 80px 120px;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.admin-top-user-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.admin-top-user-bar > div {
  height: 100%;
  background: var(--accent);
}
@media (max-width: 700px) {
  .dash-recent-row { grid-template-columns: 1fr; }
  .dash-windows { gap: 0.8rem; }
}
.snippet-frame pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  color: #d6e2ee;
  white-space: pre-wrap;
  word-break: break-word;
}
.snippet-copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  z-index: 2;
}
.btn-sm {
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
}
.token-revealed {
  background: #0a0d12;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem;
  margin-bottom: 0.75rem;
}
.token-revealed-label {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.token-revealed-value {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: #ffd866;
  word-break: break-all;
  user-select: all;
}

/* =====================================================================
   Jobs list
   ===================================================================== */
.jobs-list { display: flex; flex-direction: column; gap: 0.5rem; }
.job-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.job-row:hover { border-color: var(--text-faint); }
.job-row-info { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.job-row-filename { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-row-meta { color: var(--text-dim); font-size: 0.8rem; }
.job-row-status { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; }

.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge-pending { background: rgba(88, 166, 255, 0.15); color: var(--info); border-color: var(--info); }
.badge-running { background: rgba(210, 153, 34, 0.15); color: var(--warning); border-color: var(--warning); }
.badge-done    { background: rgba(63, 185, 80, 0.15); color: var(--success); border-color: var(--success); }
.badge-error   { background: rgba(248, 81, 73, 0.15); color: var(--danger); border-color: var(--danger); }
.badge-cancelled { background: var(--bg-elev-2); color: var(--text-faint); }

/* =====================================================================
   Job detail
   ===================================================================== */
.job-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.job-meta > div { color: var(--text-dim); }
.job-meta strong { color: var(--text); font-weight: 500; }
.job-progress { margin: 1rem 0; }
.job-progress-msg { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.4rem; }
.job-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.job-events {
  max-height: 400px; overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}
.job-event { padding: 0.2rem 0; color: var(--text-dim); }
.job-event .ts { color: var(--text-faint); margin-right: 0.5rem; }
.job-event.error { color: var(--danger); }
.job-event.warn { color: var(--warning); }

/* =====================================================================
   Forms (settings)
   ===================================================================== */
.form-row {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.form-row label { color: var(--text-dim); min-width: 140px; }
.form-row input, .form-row select {
  padding: 0.4rem 0.5rem;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex: 1;
}

/* =====================================================================
   Toasts
   ===================================================================== */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  z-index: 1000;
  max-width: 360px;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
  color: var(--text);
  animation: toast-in 0.2s;
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-info { border-left: 3px solid var(--info); }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 640px) {
  .app-header { flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 0.75rem; }
  .app-nav { order: 3; width: 100%; }
  .app-main { padding: 1rem; }
  .job-row { grid-template-columns: 1fr; gap: 0.5rem; }
  .job-row-status { align-items: flex-start; }
  .user-email { display: none; }
  .template-picker { grid-template-columns: repeat(2, 1fr); }
}

/* =====================================================================
   TEMPLATE PREVIEW — Sprint 2
   ===================================================================== */
.btn-preview-tpl {
  display: block;
  margin: 0.4rem auto 0;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  cursor: pointer;
  color: inherit;
  transition: background 0.15s, transform 0.1s;
}
.btn-preview-tpl:hover { background: rgba(0, 0, 0, 0.12); }
.btn-preview-tpl:active { transform: scale(0.95); }
.template-card.selected .btn-preview-tpl { background: var(--accent, #3a7afe); color: #fff; border-color: transparent; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.18s ease-out;
}
.modal-backdrop.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal-box {
  background: var(--bg-elev, #1a1a1a);
  color: var(--text, #eaeaea);
  border-radius: 12px;
  max-width: 90vw; width: 720px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: popIn 0.18s ease-out;
}
@keyframes popIn { from { transform: scale(0.95); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-header button { background: none; border: none; font-size: 1.6rem; line-height: 1; color: inherit; cursor: pointer; opacity: 0.6; padding: 0 0.5rem; }
.modal-header button:hover { opacity: 1; }
.modal-body { padding: 1rem 1.25rem; flex: 1; overflow: auto; }
.modal-footer {
  padding: 0.75rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.85rem; opacity: 0.75;
}
.tpl-preview-box { max-width: 640px; }
.tpl-preview-video { width: 100%; max-height: 60vh; border-radius: 8px; background: #000; display: block; }
.tpl-preview-loading { padding: 3rem 1rem; text-align: center; opacity: 0.6; }
.tpl-preview-error { padding: 2rem 1rem; text-align: center; color: #f44; }
.tpl-preview-note { font-size: 0.8rem; opacity: 0.6; text-align: center; margin: 0.5rem 0 0; }
.tpl-preview-meta { font-size: 0.8rem; opacity: 0.7; }
