@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:          #0e0e11;
  --surface:     #17171c;
  --surface-hi:  #1f1f26;
  --border:      #2a2a33;
  --border-hi:   #363642;
  --text:        #e8e8ee;
  --text-dim:    #8b8b96;
  --text-faint:  #5c5c66;
  --accent:      #e8763a;
  --accent-hi:   #f68a4d;
  --accent-ink:  #1a0e05;
  --accent-glow: rgba(232, 118, 58, 0.20);
  --drive:       #6ba1f0;
  --drive-glow:  rgba(107, 161, 240, 0.20);
  --discord:     #5865F2;
  --discord-hi:  #4752c4;
  --success:     #4ea862;
  --error:       #e05656;
  --error-bg:    rgba(224, 86, 86, 0.10);
  --error-brd:   rgba(224, 86, 86, 0.30);
  --radius:      12px;
  --radius-sm:   8px;
  --font: 'Nunito', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

body {
  font-family: var(--font);
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.card {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.login-card { max-width: 460px; }

/* Header */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.header-badges {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
header h1 {
  margin: 0;
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
header h1::before {
  content: '';
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}
.sub {
  margin: 0.35rem 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Drive / user badges */
.drive-badge, .user-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.drive-badge.drive-on {
  background: rgba(107, 161, 240, 0.10);
  border-color: rgba(107, 161, 240, 0.35);
  color: var(--drive);
}
.drive-badge.drive-off {
  background: var(--surface-hi);
  color: var(--text-dim);
}
.user-badge {
  background: var(--surface-hi);
  color: var(--text-dim);
  padding: 4px 4px 4px 10px;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  font-size: 0.75rem;
}
.user-badge #user-name {
  color: var(--text);
  font-weight: 700;
}
.logout-link {
  color: var(--text-faint);
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 999px;
  transition: color 0.15s, background 0.15s;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.logout-link:hover { color: var(--text); background: var(--border); }

/* Input row */
.input-row { display: flex; gap: 0.5rem; }
input[type="url"] {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  transition: border-color 0.15s;
}
input[type="url"]::placeholder { color: var(--text-faint); }
input[type="url"]:focus { outline: none; border-color: var(--accent); }

/* Buttons */
button, .btn-full {
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.75rem 1.25rem;
  transition: background 0.15s, transform 0.08s, opacity 0.15s;
}
button:disabled { cursor: not-allowed; opacity: 0.55; }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hi); }

.btn-secondary {
  background: var(--surface-hi);
  color: var(--text);
  border: 1px solid var(--border-hi);
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-full { display: block; width: 100%; text-align: center; text-decoration: none; }

/* Discord button */
.btn-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: var(--discord);
  color: white;
  text-decoration: none;
  padding: 0.9rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  transition: background 0.15s, transform 0.08s;
  width: 100%;
}
.btn-discord:hover { background: var(--discord-hi); }
.btn-discord:active { transform: translateY(1px); }
.btn-discord:focus-visible { outline: 2px solid var(--discord); outline-offset: 2px; }

.login-panel { display: flex; flex-direction: column; gap: 1rem; }
.login-note {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: center;
}

/* Access denied panel */
.denied-panel {
  padding: 1.5rem;
  background: var(--error-bg);
  border: 1px solid var(--error-brd);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
}
.denied-icon { font-size: 2.5rem; line-height: 1; }
.denied-panel h2 {
  margin: 0;
  color: var(--error);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}
.denied-panel p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
}
.denied-panel .dim { color: var(--text-dim); font-size: 0.8rem; }
.denied-uid {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0.25rem 0;
}
.denied-uid-label {
  font-size: 0.7rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.denied-uid code {
  font-family: var(--mono);
  color: var(--text);
  font-size: 0.9rem;
  word-break: break-all;
}

/* Status line */
.status {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-hi);
  color: var(--text-dim);
  font-size: 0.9rem;
  border: 1px solid var(--border);
}
.status.error {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error-brd);
}

[hidden] { display: none !important; }

.result { display: flex; flex-direction: column; gap: 1.25rem; }

.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.duration-badge {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.meta h2 {
  margin: 0;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.meta-row {
  margin-top: 0.5rem;
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem; flex-wrap: wrap;
}
.meta-row-sm {
  margin-top: 0.25rem;
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.8rem; color: var(--text-faint); flex-wrap: wrap;
}
.channel { color: var(--accent); font-weight: 700; }
.game-wrap { display: inline-flex; gap: 0.5rem; align-items: center; color: var(--text-dim); }
.dot { color: var(--text-faint); }

/* Download row */
.download-row { display: flex; gap: 0.5rem; align-items: stretch; }
.download-row select {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 0.9rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}
.download-row select:focus-visible { outline: none; border-color: var(--accent); }
.download-row .btn-primary { min-width: 140px; }

/* Progress */
.progress {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.progress-header {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.85rem; font-weight: 700;
}
#progress-status { color: var(--text); overflow-wrap: anywhere; }
#progress-pct { color: var(--text-dim); font-family: var(--mono); font-size: 0.8rem; }

.progress-bar {
  height: 6px;
  background: var(--surface-hi);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.25s ease-out, background 0.25s;
  box-shadow: 0 0 12px var(--accent-glow);
}

.progress.queued .progress-fill {
  background: var(--text-faint);
  width: 15% !important;
  animation: pulse 1.4s ease-in-out infinite;
}
.progress.uploading .progress-fill {
  background: var(--drive);
  box-shadow: 0 0 12px var(--drive-glow);
}
.progress.uploading #progress-status { color: var(--drive); }
.progress.done   #progress-status { color: var(--success); }
.progress.done   .progress-fill   { background: var(--success); box-shadow: none; }
.progress.failed #progress-status { color: var(--error); }
.progress.failed .progress-fill   { background: var(--error); box-shadow: none; }

@keyframes pulse {
  0%   { opacity: 0.35; transform: translateX(-100%); }
  50%  { opacity: 1;    transform: translateX(0%); }
  100% { opacity: 0.35; transform: translateX(100%); }
}

/* Uploaded links */
.uploaded-links {
  margin-top: 0.25rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.uploaded-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.15rem;
}
.uploaded-links a {
  color: var(--drive);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 10px;
  background: rgba(107, 161, 240, 0.08);
  border: 1px solid rgba(107, 161, 240, 0.25);
  border-radius: 6px;
  transition: background 0.15s;
  word-break: break-all;
  line-height: 1.4;
}
.uploaded-links a:hover { background: rgba(107, 161, 240, 0.16); }

/* Progress log */
.progress-log-wrap { margin-top: 0.25rem; font-size: 0.8rem; }
.progress-log-wrap summary {
  cursor: pointer;
  color: var(--text-dim);
  padding: 4px 0;
  user-select: none;
  list-style: none;
}
.progress-log-wrap summary::-webkit-details-marker { display: none; }
.progress-log-wrap summary::before { content: '▸ '; display: inline-block; }
.progress-log-wrap[open] summary::before { content: '▾ '; }
.progress-log-wrap summary:hover { color: var(--text); }
.progress-log {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  .card { padding: 1.5rem 1rem; gap: 1.25rem; }
  header h1 { font-size: 1.4rem; }
  .input-row, .download-row { flex-direction: column; }
  .download-row .btn-primary { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
