:root {
  --bg: #050507;
  --surface: rgba(34, 35, 39, 0.88);
  --surface-solid: #222327;
  --surface-hover: #34353b;
  --border: #3c3e45;
  --border-focus: #8f939d;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --ok: #86efac;
  --warn: #fcd34d;
  --err: #fca5a5;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --accent: #a78bfa;
  --accent-strong: #8b5cf6;
  --accent-soft: rgba(167, 139, 250, 0.16);
  --accent-ring: 0 0 0 3px rgba(167, 139, 250, 0.28);
  --glass: rgba(22, 23, 28, 0.72);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  scroll-behavior: smooth;
}

.hidden {
  display: none !important;
}

/* GPU-Composited Animated Black Background */
.bg-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, #111216 0%, #060608 55%, #020203 100%);
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform, opacity;
  transform: translate3d(0, 0, 0);
}

.bg-orb-a {
  width: 72vmax;
  height: 72vmax;
  top: -22vmax;
  left: -14vmax;
  background: radial-gradient(circle, rgba(58, 60, 68, 0.28) 0%, rgba(28, 29, 34, 0.1) 42%, transparent 70%);
  animation: orb-float-a 22s var(--ease-in-out) infinite alternate;
}

.bg-orb-b {
  width: 68vmax;
  height: 68vmax;
  right: -16vmax;
  bottom: -24vmax;
  background: radial-gradient(circle, rgba(46, 48, 56, 0.3) 0%, rgba(20, 21, 25, 0.12) 45%, transparent 72%);
  animation: orb-float-b 26s var(--ease-in-out) infinite alternate;
}

@keyframes orb-float-a {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 0.78;
  }
  50% {
    transform: translate3d(14vw, 9vh, 0) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translate3d(6vw, 18vh, 0) scale(0.96);
    opacity: 0.82;
  }
}

@keyframes orb-float-b {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 0.85;
  }
  50% {
    transform: translate3d(-12vw, -10vh, 0) scale(1.07);
    opacity: 0.65;
  }
  100% {
    transform: translate3d(-6vw, -18vh, 0) scale(1.02);
    opacity: 0.95;
  }
}

.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

@keyframes view-enter {
  from {
    opacity: 0;
    transform: translate3d(0, 10px, 0) scale(0.992);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* Top Nav */
.top-nav {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.mode-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: color 0.2s var(--ease-out), background-color 0.2s var(--ease-out),
    border-color 0.2s var(--ease-out), transform 0.16s var(--ease-out);
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn:active {
  transform: scale(0.96);
}

.mode-btn.active {
  background: var(--surface-hover);
  border-color: var(--border);
  color: #ffffff;
}

.nav-divider {
  width: 1px;
  height: 18px;
  align-self: center;
  background: var(--border);
  margin: 0 2px;
}

.account-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.account-nav-btn.signed-in {
  color: #ffffff;
}

.nav-pfp {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* Home */
.home-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 72px 24px 24px;
  animation: view-enter 0.34s var(--ease-out) both;
}

.home-box {
  width: 100%;
  max-width: 560px;
  text-align: center;
}

.simple-title {
  margin: 0 0 24px;
  font-size: clamp(3rem, 8vw, 4.75rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  background: linear-gradient(90deg, #ffffff 0%, #9a9aa0 55%, #000000 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.28)) drop-shadow(0 8px 24px rgba(0, 0, 0, 0.9));
  user-select: none;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  transition: border-color 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out),
    transform 0.22s var(--ease-out);
}

.search-form:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 9px 12px;
}

.search-input::placeholder {
  color: #7c7f87;
}

.search-btn {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 18px;
  cursor: pointer;
  transition: background-color 0.18s var(--ease-out), transform 0.14s var(--ease-out);
}

.search-btn:hover {
  background: #45474f;
}

.search-btn:active {
  transform: scale(0.96);
}

.engine-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.engine-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 11px;
  cursor: pointer;
  transition: color 0.18s var(--ease-out), background-color 0.18s var(--ease-out),
    border-color 0.18s var(--ease-out), transform 0.16s var(--ease-out);
}

.engine-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.engine-btn:active {
  transform: translateY(0) scale(0.96);
}

.engine-btn.active {
  color: #ffffff;
  background: #42444c;
  border-color: var(--border-focus);
}

.status-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  transition: background-color 0.3s var(--ease-out);
}

.status-dot.ready {
  background: #e5e7eb;
}

.status-dot.error {
  background: var(--err);
}

/* Games Catalog View */
.games-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 76px 24px 36px;
  animation: view-enter 0.34s var(--ease-out) both;
}

.games-inner {
  max-width: 1120px;
  margin: 0 auto;
}

.games-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.games-heading {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #f3f4f6;
}

.games-count {
  font-size: 12.5px;
  color: var(--text-muted);
}

.games-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.games-filter {
  width: 260px;
  max-width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.games-filter:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.games-status {
  padding: 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13.5px;
  text-align: center;
  margin-bottom: 16px;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 12px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  will-change: transform;
  transition: transform 0.24s var(--ease-out), border-color 0.24s var(--ease-out),
    background-color 0.24s var(--ease-out), box-shadow 0.24s var(--ease-out);
}

.game-card:hover {
  transform: translate3d(0, -3px, 0);
  background: var(--surface-hover);
  border-color: var(--border-focus);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.45);
}

.game-card:active {
  transform: translate3d(0, -1px, 0) scale(0.985);
}

.game-fav-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 2;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(14, 15, 18, 0.78);
  color: rgba(255, 255, 255, 0.65);
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s var(--ease-out), color 0.16s var(--ease-out),
    background-color 0.16s var(--ease-out);
}

.game-card:hover .game-fav-btn,
.game-fav-btn.active {
  opacity: 1;
}

.game-fav-btn.active {
  color: #fde047;
  border-color: rgba(253, 224, 71, 0.45);
}

.game-thumb-wrap {
  width: 100%;
  aspect-ratio: 16 / 11;
  background: #17181b;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.game-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transform: scale(1);
  transition: opacity 0.28s var(--ease-out), transform 0.35s var(--ease-out);
}

.game-thumb.loaded {
  opacity: 1;
}

.game-card:hover .game-thumb {
  transform: scale(1.045);
}

.game-thumb-fallback {
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
}

.game-card-body {
  padding: 9px 10px;
}

.game-card-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-card-author {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Browser & Game Player Views */
.browser-view {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--surface-solid);
  animation: view-enter 0.28s var(--ease-out) both;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--border);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #18191c;
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color 0.16s var(--ease-out), border-color 0.16s var(--ease-out),
    transform 0.14s var(--ease-out);
}

.tool-btn-wide {
  width: auto;
  padding: 0 11px;
  font-size: 12.5px;
  font-weight: 600;
}

.tool-btn:hover {
  background: var(--surface-hover);
}

.tool-btn:active {
  transform: scale(0.94);
}

.bar-form {
  flex: 1;
  min-width: 0;
}

.address-bar {
  width: 100%;
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #18191c;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.18s var(--ease-out);
}

.address-bar:focus {
  border-color: var(--border-focus);
}

.game-title-label {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 4px;
}

.frame-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #ffffff;
  overflow: hidden;
}

.game-frame-wrap {
  background: #000000;
}

.loading-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 38%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #d4d4d8, transparent);
  will-change: transform;
  animation: progress-sweep 1.15s var(--ease-in-out) infinite;
  z-index: 2;
}

@keyframes progress-sweep {
  0% {
    transform: translate3d(-100%, 0, 0);
  }
  100% {
    transform: translate3d(320%, 0, 0);
  }
}

.game-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 10, 12, 0.88);
  color: var(--text);
  font-size: 14px;
  z-index: 3;
  animation: view-enter 0.2s var(--ease-out) both;
}

.proxy-frame,
.game-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .bg-orb,
  .home-view,
  .games-view,
  .browser-view,
  .loading-line,
  .game-loading,
  .music-panel,
  .music-mini {
    animation: none !important;
  }
  * {
    transition-duration: 0.01ms !important;
  }
}

/* Moveable Frosted Music Widget */
.music-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 360px;
  height: 520px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 76px);
  z-index: 45;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 19, 23, 0.88);
  backdrop-filter: blur(22px) saturate(1.15);
  box-shadow: 0 26px 64px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
  animation: view-enter 0.26s var(--ease-out) both;
}

.music-panel.dragging {
  transition: none !important;
  box-shadow: 0 34px 76px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.music-bg-art {
  position: absolute;
  inset: -24px;
  background-size: cover;
  background-position: center;
  filter: blur(36px) saturate(1.25) brightness(0.42);
  opacity: 0;
  transform: scale(1.12);
  transition: opacity 0.6s var(--ease-out);
  pointer-events: none;
}

.music-bg-art.active {
  opacity: 0.7;
}

.music-surface {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: linear-gradient(180deg, rgba(16, 17, 20, 0.66) 0%, rgba(12, 13, 16, 0.88) 100%);
}

.music-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.music-head:active {
  cursor: grabbing;
}

.music-head-left {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
}

.music-grip {
  opacity: 0.65;
}

.music-brand {
  font-size: 12.5px;
  font-weight: 700;
  color: #f4f4f5;
  letter-spacing: 0.01em;
}

.music-tabs {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.music-tab {
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.18s var(--ease-out), background-color 0.18s var(--ease-out);
}

.music-tab:hover {
  color: #ffffff;
}

.music-tab.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.music-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.16s var(--ease-out), background-color 0.16s var(--ease-out), transform 0.14s var(--ease-out);
}

.music-icon-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.music-icon-btn:active {
  transform: scale(0.92);
}

.music-icon-btn.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}

.music-subview {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.music-form {
  display: flex;
  gap: 6px;
  padding: 10px 12px 6px;
}

.music-input {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.18s var(--ease-out), background-color 0.18s var(--ease-out);
}

.music-input:focus {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(0, 0, 0, 0.48);
}

.music-search-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 13px;
  cursor: pointer;
  transition: background-color 0.16s var(--ease-out), transform 0.14s var(--ease-out);
}

.music-search-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.music-search-btn:active {
  transform: scale(0.95);
}

.music-status {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.music-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.music-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.18s var(--ease-out), border-color 0.18s var(--ease-out),
    transform 0.16s var(--ease-out);
}

.music-row:hover {
  background: rgba(255, 255, 255, 0.08);
}

.music-row.active {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.18);
}

.music-row-art {
  width: 40px;
  height: 40px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
}

.music-row-art-empty {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 14px;
}

.music-row-meta {
  flex: 1;
  min-width: 0;
}

.music-row-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-row-artist {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-row-dur {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Apple Music-Style Lyrics */
.music-lyrics-view {
  padding: 6px 0;
}

.music-lyrics-empty {
  margin: auto;
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.music-lyrics-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 46% 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 18%, #000 82%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 18%, #000 82%, transparent 100%);
}

.music-lyrics-scroll::-webkit-scrollbar {
  display: none;
}

.lyric-line {
  --p: 0%;
  border: none;
  background: transparent;
  padding: 2px 0;
  text-align: left;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: -0.015em;
  color: rgba(255, 255, 255, 0.28);
  transform-origin: left center;
  transform: translate3d(0, 0, 0) scale(0.94);
  filter: blur(0.8px);
  cursor: pointer;
  will-change: transform, opacity, filter;
  transition:
    transform 0.48s var(--ease-out),
    filter 0.42s var(--ease-out),
    color 0.38s var(--ease-out),
    opacity 0.38s var(--ease-out);
}

.lyric-line:hover {
  color: rgba(255, 255, 255, 0.72);
  filter: blur(0);
}

.lyric-line.near {
  color: rgba(255, 255, 255, 0.46);
  filter: blur(0.25px);
  transform: translate3d(0, 0, 0) scale(0.97);
}

.lyric-line.active {
  transform: translate3d(0, 0, 0) scale(1.03);
  filter: blur(0) drop-shadow(0 2px 14px rgba(255, 255, 255, 0.2));
  background: linear-gradient(90deg, #ffffff var(--p), rgba(255, 255, 255, 0.48) calc(var(--p) + 6%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lyric-line.plain {
  cursor: default;
  color: rgba(255, 255, 255, 0.86);
  filter: none;
  transform: none;
  font-size: 15px;
  font-weight: 600;
}

.lyric-dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  height: 22px;
}

.lyric-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

.lyric-line.active .lyric-dots span {
  background: #ffffff;
  animation: lyric-pulse 1.35s var(--ease-in-out) infinite;
}

.lyric-line.active .lyric-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.lyric-line.active .lyric-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes lyric-pulse {
  0%,
  100% {
    opacity: 0.32;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1.18);
  }
}

.music-resync-btn {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(28, 29, 34, 0.92);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

/* Bottom Controls Deck */
.music-controls {
  padding: 11px 14px 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(14, 15, 18, 0.56);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.music-now {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.music-art-wrap {
  width: 46px;
  height: 46px;
  border-radius: 9px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.07);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.35s var(--ease-out);
}

.music-panel.is-playing .music-art-wrap {
  transform: scale(1.04);
}

.music-now-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.music-art-fallback {
  font-size: 17px;
  color: rgba(255, 255, 255, 0.45);
}

.music-now-meta {
  flex: 1;
  min-width: 0;
}

.music-now-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-now-artist {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.62);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.music-seek-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.music-time {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.56);
  font-variant-numeric: tabular-nums;
  min-width: 30px;
}

.music-seek,
.music-volume {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
  cursor: pointer;
}

.music-seek {
  flex: 1;
  min-width: 0;
}

.music-seek::-webkit-slider-thumb,
.music-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
  transition: transform 0.15s var(--ease-out);
}

.music-seek:hover::-webkit-slider-thumb,
.music-volume:hover::-webkit-slider-thumb {
  transform: scale(1.25);
}

.music-transport-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.music-vol-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 104px;
}

.music-volume {
  width: 68px;
}

.music-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.music-play-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #ffffff;
  color: #09090b;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.16s var(--ease-out), background-color 0.16s var(--ease-out);
}

.music-play-btn:hover {
  transform: scale(1.06);
}

.music-play-btn:active {
  transform: scale(0.94);
}

.music-mini {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 44;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 280px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(24, 25, 29, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  animation: view-enter 0.2s var(--ease-out) both;
}

.music-mini-art {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.music-mini-title {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.music-save-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.42);
  font-size: 14px;
  padding: 2px 5px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.16s var(--ease-out), transform 0.14s var(--ease-out);
}

.music-save-btn:hover {
  color: #ffffff;
  transform: scale(1.12);
}

.music-save-btn.saved {
  color: #f87171;
}

/* Account Modal (Email OTP) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 4, 6, 0.72);
  backdrop-filter: blur(10px);
  animation: view-enter 0.2s var(--ease-out) both;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 390px;
  padding: 24px;
  border-radius: 16px;
  background: rgba(26, 27, 31, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.72);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.auth-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
}

.auth-subtitle {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.auth-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #141518;
  color: #ffffff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s var(--ease-out);
}

.auth-input:focus {
  border-color: var(--border-focus);
}

.auth-code-input {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.28em;
  font-variant-numeric: tabular-nums;
}

.auth-primary-btn {
  border: none;
  border-radius: 9px;
  background: #ffffff;
  color: #09090b;
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
  transition: opacity 0.16s var(--ease-out), transform 0.14s var(--ease-out);
}

.auth-primary-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.auth-primary-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.auth-primary-btn:disabled,
.auth-link-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.auth-secondary-btn,
.auth-danger-btn {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  transition: background-color 0.16s var(--ease-out), border-color 0.16s var(--ease-out);
}

.auth-secondary-btn:hover {
  background: #44464e;
}

.auth-danger-btn {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.32);
  color: #fca5a5;
}

.auth-danger-btn:hover {
  background: rgba(239, 68, 68, 0.22);
}

.auth-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.auth-link-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  padding: 4px 2px;
  cursor: pointer;
}

.auth-link-btn:hover:not(:disabled) {
  color: #ffffff;
}

.auth-dev-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  margin-bottom: 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  color: #e4e4e7;
}

.auth-profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.auth-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #ffffff;
  color: #09090b;
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 800;
  flex-shrink: 0;
  overflow: hidden;
}

.auth-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-email-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.owner-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 5px;
  background: #ffffff;
  color: #09090b;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.auth-pfp-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.auth-pfp-controls .auth-secondary-btn {
  flex: 1;
}

.auth-profile-meta {
  min-width: 0;
  flex: 1;
}

.auth-profile-email {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-profile-since {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.auth-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.auth-stat {
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.auth-stat span {
  font-size: 11px;
  color: var(--text-muted);
}

.auth-stat strong {
  font-size: 12.5px;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-error {
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
  font-size: 12.5px;
}

/* ==========================================================
   Visual Polish Layer
   Overrides above rules; delete this block to revert.
   ========================================================== */

html,
body {
  font-family: "Inter", "Segoe UI Variable", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(167, 139, 250, 0.35);
  color: #ffffff;
}

:focus-visible {
  outline: none;
  box-shadow: var(--accent-ring);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.22);
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* Background: faint violet tint in the orbs */
.bg-orb-a {
  background: radial-gradient(circle, rgba(139, 92, 246, 0.16) 0%, rgba(58, 60, 68, 0.12) 40%, transparent 70%);
}

.bg-orb-b {
  background: radial-gradient(circle, rgba(56, 189, 248, 0.09) 0%, rgba(46, 48, 56, 0.14) 45%, transparent 72%);
}

/* Title keeps its original white-to-black gradient from the base rule */
.simple-title {
  margin-bottom: 28px;
}

/* Nav: rounded glass pill */
.top-nav {
  top: 16px;
  gap: 2px;
  padding: 5px;
  border-radius: 999px;
  background: var(--glass);
  border-color: var(--glass-border);
  backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), var(--glass-highlight);
}

.mode-btn {
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13px;
}

.mode-btn.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Search box */
.search-form {
  padding: 6px;
  border-radius: 16px;
  background: var(--glass);
  border-color: var(--glass-border);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), var(--glass-highlight);
}

.search-form:focus-within {
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(167, 139, 250, 0.14);
  transform: translateY(-1px);
}

.search-input {
  font-size: 16px;
  padding: 11px 14px;
}

.search-btn {
  border: none;
  border-radius: 11px;
  padding: 11px 22px;
  background: #ffffff;
  color: #09090b;
  font-weight: 700;
}

.search-btn:hover {
  background: #e9e5ff;
}

.engine-btn {
  border-radius: 999px;
  padding: 6px 13px;
  border-color: var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
}

.engine-btn.active {
  color: #ffffff;
  background: var(--accent-soft);
  border-color: rgba(167, 139, 250, 0.45);
}

.status-line {
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
}

.status-dot {
  box-shadow: 0 0 8px currentColor;
  color: var(--warn);
}

.status-dot.ready {
  background: var(--ok);
  color: var(--ok);
}

.status-dot.error {
  color: var(--err);
}

/* Games */
.games-heading {
  font-size: 26px;
  letter-spacing: -0.02em;
}

.games-filter,
.games-status {
  border-radius: 12px;
  border-color: var(--glass-border);
  background: var(--glass);
}

.games-filter:focus {
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: var(--accent-ring);
}

.games-grid {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.game-card {
  border-radius: 14px;
  border-color: var(--glass-border);
  background: var(--glass);
}

.game-card:hover {
  transform: translate3d(0, -4px, 0);
  border-color: rgba(167, 139, 250, 0.4);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(167, 139, 250, 0.12);
}

.game-card-body {
  padding: 10px 12px 12px;
}

/* Browser toolbar */
.toolbar {
  padding: 8px 12px;
  background: #121317;
  border-bottom-color: var(--glass-border);
}

.tool-btn,
.address-bar {
  border-radius: 9px;
  border-color: var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
}

.tool-btn,
.address-bar {
  height: 32px;
}

.tool-btn {
  width: 32px;
}

.address-bar:focus {
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: var(--accent-ring);
}

.loading-line {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

/* Modal and music accents */
.modal-card {
  border-radius: 20px;
  border-color: var(--glass-border);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.75), var(--glass-highlight);
}

.tool-btn.tool-btn-wide {
  width: auto;
}

.auth-input {
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.35);
}

.auth-input:focus,
.music-input:focus {
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: var(--accent-ring);
}

.auth-primary-btn,
.auth-secondary-btn,
.auth-danger-btn {
  border-radius: 11px;
}




.music-seek,
.music-volume {
  accent-color: var(--accent);
}

/* ---------- Polish round 2 ---------- */

/* Soft vignette and faint dot grid behind everything */
.bg-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 0%, transparent 70%);
  mask-image: radial-gradient(ellipse at 50% 40%, #000 0%, transparent 70%);
}

/* Home: staggered entrance */
.home-box > * {
  animation: view-enter 0.6s var(--ease-out) both;
}

.home-box > :nth-child(2) {
  animation-delay: 0.06s;
}

.home-box > :nth-child(3) {
  animation-delay: 0.12s;
}

.simple-title {
  font-size: clamp(3.4rem, 9vw, 5.5rem);
  letter-spacing: -0.05em;
}

.mode-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05);
}

.nav-divider {
  background: var(--glass-border);
}

/* Games: gradient under titles, nicer favorite button */
.game-thumb-wrap {
  position: relative;
  background: linear-gradient(135deg, #1a1b20, #121317);
}

.game-thumb-wrap::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(to top, rgba(10, 10, 14, 0.55), transparent);
  pointer-events: none;
}

.game-fav-btn {
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

.game-card-title {
  font-size: 13.5px;
}

/* Music widget: match the glass look */
.music-panel {
  border-radius: 22px;
  border-color: var(--glass-border);
}

.music-play-btn {
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

.music-row.active {
  background: var(--accent-soft);
  border-color: rgba(167, 139, 250, 0.3);
}

.music-mini {
  border-color: var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.2);
}

/* Modal */
.modal-backdrop {
  background: rgba(4, 4, 8, 0.6);
  backdrop-filter: blur(14px);
}

.modal-card {
  background: linear-gradient(180deg, rgba(30, 31, 38, 0.97), rgba(20, 21, 26, 0.97));
}

.auth-title {
  font-size: 22px;
  letter-spacing: -0.02em;
}

.auth-avatar,
.owner-badge {
  background: linear-gradient(135deg, #ffffff, #ddd6fe);
}

/* Game loading: spinner above the text */
.game-loading {
  gap: 14px;
  align-content: center;
  color: var(--text-muted);
}

.game-loading::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-box > *,
  .game-loading::before {
    animation: none !important;
  }
}

/* Search box fix: inputs inside a styled box shouldn't draw their own ring */
.search-input:focus,
.search-input:focus-visible,
.ai-input:focus-visible {
  outline: none;
  box-shadow: none;
  background: transparent;
}

.search-input {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 10px;
}

.search-form:focus-within {
  transform: none;
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(167, 139, 250, 0.18), 0 0 32px rgba(139, 92, 246, 0.12);
}

.search-btn:focus-visible,
.engine-btn:focus-visible {
  box-shadow: var(--accent-ring);
}

/* ---------- AI Assistant ---------- */
.ai-view {
  position: relative;
  z-index: 1;
  height: 100vh;
  padding: 76px 20px 20px;
  display: flex;
  justify-content: center;
  animation: view-enter 0.34s var(--ease-out) both;
}

.ai-shell {
  position: relative;
  width: 100%;
  max-width: 1040px;
  height: 100%;
  display: flex;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.6), var(--glass-highlight);
  overflow: hidden;
}

/* Sidebar */
.ai-sidebar {
  width: 248px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(8, 8, 11, 0.45);
  border-right: 1px solid var(--glass-border);
}

.ai-sidebar-head {
  padding: 14px 12px 8px;
}

.ai-new-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 12px;
  background: var(--accent-soft);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s var(--ease-out), border-color 0.18s var(--ease-out), transform 0.14s var(--ease-out);
}

.ai-new-btn:hover:not(:disabled) {
  background: rgba(167, 139, 250, 0.26);
  border-color: rgba(167, 139, 250, 0.55);
}

.ai-new-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.ai-new-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.ai-convo-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-convo-empty {
  padding: 18px 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

.ai-convo {
  display: flex;
  align-items: center;
  border-radius: 10px;
  transition: background-color 0.16s var(--ease-out);
}

.ai-convo:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ai-convo.active {
  background: rgba(255, 255, 255, 0.1);
}

.ai-convo-open {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-convo-del {
  width: 26px;
  height: 26px;
  margin-right: 4px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.14s var(--ease-out), background-color 0.14s var(--ease-out), color 0.14s var(--ease-out);
}

.ai-convo:hover .ai-convo-del,
.ai-convo-del:focus-visible {
  opacity: 1;
}

.ai-convo-del:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* Main column */
.ai-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border);
}

.ai-sidebar-toggle {
  display: none;
  flex-shrink: 0;
}

.ai-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-model-select {
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%239ca3af' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E")
    no-repeat right 11px center;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 6px 28px 6px 13px;
  cursor: pointer;
  transition: border-color 0.18s var(--ease-out);
}

.ai-model-select:hover {
  border-color: rgba(167, 139, 250, 0.4);
}

.ai-model-select option {
  background: #1a1b20;
  color: var(--text);
}

/* Messages */
.ai-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ai-messages > .ai-msg {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
}










.ai-msg {
  display: flex;
  animation: view-enter 0.22s var(--ease-out) both;
}

.ai-msg-user {
  justify-content: flex-end;
}

.ai-bubble {
  max-width: 100%;
  font-size: 14.5px;
  line-height: 1.65;
  color: #f4f4f5;
  word-break: break-word;
}

.ai-msg-user .ai-bubble {
  max-width: 82%;
  padding: 10px 15px;
  white-space: pre-wrap;
  border-radius: 18px 18px 5px 18px;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(167, 139, 250, 0.28);
}

.ai-bubble.ai-error {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.32);
  color: #fecaca;
}

.ai-bubble code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.09);
}

.ai-h {
  display: inline-block;
  margin-top: 6px;
  font-size: 15.5px;
  color: #ffffff;
}

.ai-hr {
  border: none;
  height: 1px;
  margin: 10px 0;
  background: var(--glass-border);
}

/* Code blocks */
.ai-code-wrap {
  margin: 10px 0;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--glass-border);
  overflow: hidden;
}

.ai-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--glass-border);
  font-size: 11.5px;
  color: var(--text-muted);
}

.ai-copy {
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11.5px;
  padding: 3px 9px;
  cursor: pointer;
  transition: background-color 0.14s var(--ease-out), color 0.14s var(--ease-out);
}

.ai-copy:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.ai-code {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
}

.ai-code code {
  padding: 0;
  background: none;
  line-height: 1.55;
  white-space: pre;
}

/* Typing indicator */
.ai-thinking {
  display: inline-flex;
  gap: 5px;
  padding: 8px 0;
}

.ai-thinking span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: lyric-pulse 1.2s var(--ease-in-out) infinite;
}

.ai-thinking span:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-thinking span:nth-child(3) {
  animation-delay: 0.3s;
}

/* Composer */
.ai-composer {
  padding: 0 18px 12px;
  width: 100%;
  max-width: 776px;
  margin: 0 auto;
}

.ai-form,
.ai-locked {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid var(--glass-border);
  transition: border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}

.ai-form:focus-within {
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

.ai-locked {
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.ai-input {
  flex: 1;
  min-width: 0;
  max-height: 180px;
  padding: 8px 0;
  border: none;
  background: transparent;
  color: #ffffff;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  outline: none;
}

.ai-input::placeholder {
  color: #7c7f87;
}

.ai-send-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 12px;
  background: #ffffff;
  color: #09090b;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.14s var(--ease-out), background-color 0.18s var(--ease-out);
}

.ai-send-btn:hover {
  background: #ede9fe;
}

.ai-send-btn:active {
  transform: scale(0.94);
}

.ai-send-btn .ai-icon-stop {
  display: none;
}

.ai-send-btn.busy {
  background: var(--accent);
  color: #ffffff;
}

.ai-send-btn.busy .ai-icon-send {
  display: none;
}

.ai-send-btn.busy .ai-icon-stop {
  display: block;
}


/* Narrow screens: sidebar slides in over the chat */
@media (max-width: 760px) {
  .ai-view {
    padding: 70px 10px 10px;
  }

  .ai-sidebar-toggle {
    display: grid;
  }

  .ai-sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    background: rgba(14, 15, 19, 0.97);
    transform: translateX(-100%);
    transition: transform 0.24s var(--ease-out);
  }

  .ai-sidebar.open {
    transform: translateX(0);
  }

}

@media (prefers-reduced-motion: reduce) {
  .ai-view,
  .ai-msg,
  .ai-thinking span {
    animation: none !important;
  }
}
