:root {
  --bg: #faf8f3;
  --bg-deep: #f3efe6;
  --ink: #1a1917;
  --muted: #6d6a63;
  --green: #20d67b;
  --green-deep: #129a56;
  --line: rgba(26, 25, 23, 0.12);
  --glass: rgba(250, 248, 243, 0.62);
  --sheet: rgba(255, 255, 255, 0.72);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

body {
  color: var(--ink);
  font: 100%/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
}

.pressable {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
}

html,
body {
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  isolation: isolate;
  height: 100dvh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top) + 40px)
    22px
    calc(env(safe-area-inset-bottom) + 22px);
  background: var(--bg);
  overflow: hidden;
}

.stage::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 6;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.layer-logo {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  padding-top: 8px;
  flex: 0 0 auto;
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.logo {
  width: min(58%, 220px);
  height: auto;
  object-fit: contain;
}

.layer-carousel {
  position: relative;
  z-index: 1;
  flex: 0 0 60dvh;
  height: 60dvh;
  min-height: 0;
  max-height: none;
  margin: 4px -22px 0;
  overflow: hidden;
  touch-action: none;
  background: radial-gradient(ellipse 58% 70% at 50% 38%, #fff 0%, var(--bg) 78%);
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.06s both;
}

.carousel {
  position: absolute;
  inset: 0;
  touch-action: none;
}

.slide {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  z-index: 0;
  background: var(--bg);
  transition: opacity 0.55s ease;
  pointer-events: none;
}

.slide.is-active {
  opacity: 1;
  z-index: 1;
}

.slide img {
  width: 100%;
  height: 115%;
  object-fit: contain;
  object-position: center center;
  -webkit-mask-image: radial-gradient(ellipse 82% 74% at 50% 40%, #000 48%, transparent 80%);
  mask-image: radial-gradient(ellipse 82% 74% at 50% 40%, #000 48%, transparent 80%);
}

.carousel-fade {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, var(--bg) 0%, rgba(250, 248, 243, 0.55) 8%, transparent 18%, transparent 64%, rgba(250, 248, 243, 0.42) 78%, var(--bg) 100%),
    linear-gradient(90deg, var(--bg) 0%, rgba(250, 248, 243, 0.35) 8%, transparent 18%, transparent 82%, rgba(250, 248, 243, 0.35) 92%, var(--bg) 100%);
}

.layer-cta {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}

.layer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

button.btn {
  width: 100%;
  font: inherit;
}

.btn {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  height: 48px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
  transition: transform 100ms ease-out, box-shadow 180ms ease;
  will-change: transform;
}

.btn span {
  position: relative;
  z-index: 1;
}

.btn.is-pressed,
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  color: #04140c;
  background: linear-gradient(180deg, #3ae48d 0%, var(--green) 48%, var(--green-deep) 100%);
  box-shadow: 0 8px 18px rgba(32, 214, 123, 0.24);
}

.btn-ghost {
  color: var(--ink);
  background: var(--sheet);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.layer-title {
  text-align: center;
}

.kicker {
  margin: 0 0 4px;
  font-family: Teko, ui-sans-serif, sans-serif;
  font-size: 15px;
  letter-spacing: 0.22em;
  color: var(--green-deep);
}

.layer-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.cs-entry {
  position: absolute;
  right: 0;
  top: 50%;
  z-index: 4;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 46px;
  min-height: 88px;
  padding: 12px 8px 12px 10px;
  border: 0;
  border-radius: 14px 0 0 14px;
  color: #04140c;
  background: linear-gradient(180deg, #3ae48d, var(--green-deep));
  box-shadow: -6px 8px 20px rgba(0, 0, 0, 0.12);
  transition: transform 100ms ease-out;
  will-change: transform;
}

.cs-entry.is-pressed,
.cs-entry:active {
  transform: translateY(-50%) scale(0.97);
}

.cs-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
}

.cs-icon svg {
  width: 22px;
  height: 22px;
}

.cs-label {
  writing-mode: vertical-rl;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.cs-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  background: rgba(26, 25, 23, calc(0.4 * var(--scrim, 0)));
  pointer-events: auto;
}

.cs-mask[hidden] {
  display: none;
}

.cs-sheet {
  width: min(100%, 480px);
  padding: 8px 22px calc(env(safe-area-inset-bottom) + 22px);
  border-radius: 22px 22px 0 0;
  background: var(--sheet);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-bottom: 0;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 -18px 48px rgba(26, 25, 23, 0.16);
  transform: translate3d(0, 100%, 0);
  will-change: transform;
  touch-action: none;
}

.sheet-handle {
  width: 36px;
  height: 5px;
  margin: 6px auto 14px;
  border-radius: 99px;
  background: rgba(26, 25, 23, 0.22);
}

.cs-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cs-sheet h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 700;
}

.cs-sheet p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 15px;
}

.install-steps {
  margin: 0;
  padding-left: 1.2em;
  color: var(--ink);
  line-height: 1.65;
  font-size: 15px;
}

.install-steps li + li {
  margin-top: 8px;
}

.cs-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(26, 25, 23, 0.08);
  font-size: 22px;
  line-height: 1;
  transition: transform 100ms ease-out;
}

.cs-close.is-pressed,
.cs-close:active {
  transform: scale(0.94);
}

.chat-page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 12px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.chat-head::after {
  content: "";
  pointer-events: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: -16px;
  height: 16px;
  background: linear-gradient(180deg, rgba(250, 248, 243, 0.55), transparent);
}

.chat-back {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  text-decoration: none;
  background: rgba(26, 25, 23, 0.06);
  font-size: 22px;
  transition: transform 100ms ease-out;
}

.chat-back.is-pressed,
.chat-back:active {
  transform: scale(0.94);
}

.chat-head h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.chat-list {
  flex: 1;
  overflow: auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-welcome {
  margin: 48px auto 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.bubble-row {
  display: flex;
  animation: rise 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.bubble-row.mine {
  justify-content: flex-end;
}

.bubble {
  max-width: 76%;
  padding: 9px 12px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.45;
  word-break: break-word;
}

.bubble.is-image {
  padding: 3px;
  background: transparent;
}

.bubble-img {
  display: block;
  max-width: min(220px, 64vw);
  max-height: 280px;
  border-radius: 14px;
  object-fit: cover;
}

.chat-attach {
  width: 44px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: rgba(26, 25, 23, 0.06);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  transition: transform 100ms ease-out;
}

.chat-attach.is-pressed,
.chat-attach:active {
  transform: scale(0.94);
}

.bubble-row.mine .bubble {
  background: var(--green);
  color: #04140c;
  border-bottom-right-radius: 5px;
}

.bubble-row.staff .bubble {
  background: #fff;
  color: var(--ink);
  border-bottom-left-radius: 5px;
}

.chat-dock {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.chat-capsules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px 0;
}

.chat-capsules[hidden] {
  display: none !important;
}

.chat-capsule {
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  box-shadow: 0 1px 0 rgba(26, 25, 23, 0.06);
  transition: transform 100ms ease-out, opacity 120ms ease;
}

.chat-capsule.is-pressed,
.chat-capsule:active {
  transform: scale(0.96);
}

.chat-capsule:disabled {
  opacity: 0.45;
}

.bubble.is-html {
  padding: 10px 12px;
  overflow: hidden;
}

.bubble-rich {
  font-size: 15px;
  line-height: 1.5;
  max-width: 100%;
  overflow: hidden;
}

.bubble-rich p {
  margin: 0 0 6px;
}

.bubble-rich p:last-child {
  margin-bottom: 0;
}

.bubble-rich img {
  display: block;
  max-width: 100%;
  max-height: 200px;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  border-radius: 10px;
  margin: 6px 0;
}

.chat-input {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: transparent;
}

.chat-input textarea {
  flex: 1;
  min-height: 40px;
  max-height: 96px;
  resize: none;
  border: 0;
  border-radius: 20px;
  padding: 9px 14px;
  font: inherit;
  background: rgba(26, 25, 23, 0.06);
  outline: none;
}

.chat-send {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--green);
  color: #04140c;
  font-size: 16px;
  transition: transform 100ms ease-out, opacity 120ms ease;
}

.chat-send.is-pressed:not(:disabled),
.chat-send:active:not(:disabled) {
  transform: scale(0.94);
}

.chat-send:disabled {
  opacity: 0.38;
}

@media (prefers-reduced-motion: reduce) {
  .layer-logo,
  .layer-carousel,
  .layer-cta,
  .bubble-row {
    animation: none;
  }

  .btn,
  .slide,
  .cs-entry,
  .cs-close,
  .chat-back,
  .chat-attach,
  .chat-capsule,
  .chat-send {
    transition: none;
  }

  .cs-sheet {
    transform: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .btn-ghost,
  .cs-sheet,
  .chat-head,
  .chat-dock,
  .chat-input {
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  .btn-ghost,
  .cs-sheet,
  .chat-input textarea,
  .chat-back,
  .chat-attach {
    border: 1px solid var(--ink);
  }
}
