:root {
  color-scheme: light;
  --bg-top: oklch(0.99 0 0);
  --bg-bottom: oklch(0.99 0 0);
  --text: oklch(0.05 0 0);
  --muted: oklch(0.45 0 0);
  --assistant-top: #f4e8ff;
  --assistant-bottom: #fffefe;
  --assistant-border: rgba(155, 106, 255, 0.4);
  --assistant-text: #5b21b6;
  --user-top: #2563eb;
  --user-mid: #1d4ed8;
  --user-bottom: #1e40af;
  --user-text: #ffffff;
  --shadow-soft: 0 20px 60px rgba(83, 58, 19, 0.09);
  --shadow-bubble: 0 8px 22px rgba(17, 24, 39, 0.05);
  --wrapper-width: 860px;
}

:root.dark {
  color-scheme: dark;
  --bg-top: oklch(0.06 0 0);
  --bg-bottom: oklch(0.06 0 0);
  --text: oklch(0.99 0 0);
  --muted: oklch(0.72 0 0);
  --assistant-top: rgba(76, 29, 149, 0.85);
  --assistant-bottom: rgba(67, 20, 126, 0.9);
  --assistant-border: rgba(124, 58, 237, 0.6);
  --assistant-text: #ede9fe;
  --user-top: #1c3faa;
  --user-mid: #18378e;
  --user-bottom: #172f7d;
  --user-text: #ffffff;
  --shadow-soft: 0 20px 60px rgba(2, 6, 23, 0.28);
  --shadow-bubble: 0 10px 25px rgba(2, 6, 23, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Noto Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg-top);
}

body {
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100%;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 1;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(24, 24, 27, 0.12) 2px, transparent 0);
  background-size: 32px 32px;
  background-position: 0 0;
}

:root.dark .app-shell::before {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(248, 250, 252, 0.25) 2px, transparent 0);
}

.app-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.shell-main,
.shell-footer__inner {
  width: min(var(--wrapper-width), calc(100vw - 24px));
  margin: 0 auto;
}

.shell-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 0 132px;
  overflow: hidden;
}

.package-host {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.quick-question {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.transcript {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
}

.message-row {
  display: flex;
}

.message-row--user {
  justify-content: flex-end;
}

.message-row--assistant {
  justify-content: flex-start;
}

.bubble-stack {
  max-width: min(76%, 720px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bubble {
  position: relative;
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: var(--shadow-bubble);
  line-height: 1.42;
  word-break: break-word;
  font-size: 0.99rem;
  letter-spacing: -0.01em;
}

.bubble--assistant {
  color: var(--assistant-text);
  border: 1px solid var(--assistant-border);
  background: linear-gradient(135deg, var(--assistant-top) 0%, var(--assistant-bottom) 100%);
  border-top-left-radius: 6px;
}

.bubble--user {
  color: var(--user-text);
  background: linear-gradient(135deg, var(--user-top) 0%, var(--user-mid) 50%, var(--user-bottom) 100%);
  border-top-right-radius: 6px;
}

.bubble p {
  margin: 0;
}

.bubble p + p {
  margin-top: 10px;
}

.bubble--pending {
  min-width: 40px;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.bubble-thinking {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 10px;
}

.bubble-thinking__dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(91, 33, 182, 0.3);
  animation: thinking-bounce 0.9s ease-in-out infinite;
}

.bubble-thinking__dot:nth-child(2) {
  animation-delay: 0.12s;
}

.bubble-thinking__dot:nth-child(3) {
  animation-delay: 0.24s;
}

.shell-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding:
    12px
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  border-top: 1px solid rgba(31, 26, 17, 0.08);
}

.shell-footer__inner {
  display: flex;
  justify-content: center;
  position: relative;
}

.composer-counter-float {
  position: fixed;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
  border-radius: 999px;
  background: rgb(250 250 250 / 0.96);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  color: rgb(63 63 70);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

:root.dark .composer-counter-float {
  background: rgba(24, 24, 27, 0.82);
  color: rgb(244 244 245);
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.35);
}

.composer-counter-float--visible {
  opacity: 1;
  transform: translateY(0);
}

.beach-sand-footer {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(240, 230, 140, 0.15), transparent 40%),
    radial-gradient(ellipse at 70% 40%, rgba(238, 203, 173, 0.12), transparent 35%),
    radial-gradient(ellipse at 20% 60%, rgba(222, 184, 135, 0.1), transparent 30%),
    radial-gradient(ellipse at 80% 80%, rgba(210, 180, 140, 0.08), transparent 25%),
    radial-gradient(ellipse at 50% 90%, rgba(205, 170, 125, 0.06), transparent 20%),
    linear-gradient(180deg, rgba(245, 222, 179, 0.08) 0%, rgba(238, 203, 173, 0.12) 40%, rgba(222, 184, 135, 0.15) 100%),
    radial-gradient(circle at 10% 20%, rgba(160, 140, 100, 0.03), transparent 2px),
    radial-gradient(circle at 30% 50%, rgba(180, 160, 120, 0.02), transparent 1.5px),
    radial-gradient(circle at 60% 30%, rgba(200, 180, 140, 0.025), transparent 2px),
    radial-gradient(circle at 80% 70%, rgba(170, 150, 110, 0.02), transparent 1.5px),
    radial-gradient(circle at 90% 90%, rgba(190, 170, 130, 0.03), transparent 2px),
    linear-gradient(180deg, #f5deb3 0%, #deb887 100%);
  background-size: 60% 40%, 50% 35%, 45% 30%, 40% 25%, 35% 20%, 100% 100%, 20px 20px, 15px 15px, 25px 25px, 18px 18px, 22px 22px, 100% 100%;
}

:root.dark .beach-sand-footer {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(71, 85, 105, 0.12), transparent 40%),
    radial-gradient(ellipse at 70% 40%, rgba(55, 65, 81, 0.15), transparent 35%),
    radial-gradient(ellipse at 20% 60%, rgba(75, 85, 99, 0.1), transparent 30%),
    radial-gradient(ellipse at 80% 80%, rgba(45, 55, 72, 0.08), transparent 25%),
    radial-gradient(ellipse at 50% 90%, rgba(51, 65, 85, 0.06), transparent 20%),
    radial-gradient(ellipse at 40% 30%, rgba(139, 125, 107, 0.04), transparent 15%),
    radial-gradient(ellipse at 80% 60%, rgba(120, 113, 108, 0.03), transparent 12%),
    linear-gradient(180deg, rgba(51, 65, 85, 0.08) 0%, rgba(55, 65, 81, 0.12) 40%, rgba(71, 85, 105, 0.15) 100%),
    radial-gradient(circle at 10% 20%, rgba(30, 41, 59, 0.06), transparent 2px),
    radial-gradient(circle at 30% 50%, rgba(40, 50, 65, 0.04), transparent 1.5px),
    radial-gradient(circle at 60% 30%, rgba(35, 45, 60, 0.05), transparent 2px),
    radial-gradient(circle at 80% 70%, rgba(45, 55, 70, 0.04), transparent 1.5px),
    radial-gradient(circle at 90% 90%, rgba(38, 48, 63, 0.06), transparent 2px),
    linear-gradient(180deg, #374151 0%, #1f2937 100%);
  background-size: 60% 40%, 50% 35%, 45% 30%, 40% 25%, 35% 20%, 40% 25%, 35% 20%, 100% 100%, 20px 20px, 15px 15px, 25px 25px, 18px 18px, 22px 22px, 100% 100%;
}

.composer {
  width: min(var(--wrapper-width), calc(100vw - 24px));
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 30px -24px rgba(24, 24, 27, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

:root.dark .composer {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(24, 24, 27, 0.78);
  box-shadow: 0 18px 30px -24px rgba(2, 6, 23, 0.9);
}

.composer__field {
  flex: 1;
  min-height: 52px;
  max-height: 220px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  padding: 12px 14px 11px;
  color: var(--text);
}

.composer__field::placeholder {
  color: rgba(95, 82, 57, 0.8);
}

:root.dark .composer__field::placeholder {
  color: rgba(229, 231, 235, 0.62);
}

.composer__send {
  border: 0;
  min-width: 98px;
  padding: 0 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%);
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease;
}

.composer__send:hover:not(:disabled) {
  transform: translateY(-1px);
}

.composer__send:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.composer__counter--limit {
  color: #9a3412;
}

:root.dark .composer__counter--limit {
  color: #fdba74;
}

@keyframes thinking-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0) scale(0.92);
    opacity: 0.45;
  }

  40% {
    transform: translateY(-2px) scale(1);
    opacity: 1;
  }
}

@media (max-width: 720px) {
  .bubble-stack {
    max-width: 90%;
  }

  .composer {
    width: calc(100vw - 24px);
  }

  .composer__send {
    min-width: 78px;
  }

  .composer-counter-float {
    display: none;
  }
}
