/* Brateng Music v2 — the jukebox. Layout follows the approved mockups
   (design/v2_mockups.html). One radius, one motion; kid layouts scale up
   via body.kid. */

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.45; overflow: hidden;
  transition: background 400ms ease;
}
button, input, select { font-family: var(--font); color: var(--text); }
button { background: none; border: 0; cursor: pointer; font-size: inherit; }

#app { height: 100%; }
#app.fade-in > * { animation: fadein var(--fade); }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }

.screen > * { height: 100%; display: flex; flex-direction: column; }

/* ---------- logo (lockup F) ---------- */
.logo { display: flex; align-items: center; gap: 16px; }
.logo-bars { display: flex; align-items: flex-end; gap: 5px; }
.logo-bars i {
  width: 8px; border-radius: 4px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}
.logo.live .logo-bars i { transform-origin: bottom; animation: eq 1.15s ease-in-out infinite; }
.logo.live .logo-bars i.b0 { animation-duration: 1.35s; }
.logo.live .logo-bars i.b1 { animation-delay: .18s; }
.logo.live .logo-bars i.b2 { animation-duration: .95s; animation-delay: .32s; }
.logo.live .logo-bars i.b3 { animation-delay: .1s; animation-duration: 1.5s; }
.logo.live .logo-bars i.b4 { animation-delay: .45s; }
@keyframes eq { 0%, 100% { transform: scaleY(.45) } 50% { transform: scaleY(1) } }
.logo-stack { text-align: center; }
.logo-name { font-weight: 650; letter-spacing: -.01em; }
.logo-pill {
  display: inline-block; margin-top: 7px; border: 1.5px solid var(--accent);
  border-radius: 999px; padding: 3px 15px; font-size: 11px; letter-spacing: .5em;
  text-indent: .5em; color: var(--accent-2); box-shadow: 0 0 16px var(--glow);
}

/* ---------- inline svg icons ---------- */
.ic-svg { display: inline-block; vertical-align: -3px; fill: currentColor; flex-shrink: 0; }
.tbtn .ic-svg, .home-btn .ic-svg, .gear .ic-svg { vertical-align: 0; }

/* ---------- shared chrome ---------- */
.topbar { display: flex; align-items: center; gap: 14px; padding: 18px var(--gutter) 12px; flex-shrink: 0; }

/* Compact logo lockup in the home topbar (Phil 2026-07-29) — same animated
   component as picker/enroll, scaled to chrome height. */
.topbar .logo { gap: 8px; flex-shrink: 0; }
.topbar .logo-bars { gap: 3px; }
.topbar .logo-bars i { width: 4px; border-radius: 2px; }
.topbar .logo-pill {
  font-size: 7.5px; padding: 1px 8px; margin-top: 3px; border-width: 1px;
  letter-spacing: .4em; text-indent: .4em; box-shadow: 0 0 10px var(--glow);
}
@media (max-width: 560px) { .topbar .logo-stack { display: none; } }
.chip {
  display: flex; align-items: center; gap: 9px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px 6px 7px;
  font-weight: 600; min-height: var(--touch);
}
.chip:active { transform: var(--press); }
.chip-ava {
  width: 32px; height: 32px; border-radius: 50%; display: grid;
  place-items: center; font-size: 17px;
}
.searchbox {
  flex: 1; text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 11px 18px; color: var(--text-dim); min-height: var(--touch);
}
.where-chip {
  display: flex; align-items: center; gap: 9px; font-weight: 650;
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--accent); border-radius: 999px; padding: 10px 16px;
  min-height: var(--touch); white-space: nowrap;
}
.where-chip:active { transform: var(--press); }
.where-chip .dot, .preset .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 8px var(--ok); flex-shrink: 0;
}
.gear { font-size: 20px; color: var(--text-dim); min-width: var(--touch); min-height: var(--touch); }

/* Right side + safe-area aware (Phil 2026-07-29: on iPhone the old fixed
   96px bottom sat under the npbar once the home-indicator inset grew it,
   and left-side placement fought the left-justified lists). */
.home-btn {
  position: absolute; right: var(--gutter); bottom: calc(108px + env(safe-area-inset-bottom, 0px));
  width: 52px; height: 52px;
  border-radius: var(--radius-sm); display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  z-index: 5; box-shadow: var(--shadow);
}
.home-btn:active { transform: var(--press); }
.npfull .home-btn, .lyrics .home-btn, .settings .home-btn {
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.sect {
  padding: 8px var(--gutter) 2px; color: var(--text-dim); font-size: 12.5px;
  letter-spacing: .12em; text-transform: uppercase; font-weight: 700;
}
.home-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 12px; }

.btn {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 15px; font-weight: 650; color: var(--accent-2); min-height: var(--touch);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn.primary { background: var(--accent); color: #fff; border: 0; }
.btn:active { transform: var(--press); }

.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--line); color: var(--text);
  padding: 11px 20px; border-radius: 999px; box-shadow: var(--shadow); z-index: 100;
  animation: fadein 150ms ease; max-width: 80vw; text-align: center;
}

/* ---------- sliders ---------- */
.slider { flex: 1; min-width: 70px; padding: 12px 0; touch-action: none; }
.slider-track { position: relative; height: 6px; border-radius: 3px; background: var(--surface-3); }
.slider-fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--accent); }
.slider-knob {
  position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transform: translate(-50%, -50%); box-shadow: 0 1px 6px rgba(0,0,0,.5);
}

/* ---------- enroll ---------- */
.enroll { align-items: center; justify-content: center; gap: 40px; }
.enroll-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 30px; width: min(400px, 90vw); display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
}
.enroll-card p { color: var(--text-dim); }
.enroll-card input {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 17px; outline: none;
}
.enroll-code { text-align: center; letter-spacing: .5em; font-size: 24px !important; }

/* ---------- picker ---------- */
.picker { align-items: center; justify-content: center; gap: 48px; }
.picker-cards { display: flex; gap: 26px; flex-wrap: wrap; justify-content: center; }
.pcard {
  width: 152px; padding: 26px 0 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 13px;
  transition: transform 120ms ease;
}
.pcard:active { transform: var(--press); }
.pcard-ava {
  width: 78px; height: 78px; border-radius: 50%; display: grid;
  place-items: center; font-size: 38px;
}
.pcard-name { font-size: 17px; font-weight: 650; }

/* ---------- overlays (theme/avatar, on <body> so WS renders can't kill them) */
.theme-overlay, .where-sheet-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(0, 0, 0, .45);
}
.where-sheet-overlay { backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.theme-overlay .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow); width: min(430px, 92vw);
}
.theme-overlay h2 { font-size: 17px; margin-bottom: 16px; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-opt {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.theme-opt.current { border-color: var(--accent); }
.theme-opt .swatch {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--bg)); border: 1px solid var(--line);
}
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.emoji-grid button {
  font-size: 26px; padding: 9px 0; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid transparent;
}
.emoji-grid button.current { border-color: var(--accent); }

/* ---------- home ---------- */
.sect-row { display: flex; align-items: stretch; gap: 16px; padding-right: var(--gutter); }
.sect-col { flex: 0 0 72%; min-width: 0; }
.recent-row { display: flex; gap: 14px; padding: 10px 0 4px var(--gutter); overflow-x: auto; scrollbar-width: none; }
.recent-row::-webkit-scrollbar { display: none; }
.mini { width: 116px; flex-shrink: 0; text-align: left; }
.mini:active { transform: var(--press); }
.mini .art {
  display: block; width: 100%; aspect-ratio: 1; border-radius: var(--radius-sm);
  background: var(--surface-2) center/cover no-repeat;
}
.mini .t {
  display: block; padding: 6px 2px 0; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-empty, .grid-empty { color: var(--text-dim); padding: 18px 8px; grid-column: 1/-1; }
.grid-empty .btn { margin-top: 10px; }
.songs-tile {
  margin: 30px 0 10px auto; width: 128px; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; font-weight: 700; font-size: 16px;
  background: linear-gradient(135deg, var(--accent), var(--surface-3));
  border: 1px solid var(--accent); color: #fff;
}
.songs-tile .ic { font-size: 30px; }
.songs-tile:active { transform: var(--press); }

.pl-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px; padding: 10px var(--gutter);
}
.tile { text-align: left; border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.tile:active { transform: var(--press); }
.tile .art {
  display: block; width: 100%; aspect-ratio: 1;
  background: var(--surface-2) center/cover no-repeat;
}
.tile .t { display: block; padding: 9px 12px 11px; font-weight: 600; font-size: 13.5px; }
.tile .t small { display: block; color: var(--text-dim); font-weight: 400; font-size: 11.5px; }
.skeleton .art, .skeleton .t {
  background: linear-gradient(100deg, var(--surface-2) 40%, var(--surface-3) 50%, var(--surface-2) 60%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; color: transparent;
}
@keyframes shimmer { to { background-position: -200% 0 } }

/* ---------- npbar ---------- */
.npbar {
  position: relative; flex-shrink: 0; background: var(--surface);
  border-top: 1px solid var(--line); cursor: pointer;
}
.np-hairline {
  position: absolute; top: -1px; left: 0; height: 2px; background: var(--accent);
  box-shadow: 0 0 8px var(--glow); transition: width 1s linear; z-index: 2;
}
.npbar-in { display: flex; align-items: center; gap: 14px; padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom, 0px)); min-height: 72px; }
.npbar-empty { color: var(--text-dim); padding: 6px 2px; }
.np-thumb {
  width: 52px; height: 52px; border-radius: var(--radius-sm); object-fit: cover;
  background: var(--surface-2); flex-shrink: 0;
}
.np-meta { min-width: 0; margin-right: auto; }
.np-meta b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-meta span { color: var(--text-dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.tbtn {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 17px; flex-shrink: 0;
}
.tbtn:active { transform: var(--press); }
.tbtn.play { width: 54px; height: 54px; background: var(--accent); border: 0; font-size: 20px; color: #fff; }
.tbtn.on { border-color: var(--accent); color: var(--accent-2); }
.np-vol { display: flex; align-items: center; gap: 8px; flex: 0 1 220px; min-width: 110px; }
.np-vol-ic { color: var(--text-dim); }
.lyr-btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 9px 14px; font-size: 13px; color: var(--accent-2); font-weight: 650; flex-shrink: 0;
}
.lyr-btn.on, .lyr-btn:active { border-color: var(--accent); }

/* ---------- where sheet ---------- */
.where-sheet {
  width: min(860px, 92vw); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px 26px; box-shadow: var(--shadow);
}
.where-sheet h3 { font-size: 17px; margin-bottom: 3px; }
.where-cap { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }
.where-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.preset {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 10px;
  background: var(--surface-2); min-height: 64px; display: flex; align-items: center;
  justify-content: center; gap: 8px; text-align: center; font-weight: 650; font-size: 13.5px;
  line-height: 1.25;
}
.preset:active { transform: var(--press); }
.preset .dot { display: none; }
.preset.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
  box-shadow: 0 0 0 1px var(--accent), 0 6px 22px var(--glow);
}
.preset.active .dot { display: inline-block; }
.where-vol { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: var(--text-dim); }
.where-vol b { min-width: 44px; text-align: right; color: var(--text); }

/* ---------- now playing full ---------- */
.npfull { position: relative; }
.np-tint { position: absolute; inset: 0; pointer-events: none; transition: background 600ms ease; }
.npfull .topbar, .npfull-body { position: relative; z-index: 1; }
.npfull-body {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 0 var(--gutter) 28px; min-height: 0;
}
.np-bigart {
  width: min(34vh, 62vw); aspect-ratio: 1; border-radius: var(--radius);
  object-fit: cover; background: var(--surface-2); box-shadow: 0 26px 60px rgba(0,0,0,.55);
}
.np-title { font-size: 23px; text-align: center; }
.np-artist { color: var(--text-dim); margin-top: -10px; text-align: center; }
.np-prog { width: min(560px, 88vw); display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: 12.5px; }
.np-trans { display: flex; align-items: center; gap: 18px; }
.np-trans .tbtn { width: 54px; height: 54px; font-size: 20px; }
.np-trans .tbtn.play { width: 70px; height: 70px; font-size: 26px; }
.npfull-body .np-vol { flex: 0 1 auto; width: min(340px, 80vw); }
.lyr-btn.big { font-size: 15px; padding: 11px 20px; }

/* ---------- lyrics ---------- */
.lyrics { position: relative; }
.lyrics-body {
  flex: 1; overflow-y: auto; padding: 10vh 28px 22vh; text-align: center;
  scroll-behavior: smooth; overscroll-behavior: contain;
}
.lyrics-body .line {
  color: var(--text-dim); opacity: .55; font-size: 18px; font-weight: 600;
  padding: 7px 0; transition: all 200ms ease;
}
.lyrics-body .line.near { opacity: .8; font-size: 19px; }
.lyrics-body .line.now {
  color: var(--text); opacity: 1; font-size: 26px; font-weight: 750;
  text-shadow: 0 0 26px var(--glow);
}
.lyrics-body.plain .line { opacity: .9; font-size: 17px; }
.lyrics-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 22vh; color: var(--text-dim); }
.lyrics-empty .big { font-size: 44px; }
.lyrics-foot {
  flex-shrink: 0; display: flex; align-items: center; gap: 14px;
  padding: 12px var(--gutter) calc(16px + env(safe-area-inset-bottom, 0px)) 96px; border-top: 1px solid var(--line); background: var(--surface);
}
.lf-meta { min-width: 0; margin-right: auto; }
.lf-meta b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lf-meta span { color: var(--text-dim); font-size: 12px; }

/* ---------- search / playlist ---------- */
.search-input {
  flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 12px 20px; font-size: 16px; outline: none; min-height: var(--touch);
}
.search-input:focus { border-color: var(--accent); }
.song-list { display: flex; flex-direction: column; padding: 6px var(--gutter); }
.song-row {
  display: flex; align-items: center; gap: 13px; padding: 8px 6px; text-align: left;
  border-radius: var(--radius-sm); min-height: 58px;
}
.song-row:active { background: var(--surface-2); }
.song-row .art {
  width: 46px; height: 46px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: var(--surface-2) center/cover no-repeat;
}
.sr-meta { min-width: 0; margin-right: auto; }
.sr-meta b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-meta span { color: var(--text-dim); font-size: 12.5px; }
.sr-dur { color: var(--text-dim); font-size: 12.5px; }
.sr-tag { color: var(--text-dim); font-size: 11px; border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; }
.song-row.dead { opacity: .45; }
.song-row.current {
  background: var(--surface-2); border: 1px solid var(--accent);
  box-shadow: 0 0 14px var(--glow);
}
.q-n { width: 28px; text-align: right; color: var(--text-dim); font-size: 12px; flex-shrink: 0; }
.back-btn { color: var(--accent-2); font-weight: 650; min-height: var(--touch); font-size: 15px; }
.np-actions { display: flex; gap: 12px; }
.pl-head { display: flex; gap: 18px; padding: 14px var(--gutter) 4px; align-items: center; }
.pl-head .art {
  width: 110px; height: 110px; border-radius: var(--radius); flex-shrink: 0;
  background: var(--surface-2) center/cover no-repeat;
}
.pl-head-meta h2 { font-size: 21px; }
.pl-count { color: var(--text-dim); margin: 3px 0 10px; }

/* ---------- settings ---------- */
.settings-title { flex: 1; text-align: center; font-weight: 700; font-size: 16px; }
.set-grid {
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; padding: 4px var(--gutter) 24px;
  align-items: start;
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.card h3 { font-size: 14px; margin-bottom: 10px; }
.spk { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--surface-2); }
.spk:last-child { border-bottom: 0; }
.spk-name { width: 165px; font-weight: 600; font-size: 13.5px; flex-shrink: 0; }
.spk-unjoin { color: var(--danger); font-size: 13px; min-width: 30px; }
.spk-join {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px;
  font-size: 11.5px; color: var(--text-dim); max-width: 110px; padding: 4px;
}
.dev-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--surface-2); }
.dev-row:last-child { border-bottom: 0; }
.dev-meta small { display: block; color: var(--text-dim); }
.dev-code-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.dev-code {
  font-size: 26px; font-weight: 800; letter-spacing: .3em; color: var(--accent-2);
  background: var(--surface-2); border: 1px dashed var(--accent); border-radius: var(--radius-sm);
  padding: 8px 16px;
}
.dev-hint { color: var(--text-dim); font-size: 12px; margin-top: 10px; }

/* ---------- kid scaling ---------- */
body.kid { font-size: 17px; }
body.kid .tile .t { font-size: 16px; padding: 11px 14px 13px; }
body.kid .pl-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
body.kid .tbtn { width: 56px; height: 56px; font-size: 21px; }
body.kid .tbtn.play { width: 66px; height: 66px; font-size: 25px; }
body.kid .np-trans .tbtn { width: 64px; height: 64px; font-size: 24px; }
body.kid .np-trans .tbtn.play { width: 84px; height: 84px; font-size: 32px; }
body.kid .npbar-in { min-height: 84px; }
body.kid .lyr-btn { font-size: 15px; padding: 11px 18px; }
body.kid .mini { width: 132px; }
body.kid .mini .t { font-size: 14px; }
body.kid .where-grid { grid-template-columns: repeat(3, 1fr); }
body.kid .preset { min-height: 76px; font-size: 15.5px; }
body.kid .lyrics-body .line.now { font-size: 30px; }

/* ---------- narrow screens ---------- */
@media (max-width: 720px) {
  .where-grid { grid-template-columns: repeat(2, 1fr); }
  .set-grid { grid-template-columns: 1fr; }
  .sect-col { flex-basis: 64%; }
  .np-vol { display: none; }
  .npfull-body .np-vol { display: flex; }
  .chip-name { display: none; }
}
