*{box-sizing:border-box}html,body,#app{margin:0;width:100%;height:100%;overflow:hidden;background:#000;color:#fff;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}body{position:fixed;inset:0}button,input,select{font:inherit}#app{position:fixed;inset:0;touch-action:manipulation}
#videoLayer,#playerHost{position:absolute;inset:0;width:100%;height:100%;overflow:hidden;background:#000;z-index:1}#ytFrame{position:absolute;border:0;display:block;background:#000}
.fit-contain #ytFrame{width:min(100vw,177.7778vh);height:min(56.25vw,100vh);left:50%;top:50%;transform:translate(-50%,-50%)}
.fit-cover #ytFrame{width:max(100vw,177.7778vh);height:max(56.25vw,100vh);left:50%;top:50%;transform:translate(-50%,-50%)}
#empty{position:absolute;inset:0;display:grid;place-content:center;gap:14px;text-align:center;background:#000;z-index:2}.play{font-size:64px}#empty button{justify-self:center;padding:10px 16px;border-radius:12px;border:0}
#chat{position:absolute;top:10px;right:10px;width:30vw;height:40vh;min-width:210px;min-height:160px;border:1px solid rgba(255,255,255,.16);border-radius:16px;overflow:hidden;background:rgba(0,0,0,.34);box-shadow:0 8px 24px rgba(0,0,0,.28);z-index:20;display:flex;flex-direction:column}
#handle{display:flex;justify-content:space-between;align-items:center;padding:7px 9px;font-size:12px;font-weight:700;background:rgba(0,0,0,.15);touch-action:none;user-select:none}#hideChat{width:26px;height:26px;border-radius:50%;border:0;color:#fff;background:rgba(255,255,255,.12)}
#status{padding:5px 9px;font-size:11px;opacity:.72;text-shadow:0 1px 2px #000}#messages{flex:1;overflow:auto;padding:3px 9px 10px;-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none}#messages::-webkit-scrollbar{display:none;width:0;height:0}
.msg{display:flex;gap:6px;margin:6px 0;align-items:flex-start}.avatar{width:22px;height:22px;border-radius:50%;object-fit:cover;background:rgba(255,255,255,.12);flex:0 0 22px}.txt{font-size:15px;line-height:1.3;text-shadow:0 1px 2px #000;overflow-wrap:anywhere}.author{font-size:10px;font-weight:700;opacity:.70;margin-bottom:1px}
#controls{position:absolute;left:50%;bottom:max(10px,env(safe-area-inset-bottom));transform:translateX(-50%);display:flex;gap:7px;padding:7px;border-radius:999px;background:rgba(0,0,0,.48);border:1px solid rgba(255,255,255,.14);z-index:30;transition:opacity .2s}#controls.hidden{opacity:0;pointer-events:none}#controls button{border:0;border-radius:999px;padding:8px 11px;color:#fff;background:rgba(255,255,255,.1);white-space:nowrap}
dialog{width:min(92vw,560px);border:0;background:transparent;padding:0}dialog::backdrop{background:rgba(0,0,0,.58)}.card{background:#fff;color:#111;border-radius:18px;padding:18px}.card h2{margin:0 0 8px}.hint{font-size:13px;color:#666;margin:0 0 12px}.card label{display:grid;gap:7px;margin:13px 0;font-weight:600}.card input[type=password],.card input:not([type]){padding:11px 12px;border:1px solid #bbb;border-radius:10px;width:100%}.check{display:flex!important;align-items:center;gap:9px!important}.quick,.actions{display:flex;gap:8px;flex-wrap:wrap}.quick{margin-top:9px}.actions{justify-content:flex-end;margin-top:17px}.actions button,.quick button,#resetPos{border:0;border-radius:10px;padding:9px 12px}.substatus{min-height:20px;margin-top:8px;font-size:12px;color:#555}.apiState{padding:9px 10px;border-radius:10px;background:#f3f3f3;font-size:13px}
body.lite #chat{box-shadow:none}body.lite .txt{text-shadow:0 1px 1px #000}
:fullscreen #chat,:-webkit-full-screen #chat{z-index:50}:fullscreen #controls,:-webkit-full-screen #controls{z-index:60}
@media(max-width:800px){#controls button{padding:7px 9px;font-size:13px}#chat{min-width:190px}}


/* v2.2 iPad/PWA tuning */
@supports (-webkit-touch-callout: none){
  html,body,#app{
    width:100%;
    height:100%;
    min-height:100dvh;
  }
}

/* v2.4 */
#chat{width:30vw;height:40vh}
#messages{scrollbar-width:none;-ms-overflow-style:none}
#messages::-webkit-scrollbar{display:none;width:0;height:0}


/* v2.5 favorites */
.favoritesCard{max-height:82vh;overflow:hidden}
.favAddRow{display:flex;gap:8px;align-items:center}
.favAddRow input{flex:1;min-width:0;padding:10px 12px;border:1px solid #bbb;border-radius:10px}
.favAddRow button,.favTopActions button,.favAction{
  border:0;border-radius:10px;padding:8px 10px
}
.favTopActions{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}
.favoritesList{
  margin-top:10px;
  max-height:50vh;
  overflow:auto;
  scrollbar-width:none;
  -ms-overflow-style:none;
}
.favoritesList::-webkit-scrollbar{display:none;width:0;height:0}
.favoriteRow{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
  align-items:center;
  padding:10px 0;
  border-bottom:1px solid #e5e5e5;
}
.favoriteMain{min-width:0}
.favoriteName{font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.favoriteHandle{font-size:12px;color:#666;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.favoriteMeta{display:flex;align-items:center;gap:7px;margin-top:4px;font-size:12px}
.liveBadge{
  display:inline-flex;
  align-items:center;
  padding:2px 6px;
  border-radius:999px;
  background:#d70000;
  color:#fff;
  font-size:11px;
  font-weight:800;
}
.offlineBadge{
  display:inline-flex;
  align-items:center;
  padding:2px 6px;
  border-radius:999px;
  background:#ddd;
  color:#555;
  font-size:11px;
  font-weight:700;
}
.favoriteActions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.favoriteActions button{font-size:12px}

/* v2.5.1 controls visibility */
#controls{
  max-width:calc(100vw - 16px);
  overflow-x:auto;
  scrollbar-width:none;
  -webkit-overflow-scrolling:touch;
}
#controls::-webkit-scrollbar{display:none}
#favorites{font-weight:700}
@media(max-width:900px){
  #controls{gap:5px;padding:6px}
  #controls button{font-size:12px;padding:7px 8px}
}


/* v2.5.4 favorite avatars */
.favoriteMainWrap{
  display:flex;
  align-items:center;
  gap:9px;
  min-width:0;
}
.favoriteAvatar{
  width:38px;
  height:38px;
  border-radius:50%;
  object-fit:cover;
  flex:0 0 38px;
  background:#ddd;
}
.favoriteMain{
  min-width:0;
}

/* v2.7.0 favorite tags */
.favTagsInput{width:100%;margin-top:8px;padding:9px 11px;border:1px solid #bbb;border-radius:10px}
#favoriteTagFilter{border:0;border-radius:10px;padding:8px 10px;background:#eee}
.favoriteTags{display:flex;flex-wrap:wrap;gap:5px;margin-top:5px}
.favoriteTagChip{border:0;border-radius:999px;padding:3px 7px;font-size:11px;background:#e8e8e8;color:#333}

/* v2.8.0 open favorites */
.openFavoritesSection{margin-top:12px;padding-top:10px;border-top:1px solid #e5e5e5}
.openFavoritesHeader{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
.openFavoritesHeader button{border:0;border-radius:9px;padding:6px 8px;font-size:12px}
.openFavoritesList{max-height:34vh;overflow:auto;scrollbar-width:none;-ms-overflow-style:none}
.openFavoritesList::-webkit-scrollbar{display:none}
.openFavoriteRow{width:100%;display:grid;grid-template-columns:36px 1fr auto;align-items:center;gap:9px;padding:8px 6px;border:0;border-bottom:1px solid #eee;background:transparent;text-align:left}
.openFavoriteAvatar{width:36px;height:36px;border-radius:50%;object-fit:cover;background:#ddd}
.openFavoriteText{min-width:0}.openFavoriteName{font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.openFavoriteSub{font-size:11px;color:#666;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.openFavoriteTags{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}.openFavoriteTag{font-size:10px;padding:2px 6px;border-radius:999px;background:#ededed;color:#444}
.openLiveBadge,.openOfflineBadge{padding:3px 7px;border-radius:999px;font-size:10px;font-weight:800}
.openLiveBadge{background:#d70000;color:#fff}.openOfflineBadge{background:#ddd;color:#666}
.openFavoriteEmpty{padding:14px 6px;color:#777;font-size:13px;text-align:center}

/* v2.9.0 data backup */
.dataBackupBlock{margin-top:14px;padding-top:12px;border-top:1px solid #e5e5e5}
.dataBackupActions{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.dataBackupActions button{border:0;border-radius:10px;padding:8px 10px}

/* v3.0.0 Twitch */
.twitchChatFrame{width:100%;height:100%;border:0;flex:1;background:#18181b}

/* v3.1.0 cloud sync */
.cloudSyncNote{
  margin-top:12px;
  padding:9px 10px;
  border-radius:10px;
  background:#eef6ff;
  color:#245;
  font-size:12px;
  font-weight:600;
}


/* v3.2.0 platform chat */
.platformSettings{
  margin-top:14px;
  padding:12px;
  border:1px solid #e3e3e3;
  border-radius:12px;
}
.platformSettings h3{
  margin:0 0 8px;
  font-size:15px;
}
.youtubeSettings{background:#fafafa}
.twitchSettings{
  background:#f5f0ff;
  border-color:#ded0ff;
}
.twitchChatFrame{
  width:100%;
  height:100%;
  min-height:0;
  border:0;
  flex:1;
  background:#18181b;
}
.twitchBadge,.openTwitchBadge,
.twitchLiveBadge,.openTwitchLiveBadge{
  display:inline-flex;
  align-items:center;
  padding:3px 7px;
  border-radius:999px;
  color:#fff;
  font-size:10px;
  font-weight:800;
}
.twitchBadge,.openTwitchBadge{background:#6441a5}
.twitchLiveBadge,.openTwitchLiveBadge{background:#9147ff}
.primaryFavAction{font-weight:700}


/* v3.3.0 Twitch overlay */
#chat.twitchOverlayMode{
  position:absolute;
  top:10px;
  right:10px;
  width:40vw;
  height:72vh;
  min-width:240px;
  min-height:220px;
  border-radius:16px;
  overflow:hidden;
  z-index:20;
  background:rgba(24,24,27,.92);
  border:1px solid rgba(255,255,255,.15);
  box-shadow:0 8px 24px rgba(0,0,0,.30);
}

#chat.twitchOverlayMode #handle{
  display:flex;
}

#chat.twitchOverlayMode #status,
#chat.twitchOverlayMode #messages{
  display:none !important;
}

#chat.twitchOverlayMode .twitchOverlayFrame{
  display:block !important;
  width:100%;
  height:100%;
  flex:1;
  border:0;
  background:#18181b;
  opacity:1;
}

/* Make Twitch overlay visually closer to YouTube overlay */
#chat.twitchOverlayMode #handle{
  background:rgba(0,0,0,.28);
  backdrop-filter:blur(2px);
  -webkit-backdrop-filter:blur(2px);
}

#chat.twitchOverlayMode #hideChat{
  background:rgba(255,255,255,.10);
}

/* Smaller default on compact iPad screens */
@media(max-width:1100px){
  #chat.twitchOverlayMode{
    width:36vw;
    height:58vh;
  }
}

/* v3.4.1 */
.favoritePlatformRow{display:flex;gap:8px;align-items:center}
.favoritePlatformRow select{border:1px solid #bbb;border-radius:10px;padding:10px}
.favoritePlatformRow input{flex:1}
.appVersion{font-size:11px;font-weight:700;color:#777}
#chat.twitchNativeOverlay{
  position:absolute;top:10px;right:10px;width:30vw;height:40vh;
  min-width:210px;min-height:160px;border:1px solid rgba(255,255,255,.16);
  border-radius:16px;overflow:hidden;background:rgba(0,0,0,.34);
  box-shadow:0 8px 24px rgba(0,0,0,.28);z-index:20;
  display:flex;flex-direction:column
}
#chat.twitchNativeOverlay #messages{display:block!important;flex:1;overflow:auto;padding:3px 9px 10px;scrollbar-width:none}
#chat.twitchNativeOverlay #messages::-webkit-scrollbar{display:none}
#chat.twitchNativeOverlay #status{display:block!important}
.twitchMsg{margin:6px 0}.twitchAuthor{font-size:10px;font-weight:800}
.twitchMessageText{line-height:1.3;text-shadow:0 1px 2px #000;overflow-wrap:anywhere}
.twitchEmote{height:1.35em;width:auto;vertical-align:-.22em;margin:0 1px}
