/* Base layout */
:root {
  color-scheme: dark;
  --bg: #0c0d13;
  --card: #16182b;
  --border: rgba(255,255,255,0.08);
  --text: #f6f7fb;
  --muted: rgba(255,255,255,0.6);
  --accent: #ff3b5c;
  --accent-dark: #d81e42;
  --success: #2dcf81;
  --warning: #f6c343;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, #1b1f35, #080910);
  color: var(--text);
  min-height: 100vh;
}

main.container {
  width: min(1120px, 94vw);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 48px) 0 64px;
}

.main-page {
  background:
    radial-gradient(circle at top, rgba(255, 45, 85, 0.16), transparent 28%),
    linear-gradient(180deg, #0d0f14 0%, #08090d 100%);
}

.main-page .app-header {
  justify-content: center;
  color: #f5f7fb;
  margin-bottom: 0.5rem;
  letter-spacing: -0.035em;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: clamp(1.5rem, 7vw, 2.4rem);
  font-weight: 800;
  margin-bottom: 1.5rem;
}

.yt-red { color: #ff3050; }
.to-text { color: #8a91a1; }
.mp3-text { color: #f5f7fb; }
.note-icon { color: #ff3050; }

.tab-nav {
  display: flex;
  justify-content: center;
  gap: 0;
  margin: 0 auto 0.85rem;
  max-width: 420px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 0.24rem;
  box-shadow: 0 18px 40px rgba(0,0,0,0.26);
}

.tab-link {
  flex: 1 1 0;
  min-width: 0;
  max-width: 220px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.72rem 1rem;
  text-decoration: none;
  background: transparent;
  color: #8d95a5;
  border: 0;
  border-radius: 12px;
  box-shadow: none;
  font-weight: 700;
  font-size: 0.95rem;
}

.tab-link.active {
  background: linear-gradient(180deg, #ff4566 0%, #ff2a4b 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 42, 75, 0.28);
}

.card {
  background: linear-gradient(180deg, rgba(24, 27, 35, 0.96) 0%, rgba(15, 17, 23, 0.98) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: clamp(1rem, 3vw, 1.25rem);
  margin-bottom: 1rem;
  box-shadow: 0 28px 60px rgba(0,0,0,0.28);
  backdrop-filter: blur(10px);
}

.convert-shell {
  padding: 1rem 1rem 0.8rem;
}

.jobs-shell {
  padding-top: 1rem;
}

.convert-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.convert-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.convert-submit {
  white-space: nowrap;
}

.convert-form label {
  color: #c7cfdb;
  font-size: 0.92rem;
  font-weight: 600;
}

.convert-form input[type="url"],
.search-form input[type="text"],
.filters input[type="number"],
.admin-panel input[type="password"] {
  width: 100%;
  padding: 0.92rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #f5f7fb;
  font-size: 1rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

.convert-form input[type="url"]::placeholder,
.admin-panel input[type="password"]::placeholder {
  color: #7e8797;
}

.convert-form input[type="url"]:focus,
.admin-panel input[type="password"]:focus {
  outline: none;
  border-color: rgba(255, 53, 87, 0.5);
  box-shadow: 0 0 0 4px rgba(255, 53, 87, 0.1);
}

button,
.btn,
.secondary {
  border: none;
  border-radius: 16px;
  padding: 0.8rem 1.1rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
}

button[type="submit"],
.btn,
.convert-submit {
  background: linear-gradient(180deg, #ff4969 0%, #ff2746 100%);
  color: white;
  transition: background 0.2s;
  box-shadow: 0 14px 26px rgba(255, 39, 70, 0.24);
}

button[type="submit"]:hover,
.btn:hover,
.convert-submit:hover {
  background: linear-gradient(180deg, #ff3e60 0%, #ef2343 100%);
}

.secondary {
  background: rgba(255,255,255,0.05);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.09);
}

.warning {
  background: rgba(246, 195, 67, 0.14);
  color: #ffd979;
  border: 1px solid rgba(246, 195, 67, 0.18);
}

.danger {
  background: rgba(255, 84, 84, 0.14);
  color: #ffabab;
  border: 1px solid rgba(255, 84, 84, 0.18);
}

.status {
  margin-top: 0.55rem;
  font-size: 0.92rem;
  color: #8b93a3;
}

.header-row,
.jobs-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.header-row h2,
.admin-panel h2 {
  margin: 0;
  color: #f5f7fb;
  font-size: 1.06rem;
}

.jobs {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.job-card,
.queue-card {
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 18px;
  padding: 0.9rem 1rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.015) 100%);
}

.job-header,
.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.job-title {
  color: #f7f9fc;
  text-decoration: none;
  font-size: 1rem;
}

.job-title:hover {
  text-decoration: underline;
}

.job-meta {
  color: #8c95a6;
  font-size: 0.82rem;
}

.badge {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.badge-queued { background: rgba(255,255,255,0.08); }
.badge-processing { background: rgba(95, 164, 255, 0.15); }
.badge-done { background: rgba(45,207,129,0.18); }
.badge-failed { background: rgba(255,99,71,0.18); }

.progress {
  width: 100%;
  height: 0.38rem;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.7rem 0 0.55rem;
}

.progress .bar {
  height: 100%;
  background: linear-gradient(90deg, #ff6a8f, #ff9a62);
}

.progress-label,
.queue-meta,
.muted {
  color: #8b93a3;
  font-size: 0.84rem;
}

.error {
  color: #ff8f9e;
  margin: 0.45rem 0;
}

.job-actions {
  margin-top: 0.45rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.job-actions .btn,
.job-actions .convert-btn,
.job-actions .download-btn,
.job-actions a {
  min-width: 0;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font-size: 0.84rem;
  line-height: 1.1;
}

.top-stats {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: #8b93a3;
}

.top-stats .stat strong {
  color: #f5f7fb;
}

.status-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.status-label {
  color: #8b93a3;
  font-size: 0.88rem;
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-idle {
  background: rgba(255,255,255,0.06);
  color: #d6dce8;
}

.status-queued {
  background: rgba(255,255,255,0.08);
  color: #f5f7fb;
}

.status-processing {
  background: rgba(95, 164, 255, 0.16);
  color: #b9d9ff;
}

.status-done {
  background: rgba(45,207,129,0.18);
  color: #97efbf;
}

.status-error {
  background: rgba(255,99,71,0.18);
  color: #ffb1a2;
}

.admin-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.log {
  max-height: 200px;
  overflow-y: auto;
  font-family: 'SFMono-Regular', Consolas, monospace;
  background: rgba(255,255,255,0.03);
  color: #c7cfdb;
  padding: 0.75rem;
  border-radius: 14px;
  margin-top: 0.8rem;
}

.empty {
  text-align: center;
  padding: 1rem;
}

.link-btn {
  background: none;
  padding: 0;
  color: #8b93a3;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
}

.filters {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  color: #8b93a3;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.result-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  padding: 1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  cursor: pointer;
}

.result-card.selected {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(120, 190, 255, 0.08);
}

.result-thumb img {
  width: 120px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 12px;
}

.result-thumb figcaption {
  font-size: 0.75rem;
  color: #8b93a3;
  margin-top: 0.35rem;
}

.result-info h3 {
  margin: 0;
  font-size: 1rem;
}

.meta {
  font-size: 0.85rem;
  color: #8b93a3;
  margin: 0.25rem 0;
}

.actions {
  margin-top: 0.5rem;
}

.convert-btn {
  background: rgba(255,255,255,0.12);
  color: var(--text);
  border-radius: 10px;
  padding: 0.45rem 0.85rem;
  border: none;
}

.batch-bar,
.queue-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.queue-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

@media (max-width: 760px) {
  .convert-row,
  .header-row,
  .jobs-header-row,
  .admin-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .tab-link {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .convert-form button,
  .search-form button {
    width: 100%;
  }
  .result-card {
    grid-template-columns: 1fr;
  }
}
