/* D-Stream — Dark minimal mobile-first */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1e1e1e;
  --border: #2a2a2a;
  --text: #e5e5e5;
  --text-2: #888;
  --accent: #4f8cff;
  --accent-hover: #3a7bf0;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.screen { padding: 24px 20px; max-width: 480px; margin: 0 auto; }
.hidden { display: none !important; }

/* Auth */
#auth-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100dvh; gap: 12px;
}
.logo { font-size: 48px; margin-bottom: 8px; }
#auth-screen h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.subtitle { color: var(--text-2); font-size: 14px; margin-bottom: 20px; }

/* Inputs */
input[type="url"], input[type="password"], input[type="text"] {
  width: 100%; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 15px; outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-2); }

/* Buttons */
button {
  font-family: var(--font); font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: all 0.15s;
}
#token-btn, #analyze-btn {
  width: 100%; padding: 14px; border-radius: var(--radius);
  background: var(--accent); color: #fff;
}
#token-btn:hover, #analyze-btn:hover { background: var(--accent-hover); }
#analyze-btn { width: auto; padding: 14px 20px; flex-shrink: 0; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-icon {
  background: transparent; color: var(--text-2); font-size: 18px;
  padding: 4px 8px; border-radius: 6px;
}
.btn-icon:hover { color: var(--text); background: var(--surface-2); }

/* Header */
header {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 20px; margin-bottom: 4px;
}
.logo-sm { font-size: 20px; }
.title { font-size: 16px; font-weight: 700; flex: 1; letter-spacing: -0.3px; }

/* URL bar */
.url-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.url-bar input { flex: 1; }

/* Media card */
.media-card {
  display: flex; gap: 14px; padding: 14px;
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 12px;
}
.media-card img {
  width: 100px; height: 60px; border-radius: 6px;
  object-fit: cover; background: var(--surface-2);
}
.media-info { flex: 1; min-width: 0; }
.media-titre {
  font-size: 13px; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.media-duree { font-size: 12px; color: var(--text-2); margin-top: 4px; font-family: var(--mono); }

/* Formats grid */
.formats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px; margin-bottom: 20px;
}
.format-btn {
  padding: 12px 8px; border-radius: 8px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text);
}
.format-btn:hover { border-color: var(--accent); color: var(--accent); }
.format-btn .label { display: block; font-size: 14px; font-weight: 700; }
.format-btn .size { display: block; font-size: 10px; color: var(--text-2); margin-top: 2px; font-family: var(--mono); }

/* Jobs */
.job-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.job-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.job-etat {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; font-family: var(--mono);
}
.job-etat.en_attente { color: var(--text-2); }
.job-etat.telechargement { color: var(--accent); }
.job-etat.termine { color: var(--success); }
.job-etat.erreur { color: var(--danger); }

.progress-bar {
  height: 4px; background: var(--surface-2); border-radius: 2px;
  overflow: hidden; margin-bottom: 8px;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width 0.3s ease;
}
.job-meta { font-size: 11px; color: var(--text-2); font-family: var(--mono); }

.btn-download {
  display: block; width: 100%; padding: 12px; margin-top: 10px;
  background: var(--success); color: #000; font-weight: 700;
  border-radius: 8px; text-align: center; font-size: 14px;
}
.btn-download:hover { opacity: 0.9; }

.job-erreur { font-size: 12px; color: var(--danger); margin-top: 6px; }

/* Status bar */
#status-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 10px 20px; text-align: center;
  font-size: 13px; background: var(--surface);
  border-top: 1px solid var(--border);
}

/* Safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #main-screen { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
