/* ===== Twitch-clone theme ===== */
:root {
  --purple: #9146ff;
  --purple-hover: #772ce8;
  --bg: #0e0e10;
  --bg-alt: #18181b;
  --bg-hover: #26262c;
  --bg-input: #2f2f35;
  --border: #2f2f35;
  --text: #efeff1;
  --text-dim: #adadb8;
  --live: #eb0400;
  --gold: #ffd37a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Roobert", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Top nav ===== */
.topnav {
  height: 50px;
  min-height: 50px;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.5);
  z-index: 10;
}

.topnav-left { display: flex; align-items: center; gap: 20px; }

.logo { display: flex; align-items: center; gap: 8px; }
.logo:hover { text-decoration: none; }
.logo-text { font-weight: 800; font-size: 18px; color: var(--text); letter-spacing: -.5px; }

.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-link { color: var(--text); font-weight: 600; font-size: 15px; }
.nav-link:hover, .nav-link.active { color: var(--purple); text-decoration: none; }
.nav-dots { font-weight: 800; letter-spacing: 2px; }

.topnav-center { flex: 1; display: flex; justify-content: center; padding: 0 20px; }
.search-box { display: flex; width: 100%; max-width: 400px; }
.search-box input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 6px 0 0 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search-box input:focus { border-color: var(--purple); background: #000; }
.search-btn {
  background: var(--bg-hover);
  border: none;
  border-radius: 0 6px 6px 0;
  color: var(--text-dim);
  padding: 0 10px;
  cursor: pointer;
}
.search-btn:hover { color: var(--text); }

.topnav-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
}
.icon-btn:hover { background: var(--bg-hover); }

.btn {
  border: none;
  border-radius: 4px;
  padding: 7px 12px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-hover); }
.btn-secondary { background: var(--bg-hover); }
.btn-secondary:hover { background: #3d3d44; }
.btn-sub { background: var(--bg-hover); }
.btn-sub:hover { background: #3d3d44; }
.btn.following { background: var(--bg-hover); }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #9146ff, #ff75e6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  cursor: pointer;
}

/* ===== Layout ===== */
.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-alt);
  overflow-y: auto;
  padding-bottom: 10px;
  transition: width .15s, min-width .15s;
}
.sidebar.collapsed { width: 50px; min-width: 50px; }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .ch-meta,
.sidebar.collapsed .ch-viewers { display: none; }
.sidebar.collapsed .collapse-btn svg { transform: rotate(180deg); }
.sidebar.collapsed .channel-item { justify-content: center; padding: 6px 0; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px;
}
.sidebar-title { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }

.sidebar-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 12px 4px;
  letter-spacing: .5px;
}

.channel-list { list-style: none; }
.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  cursor: pointer;
}
.channel-item:hover { background: var(--bg-hover); }
.channel-item.active { background: var(--bg-hover); }

.ch-avatar {
  width: 30px; height: 30px;
  min-width: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.ch-avatar.offline { filter: grayscale(1) brightness(.6); }

.ch-meta { flex: 1; min-width: 0; }
.ch-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-game { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ch-viewers {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-dim);
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
.offline-label { font-size: 11px; color: var(--text-dim); }

/* ===== Main ===== */
.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.player-wrap { background: #000; }
.player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 220px);
  background: #000;
  margin: 0 auto;
}
.player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.player-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--text-dim);
  padding: 20px;
}
.fallback-hint { font-size: 12px; max-width: 420px; }
.fallback-hint code { background: var(--bg-hover); padding: 1px 5px; border-radius: 3px; }

/* ===== Channel info ===== */
.channel-info {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  flex-wrap: wrap;
}
.channel-info-left { display: flex; gap: 14px; min-width: 0; }

.channel-avatar {
  position: relative;
  width: 60px; height: 60px; min-width: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #9146ff, #00c8af);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff;
}
.live-ring { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--live); }
.live-badge {
  position: absolute;
  bottom: -6px; left: 50%;
  transform: translateX(-50%);
  background: var(--live);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  border: 2px solid var(--bg);
}

.channel-meta { min-width: 0; }
.channel-name { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.stream-title { font-size: 14px; margin: 4px 0 6px; }
.stream-tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.category { color: var(--purple); font-weight: 600; font-size: 13px; }
.tag {
  background: var(--bg-hover);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}
.tag:hover { background: #3d3d44; cursor: pointer; }

.channel-info-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.action-row { display: flex; gap: 8px; }
.stat-row { display: flex; align-items: center; gap: 12px; }
.viewer-count { color: var(--live); display: flex; align-items: center; gap: 5px; font-size: 14px; }
.uptime { color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ===== About ===== */
.about-panel {
  margin: 10px 20px 30px;
  background: var(--bg-alt);
  border-radius: 8px;
  padding: 20px;
}
.about-panel h2 { font-size: 16px; margin-bottom: 10px; }
.about-panel p { margin-bottom: 8px; color: var(--text-dim); }
.about-panel p strong { color: var(--text); }

/* ===== Alien mascot: Thrum ===== */
.alien-panel {
  margin: 0 20px 30px;
  background: var(--bg-alt);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid var(--border);
}
.alien-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.alien-panel-head h2 { font-size: 16px; }
.alien-name { color: var(--gold); letter-spacing: 1px; }
.alien-species { font-size: 12px; color: var(--text-dim); }
.alien-mute { margin-left: auto; color: var(--text-dim); }
.alien-mute.muted { color: var(--live); }

.alien-stage {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 90%, rgba(0,200,175,.08), transparent 60%),
    linear-gradient(#0a0a0c, #131316);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
.alien-svg { display: block; width: 100%; max-height: 300px; }

.leg-line { fill: none; stroke: #8a5a24; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.joint { fill: #ffd37a; }
.foot { fill: #5c3a15; }

/* idle skitter + whisker sway */
.leg { transform-box: view-box; animation: legTwitch 2.6s ease-in-out infinite; }
.leg:nth-of-type(odd) { animation-delay: .4s; }
.leg:nth-of-type(3n) { animation-delay: .9s; animation-duration: 3.1s; }
@keyframes legTwitch {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(2.5deg); }
}
.whisker { transform-box: view-box; animation: whiskerSway 3.4s ease-in-out infinite; }
.whisker.w2 { animation-delay: 1.7s; }
@keyframes whiskerSway {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-7deg); }
}

#alienBody { transform-box: view-box; transform-origin: 160px 110px; }
#resonatorGlow, #resonatorVents { transition: opacity .2s; }

.alien-stage.speaking #alienBody { animation: bodyBob .28s ease-in-out infinite; }
@keyframes bodyBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.alien-stage.speaking #resonatorGlow { animation: resonate .28s ease-in-out infinite; }
@keyframes resonate {
  0%, 100% { opacity: .25; }
  50% { opacity: .9; }
}
.alien-stage.speaking #resonatorVents rect { fill: #7dfff0; }

/* floating musical notes */
.note-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float-note {
  position: absolute;
  bottom: 45%;
  font-size: 20px;
  color: #7dfff0;
  text-shadow: 0 0 8px rgba(0,200,175,.8);
  animation: noteRise 1.6s ease-out forwards;
}
@keyframes noteRise {
  0%   { transform: translateY(0) rotate(0deg) scale(.7); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translateY(-90px) rotate(18deg) scale(1.2); opacity: 0; }
}

/* translator console */
.alien-console { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.alien-chord-readout {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: #00c8af;
  background: #0a0a0c;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}
.alien-subtitle {
  min-height: 40px;
  font-size: 14px;
  color: var(--gold);
  background: #0a0a0c;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-style: italic;
}
.alien-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.alien-hint { font-size: 12px; color: var(--text-dim); }

/* ===== Chat ===== */
.chat {
  width: 340px;
  min-width: 340px;
  background: var(--bg-alt);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.chat-header {
  height: 45px;
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
}
.chat-title { font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--text-dim); }

.chat-embed { flex: 1; position: relative; }
.chat-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.chat-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-dim);
  text-align: center;
  padding: 16px;
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .sidebar { display: none; }
}
@media (max-width: 850px) {
  .app-body { flex-direction: column; overflow-y: auto; }
  body { overflow: auto; }
  .main { overflow: visible; }
  .chat { width: 100%; min-width: 0; height: 450px; border-left: none; border-top: 1px solid var(--border); }
  .channel-info-right { align-items: flex-start; }
  .topnav-center { display: none; }
}
