:root {
  --bg: #0B0E11;
  --card: #12161B;
  --card-2: #171C23;
  --border: #1E252D;
  --lime: #A3FF12;
  --lime-hover: #92E80A;
  --cyan: #22D3EE;
  --text: #F3F4F6;
  --muted: #8B949E;
  --danger: #EF4444;
  --radius: 14px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  padding: 16px 14px 36px;
}

/* Header */
.app-header {
  margin-bottom: 14px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--lime);
  color: #0B0E11;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(163, 255, 18, 0.25);
}

.brand-logo svg {
  width: 24px;
  height: 24px;
}

.brand-text h1 {
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  line-height: 1.15;
}

.brand-text p {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.8px;
  margin-top: 2px;
}

.status-pill {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--lime);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}

.status-pill.offline {
  color: var(--danger);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* Tabs */
.tab-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 16px;
  background: var(--card);
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 9px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--lime);
  color: #0B0E11;
  font-weight: 700;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Cards & Inputs */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: -6px;
  margin-bottom: 12px;
}

.card-head-icon {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.card-head-icon svg {
  width: 22px;
  height: 22px;
  margin-top: 2px;
}

.field-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.7px;
  margin-bottom: 6px;
  margin-top: 10px;
}

.input-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.input-box:focus-within {
  border-color: var(--cyan);
}

.input-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.input-box input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.86rem;
}

.icon-clear {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.bulk-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.5;
  resize: vertical;
  margin-bottom: 12px;
  outline: none;
}

.bulk-textarea:focus {
  border-color: var(--cyan);
}

/* Buttons */
.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-lime {
  background: var(--lime);
  color: #0B0E11;
}

.btn-cyan {
  background: var(--cyan);
  color: #0B0E11;
}

.btn-cyan-outline {
  background: transparent;
  border: 1.5px solid var(--cyan);
  color: var(--cyan);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.76rem;
}

.btn-outline-lime {
  background: transparent;
  border: 1px solid var(--lime);
  color: var(--lime);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline-muted {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

/* Quality Pills */
.quality-section {
  margin-top: 16px;
}

.section-label {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.quality-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
}

.q-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.q-pill.active {
  background: var(--lime);
  border-color: var(--lime);
  color: #0B0E11;
  font-weight: 800;
}

/* Toggle Switch */
.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
}

.toggle-label {
  font-size: 0.86rem;
  font-weight: 600;
}

.switch {
  position: relative;
  width: 48px;
  height: 26px;
  display: inline-block;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #2A323D;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--lime);
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
}

/* Preview Card */
.preview-card {
  display: flex;
  gap: 12px;
  align-items: center;
}

.preview-thumb-wrap {
  position: relative;
  width: 112px;
  height: 76px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}

.preview-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.platform-badge {
  position: absolute;
  bottom: 5px;
  left: 5px;
  background: rgba(11, 14, 17, 0.85);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
}

.preview-info {
  flex: 1;
  min-width: 0;
}

.preview-info h3 {
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Queue & History List */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.6px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.queue-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.queue-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.queue-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.queue-meta {
  min-width: 0;
}

.queue-name {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-sub {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 2px;
}

.queue-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.badge-status {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
  background: #232A34;
  color: var(--muted);
}

.badge-status.downloading {
  background: rgba(34, 211, 238, 0.16);
  color: var(--cyan);
}

.badge-status.completed {
  background: var(--lime);
  color: #0B0E11;
}

.badge-status.failed {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.btn-dl-sm {
  background: transparent;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.complete-banner {
  margin-top: 12px;
  background: var(--card);
  border: 1px solid rgba(163, 255, 18, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--lime);
  font-size: 0.82rem;
  font-weight: 700;
}

.check-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--lime);
  color: #0B0E11;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.75rem;
}

/* Channel Scan Grid */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.found-text {
  font-size: 0.88rem;
  font-weight: 700;
}

.results-actions {
  display: flex;
  gap: 6px;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.channel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.channel-thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg);
}

.channel-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chan-check {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 20px;
  height: 20px;
  accent-color: var(--lime);
  cursor: pointer;
}

.chan-duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(11, 14, 17, 0.85);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
}

.channel-card-body {
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.channel-card-title {
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.channel-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.channel-card-meta {
  font-size: 0.64rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chan-dl-icon {
  background: none;
  border: none;
  color: var(--cyan);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
}

.channel-footer {
  margin-top: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  font-weight: 600;
}

/* Helpers */
.cyan-text { color: var(--cyan); }
.lime-text { color: var(--lime); }
.hidden { display: none !important; }
.empty-msg {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 20px 10px;
}

.pwa-hint {
  text-align: center;
  color: var(--cyan);
  font-size: 0.74rem;
  margin-top: 8px;
}

/* Toast & Modal */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-2);
  border: 1px solid var(--lime);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 100;
  max-width: 90%;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 200;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.modal-card h3 {
  margin-bottom: 10px;
}

.modal-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  margin-bottom: 12px;
  outline: none;
}
