:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --bg: #05090d;
  --text: #eef9fb;
  --muted: #7d929b;
  --cyan: #d2fbff;
  --cyan-line: rgba(178, 236, 248, .58);
  --red: #d84c42;
  --line: rgba(170, 228, 241, .11);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body {
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 28%, rgba(80, 150, 170, .08), transparent 32rem),
    linear-gradient(180deg, #04080c 0%, #05090d 60%, #03070a 100%);
}
button, textarea, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid rgba(204, 249, 255, .42);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.stage {
  min-height: 100dvh;
  width: min(920px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
}
.center-view {
  min-height: calc(100dvh - max(40px, env(safe-area-inset-top)) - max(40px, env(safe-area-inset-bottom)));
  display: grid;
  place-items: center;
}

/* Invite */
.invite-card { width: min(390px, 100%); text-align: center; }
.wordmark {
  margin-bottom: 22px;
  color: #dff8fb;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .24em;
  text-indent: .24em;
}
#invite-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
#invite-code {
  min-width: 0;
  border: 1px solid rgba(159,226,238,.18);
  border-radius: 18px;
  background: rgba(7,16,21,.68);
  color: #eef9fb;
  padding: 14px 15px;
  outline: none;
  font-size: 17px;
}
#invite-code::placeholder { color: #5e7077; }
#invite-code:focus { border-color: rgba(159,226,238,.44); }
#invite-button {
  border: 1px solid rgba(159,226,238,.22);
  border-radius: 18px;
  padding: 0 18px;
  background: #dff8fb;
  color: #061014;
  font-weight: 700;
}
#invite-button:disabled { opacity: .5; }
.inline-error { min-height: 20px; margin: 11px 4px 0; color: #dc8178; font-size: 13px; }

/* Brand */
.brand-lockup { text-align: center; }
.chuck-logo {
  color: #d1fbff;
  font-family: "Avenir Next", Avenir, "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: clamp(64px, 16.8vw, 82px);
  font-weight: 400;
  line-height: .98;
  letter-spacing: .052em;
  white-space: nowrap;
  text-shadow:
    0 0 2px rgba(239, 254, 255, 1),
    0 0 7px rgba(210, 249, 255, .86),
    0 0 16px rgba(156, 230, 246, .54),
    0 0 34px rgba(91, 183, 211, .27),
    0 0 58px rgba(70, 145, 171, .12);
}
.chuck-tagline {
  margin-top: 20px;
  color: #8299a4;
  font-size: clamp(13px, 3.5vw, 16px);
  font-weight: 400;
  letter-spacing: .12em;
}

/* Primary prompt screen */
.prompt-view { display: flex; align-items: stretch; }
.prompt-layout {
  width: min(620px, 100%);
  min-height: calc(100dvh - max(40px, env(safe-area-inset-top)) - max(40px, env(safe-area-inset-bottom)));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(28px, 6vh, 54px) 0 clamp(16px, 3vh, 28px);
}
.prompt-layout > .brand-lockup { flex: 0 0 auto; }

.prompt-layout > .mic {
  position: relative;
  isolation: isolate;
  flex: 0 0 auto;
  width: 158px;
  height: 158px;
  margin-top: clamp(82px, 13vh, 116px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1.25px solid rgba(201, 247, 255, .92);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 35%, rgba(179, 239, 251, .12) 0%, rgba(88, 173, 194, .08) 33%, rgba(18, 39, 49, .28) 61%, rgba(3, 10, 15, .82) 100%);
  color: #d0fbff;
  box-shadow:
    inset 0 0 28px rgba(160, 232, 246, .10),
    inset 0 0 1px 1px rgba(229, 253, 255, .18),
    0 0 2px rgba(239, 255, 255, 1),
    0 0 13px rgba(158, 230, 246, .38),
    0 0 31px rgba(84, 172, 199, .18),
    0 20px 52px rgba(0, 0, 0, .48);
}
.prompt-layout > .mic::before {
  content: "";
  position: absolute;
  inset: 8%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle at 48% 30%, rgba(220, 251, 255, .06), transparent 58%);
  box-shadow: inset 0 -18px 28px rgba(0, 0, 0, .18);
  pointer-events: none;
}
.prompt-layout > .mic svg {
  width: 70px;
  height: 70px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
  filter:
    drop-shadow(0 0 2px rgba(239, 255, 255, 1))
    drop-shadow(0 0 7px rgba(175, 240, 252, .60))
    drop-shadow(0 0 14px rgba(113, 207, 229, .25));
}
.mic.listening { animation: micListening 1.4s ease-in-out infinite; }
@keyframes micListening {
  0%, 100% {
    box-shadow:
      inset 0 0 28px rgba(160, 232, 246, .10),
      inset 0 0 1px 1px rgba(229, 253, 255, .18),
      0 0 2px rgba(239, 255, 255, 1),
      0 0 13px rgba(158, 230, 246, .38),
      0 0 31px rgba(84, 172, 199, .18),
      0 20px 52px rgba(0, 0, 0, .48);
  }
  50% {
    box-shadow:
      inset 0 0 36px rgba(160, 232, 246, .15),
      inset 0 0 1px 1px rgba(229, 253, 255, .28),
      0 0 3px rgba(239, 255, 255, 1),
      0 0 22px rgba(158, 230, 246, .52),
      0 0 42px rgba(84, 172, 199, .25),
      0 20px 52px rgba(0, 0, 0, .48);
  }
}

.prompt-box {
  position: relative;
  width: min(390px, 100%);
  margin-top: auto;
}
#prompt {
  width: 100%;
  min-height: 90px;
  max-height: 34dvh;
  resize: none;
  overflow-y: auto;
  border: 1px solid rgba(161, 226, 240, .55);
  outline: none;
  border-radius: 20px;
  background: rgba(5, 13, 18, .30);
  color: #eefcff;
  padding: 19px 62px 19px 18px;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: .002em;
  box-shadow: inset 0 0 20px rgba(132,207,222,.025), 0 0 14px rgba(132,207,222,.025);
}
#prompt::placeholder { color: transparent; }
#prompt:focus { border-color: rgba(195, 242, 251, .80); box-shadow: 0 0 0 1px rgba(185,239,248,.06); }
.prompt-box > .send {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(165,225,236,.28);
  border-radius: 50%;
  background: rgba(18,33,39,.86);
  color: var(--cyan);
}
.prompt-box > .send svg { width: 21px; height: 21px; fill: currentColor; }

/* Waiting */
.working-view {
  position: relative;
  display: block;
  overflow: hidden;
  isolation: isolate;
  min-height: calc(100dvh - max(40px, env(safe-area-inset-top)) - max(40px, env(safe-area-inset-bottom)));
  color: #cbd9dd;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
}
.working-brand {
  position: absolute;
  top: clamp(38px, 7vh, 68px);
  left: 50%;
  width: 100%;
  transform: translateX(-50%);
  pointer-events: none;
}
.working-brand .chuck-logo { font-size: clamp(48px, 11vw, 62px); }
.working-brand .chuck-tagline { margin-top: 12px; font-size: 12px; }
.fidget-dot {
  position: absolute;
  z-index: 2;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: 0;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  background: var(--red);
  box-shadow: 0 8px 22px rgba(0,0,0,.34);
  will-change: left, top, transform;
  transition: transform 90ms ease, box-shadow 120ms ease;
}
.fidget-dot.dragging { cursor: grabbing; transform: scale(.88, 1.10); box-shadow: 0 7px 20px rgba(0,0,0,.40); }
.working-copy {
  position: absolute;
  left: 50%;
  bottom: 12%;
  z-index: 1;
  width: min(440px, 88%);
  transform: translateX(-50%);
  pointer-events: none;
}
.working-copy p { margin: 0; color: #c5d2d6; font-size: 15px; }
.working-copy small { display: block; margin-top: 10px; color: #6f8188; font-size: 12px; letter-spacing: .03em; }

/* Playlist */
.result-view { position: relative; padding: 18px 0 42px; }
.result-brand { margin: 0 auto 28px; text-align: center; }
.result-brand .chuck-logo {
  font-size: 31px;
  letter-spacing: .052em;
  text-shadow:
    0 0 2px rgba(239, 254, 255, .9),
    0 0 7px rgba(193, 241, 251, .42),
    0 0 16px rgba(109, 196, 218, .17);
}
.result-brand .chuck-tagline { margin-top: 6px; font-size: 10px; letter-spacing: .10em; }
.result-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 22px;
}
.result-head h1 {
  margin: 0 0 7px;
  color: #eef9fb;
  font-size: clamp(30px, 7vw, 48px);
  line-height: 1.04;
  letter-spacing: -.025em;
}
.result-head p { margin: 0; max-width: 700px; color: #82939a; font-size: 14px; line-height: 1.48; }
.round-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(159,226,238,.18);
  background: rgba(7,16,21,.72);
  color: #dff8fb;
}
.round-button svg { width: 21px; height: 21px; fill: currentColor; }
.tracks { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.track {
  display: grid;
  grid-template-columns: 24px 52px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  min-height: 74px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  transition: background .14s ease;
  cursor: pointer;
}
.track:hover { background: rgba(181,239,248,.018); }
.track-number { color: #52656c; font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.track-art-shell { width: 52px; height: 52px; overflow: hidden; border-radius: 8px; background: #0d171b; }
.track-art, .track-art-placeholder { width: 100%; height: 100%; display: block; object-fit: cover; }
.track-art-placeholder { background: linear-gradient(135deg, #152229, #091115); }
.track-info { min-width: 0; }
.track-title { overflow: hidden; color: #eef8fa; font-size: 16px; line-height: 1.28; text-overflow: ellipsis; white-space: nowrap; }
.track-meta { overflow: hidden; margin-top: 4px; color: #758990; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.result-actions { display: flex; justify-content: flex-start; padding-top: 24px; }
.share-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(159,226,238,.18);
  border-radius: 999px;
  padding: 11px 16px;
  background: #dff8fb;
  color: #061014;
  font-weight: 700;
}
.share-button svg { width: 18px; height: 18px; fill: currentColor; }
.result-fidget-dot { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 90;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  max-width: min(92vw, 640px);
  padding: 11px 15px;
  border-radius: 16px;
  background: rgba(8,18,22,.97);
  border: 1px solid rgba(159,226,238,.15);
  color: #d7e7ea;
  font-size: 14px;
  box-shadow: 0 18px 48px rgba(0,0,0,.4);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 700px) {
  .stage { padding-left: 16px; padding-right: 16px; }
  .prompt-layout { width: 100%; padding-top: clamp(28px, 5.5vh, 48px); }
  .chuck-logo { font-size: clamp(66px, 17.4vw, 78px); }
  .chuck-tagline { margin-top: 18px; font-size: 14px; }
  .prompt-layout > .mic { width: 156px; height: 156px; margin-top: clamp(80px, 12vh, 106px); }
  .prompt-layout > .mic svg { width: 69px; height: 69px; }
  .prompt-box { width: min(388px, 100%); }
  #prompt { min-height: 90px; font-size: 24px; }
  .prompt-box > .send { width: 44px; height: 44px; }
  .working-brand .chuck-logo { font-size: 51px; }
  .working-brand .chuck-tagline { font-size: 11px; }
  .result-view { padding-top: 12px; }
  .result-brand { margin-bottom: 24px; }
  .result-brand .chuck-logo { font-size: 29px; }
  .result-head { align-items: flex-start; }
  .track { grid-template-columns: 21px 50px minmax(0, 1fr); gap: 10px; min-height: 71px; }
  .track-art-shell { width: 50px; height: 50px; }
  .track-title { font-size: 15px; }
  .track-meta { font-size: 12px; }
}

@media (max-height: 700px) {
  .prompt-layout { padding-top: 22px; }
  .prompt-layout > .mic { width: 142px; height: 142px; margin-top: 48px; }
  .prompt-layout > .mic svg { width: 61px; height: 61px; }
  .prompt-box { margin-top: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .mic.listening { animation: none !important; }
}

/* Fine-tune approved visual treatment */
#chuck-wordmark path {
  stroke-width: 1.55px;
}

.prompt-layout > .mic {
  border-color: rgba(201, 247, 255, .78);
  box-shadow:
    inset 0 0 20px rgba(160, 232, 246, .06),
    inset 0 0 1px 1px rgba(229, 253, 255, .13),
    0 0 1px rgba(239, 255, 255, .70),
    0 0 7px rgba(158, 230, 246, .18),
    0 0 16px rgba(84, 172, 199, .07),
    0 18px 46px rgba(0, 0, 0, .44);
}
.prompt-layout > .mic svg {
  filter:
    drop-shadow(0 0 1px rgba(239, 255, 255, .72))
    drop-shadow(0 0 4px rgba(175, 240, 252, .30))
    drop-shadow(0 0 8px rgba(113, 207, 229, .10));
}
.mic.listening {
  box-shadow:
    inset 0 0 24px rgba(160, 232, 246, .08),
    inset 0 0 1px 1px rgba(229, 253, 255, .16),
    0 0 2px rgba(239, 255, 255, .78),
    0 0 10px rgba(158, 230, 246, .25),
    0 0 22px rgba(84, 172, 199, .10),
    0 18px 46px rgba(0, 0, 0, .44);
}

.fidget-dot {
  border: 1px solid rgba(255, 215, 205, .14);
  background:
    radial-gradient(circle at 31% 27%, rgba(255, 197, 184, .58) 0%, rgba(240, 116, 101, .48) 14%, rgba(216, 76, 66, 1) 38%, rgba(184, 55, 48, 1) 70%, rgba(126, 35, 31, 1) 100%);
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,.18),
    inset 0 -6px 10px rgba(74, 14, 12, .20),
    0 7px 18px rgba(0,0,0,.34),
    0 0 0 1px rgba(96, 25, 22, .10);
}
.fidget-dot.dragging {
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,.15),
    inset 0 -5px 9px rgba(74, 14, 12, .22),
    0 6px 17px rgba(0,0,0,.40);
}


.chuck-failure-panel {
  width: min(100%, 640px);
  margin: 16px auto 0;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  background: rgba(13, 20, 25, .82);
  box-shadow: 0 12px 38px rgba(0,0,0,.18);
  text-align: left;
}

.chuck-failure-panel[hidden] { display: none !important; }

.chuck-failure-panel.state-blocked { border-color: rgba(241, 198, 105, .23); }
.chuck-failure-panel.state-failed { border-color: rgba(232, 132, 119, .25); }
.chuck-failure-panel.state-degraded { border-color: rgba(156, 221, 235, .20); }

.chuck-failure-message {
  margin: 0;
  color: #e7f2f4;
  font: 600 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.chuck-failure-hint {
  margin: 6px 0 0;
  color: #8da4aa;
  font: 500 12px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.chuck-failure-hint:empty { display: none; }

.chuck-failure-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chuck-failure-actions:empty { display: none; }

.chuck-failure-action {
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid rgba(174, 225, 235, .16);
  border-radius: 999px;
  background: rgba(6, 14, 18, .62);
  color: #b8cdd1;
  font: 600 12px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
}

.chuck-failure-action.primary {
  border-color: rgba(189, 238, 246, .28);
  color: #e3f8fa;
  background: rgba(29, 59, 68, .58);
}

.chuck-failure-action:focus-visible {
  outline: 2px solid rgba(203, 246, 251, .72);
  outline-offset: 2px;
}

.chuck-result-notice {
  margin: 2px 0 18px;
  padding: 11px 13px;
  border: 1px solid rgba(164, 226, 238, .13);
  border-radius: 14px;
  background: rgba(13, 24, 29, .62);
  color: #a9bec3;
  font: 500 13px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.chuck-result-notice[hidden] { display: none !important; }

@media (max-width: 520px) {
  .chuck-failure-panel { margin-top: 13px; padding: 13px 14px; border-radius: 16px; }
  .chuck-failure-actions { gap: 7px; }
  .chuck-result-notice { margin-bottom: 14px; }
}
