:root {
  --bg: #0b0e0f;
  --card: #13171a;
  --surface: #1b2125;
  --border: #262e34;
  --text: #f3f6f8;
  --muted: #93a1ab;
  --accent: #53fc18;
  --accent-dim: rgba(83, 252, 24, 0.14);
  --danger: #ff3b5c;
  --danger-dim: rgba(255, 59, 92, 0.14);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top center, rgba(83, 252, 24, 0.06), transparent 40%), var(--bg);
  color: var(--text);
  font-family: 'Cairo', 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.accent {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(12px);
  background: rgba(11, 14, 15, 0.85);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  padding-bottom: 12px;
  gap: 12px;
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #071005;
  font-weight: 800;
  font-size: 1.35rem;
  display: grid;
  place-items: center;
  box-shadow: 0 0 20px rgba(83, 252, 24, 0.3);
}

.brand-name {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-content {
  padding-top: 24px;
  padding-bottom: 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* Pills & Buttons */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.pill-muted {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

.pill-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(83, 252, 24, 0.3);
}

button, .btn-primary, .btn-secondary, .btn-ghost {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

button:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #071005;
  padding: 12px 22px;
  font-size: 0.98rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  background: #67ff33;
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 14px;
  font-size: 0.85rem;
  text-decoration: none;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 0.84rem;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: #3d4952;
}

/* Search Card */
.search-card {
  text-align: center;
  padding: 28px 24px;
}

.hero-title {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2.5vw, 1.9rem);
  font-weight: 800;
}

.hero-desc {
  margin: 0 auto 20px;
  max-width: 720px;
  color: var(--muted);
  font-size: 0.95rem;
}

.search-form {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}

.search-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 13px 16px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

.search-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(83, 252, 24, 0.14);
}

.quick-examples {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.chip-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.chip-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.alert-error {
  max-width: 780px;
  margin: 14px auto 0;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--danger-dim);
  border: 1px solid rgba(255, 59, 92, 0.35);
  color: #ff8ea1;
  font-size: 0.9rem;
}

/* Loading */
.loading-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Channel Card */
.channel-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.channel-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.channel-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  border: 2px solid var(--border);
}

.channel-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.channel-name {
  margin: 0;
  font-size: 1.25rem;
}

.channel-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--danger-dim);
  color: #ff6e86;
  border: 1px solid rgba(255, 59, 92, 0.45);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.live-sync-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.live-duration-readout {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.live-sync-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--muted);
  cursor: pointer;
}

.toggle-label input {
  accent-color: var(--accent);
}

/* Studio Layout */
.studio-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 20px;
  align-items: start;
}

.stream-header {
  margin-bottom: 12px;
}

.stream-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.stream-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.video-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
}

.player-sync-bar {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Clipper Controls */
.controls-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.control-block h4 {
  margin: 0 0 10px;
  font-size: 0.92rem;
  color: var(--text);
}

.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.block-header h4 {
  margin: 0;
}

/* Dual Range Slider */
.range-slider-wrap {
  position: relative;
  height: 34px;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.range-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: 999px;
  background: var(--surface);
}

.range-highlight {
  position: absolute;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  pointer-events: none;
}

.range-slider-wrap input[type="range"] {
  position: absolute;
  left: 0;
  width: 100%;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.range-slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #071005;
  cursor: grab;
  box-shadow: 0 0 10px rgba(83, 252, 24, 0.45);
}

.range-slider-wrap input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #071005;
  cursor: grab;
}

/* Time Boxes */
.time-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.time-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.time-box label {
  font-size: 0.78rem;
  color: var(--muted);
}

.time-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 1rem;
  text-align: center;
  outline: none;
}

.time-input:focus {
  border-color: var(--accent);
}

.nudge-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.nudge-btn {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
  font-size: 0.74rem;
}

.nudge-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.presets-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
}

.preset-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Summary Strip */
.summary-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
}

.summary-item strong {
  font-size: 1.05rem;
}

/* Quality & Format */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
  gap: 8px;
}

.quality-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quality-btn span {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 500;
}

.quality-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.quality-btn.active strong {
  color: var(--accent);
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.format-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.format-btn span {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.format-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.format-btn.active strong {
  color: var(--accent);
}

.download-cta {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
}

/* Progress */
.progress-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-top, .progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.progress-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Clip Single */
.clip-single-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
  align-items: center;
}

.clip-single-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

/* VODs Grid */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-header h3 {
  margin: 0;
}

.vods-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.vod-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.vod-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.vod-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(83, 252, 24, 0.2);
}

.vod-thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface);
}

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

.vod-duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.75rem;
}

.vod-live-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--danger);
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.vod-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vod-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vod-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Read-only Download History Section */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.history-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.history-title-group h3 {
  margin: 0;
  font-size: 1.05rem;
}

.latest-download-banner {
  background: var(--accent-dim);
  border: 1px solid rgba(83, 252, 24, 0.35);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.latest-minute-big {
  font-size: 1.35rem;
  margin-inline-start: 8px;
}

.history-details-line {
  font-size: 0.86rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  cursor: default;
  user-select: text;
}

.history-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.history-item-range {
  font-weight: 700;
  color: var(--text);
}

.history-item-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 960px) {
  .studio-grid, .clip-single-grid {
    grid-template-columns: 1fr;
  }
  .live-sync-controls {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .search-form {
    flex-direction: column;
  }
  .time-inputs-grid, .format-grid {
    grid-template-columns: 1fr;
  }
}
