:root {
  --bg: #f9f1e1;
  --card: #fff;
  --text: #5f3f16;
  --muted: #8b6f48;
  --brand: #ff7a00;
  --accent: #f28a24;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Nunito", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  overflow: hidden;
  color: var(--text);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0) 60%),
    radial-gradient(circle at 85% 80%, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 40%),
    linear-gradient(to bottom, rgba(255, 225, 183, 0.88), rgba(255, 235, 208, 0.96)),
    linear-gradient(120deg, #f3d6b3 0%, #f8e5cd 25%, #f6dcba 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(#f5bd7a 1px, transparent 1px),
    radial-gradient(#f7cf99 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: 0.7;
  z-index: 0;
}

.app-shell { min-height: 100vh; display: flex; flex-direction: column; position: relative; z-index: 1; }
.topbar {
  height: 70px;
  border-bottom: 1px solid #e5c8a2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(10px);
  z-index: 10;
}
.brand-row {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  font-family: "Comic Neue", "Bubblegum Sans", "Nunito", sans-serif;
  font-weight: 900;
  font-size: 26px;
  color: #b13f5b;
  text-shadow: 0 0 8px rgba(0,0,0,0.2);
}
.topic-nav { z-index: 2; }
.icon-btn { z-index: 2; }
.topbar-actions { display: flex; align-items: center; gap: 10px; z-index: 2; }

.celebration-nav {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  border: 1px solid #ffd99d;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.55);
}

.settings-dev-actions {
  margin: 8px 0 12px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.celebration-button {
  border: none;
  border-radius: 999px;
  background: #fff3de;
  color: #92561f;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.celebration-button:hover {
  transform: translateY(-1px);
  background: #ffe1b6;
  box-shadow: 0 8px 14px rgba(201, 123, 21, 0.16);
}

.topic-nav { display: flex; gap: 8px; background: rgba(255,255,255,.9); padding: 6px; border-radius: 999px; border: 1px solid #ffd99d; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6); }
.topic-button {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #58421c;
  font-weight: 700;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.topic-button:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 10px 18px rgba(0,0,0,0.12);
  background: #f8f2e4;
}
.topic-icon {
  width: 20px;
  height: 20px;
  filter: grayscale(80%);
  transition: filter .2s ease, transform .2s ease;
}
.topic-button:hover .topic-icon {
  filter: grayscale(0%);
  transform: scale(1.15);
}
.topic-button.active {
  background: linear-gradient(90deg, #b8ff9f, #57f3a1);
  color: #1e3b20;
  box-shadow: 0 6px 12px rgba(68,157,75,0.28);
}
.topic-button.active .topic-icon {
  filter: none;
  transform: scale(1.15);
}
/* remove the dot from active */
.topic-button.active::before { content: none; }
.brand-row { font-size: 24px; font-weight: 900; color: #f1781f; letter-spacing: .06em; }
.icon-btn { border: none; background: #ffe0ba; border-radius: 999px; width: 36px; height: 36px; cursor: pointer; font-size: 18px; display: grid; place-items: center; padding: 0; }
.icon-svg { width: 18px; height: 18px; }

.settings-panel {
  position: fixed; right: -320px; top: 0; width: 320px; height: 100vh; background: #fff; box-shadow: -8px 0 18px rgba(0,0,0,.16); padding: 16px; transition: right .3s ease;
  z-index: 25;
}
.settings-panel.open { right: 0; }
.settings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.pill-group { display: flex; gap: 8px; margin-bottom: 12px; }
.pill { display: inline-flex; align-items: center; background: #f8f0e4; color: #a05f27; border-radius: 999px; padding: 6px 10px; font-size: 14px; }
.pill.active { background: #ffd09b; font-weight: 700; }
.primary { background: var(--brand); color: white; border: 0; border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.settings-content input { width: 100%; font-size: 13px; margin-bottom: 12px; border: 1px solid #f0d2b4; border-radius: 8px; padding: 8px; }
.chat-preview { border: 1px solid #f7cf9c; border-radius: 10px; background: #fff4e8; padding: 8px; margin-bottom: 8px; }

.main-content { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; position: relative; overflow: hidden; }
.mobile-controls { display: none; }
.scene { max-width: 900px; width: 100%; display: grid; place-items: center; gap: 10px; position: relative; transform: translateY(-72px); }
.celebration-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.celebration-piece { position: absolute; will-change: transform, opacity; }
.celebration-piece.confetti {
  width: 18px;
  height: 40px;
  border-radius: 7px;
  animation: confettiFall 7.8s cubic-bezier(.18, .78, .28, 1) forwards;
}
.celebration-piece.firework {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  animation: fireworkBurst 4.8s ease-out forwards;
  box-shadow: 0 0 26px currentColor;
}
.scene.is-celebrating .jot-container { animation: jotCelebrateBounce 1.15s ease-in-out 4; }
.scene.is-celebrating .feedback-bubble.visible { animation: bubbleCelebrate 0.6s ease, bubbleFloat 1.6s ease .15s; }
.jot-container { width: 300px; height: 300px; display: grid; place-items: center; }
.jot-container img { width: 100%; height: auto; max-height: 100%; object-fit: contain; }
.bubble-wrapper { position: absolute; right: 34px; top: 60%; display: flex; flex-direction: column; align-items: flex-start; }
.topic-bubble, .feedback-bubble { border-radius: 24px; padding: 16px 20px; min-width: 250px; max-width: 340px; text-align: left; background: #fff; box-shadow: 0 10px 20px rgba(0, 0, 0, .15); position: relative; }
.topic-bubble.hidden { display: none; opacity: 0; }
.topic-bubble::before, .feedback-bubble::before { content: ""; position: absolute; left: -14px; top: 20px; width: 0; height: 0; border: 10px solid transparent; border-right-color: #fff; }
.topic-bubble { font-weight: 900; font-size: 20px; letter-spacing: 0.02em; }
.feedback-bubble { font-weight: 700; }

.topic-bubble, .feedback-bubble { animation: bubbleFade 0.5s ease forwards; opacity: 0; transform: translateY(10px); }
.topic-bubble { opacity: 1; transform: translateY(0); }
.feedback-bubble { display: none; }
.feedback-bubble.visible { display: block; opacity: 1; transform: translateY(0); }

.topic-bubble-enter { animation: bubbleEnter 0.35s ease forwards; }
.topic-bubble-exit { animation: bubbleExit 0.25s ease forwards; }

@keyframes bubbleFade {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes bubbleEnter {
  0% { opacity: 0; transform: translateX(24px) scale(0.96); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes bubbleExit {
  0% { opacity: 1; transform: translateX(0) scale(1); }
  100% { opacity: 0; transform: translateX(-24px) scale(0.96); }
}

@keyframes bubbleFade {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translate3d(0, -140px, 0) rotate(0deg) scale(.7);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift-x), 115vh, 0) rotate(var(--spin)) scale(1);
  }
}

@keyframes fireworkBurst {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(.2);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--burst-x), var(--burst-y), 0) scale(1.1);
  }
}

@keyframes jotCelebrateBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  20% { transform: translateY(-16px) scale(1.03); }
  40% { transform: translateY(0) scale(.985); }
  60% { transform: translateY(-10px) scale(1.015); }
  80% { transform: translateY(0) scale(1); }
}

@keyframes bubbleCelebrate {
  0% { transform: scale(.96); }
  65% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes bubbleFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

@keyframes micIdleRing {
  0%, 58%, 100% {
    opacity: 0;
    transform: scale(0.84);
  }
  10% {
    opacity: 0.42;
    transform: scale(1);
  }
  26% {
    opacity: 0;
    transform: scale(1.28);
  }
}

@keyframes micIdleIconBob {
  0%, 58%, 100% { transform: translateY(0); }
  12% { transform: translateY(-3px) scale(1.04); }
  20% { transform: translateY(-1px); }
}

.mic-footer { background: rgba(255, 255, 255, .92); border-top: 1px solid #f0dbc4; padding: 18px 16px 28px; display: flex; align-items: center; justify-content: center; position: relative; }
.mic-button { border: none; border-radius: 50%; width: 86px; height: 86px; background: linear-gradient(135deg, #ff7a00, #f77400); color: white; cursor: pointer; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25); display: grid; place-items: center; position: relative; overflow: visible; transition: transform .7s ease, box-shadow .7s ease, filter .7s ease; }
.mic-button::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(247, 116, 0, 0.28) 0%, rgba(247, 116, 0, 0.14) 45%, rgba(247, 116, 0, 0) 72%);
  opacity: 0;
  transform: scale(0.84);
  pointer-events: none;
  transition: transform .7s ease, opacity .7s ease;
}
.mic-button:not(.active)::before { animation: micIdleRing 3.2s ease-in-out infinite; }
.mic-button:not(.active):hover {
  transform: scale(1.08);
  box-shadow: 0 14px 30px rgba(247, 116, 0, 0.34);
  filter: brightness(1.04);
}
.mic-button:not(.active):hover::before { animation: none; opacity: 0.34; transform: scale(1.16); }
.mic-button.active:hover {
  transform: scale(1.08);
  box-shadow: 0 14px 30px rgba(247, 116, 0, 0.34);
  filter: brightness(1.04);
}
.mic-button.active:hover::before { opacity: 0.3; transform: scale(1.14); }
.mic-button img { width: 40px; height: 40px; filter: brightness(0) saturate(100%) invert(28%) sepia(91%) saturate(712%) hue-rotate(345deg) brightness(104%) contrast(103%); position: relative; z-index: 1; }
.mic-button img { transition: transform .7s ease, filter .7s ease; }
.mic-button:not(.active):hover img { transform: scale(1.05); }
.mic-button.active img { filter: brightness(0) saturate(100%) invert(23%) sepia(95%) saturate(700%) hue-rotate(350deg) brightness(110%) contrast(105%); }
.mic-button.active { background: linear-gradient(135deg, #ff7a00, #f77400); }
.mic-button .ring { position: absolute; border: 2px solid rgba(255, 70, 70, .75); border-radius: 50%; width: 100px; height: 100px; top: -7px; left: -7px; opacity: 0; pointer-events: none; transform: scale(var(--ring-scale, 0.8)); transition: transform .7s ease, opacity .7s ease; }
.mic-button.active .ring { opacity: 0.6; }
.mic-button .ring-inner { position: absolute; border: 2px solid rgba(255, 110, 110, .5); border-radius: 50%; width: 72px; height: 72px; top: 7px; left: 7px; opacity: 0; transform: scale(var(--inner-scale, 0.9)); transition: transform .2s ease, opacity .2s ease; }
.mic-button.active .ring-inner { opacity: 0.45; }
.volume-meter { display: none; }
.volume-level { width: 0%; height: 100%; transition: width .08s linear; background: linear-gradient(90deg, #3f9cff, #45f0ff); }

@media (max-width: 768px) {
  .topbar { justify-content: flex-end; }
  .brand-row { left: 18px; top: 50%; transform: translateY(-50%); text-align: left; }
  .topbar-actions { margin-left: auto; }
  .desktop-topic-nav { display: none; }
  .brand-row { font-size: 18px; }
  .mobile-controls {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 8;
    pointer-events: none;
  }
  .mobile-topic-nav,
  .mobile-celebration-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
    border-radius: 22px;
    background: rgba(255,255,255,.92);
    box-shadow: 0 10px 22px rgba(124, 89, 36, 0.14);
    pointer-events: auto;
  }
  .mobile-topic-nav { width: 108px; align-items: stretch; }
  .mobile-celebration-nav { align-items: stretch; }
  .topic-button,
  .celebration-button {
    width: 100%;
    justify-content: center;
    font-size: 11px;
    padding: 8px 10px;
  }
  .topic-button { gap: 6px; }
  .topic-icon { width: 16px; height: 16px; }
  .scene { transform: translateY(-48px); }
  .jot-container { width: 260px; height: 260px; }
  .bubble-wrapper { right: 50%; top: -102px; transform: translateX(50%); align-items: center; }
  .topic-bubble::before, .feedback-bubble::before { left: 50%; top: auto; bottom: -18px; transform: translateX(-50%) rotate(90deg); }
  .topic-bubble, .feedback-bubble { min-width: 230px; max-width: 320px; }
}
