/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:      #ff6700;
  --primary-dark: #d05401;
  --bg:        #000000;
  --surface:   #121212;
  --surface2:  #1c1c1c;
  --border:    rgba(255, 255, 255, 0.1);
  --text:      #ffffff;
  --text-muted:#a0a0a0;
  --green:     #2ecc71;
  --error:     #ff5252;
  --radius:    12px;
  --font-heading: "Raleway", sans-serif;
  --font-body:    "Inter", sans-serif;
  --glass-bg:     rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur:   10px;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  /* background: radial-gradient(circle at 50% 0%, rgba(255, 103, 0, 0.12) 0%, rgba(0, 0, 0, 0) 60%); */
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url('/static/img/i36T-BG-Logo-04b.png');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: min(92vw, 92vh);
  opacity: 0.2;
  pointer-events: none;
}

/* ── Header ──────────────────────────────────────────────── */
header {
  width: 100%;
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
}

.logo {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  padding-top: 10px;
}

.logo-yt {
  color: var(--primary);
  margin-right: 4px;
}

.logo-36t {
  color: var(--primary);
}

.i36t-intro .tagline {
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: normal;
  margin-top: 4px;
  margin-bottom: 20px;
  text-align: center !important;

}

.i36t-intro {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  max-width: 560px;
  margin: 14px auto 0;
  padding: 10px 10px;
  /* background: var(--glass-bg); */
  /* border: 1px solid var(--glass-border); */
  /* border-radius: 10px; */
  text-align: center;

}

.i36t-logo {
  height: 120px;
  width: auto;
  flex-shrink: 0;
}

.i36t-intro p {
  color: var(--text-muted);
  font-size: 0.98rem;
  text-align: left;
  line-height: 1.5;
  text-align: center;
}

.i36t-intro strong {
  color: var(--text);
}

.i36t-intro a {
  color: var(--primary);
  font-weight: 600;
}

.i36t-intro a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .i36t-logo { height: 90px; }
}

@media (max-width: 480px) {
  .i36t-intro { flex-direction: column; text-align: center; }
  .i36t-intro p { text-align: center; }
  .i36t-logo { height: 60px; }
}

@media (max-width: 360px) {
  .i36t-logo { height: 48px; }
}

/* ── Main ────────────────────────────────────────────────── */
main {
  width: 100%;
  max-width: 700px;
  padding: 32px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius);
  padding: 24px;
  border-color: var(--primary);
}

.hidden { display: none !important; }

/* ── URL Input ───────────────────────────────────────────── */
.input-row {
  display: flex;
  gap: 10px;
}

#url-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px; /* iOS Safari auto-zooms on focus if an input is under 16px */
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s;
}

#url-input:focus { border-color: var(--primary); }

#btn-fetch {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 24px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#btn-fetch:hover { background: var(--primary-dark); }
#btn-fetch:disabled { background: #555; cursor: not-allowed; }

#btn-clear {
  background: #d0d0d0;
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#btn-clear:hover { background: #bdbdbd; }

.hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 8px;
}

/* ── Why i36T.com (USPs) ─────────────────────────────────── */
.usp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.usp-item {
  text-align: center;
  padding: 8px;
}

.usp-icon {
  font-size: 1.8rem;
  margin-bottom: 10px;
}

.usp-item h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.usp-item p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .usp-grid { grid-template-columns: 1fr; }
}

/* ── FAQ ─────────────────────────────────────────────────── */
.section-heading {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.faq-item {
  border-top: 1px solid var(--border);
  padding: 14px 0;
}

.faq-item:last-child { padding-bottom: 0; }

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::before {
  content: "+";
  color: var(--primary);
  font-weight: 700;
  margin-right: 10px;
}

.faq-item[open] summary::before {
  content: "−";
}

.faq-item p {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
  margin-top: 10px;
  padding-left: 20px;
}

/* ── Download History ────────────────────────────────────── */
.history-title {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.history-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.history-item-thumb {
  width: 100px;
  height: 100px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}

.history-item-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.history-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-type {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 8px;
  border-radius: 99px;
  flex-shrink: 0;
}

.history-item-link {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.history-item-link:hover { text-decoration: underline; }

/* ── Video Meta ──────────────────────────────────────────── */
.video-meta {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

#meta-thumb {
  width: 140px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--surface2);
}

.meta-details h2 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
}

.meta-details p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 3px;
}

/* ── Format Buttons ──────────────────────────────────────── */
.btn-format {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-format:hover { opacity: 0.88; }
.btn-format:active { transform: scale(0.98); }

/* ── Option Row (format/quality/bitrate/subtitle selects) ───── */
.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.option-row select {
  flex: 1;
  min-width: 120px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px; /* iOS Safari auto-zooms on focus if under 16px */
  padding: 10px 12px;
  outline: none;
  cursor: pointer;
}

.option-row select:focus { border-color: var(--primary); }

.btn-download {
  width: 100%;
  background: var(--primary);
  color: #fff;
}

.btn-download:hover { background: var(--primary-dark); opacity: 1; }

/* ── Playlist ────────────────────────────────────────────── */
.playlist-header {
  margin-bottom: 12px;
}

.playlist-header h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.select-all-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  cursor: pointer;
}

/* Bigger tap targets for checkboxes — default browser size is too small for touch */
#select-all-checkbox,
.playlist-item-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.playlist-items {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.88rem;
}

.playlist-item:last-child { border-bottom: none; }
.playlist-item:hover { background: var(--surface2); }

.playlist-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-item-duration {
  color: var(--text-muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ── Progress ────────────────────────────────────────────── */
.progress-gif {
  display: block;
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
}

#progress-label {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.progress-bar-track {
  background: var(--surface2);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #ff9c4d);
  border-radius: 99px;
  transition: width 0.4s ease;
}

#progress-pct {
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.progress-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Done ────────────────────────────────────────────────── */
.done-icon {
  font-size: 2.5rem;
  color: var(--green);
  text-align: center;
  margin-bottom: 8px;
}

.done-text {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.btn-download-file {
  display: block;
  text-align: center;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px;
  margin-bottom: 12px;
  transition: opacity 0.2s;
}

.btn-download-file:hover { opacity: 0.85; }

/* ── Error ───────────────────────────────────────────────── */
.error-icon {
  font-size: 2.5rem;
  color: var(--error);
  text-align: center;
  margin-bottom: 8px;
}

.error-text {
  text-align: center;
  color: var(--error);
  font-size: 0.95rem;
  margin-bottom: 20px;
  word-break: break-word;
}

/* ── Shared ──────────────────────────────────────────────── */
.btn-another {
  display: block;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 0.9rem;
  padding: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-another:hover { background: #2e2e2e; }

/* ── Footer ──────────────────────────────────────────────── */
footer {
  margin-top: auto;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  border-top: 1px solid var(--border);
  width: 100%;
}

/* ── Responsive ──────────────────────────────────────────── */

/* Tablets / iPad portrait */
@media (max-width: 768px) {
  main { padding: 24px 14px 40px; }
}

/* Phones */
@media (max-width: 480px) {
  .video-meta { flex-direction: column; }
  #meta-thumb { width: 100%; height: 180px; }
  .format-buttons { flex-direction: column; }
  .input-row { flex-direction: column; }
  #btn-fetch { width: 100%; }
  #btn-clear { width: 100%; }
  .option-row { flex-direction: column; }

  .history-item-thumb { width: 44px; height: 44px; }
  .history-item-type { font-size: 0.65rem; padding: 2px 6px; }
  .history-item-link { font-size: 0.75rem; }

  .playlist-item { font-size: 0.82rem; }
  .faq-item summary { font-size: 0.9rem; }
  .usp-item h3 { font-size: 0.95rem; }
}

/* Small phones (iPhone SE and similar) */
@media (max-width: 360px) {
  .history-item { gap: 8px; padding: 8px 10px; }
  .history-item-link { font-size: 0.72rem; }
}
