:root {
  --cream: #f6ede6;
  --peach: #f4b7a0;
  --rose: #e27d95;
  --teal: #2f8f83;
  --ink: #201a1c;
  --muted: #6d5f66;
  --card: rgba(255, 255, 255, 0.75);
  --shadow: 0 18px 40px rgba(58, 34, 40, 0.15);
  --ring: #e27d95;
}

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

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 20%, #fff3e9 0%, transparent 45%),
    radial-gradient(circle at 80% 10%, #ffe0d4 0%, transparent 35%),
    linear-gradient(180deg, var(--cream) 0%, #f7d9c8 45%, #f1c9d5 100%);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(226, 125, 149, 0.4), transparent 70%);
  filter: blur(8px);
  z-index: -1;
  animation: drift 12s ease-in-out infinite;
}

body::before {
  top: -40px;
  left: -60px;
}

body::after {
  bottom: -60px;
  right: -40px;
  animation-delay: 4s;
}

@keyframes drift {
  0%,
  100% {
    transform: translateY(0px) translateX(0px);
  }
  50% {
    transform: translateY(12px) translateX(8px);
  }
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  z-index: 0;
}

.app::before,
.app::after {
  content: "";
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 15% 10%, rgba(47, 143, 131, 0.18), transparent 42%),
    radial-gradient(circle at 85% 20%, rgba(226, 125, 149, 0.22), transparent 40%),
    radial-gradient(circle at 60% 80%, rgba(244, 183, 160, 0.22), transparent 45%);
  opacity: 0.65;
  z-index: -1;
  pointer-events: none;
  animation: hazeDrift 18s ease-in-out infinite;
}

.app::after {
  animation-delay: -9s;
  opacity: 0.45;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: riseIn 0.8s ease-out both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.orb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff6f0, #f2a6b8 60%, #e27d95 100%);
  box-shadow: 0 8px 20px rgba(226, 125, 149, 0.35);
  position: relative;
  overflow: hidden;
  animation: orbPulse 6s ease-in-out infinite;
  will-change: transform;
}

.orb::after {
  content: "";
  position: absolute;
  inset: 10% 15% auto auto;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8), transparent 70%);
  opacity: 0.8;
  animation: orbGlint 6s ease-in-out infinite;
}

.brand-text h1 {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
}

.brand-kicker {
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.28em;
  color: var(--muted);
  margin-bottom: 2px;
}

.install-btn {
  border: none;
  background: var(--teal);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(47, 143, 131, 0.3);
}

.status-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  animation: riseIn 0.8s ease-out both;
  animation-delay: 0.08s;
}

.mood-card,
.prefs-card {
  background: var(--card);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.mood-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.mood-ring {
  --mood-progress: 55%;
  --ring-color: var(--ring);
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.95) 58%, transparent 59%),
    conic-gradient(var(--ring-color) var(--mood-progress), rgba(226, 125, 149, 0.2) 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.4);
  position: relative;
  animation: ringPulse 6s ease-in-out infinite;
}

.mood-ring::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(226, 125, 149, 0.25);
  box-shadow: 0 0 24px rgba(226, 125, 149, 0.18);
  animation: ringGlow 6s ease-in-out infinite;
  pointer-events: none;
}

.mood-label {
  font-size: 1.1rem;
  font-weight: 600;
}

.mood-sub {
  font-size: 0.75rem;
  color: var(--muted);
  max-width: 120px;
}

.meter {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meter-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
}

.meter-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(32, 26, 28, 0.08);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 55%;
  background: linear-gradient(90deg, #f2a6b8 0%, #e27d95 60%, #d4576b 100%);
  border-radius: 999px;
  transition: width 300ms ease;
  background-size: 200% 100%;
  animation: gradientShift 6s ease-in-out infinite;
}

.prefs-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pref-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.pref-row label {
  color: var(--muted);
}

.pref-row select {
  border: 1px solid rgba(32, 26, 28, 0.15);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.7);
}

.scenario {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(32, 26, 28, 0.08);
}

.scenario-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.scenario-head button {
  border: 1px solid rgba(32, 26, 28, 0.12);
  background: rgba(255, 255, 255, 0.9);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
}

.scenario-text {
  font-size: 0.9rem;
  color: var(--ink);
  line-height: 1.4;
}

.scenario-label {
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--muted);
}

#scenarioInput {
  border: 1px solid rgba(32, 26, 28, 0.15);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.75);
  min-height: 70px;
  resize: vertical;
  color: var(--ink);
}

.live-draft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.7rem;
  color: var(--muted);
}

.live-draft span:first-child {
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.live-draft span:last-child {
  flex: 1;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  font-weight: 500;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.chat-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  flex: 1;
  min-height: 280px;
  min-width: 0;
  min-height: 0;
  align-content: stretch;
  animation: riseIn 0.8s ease-out both;
  animation-delay: 0.16s;
}

.chat-window {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  padding: 14px 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 260px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  animation: panelFloat 10s ease-in-out infinite;
  will-change: transform;
}

.panel-title {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.65rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.coach-window .panel-title {
  color: var(--teal);
}

.girl-window .panel-title {
  color: var(--rose);
}

.coach-window {
  animation-delay: -2s;
}

.girl-window {
  animation-delay: -6s;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-right: 6px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.msg {
  max-width: 75%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.4;
  box-shadow: 0 10px 18px rgba(32, 26, 28, 0.08);
  animation: floatIn 240ms ease-out;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg.coach,
.msg.girl {
  align-self: flex-start;
  background: #fff;
  border-bottom-left-radius: 6px;
}

.msg.girl {
  background: rgba(226, 125, 149, 0.12);
  border: 1px solid rgba(226, 125, 149, 0.2);
}

.msg.user {
  align-self: flex-end;
  background: var(--teal);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.msg.typing {
  font-style: italic;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.85);
}

@keyframes floatIn {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0px);
    opacity: 1;
  }
}

.actions-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  animation: riseIn 0.8s ease-out both;
  animation-delay: 0.24s;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.quick-actions button {
  border: 1px solid rgba(32, 26, 28, 0.12);
  background: rgba(255, 255, 255, 0.8);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.quick-actions button:hover,
.quick-actions button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(32, 26, 28, 0.12);
}

#chatForm {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 12px;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

#chatForm input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  outline: none;
}

#chatForm button[type="submit"] {
  border: none;
  background: var(--rose);
  color: #fff;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
}

#chatForm .mic-btn {
  border: 1px solid rgba(32, 26, 28, 0.18);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  min-width: 56px;
}

#chatForm .mic-btn.is-recording {
  border: none;
  background: linear-gradient(135deg, #c4455a, #e27d95);
  color: #fff;
  box-shadow: 0 8px 16px rgba(196, 69, 90, 0.35);
}

#chatForm .mic-btn.is-busy {
  border-color: rgba(47, 143, 131, 0.4);
  color: var(--teal);
  background: rgba(47, 143, 131, 0.12);
}

#chatForm .mic-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.voice-status {
  min-height: 18px;
  font-size: 0.8rem;
  color: var(--muted);
  padding-left: 2px;
}

.voice-status.active {
  color: var(--teal);
}

.voice-status.error {
  color: #c4455a;
}

.install-tip,
.update-banner {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.update-banner button {
  border: none;
  background: var(--teal);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

@keyframes hazeDrift {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(12px, -8px, 0);
  }
}

@keyframes riseIn {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes orbPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 8px 20px rgba(226, 125, 149, 0.35);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 12px 26px rgba(226, 125, 149, 0.45);
  }
}

@keyframes orbGlint {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
    opacity: 0.8;
  }
  50% {
    transform: translate3d(-6px, 6px, 0);
    opacity: 0.6;
  }
}

@keyframes ringPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

@keyframes ringGlow {
  0%,
  100% {
    opacity: 0.5;
    box-shadow: 0 0 18px rgba(226, 125, 149, 0.18);
  }
  50% {
    opacity: 0.9;
    box-shadow: 0 0 30px rgba(226, 125, 149, 0.32);
  }
}

@keyframes panelFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes gradientShift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .mood-card {
    flex-direction: column;
  }

  .msg {
    max-width: 85%;
  }
}

@media (max-width: 480px) {
  #chatForm {
    flex-wrap: wrap;
  }

  #chatForm input {
    flex-basis: 100%;
  }

  #chatForm .mic-btn,
  #chatForm button[type="submit"] {
    flex: 1;
  }
}

@media (max-width: 720px) {
  .app {
    gap: 14px;
    padding: calc(18px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
  }

  .mood-ring {
    width: 130px;
    height: 130px;
  }

  .mood-card,
  .prefs-card {
    padding: 14px;
  }

  .chat-panel {
    min-height: 200px;
  }
}

@media (min-width: 980px) {
  .app {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "header header"
      "status chat"
      "status chat"
      "status actions";
    align-items: start;
  }

  .app-header {
    grid-area: header;
  }

  .status-panel {
    grid-area: status;
  }

  .chat-panel {
    grid-area: chat;
  }

  .actions-panel {
    grid-area: actions;
    margin-top: 0;
  }
}
