:root {
  --yt-bg: #fff8ef;
  --yt-surface: #ffffff;
  --yt-ink: #1b1b1f;
  --yt-muted: #5f6368;
  --yt-line: #ece3d6;
  --yt-red: #ff4d6d;
  --yt-red-deep: #e11d48;
  --yt-yellow: #ffd166;
  --yt-sky: #4cc9f0;
  --yt-mint: #06d6a0;
  --yt-purple: #7b2cbf;
  --yt-orange: #ff9f1c;
  --shadow: 0 10px 28px rgba(27, 27, 31, 0.08);
  --radius: 16px;
  --font-display: "Fredoka", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.yt-kids {
  color: var(--yt-ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 8% -10%, rgba(255, 209, 102, 0.55), transparent 28%),
    radial-gradient(circle at 92% 0%, rgba(76, 201, 240, 0.35), transparent 26%),
    linear-gradient(180deg, #fff3e0 0%, var(--yt-bg) 40%, #fff 100%);
}

a { color: var(--yt-purple); text-decoration: none; }
button, input { font: inherit; }

.yt-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--yt-line);
}
.yt-topbar-inner {
  width: min(1440px, calc(100% - 1.2rem));
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.7rem 0;
}
.yt-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--yt-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  white-space: nowrap;
}
.yt-logo {
  width: 2.2rem;
  height: 1.55rem;
  border-radius: 0.55rem;
  background: linear-gradient(135deg, var(--yt-red), var(--yt-orange));
  display: grid;
  place-items: center;
  box-shadow: 0 6px 14px rgba(255, 77, 109, 0.35);
}
.yt-logo-play {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid #fff;
  margin-left: 2px;
}
.yt-search {
  display: grid;
  grid-template-columns: 1fr auto;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  border: 2px solid var(--yt-line);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}
.yt-search input {
  border: 0;
  outline: 0;
  padding: 0.7rem 1rem;
  min-width: 0;
  background: transparent;
}
.yt-search button {
  border: 0;
  background: var(--yt-yellow);
  padding: 0 1.1rem;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
}
.yt-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; justify-content: end; }
.yt-btn {
  border: 2px solid var(--yt-line);
  background: #fff;
  color: var(--yt-ink);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font-weight: 800;
  cursor: pointer;
}
.yt-btn.primary {
  background: linear-gradient(135deg, var(--yt-red), var(--yt-orange));
  border-color: transparent;
  color: #fff;
}
.yt-btn.mini { padding: 0.4rem 0.75rem; font-size: 0.88rem; }
.yt-btn:hover { filter: brightness(1.03); transform: translateY(-1px); }

.yt-shell {
  width: min(1440px, calc(100% - 1.2rem));
  margin: 0.8rem auto 2rem;
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 1rem;
}
.yt-sidebar {
  position: sticky;
  top: 4.4rem;
  align-self: start;
  max-height: calc(100vh - 5rem);
  overflow: auto;
  background: rgba(255,255,255,0.88);
  border: 2px solid var(--yt-line);
  border-radius: 22px;
  padding: 0.75rem;
  display: grid;
  gap: 0.35rem;
}
.side-link {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  font-weight: 800;
  color: var(--yt-ink);
  cursor: pointer;
  text-decoration: none;
}
.side-link:hover, .side-link.active {
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.55), rgba(76, 201, 240, 0.35));
}
.side-label {
  margin-top: 0.55rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--yt-muted);
  font-weight: 800;
}
.side-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.side-chips .chip, .yt-chips-row .chip {
  border: 0;
  background: #fff;
  border: 1px solid var(--yt-line);
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--yt-ink);
  text-decoration: none;
}
.side-chips .chip.active, .yt-chips-row .chip.active {
  background: var(--yt-mint);
  border-color: transparent;
  color: #043b2d;
}
.side-note { color: var(--yt-muted); font-size: 0.8rem; margin: 0.35rem 0 0; }
.side-hint {
  margin: -0.1rem 0 0.15rem;
  color: var(--yt-muted);
  font-size: 0.75rem;
  font-weight: 700;
}
.side-chips.is-empty::after {
  content: "No matches for this selection";
  display: block;
  color: var(--yt-muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.2rem 0.45rem;
}
.side-chips .chip.locked-active,
.yt-chips-row .chip.locked-active {
  background: linear-gradient(135deg, var(--yt-orange), var(--yt-red));
  color: #fff;
  border-color: transparent;
}
.filter-path {
  margin: 0.35rem 0 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,209,102,.45), rgba(6,214,160,.22));
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.35;
}

.yt-main { min-width: 0; }
.yt-chips-row {
  display: none;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 0.4rem;
}
.yt-status {
  color: var(--yt-muted);
  font-weight: 700;
  margin: 0.2rem 0 0.8rem;
  min-height: 1.2rem;
}
.yt-empty {
  grid-column: 1 / -1;
  background: #fff;
  border: 2px dashed var(--yt-line);
  border-radius: 22px;
  padding: 1.4rem 1.5rem;
  max-width: 34rem;
}
.yt-empty h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
}
.yt-empty p {
  margin: 0 0 1rem;
  color: var(--yt-muted);
  line-height: 1.45;
}
.yt-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.yt-empty-form {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}
.yt-empty-form label {
  display: grid;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.92rem;
}
.yt-empty-form input {
  border: 2px solid var(--yt-line);
  border-radius: 14px;
  padding: 0.65rem 0.8rem;
  font: inherit;
}

.yt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem 1rem;
}
.yt-card {
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  display: grid;
  gap: 0.55rem;
  animation: rise 0.35s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.yt-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, #ffe8a3, #bdefff);
  box-shadow: var(--shadow);
}
.yt-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #f3f0ea;
}
.yt-thumb .play-badge {
  position: absolute;
  right: 0.55rem;
  bottom: 0.55rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(255, 77, 109, 0.95);
  display: grid;
  place-items: center;
}
.yt-thumb .play-badge::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid #fff;
  margin-left: 2px;
}
.yt-card-meta {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0.65rem;
  align-items: start;
}
.yt-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--yt-sky), var(--yt-purple));
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
}
.yt-card h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.3;
  font-weight: 800;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.yt-card .channel {
  color: var(--yt-muted);
  font-size: 0.86rem;
  margin-top: 0.15rem;
}

/* YouTube-style watch page: player left, up-next right */
body.watching .yt-sidebar { display: none; }
body.watching .yt-shell { grid-template-columns: 1fr; }
body.watching #home-view { display: none; }
body.watching #watch-view { display: grid; }

.watch-view {
  display: none;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.1rem;
  align-items: start;
}
.watch-primary { min-width: 0; display: grid; gap: 0.85rem; }
.watch-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f0f0f;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.watch-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.watch-meta h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  line-height: 1.25;
}
.watch-channel {
  color: var(--yt-muted);
  font-weight: 700;
  margin-top: 0.25rem;
}
.watch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.watch-rail {
  background: rgba(255,255,255,0.9);
  border: 2px solid var(--yt-line);
  border-radius: 18px;
  padding: 0.7rem;
  position: sticky;
  top: 4.5rem;
  max-height: calc(100vh - 5.2rem);
  overflow: auto;
}
.watch-rail-head {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0.15rem 0.35rem 0.65rem;
}
.watch-next-list { display: grid; gap: 0.45rem; }
.watch-next-item {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 0.55rem;
  align-items: start;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.35rem;
  border-radius: 12px;
  cursor: pointer;
  color: inherit;
}
.watch-next-item:hover,
.watch-next-item.active {
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.45), rgba(76, 201, 240, 0.28));
}
.watch-next-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #f3f0ea;
}
.watch-next-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.watch-next-item h3 {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.3;
  font-weight: 800;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.watch-next-item .channel {
  color: var(--yt-muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

@media (max-width: 1100px) {
  .watch-view { grid-template-columns: 1fr; }
  .watch-rail {
    position: static;
    max-height: none;
  }
}

.account-dialog {
  border: 0;
  border-radius: 24px;
  padding: 0;
  width: min(420px, calc(100vw - 2rem));
  box-shadow: var(--shadow);
  background: #fffaf2;
}
.account-dialog::backdrop { background: rgba(27, 27, 31, 0.45); }
.account-form { display: grid; gap: 0.75rem; padding: 1.3rem; }
.account-form h2 { margin: 0; font-family: var(--font-display); }
.account-form label { display: grid; gap: 0.3rem; font-weight: 800; }
.account-form input {
  border: 2px solid var(--yt-line);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
}
.dialog-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.fine { color: var(--yt-muted); font-size: 0.92rem; margin: 0; }
.status { color: var(--yt-muted); }

/* Onboarding + admin reuse */
.shell { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; }
.admin {
  width: min(820px, calc(100% - 2rem));
  margin: 2rem auto 4rem;
  background: rgba(255,255,255,0.92);
  border-radius: 28px;
  padding: 1.4rem;
  box-shadow: var(--shadow);
}
.admin h1, .admin h2 { font-family: var(--font-display); }
.admin label { display: grid; gap: 0.35rem; margin-bottom: 1rem; font-weight: 800; }
.admin input, .admin textarea, .admin select {
  width: 100%;
  border: 2px solid var(--yt-line);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  background: white;
}
.admin-save {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--yt-red), var(--yt-orange));
  color: #fff;
  font-weight: 800;
  padding: 0.8rem 1.2rem;
  cursor: pointer;
}
.chip {
  border: 1px solid var(--yt-line);
  background: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-weight: 800;
  cursor: pointer;
}
.steps {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0;
  margin: 0 0 1rem;
}
.steps li {
  background: #fff;
  border: 2px solid var(--yt-line);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--yt-muted);
}
.steps li.active { background: var(--yt-red); color: #fff; border-color: transparent; }
.steps li.done { background: var(--yt-mint); color: #043b2d; border-color: transparent; }
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}
.channel-card {
  text-align: left;
  border: 2px solid var(--yt-line);
  background: #fff;
  border-radius: 18px;
  padding: 0.9rem;
  cursor: pointer;
  display: grid;
  gap: 0.35rem;
  font: inherit;
}
.channel-card.active {
  border-color: var(--yt-mint);
  box-shadow: 0 0 0 3px rgba(6, 214, 160, 0.2);
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.35rem;
}
.playlist-tracks { padding-left: 1.2rem; color: var(--yt-muted); }
.hero { padding: 1.5rem 0 0.5rem; }
.brand h1 { font-family: var(--font-display); margin: 0; }
.logo-orb {
  width: 2.6rem; height: 2.6rem; border-radius: 30%;
  background: linear-gradient(145deg, var(--yt-yellow), var(--yt-red));
  display: inline-block;
}
.brand-mark { display: inline-flex; gap: 0.6rem; align-items: center; }

@media (max-width: 960px) {
  .yt-shell { grid-template-columns: 1fr; }
  .yt-sidebar { display: none; }
  .yt-chips-row { display: flex; }
  .yt-topbar-inner { grid-template-columns: auto 1fr; }
  .yt-actions { grid-column: 1 / -1; justify-content: start; }
}
@media (max-width: 640px) {
  .yt-brand-text { font-size: 1rem; }
  .yt-grid { grid-template-columns: 1fr; }
  .player-actions { flex-direction: column; align-items: stretch; }
}
