/* PappaTube – hand-written CSS, no build step, no external fonts */
:root {
  --bg: #FFFBEB;
  --dot: #FDE68A;
  --ink: #1E293B;
  --muted: #64748B;
  --amber: #F59E0B;
  --amber-d: #D97706;
  --rose: #F43F5E;
  --card: #FFFFFF;
  --line: #E2E8F0;
  --radius: 22px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  min-height: 100vh;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
img { -webkit-user-drag: none; user-select: none; }
input { font: inherit; user-select: text; -webkit-user-select: text; }
code { background: #F1F5F9; padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* press effect */
.kid-press, .channel-tile, .video-card, .tab, .shuffle-btn, .back-btn, .kbtn, .pbtn, .pin-pad button, .brand, .parent-btn {
  transition: transform .16s cubic-bezier(.34,1.56,.64,1), box-shadow .16s ease, background-color .16s;
}
.channel-tile:active, .video-card:active, .tab:active, .shuffle-btn:active, .back-btn:active,
.kbtn:active, .pbtn:active, .pin-pad button:active, .brand:active, .parent-btn:active { transform: scale(.95); }

/* ---------------- header ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + var(--safe-top)) 18px 10px;
  background: rgba(255,255,255,.95);
  border-bottom: 4px solid #FDE68A;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 15px;
  background: linear-gradient(135deg, #FBBF24, #F97316 55%, #F43F5E);
  display: grid; place-items: center; box-shadow: 0 3px 8px rgba(249,115,22,.35);
}
.brand-logo svg { width: 26px; height: 26px; fill: #fff; margin-left: 3px; }
.brand-text { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.tabs { display: flex; gap: 8px; margin-left: auto; }
.tab {
  padding: 10px 18px; border-radius: 18px; font-size: 19px; font-weight: 700;
  background: #fff; border: 3px solid var(--line);
}
.tab.active { background: var(--amber); border-color: var(--amber-d); color: #fff; box-shadow: 0 3px 8px rgba(217,119,6,.3); }
.parent-btn {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center;
  background: #F1F5F9; color: #94A3B8; border: 2px solid var(--line);
}
.parent-btn svg { width: 22px; height: 22px; }

/* ---------------- content ---------------- */
.main { max-width: 1400px; margin: 0 auto; padding: 18px 18px calc(40px + var(--safe-bottom)); }
.section-title { font-size: 24px; font-weight: 800; margin: 8px 0 14px; color: #334155; display: flex; align-items: center; gap: 8px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.list-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.list-title .section-title { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-btn {
  width: 52px; height: 52px; border-radius: 18px; background: var(--amber); color: #fff;
  display: grid; place-items: center; box-shadow: 0 3px 8px rgba(217,119,6,.3); flex-shrink: 0;
}
.back-btn svg { width: 28px; height: 28px; }
.shuffle-btn {
  padding: 11px 18px; border-radius: 18px; font-size: 18px; font-weight: 800;
  background: #8B5CF6; color: #fff; box-shadow: 0 3px 10px rgba(139,92,246,.35); white-space: nowrap;
}
#view-list .list-head { margin-top: 4px; margin-bottom: 16px; }

/* channel tiles */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.channel-tile {
  display: flex; align-items: center; gap: 14px; padding: 14px; text-align: left;
  border-radius: var(--radius); border: 4px solid; box-shadow: 0 2px 6px rgba(0,0,0,.05);
}
.channel-icon { width: 70px; height: 70px; border-radius: 18px; display: grid; place-items: center; font-size: 42px; flex-shrink: 0; }
.channel-name { font-size: 20px; font-weight: 800; line-height: 1.15; }
.channel-count { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 800; padding: 2px 10px; border-radius: 99px; }

.c-pink   { background: #FDF2F8; border-color: #FBCFE8; } .c-pink .channel-icon { background: #FBCFE8; } .c-pink .channel-count, .b-pink { background: #FCE7F3; color: #9D174D; }
.c-sky    { background: #F0F9FF; border-color: #BAE6FD; } .c-sky .channel-icon { background: #BAE6FD; } .c-sky .channel-count, .b-sky { background: #E0F2FE; color: #075985; }
.c-amber  { background: #FFFBEB; border-color: #FDE68A; } .c-amber .channel-icon { background: #FDE68A; } .c-amber .channel-count, .b-amber { background: #FEF3C7; color: #92400E; }
.c-green  { background: #ECFDF5; border-color: #A7F3D0; } .c-green .channel-icon { background: #A7F3D0; } .c-green .channel-count, .b-green { background: #D1FAE5; color: #065F46; }
.c-purple { background: #FAF5FF; border-color: #E9D5FF; } .c-purple .channel-icon { background: #E9D5FF; } .c-purple .channel-count, .b-purple { background: #F3E8FF; color: #6B21A8; }
.c-rose   { background: #FFF1F2; border-color: #FECDD3; } .c-rose .channel-icon { background: #FECDD3; } .c-rose .channel-count, .b-rose { background: #FFE4E6; color: #9F1239; }

/* video cards */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.video-card {
  position: relative; background: var(--card); border-radius: var(--radius); overflow: hidden;
  border: 4px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.07); text-align: left; display: flex; flex-direction: column;
}
.thumb { position: relative; aspect-ratio: 16 / 9; background: #0F172A; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .play-dot {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 58px; height: 58px; border-radius: 50%; background: rgba(245,158,11,.95);
  border: 4px solid #fff; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
.thumb .play-dot svg { width: 26px; height: 26px; fill: #fff; margin-left: 3px; }
.thumb .ch-badge { position: absolute; left: 8px; top: 8px; font-size: 13px; font-weight: 800; padding: 4px 10px; border-radius: 12px; max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .watched-badge {
  position: absolute; left: 8px; bottom: 8px; background: rgba(16,185,129,.95); color: #fff;
  font-size: 13px; font-weight: 800; padding: 4px 10px; border-radius: 12px;
}
.thumb .progress-line { position: absolute; left: 0; bottom: 0; height: 6px; background: var(--rose); }
.video-card.watched .thumb img { filter: saturate(.55) brightness(.85); }
.video-title {
  padding: 12px 14px 14px; font-size: 17px; font-weight: 700; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.fav-btn {
  position: absolute; right: 8px; top: 8px; z-index: 2;
  width: 48px; height: 48px; border-radius: 50%; font-size: 26px; line-height: 1;
  background: rgba(255,255,255,.92); box-shadow: 0 2px 8px rgba(0,0,0,.2); display: grid; place-items: center;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.fav-btn.on { background: #FDE047; }
.fav-btn:active { transform: scale(.85); }
.fav-btn.pop { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.35); } }

.empty { text-align: center; padding: 50px 20px; background: #fff; border: 4px dashed #FCD34D; border-radius: 28px; font-size: 20px; font-weight: 700; color: #475569; max-width: 560px; margin: 30px auto; }
.empty .big { font-size: 60px; display: block; margin-bottom: 10px; }

/* ---------------- player ---------------- */
.player { position: fixed; inset: 0; z-index: 40; background: #000; overflow: hidden; }
.player-stage { position: absolute; inset: 0; }
.player-stage iframe { width: 100%; height: 100%; border: 0; display: block; pointer-events: none; }
.tap-layer { position: absolute; inset: 0; z-index: 2; }
.controls { position: absolute; left: 0; right: 0; z-index: 4; display: flex; align-items: center; gap: 10px; transition: opacity .3s, transform .3s; }
.player.idle .controls { opacity: 0; pointer-events: none; }
.player.idle .player-top { transform: translateY(-20px); }
.player.idle .player-bottom { transform: translateY(20px); }
.player-top { top: 0; padding: calc(12px + var(--safe-top)) 14px 40px; background: linear-gradient(#000 0%, rgba(0,0,0,.85) 55%, transparent); }
.player-bottom { bottom: 0; padding: 40px 14px calc(14px + var(--safe-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.85) 45%, #000); }
.player-title { flex: 1; min-width: 0; color: #fff; }
.player-title > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#player-title { font-size: 18px; font-weight: 800; }
#player-channel { font-size: 14px; color: #94A3B8; }
.pbtn {
  min-width: 56px; height: 56px; padding: 0 14px; border-radius: 18px;
  background: rgba(51,65,85,.9); color: #fff; font-size: 20px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex-shrink: 0;
}
.pbtn.back { background: var(--rose); padding: 0 18px; }
.pbtn.back svg { width: 24px; height: 24px; }
.pbtn.playpause { background: var(--amber); min-width: 68px; font-size: 22px; }
.pbtn.star { font-size: 30px; }
.pbtn.star.on { background: #FDE047; color: #000; }
.progress { position: relative; flex: 1; height: 56px; cursor: pointer; touch-action: none; }
.progress::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 10px; margin-top: -5px; border-radius: 6px; background: rgba(255,255,255,.25); }
.progress-fill { position: absolute; left: 0; top: 50%; height: 10px; margin-top: -5px; border-radius: 6px; background: var(--amber); width: 0; }
.progress-knob { position: absolute; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: #fff; border: 4px solid var(--amber); left: 0; }
.time { color: #fff; font-weight: 800; font-size: 16px; min-width: 96px; text-align: center; font-variant-numeric: tabular-nums; }

.pause-cover, .loading-cover, .end-cover { position: absolute; inset: 0; display: grid; place-items: center; }
.pause-cover { z-index: 3; background: rgba(0,0,0,.72); }
.loading-cover { z-index: 3; background: #000; }
.end-cover { z-index: 6; background: rgba(15,23,42,.96); }
.big-play { width: 130px; height: 130px; border-radius: 50%; background: var(--amber); border: 6px solid #fff; display: grid; place-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.big-play svg { width: 60px; height: 60px; fill: #fff; margin-left: 8px; }
.spinner { width: 60px; height: 60px; border-radius: 50%; border: 7px solid rgba(255,255,255,.2); border-top-color: var(--amber); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.end-card { text-align: center; color: #fff; padding: 20px; }
.end-card h2 { font-size: 40px; margin: 6px 0 26px; }
.end-emoji { font-size: 80px; }
.end-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }

/* ---------------- buttons ---------------- */
.kbtn { padding: 12px 20px; border-radius: 16px; font-size: 17px; font-weight: 800; background: #F1F5F9; color: #334155; border: 2px solid var(--line); }
.end-actions .kbtn { font-size: 22px; padding: 16px 26px; border-radius: 22px; }
.kbtn.primary { background: var(--amber); color: #fff; border-color: var(--amber-d); }
.kbtn.danger { background: #FFF1F2; color: #BE123C; border-color: #FECDD3; }
.kbtn.small-btn { font-size: 14px; padding: 7px 12px; border-radius: 12px; }

/* ---------------- PIN ---------------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(15,23,42,.75); display: grid; place-items: center; padding: 16px; }
.modal-card { background: #fff; border-radius: 28px; padding: 22px; width: 100%; max-width: 360px; border: 4px solid #FDE68A; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 24px; }
.x-btn { width: 40px; height: 40px; border-radius: 50%; background: #F1F5F9; font-weight: 800; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 22px 0 8px; }
.pin-dots i { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #CBD5E1; background: #F1F5F9; transition: all .15s; }
.pin-dots i.on { background: var(--amber); border-color: var(--amber); transform: scale(1.12); }
.pin-msg { text-align: center; color: var(--rose); font-weight: 700; font-size: 14px; min-height: 20px; margin: 0 0 10px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-pad button { padding: 15px 0; font-size: 26px; font-weight: 800; background: #F1F5F9; border-radius: 18px; }
.pin-pad button.soft { font-size: 16px; color: #64748B; }
.pin-pad.locked { opacity: .4; pointer-events: none; }
.shake { animation: shake .35s; }
@keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }

/* ---------------- parent ---------------- */
.parent { position: fixed; inset: 0; z-index: 50; background: #F8FAFC; overflow-y: auto; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: text; -webkit-user-select: text; }
.parent-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: calc(14px + var(--safe-top)) 22px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.parent-head h2 { margin: 0; font-size: 22px; }
.parent-body { max-width: 900px; margin: 0 auto; padding: 20px 16px 60px; display: flex; flex-direction: column; gap: 18px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 18px 20px; }
.card h3 { margin: 0 0 6px; font-size: 19px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.form-row input { flex: 1 1 200px; padding: 11px 14px; border: 2px solid var(--line); border-radius: 14px; font-size: 16px; outline: none; }
.form-row input:focus { border-color: var(--amber); }
.form-row input.emoji-input { flex: 0 0 72px; width: 72px; max-width: 72px; text-align: center; }
.form-row.narrow { max-width: 420px; }
.parent-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.p-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 16px; flex-wrap: wrap; }
.p-row.off { opacity: .55; background: #F1F5F9; }
.p-emoji { font-size: 30px; width: 46px; height: 46px; display: grid; place-items: center; background: #F1F5F9; border-radius: 12px; flex-shrink: 0; }
.p-info { flex: 1; min-width: 180px; }
.p-name { font-weight: 800; }
.p-meta { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.p-meta.err { color: #BE123C; }
.p-actions { display: flex; gap: 8px; margin-left: auto; }
.row-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.steps { padding-left: 20px; line-height: 1.6; }
.ok { color: #047857; } .bad { color: #BE123C; } .info { color: #0369A1; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); z-index: 80; background: #0F172A; color: #fff; padding: 12px 20px; border-radius: 16px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: 90vw; text-align: center; }

/* ---------------- smaller screens / portrait ---------------- */
@media (max-width: 760px) {
  .brand-text { font-size: 22px; }
  .tab span { display: none; }
  .tab { padding: 10px 14px; font-size: 22px; }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .shuffle-btn span { display: none; }
  .shuffle-btn { font-size: 24px; padding: 10px 16px; }
  .pbtn[data-action="rewind"], .pbtn[data-action="forward"] { display: none; }
  .time { min-width: 0; font-size: 14px; }
}

/* channel pictures */
.avatar { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: #fff; }
.channel-icon .avatar { width: 62px; height: 62px; box-shadow: 0 0 0 3px #fff; }
.emoji-icon { line-height: 1; }
.avatar.mini, .emoji-icon.mini { display: inline-block; width: 18px; height: 18px; vertical-align: -4px; font-size: 14px; box-shadow: none; }
#player-channel .avatar.mini { width: 20px; height: 20px; vertical-align: -5px; }
.avatar.title-avatar { width: 40px; height: 40px; box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(0,0,0,.15); }
.p-emoji .avatar { width: 40px; height: 40px; }
