:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17211d;
  background: #f4f7f5;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.watch {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 0%, rgba(105, 214, 168, 0.18), transparent 38%),
    #edf3f0;
}

.watch-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(100%, 460px);
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  background: rgba(250, 252, 251, 0.93);
  box-shadow: 0 0 50px rgba(20, 59, 43, 0.08);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: max(12px, env(safe-area-inset-top)) 14px 11px;
  border-bottom: 1px solid rgba(24, 65, 48, 0.08);
  background: rgba(250, 252, 251, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 2;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #238261, #115a43);
  box-shadow: 0 6px 16px rgba(26, 112, 82, 0.22);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-copy {
  min-width: 0;
  flex: 1;
}

.brand-copy h1 {
  margin: 0 0 3px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #718078;
  font-size: 11px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a7b0ab;
}

.status-dot.connecting {
  animation: pulse 1.4s ease-in-out infinite;
}

.status-dot.online {
  background: #25aa72;
  box-shadow: 0 0 0 3px rgba(37, 170, 114, 0.11);
}

.status-dot.offline {
  background: #c98e60;
}

.header-action {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 11px;
  color: #69766f;
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.header-action:hover {
  color: #1f6e53;
  background: #e9f2ed;
}

.header-action:active {
  transform: scale(0.94);
}

.header-action svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.messages {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 18px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(55, 90, 74, 0.16) transparent;
}

.bubble {
  position: relative;
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 17px;
  line-height: 1.48;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: bubble-in 180ms ease-out both;
}

.bubble.user {
  align-self: flex-end;
  border-bottom-right-radius: 5px;
  background: linear-gradient(145deg, #247e60, #17664d);
  color: white;
  box-shadow: 0 5px 14px rgba(24, 105, 77, 0.14);
}

.bubble.assistant {
  align-self: flex-start;
  border: 1px solid rgba(31, 83, 61, 0.08);
  border-bottom-left-radius: 5px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(34, 66, 52, 0.06);
}

.bubble.assistant.rich {
  width: 100%;
  max-width: 100%;
  padding: 14px 15px 9px;
  border-radius: 18px;
  border-bottom-left-radius: 5px;
}

.bubble-content {
  min-width: 0;
}

.bubble-content > :first-child {
  margin-top: 0;
}

.bubble-content > :last-child {
  margin-bottom: 0;
}

.bubble-content p {
  margin: 0 0 0.72em;
}

.bubble-content h1,
.bubble-content h2,
.bubble-content h3,
.bubble-content h4 {
  margin: 1.15em 0 0.5em;
  color: #12251d;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.bubble-content h1 {
  font-size: 1.24em;
}

.bubble-content h2 {
  font-size: 1.16em;
}

.bubble-content h3,
.bubble-content h4 {
  font-size: 1.06em;
}

.bubble-content ul,
.bubble-content ol {
  margin: 0.4em 0 0.85em;
  padding-left: 1.5em;
}

.bubble-content li {
  padding-left: 0.18em;
}

.bubble-content li + li {
  margin-top: 0.55em;
}

.bubble-content li > p {
  margin: 0.2em 0;
}

.bubble-content strong {
  color: #11271e;
  font-weight: 700;
}

.bubble-content a {
  color: #147256;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.bubble-content blockquote {
  margin: 0.8em 0;
  padding: 0.6em 0.8em;
  border-left: 3px solid #75b49e;
  border-radius: 0 8px 8px 0;
  color: #50635a;
  background: #f2f7f4;
}

.bubble-content code {
  padding: 0.12em 0.35em;
  border-radius: 5px;
  color: #7a3441;
  background: #f2f4f3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.bubble-content pre {
  margin: 0.8em 0;
  padding: 12px;
  overflow-x: auto;
  border-radius: 10px;
  color: #e9f2ee;
  background: #17241e;
  -webkit-overflow-scrolling: touch;
}

.bubble-content pre code {
  padding: 0;
  color: inherit;
  background: transparent;
  font-size: 12px;
  white-space: pre;
}

.bubble-content hr {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid #e0e8e4;
}

.table-scroll {
  max-width: 100%;
  margin: 0.8em 0;
  overflow-x: auto;
  border: 1px solid #dde7e2;
  border-radius: 9px;
  -webkit-overflow-scrolling: touch;
}

.bubble-content table {
  width: 100%;
  min-width: 360px;
  border-collapse: collapse;
  font-size: 12px;
}

.bubble-content th,
.bubble-content td {
  padding: 8px 9px;
  border-right: 1px solid #e2e9e6;
  border-bottom: 1px solid #e2e9e6;
  text-align: left;
  vertical-align: top;
}

.bubble-content th {
  background: #f1f6f3;
  font-weight: 700;
}

.bubble-content tr:last-child td {
  border-bottom: 0;
}

.bubble-content th:last-child,
.bubble-content td:last-child {
  border-right: 0;
}

.copy-button {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 8px 0 0 auto;
  padding: 4px 5px;
  border: 0;
  border-radius: 6px;
  color: #7c8b84;
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

.response-meta {
  margin-top: 10px;
  color: #829088;
  font-size: 10px;
  letter-spacing: 0.02em;
}

.copy-button:hover,
.copy-button:focus-visible {
  color: #176b50;
  background: #edf5f1;
  outline: none;
}

.copy-button.copied {
  color: #16815d;
}

.copy-button svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bubble.pending {
  display: flex;
  align-items: center;
  min-width: 54px;
  min-height: 38px;
  gap: 4px;
}

.bubble.pending > span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6d8278;
  animation: typing 1s ease-in-out infinite;
}

.bubble.pending > span:nth-child(2) {
  animation-delay: 140ms;
}

.bubble.pending > span:nth-child(3) {
  animation-delay: 280ms;
}

.composer {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: end;
  gap: 5px;
  margin: 0 10px max(10px, env(safe-area-inset-bottom));
  padding: 6px;
  border: 1px solid rgba(29, 83, 60, 0.12);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(24, 67, 48, 0.12);
  z-index: 2;
}

.composer textarea {
  width: 100%;
  min-width: 0;
  height: 38px;
  max-height: 84px;
  padding: 9px 4px 8px;
  overflow-y: auto;
  resize: none;
  border: 0;
  outline: 0;
  color: #1b2621;
  background: transparent;
  line-height: 1.4;
}

.composer textarea::placeholder {
  color: #96a19b;
}

.composer button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease, opacity 150ms ease;
}

.composer button:active:not(:disabled) {
  transform: scale(0.92);
}

.composer-action {
  color: #65736c;
  background: transparent;
}

.composer-action:hover {
  color: #1d7657;
  background: #edf5f1;
}

.send-button {
  color: #fff;
  background: linear-gradient(145deg, #2b8a68, #17664d);
  box-shadow: 0 4px 10px rgba(25, 106, 78, 0.2);
}

.send-button.stop-button {
  color: #fff;
  background: linear-gradient(145deg, #e26e64, #c7524a);
  box-shadow: 0 4px 10px rgba(184, 69, 60, 0.2);
}

.composer button:disabled {
  cursor: default;
  opacity: 0.36;
  box-shadow: none;
}

.composer button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer button.listening {
  color: #fff;
  background: #e4685d;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.55;
    transform: scale(0.9);
  }
}

@media (max-height: 420px) {
  .chat-header {
    padding-top: max(7px, env(safe-area-inset-top));
    padding-bottom: 7px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 11px;
  }

  .brand-mark svg {
    width: 20px;
  }

  .messages {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .bubble {
    padding: 8px 11px;
    font-size: 13px;
  }

  .bubble.assistant.rich {
    padding: 11px 12px 7px;
  }

  .composer {
    margin-bottom: max(6px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

[hidden] {
  display: none !important;
}

.voice-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(100%, 460px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  color: #f4fbf7;
  background:
    radial-gradient(circle at 50% 43%, rgba(66, 198, 148, 0.18), transparent 31%),
    radial-gradient(circle at 15% 5%, rgba(86, 165, 142, 0.18), transparent 35%),
    linear-gradient(165deg, #132820 0%, #0b1b15 57%, #08130f 100%);
}

.voice-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(20px, env(safe-area-inset-top)) 20px 12px;
}

.voice-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: #8bbca8;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.voice-panel-header h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.voice-close-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #d7e7df;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.voice-close-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.voice-stage {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 0;
  padding: 20px 28px 36px;
}

.voice-orb-button {
  position: relative;
  display: grid;
  width: 152px;
  height: 152px;
  margin-bottom: 56px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.voice-orb-button:focus-visible {
  outline: 2px solid #75d3ae;
  outline-offset: 12px;
}

.voice-ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(107, 217, 172, 0.18);
  border-radius: 50%;
  transition: border-color 240ms ease, transform 240ms ease;
}

.ring-two {
  inset: 13px;
  background: rgba(37, 134, 98, 0.08);
}

.voice-orb-core {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100px;
  height: 100px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 50%;
  background: linear-gradient(145deg, #37a77c, #176b50);
  box-shadow:
    0 20px 60px rgba(25, 142, 100, 0.28),
    inset 0 1px 1px rgba(255, 255, 255, 0.22);
  transition: background 240ms ease, box-shadow 240ms ease, transform 180ms ease;
}

.voice-orb-button:active .voice-orb-core {
  transform: scale(0.94);
}

.voice-bar {
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: currentColor;
  transform-origin: center;
}

.voice-bar:nth-child(1),
.voice-bar:nth-child(5) {
  height: 12px;
}

.voice-bar:nth-child(2),
.voice-bar:nth-child(4) {
  height: 25px;
}

.voice-bar:nth-child(3) {
  height: 34px;
}

.voice-panel[data-state="listening"] .voice-ring {
  border-color: rgba(106, 231, 179, 0.34);
  animation: voice-ring 2s ease-out infinite;
}

.voice-panel[data-state="listening"] .ring-two {
  animation-delay: 700ms;
}

.voice-panel[data-state="listening"] .voice-bar {
  animation: voice-bars 760ms ease-in-out infinite alternate;
}

.voice-panel[data-state="listening"] .voice-bar:nth-child(2) {
  animation-delay: 120ms;
}

.voice-panel[data-state="listening"] .voice-bar:nth-child(3) {
  animation-delay: 240ms;
}

.voice-panel[data-state="listening"] .voice-bar:nth-child(4) {
  animation-delay: 360ms;
}

.voice-panel[data-state="thinking"] .voice-orb-core {
  background: linear-gradient(145deg, #548c7a, #285d4c);
  box-shadow: 0 20px 60px rgba(46, 116, 91, 0.25);
}

.voice-panel[data-state="thinking"] .voice-ring {
  border-style: dashed;
  border-color: rgba(140, 207, 181, 0.34);
  animation: voice-spin 6s linear infinite;
}

.voice-panel[data-state="speaking"] .voice-orb-core {
  background: linear-gradient(145deg, #60a8a2, #27736d);
}

.voice-panel[data-state="speaking"] .voice-bar {
  animation: voice-bars 520ms ease-in-out infinite alternate;
}

.voice-panel[data-state="speaking"] .voice-bar:nth-child(even) {
  animation-delay: 180ms;
}

.voice-panel[data-state="error"] .voice-orb-core {
  background: linear-gradient(145deg, #c67868, #8d493e);
}

.voice-copy {
  width: 100%;
  text-align: center;
}

.voice-status {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.voice-transcript {
  display: -webkit-box;
  max-width: 340px;
  min-height: 48px;
  margin: 0 auto;
  overflow: hidden;
  color: #a9bdb4;
  font-size: 14px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.voice-panel-footer {
  display: grid;
  gap: 15px;
  padding: 12px 20px max(20px, env(safe-area-inset-bottom));
}

.voice-tip {
  color: #748e82;
  font-size: 11px;
  text-align: center;
}

.voice-end-button {
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 16px;
  color: #e2eee8;
  background: rgba(255, 255, 255, 0.07);
  font-weight: 650;
  cursor: pointer;
}

@keyframes voice-ring {
  from {
    opacity: 0.9;
    transform: scale(0.84);
  }
  to {
    opacity: 0;
    transform: scale(1.18);
  }
}

@keyframes voice-bars {
  to {
    transform: scaleY(0.45);
  }
}

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

@media (max-height: 620px) {
  .voice-stage {
    padding-top: 8px;
    padding-bottom: 16px;
  }

  .voice-orb-button {
    width: 126px;
    height: 126px;
    margin-bottom: 28px;
  }

  .voice-orb-core {
    width: 84px;
    height: 84px;
  }

  .voice-status {
    font-size: 19px;
  }
}

.parent-shell {
  width: min(920px, calc(100vw - 32px));
  margin: 24px auto;
}

.parent-shell header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.parent-shell h1 {
  margin: 0;
  font-size: 24px;
}

.parent-shell input {
  padding: 8px;
  border: 1px solid #cdd5df;
  border-radius: 6px;
}

.panel {
  display: grid;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid #d7dde5;
}

.panel button {
  width: fit-content;
  padding: 8px 14px;
  border: 0;
  border-radius: 6px;
  background: #1c6b5a;
  color: white;
}

.panel-title {
  font-weight: 700;
}

.parent-messages {
  display: grid;
  gap: 8px;
}

.message-row {
  padding: 10px;
  border: 1px solid #d7dde5;
  border-radius: 8px;
  background: white;
}

.message-meta {
  margin-bottom: 4px;
  font-size: 12px;
  color: #6b7280;
}
