:root {
  --ink: #20242a;
  --muted: #7d838c;
  --soft: #eef1f5;
  --bubble: #f0f1f3;
  --blue: #dcecff;
  --blue-strong: #cfe3ff;
  --avatar: #e7ecf8;
  --avatar-ink: #566885;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; }
body {
  min-height: 100dvh;
  overflow: hidden;
  background: #fbfbfc;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(78% 34% at 50% 87%, rgba(156, 202, 250, .26) 0%, rgba(195, 222, 249, .16) 52%, rgba(255,255,255,0) 100%),
    linear-gradient(180deg, #fbfbfc 0%, #fbfcfd 52%, #f2f8fe 72%, #e6f2ff 100%);
}

.topbar {
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 16px) 18px 8px;
}

.round-button,
.avatar {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.round-button {
  background: rgba(255,255,255,.82);
  box-shadow: 0 1px 0 rgba(0,0,0,.03), 0 6px 18px rgba(61,77,95,.035);
}

.menu-button { flex-direction: column; gap: 5px; }
.menu-button span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 99px;
  background: #606770;
}

.brand-lockup {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  white-space: nowrap;
  letter-spacing: -.025em;
}
.brand-name { font-size: 16px; font-weight: 650; }
.model-name { font-size: 16px; font-weight: 400; color: #9499a1; }
.chevron { width: 18px; height: 18px; color: #a2a7ae; flex: none; }

.avatar {
  justify-self: end;
  background: var(--avatar);
  color: var(--avatar-ink);
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(67,87,116,.04);
}

.welcome-state,
.conversation-state {
  position: absolute;
  inset: 0;
  transition: opacity .34s ease, transform .34s ease;
}

.welcome-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 118px 24px 206px;
}

.welcome-content {
  width: 100%;
  max-width: 620px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-3.5vh);
}

.hero-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  max-width: 650px;
  font-size: clamp(34px, 7.2vw, 48px);
  line-height: 1.06;
  font-weight: 400;
  letter-spacing: -.047em;
  text-align: center;
  color: #2f3339;
}

.conversation-state {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top) + 88px) 24px 178px;
}
.conversation-inner { width: 100%; max-width: 760px; margin: 0 auto; }
.user-row { display: flex; justify-content: flex-end; margin: 20px 0 34px; }
.user-bubble {
  max-width: min(86%, 620px);
  padding: 14px 18px;
  border-radius: 26px;
  background: rgba(239,240,242,.96);
  border: 1px solid rgba(20,28,38,.018);
  color: #2d3035;
  font-size: 16px;
  line-height: 1.42;
  letter-spacing: -.014em;
}

.assistant-row {
  display: grid;
  grid-template-columns: 30px minmax(0,1fr);
  gap: 12px;
  align-items: start;
}
.assistant-mark img { width: 26px; height: 26px; object-fit: contain; }
.assistant-copy { min-width: 0; }
.response-text {
  max-width: 680px;
  font-size: 17px;
  line-height: 1.58;
  letter-spacing: -.018em;
  white-space: pre-wrap;
  color: #2c3035;
}
.response-image {
  display: block;
  width: 100%;
  max-width: 480px;
  border-radius: 20px;
  margin-top: 2px;
  cursor: pointer;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(10, 10, 12, .94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  transition: opacity .25s ease;
}
.image-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.image-lightbox-actions {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  right: 16px;
  display: flex;
  gap: 10px;
}
.image-lightbox-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.image-lightbox-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.response-actions { display: flex; align-items: center; gap: 6px; margin-top: 18px; }
.response-actions button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #6f757d;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.response-actions svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dots-button { font-size: 16px; letter-spacing: 1px; }

.thinking { display: flex; gap: 5px; align-items: center; height: 28px; padding-top: 6px; }
.thinking span { width: 6px; height: 6px; border-radius: 50%; background: #7e8792; animation: bounce 1.05s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: .11s; }
.thinking span:nth-child(3) { animation-delay: .22s; }
@keyframes bounce { 0%,80%,100% { transform: translateY(0); opacity:.28; } 40% { transform: translateY(-5px); opacity:1; } }

.composer-wrap {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 14px calc(env(safe-area-inset-bottom) + 9px);
  background: linear-gradient(180deg, rgba(231,243,255,0) 0%, rgba(231,243,255,.46) 40%, rgba(231,243,255,.74) 100%);
}

.composer {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  min-height: 60px;
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) 42px 44px;
  align-items: end;
  gap: 3px;
  padding: 7px 8px;
  border-radius: 34px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(36,49,66,.055);
  box-shadow: 0 12px 36px rgba(69,101,139,.10);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.composer-icon,
.send-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.composer-icon { background: transparent; color: #69717a; }
.composer-icon svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mic-button svg { width: 24px; height: 24px; }

.send-button {
  background: #e3efff;
  color: #88a5ca;
  opacity: .74;
  transition: transform .15s ease, background .15s ease, color .15s ease, opacity .15s ease;
}
.send-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.send-button.is-ready { background: var(--blue-strong); color: #4d77ad; opacity: 1; }
.send-button:active { transform: scale(.95); }

textarea {
  width: 100%;
  min-height: 42px;
  max-height: 124px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 10px 5px 8px;
  color: #2e3237;
  font-size: 17px;
  line-height: 1.34;
  letter-spacing: -.015em;
}
textarea::placeholder { color: #9da3ab; opacity: 1; }

.footer-note {
  margin: 10px auto 0;
  text-align: center;
  color: rgba(109,117,127,.68);
  font-size: 12px;
  line-height: 1.25;
  letter-spacing: -.005em;
}

.is-hidden { opacity: 0 !important; pointer-events: none !important; transform: translateY(8px); }

@media (max-width: 430px) {
  .topbar { grid-template-columns: 50px minmax(0,1fr) 50px; padding-left: 16px; padding-right: 16px; }
  .round-button,.avatar { width: 46px; height: 46px; }
  .brand-name,.model-name { font-size: 15px; }
  .welcome-state { padding-left: 20px; padding-right: 20px; }
  .hero-logo { width: 54px; height: 54px; }
  h1 { font-size: clamp(33px, 9.2vw, 42px); }
  .conversation-state { padding-left: 18px; padding-right: 18px; }
}

@media (max-height: 700px) {
  .welcome-content { transform: translateY(-1vh); }
  .welcome-state { padding-bottom: 170px; }
  .hero-logo { margin-bottom: 12px; }
}

/* V0.4: response-state-only styling. Approved welcome state above remains unchanged. */
.response-top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 48px;
  padding: 0 7px;
  border-radius: 24px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 1px 0 rgba(0,0,0,.025), 0 5px 16px rgba(61,77,95,.035);
}
.response-top-actions button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #1d2024;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.response-top-actions svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.response-top-actions .top-dots { font-size: 18px; letter-spacing: 1px; padding-bottom: 3px; }

.response-note {
  margin: 14px 0 0;
  color: #7c8188;
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: -.008em;
}

.live-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dff1ff;
  color: #24384f;
}
.live-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.app-shell.response-mode {
  background: #fbfbfc;
}
.app-shell.response-mode .avatar { display: none; }
.app-shell.response-mode .response-top-actions { opacity: 1 !important; pointer-events: auto !important; transform: none; }
.app-shell.response-mode .conversation-state {
  padding-top: calc(env(safe-area-inset-top) + 88px);
  padding-bottom: 170px;
}
.app-shell.response-mode .user-row { margin-top: 20px; margin-bottom: 34px; }
.app-shell.response-mode .user-bubble {
  background: #f1f1f2;
  border-color: transparent;
}
.app-shell.response-mode .assistant-row {
  display: block;
}
.app-shell.response-mode .assistant-mark { display: none; }
.app-shell.response-mode .assistant-copy { padding-left: 14px; }
.app-shell.response-mode .response-actions { gap: 5px; margin-top: 17px; }
.app-shell.response-mode .response-actions button { color: #171a1f; }
.app-shell.response-mode .composer-wrap {
  background: transparent;
  padding-bottom: calc(env(safe-area-inset-bottom) + 9px);
}
.app-shell.response-mode .composer {
  grid-template-columns: 42px minmax(0,1fr) 42px 44px;
}
.app-shell.response-mode .footer-note { display: none; }
.app-shell.response-mode .send-button { display: none; }
.app-shell.response-mode .live-button { opacity: 1 !important; pointer-events: auto !important; transform: none; }

@media (max-width: 430px) {
  .app-shell.response-mode .assistant-copy { padding-left: 14px; }
}

/* V0.4 FIX: response-only controls must not affect the locked V0.2 welcome layout. */
.app-shell:not(.response-mode) .live-button,
.app-shell:not(.response-mode) .response-top-actions {
  display: none !important;
}

.app-shell.response-mode .live-button {
  display: inline-flex !important;
}

.app-shell.response-mode .response-top-actions {
  display: flex !important;
}


/* V0.8 interaction polish.
   The approved V0.4/V0.7 layout remains untouched.
   These rules only affect the response/loading states requested by the user. */

/* Gemini-like three-dot thinking capsule */
.app-shell.response-mode .thinking {
  width: 58px;
  height: 34px;
  padding: 0;
  border-radius: 18px;
  background: rgba(246, 246, 247, .9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 1px 0 rgba(0,0,0,.025);
}
.app-shell.response-mode .thinking span {
  width: 5px;
  height: 5px;
  background: #15191f;
}

/* During the first AI request only, let soft colour move through the page. */
.app-shell.response-mode.ai-loading.first-search {
  background:
    radial-gradient(70% 44% at 12% 8%, rgba(108, 213, 242, .72) 0%, rgba(108, 213, 242, 0) 68%),
    radial-gradient(62% 52% at 84% 14%, rgba(108, 165, 246, .52) 0%, rgba(108, 165, 246, 0) 70%),
    radial-gradient(65% 60% at 20% 48%, rgba(133, 238, 219, .38) 0%, rgba(133, 238, 219, 0) 72%),
    linear-gradient(180deg, #f4fbff 0%, #f8fbff 55%, #fbfbfc 100%);
  background-size: 125% 125%, 130% 130%, 125% 125%, 100% 100%;
  animation: aiFlow 3.8s ease-in-out infinite alternate;
}
@keyframes aiFlow {
  0% {
    background-position: -10% -5%, 105% -5%, -8% 40%, 0 0;
  }
  50% {
    background-position: 8% 10%, 88% 8%, 8% 52%, 0 0;
  }
  100% {
    background-position: -2% 4%, 98% 14%, 0% 44%, 0 0;
  }
}

/* In response mode, empty input shows the blue audio button.
   As soon as text is typed, it changes to the send arrow. */
.app-shell.response-mode:not(.has-prompt) .live-button {
  display: inline-flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
}
.app-shell.response-mode:not(.has-prompt) .send-button {
  display: none !important;
}
.app-shell.response-mode.has-prompt .live-button {
  display: none !important;
}
.app-shell.response-mode.has-prompt .send-button {
  display: inline-flex !important;
  opacity: 1;
  background: #95cbff;
  color: #183b63;
}


/* V1.1 multi-turn conversation.
   No approved sizing, colours, header or composer styling is changed. */
.app-shell.response-mode .conversation-inner > .user-row:not(:first-child) {
  margin-top: 38px;
}
.app-shell.response-mode .conversation-inner > .assistant-row + .user-row {
  margin-top: 42px;
}
