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

:root {
  --white: #ffffff;
  --gray-bg: #f5f5f7;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --text-subtle: #86868b;
  --link: #0066cc;
  --link-hover: #0077ed;
  --border: #d2d2d7;
  --nav-height: 44px;
  --max-width: 980px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --bottom-watermark-offset: 1.25rem;
  --bottom-switch-offset: 2.875rem;
  --page-nav-gutter: 5rem;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
  background: var(--white);
  color: var(--text);
  line-height: 1.47059;
  letter-spacing: -0.022em;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Nav — apple.com global nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-logo {
  font-size: 1.3125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  flex-shrink: 0;
}

/* Page tabs — segmented control */
.page-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--gray-bg);
  border-radius: 980px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.page-tab {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 400;
  padding: 0.3125rem 0.875rem;
  border: none;
  border-radius: 980px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.page-tab:hover {
  color: var(--text);
}

.page-tab.active {
  background: var(--white);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Pages — horizontal swipe layout */
.pages-viewport {
  overflow: hidden;
  width: 100%;
  touch-action: pan-y;
}

.pages-track {
  display: flex;
  width: 200%;
  transition: transform 0.45s var(--ease);
  will-change: transform;
}

.pages-track.is-dragging {
  transition: none;
}

.page {
  flex: 0 0 50%;
  width: 50%;
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  flex-direction: column;
}

.page-profile {
  background: var(--white);
}

.page-chat {
  background: var(--gray-bg);
  height: calc(100vh - var(--nav-height));
  overflow: hidden;
}

.page-chat .chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 2rem 22px 1rem;
}

.page-chat .section-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.page-dots {
  position: fixed;
  bottom: calc(var(--bottom-switch-offset) + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  z-index: 50;
  pointer-events: none;
}

.page-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
}

.page-dot.active {
  background: var(--text-subtle);
  transform: scale(1.25);
}

/* Page nav — side switch buttons */
.page-nav {
  position: fixed;
  inset: var(--nav-height) 0 0;
  pointer-events: none;
  z-index: 90;
}

.page-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), opacity 0.25s var(--ease), transform 0.2s var(--ease);
}

.page-nav-btn:hover {
  background: var(--white);
  color: var(--text);
  transform: translateY(-50%) scale(1.05);
}

.page-nav-btn:active {
  transform: translateY(-50%) scale(0.96);
}

.page-nav-btn[hidden] {
  display: none;
}

.page-nav-prev {
  left: max(16px, env(safe-area-inset-left));
}

.page-nav-next {
  right: max(16px, env(safe-area-inset-right));
}

.page-nav-btn svg {
  display: block;
  width: 16px;
  height: 26px;
}

.page-nav-prev svg {
  margin-right: 2px;
}

.page-nav-next svg {
  margin-left: 2px;
}

/* Hero — apple.com product hero */
.hero {
  background: var(--white);
  text-align: center;
  padding: 3.5rem 22px 4.5rem;
}

.hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.avatar {
  width: 120px;
  height: 120px;
  margin: 0 auto 1.75rem;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  object-position: center;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.name {
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.tagline {
  margin-top: 0.75rem;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: 28em;
  margin-left: auto;
  margin-right: auto;
}

.hero-chat-link {
  display: block;
  width: fit-content;
  margin: 1rem auto 0;
  font-family: inherit;
  font-size: clamp(1.0625rem, 2.5vw, 1.3125rem);
  font-weight: 400;
  padding: 0;
  border: none;
  background: none;
  color: var(--link);
  cursor: pointer;
  letter-spacing: -0.022em;
  transition: color 0.2s var(--ease);
}

.hero-chat-link:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.hero-chat-link::after {
  content: " ›";
}

.page-profile .hero {
  padding-bottom: 2rem;
}

.page-profile .info-section {
  padding-top: 2rem;
}

/* Sections — full-width bands like apple.com */
.section {
  padding: 4.5rem 22px;
  background: var(--white);
}

.section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section-headline {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-align: center;
  margin-bottom: 2.5rem;
}

/* Info — apple.com feature columns */
.info-grid {
  display: grid;
  gap: 2rem 1.5rem;
}

.info-item {
  text-align: center;
  padding: 0 0.5rem;
}

.info-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-subtle);
  letter-spacing: -0.01em;
  margin-bottom: 0.375rem;
}

.info-value {
  display: block;
  font-size: clamp(1.0625rem, 2vw, 1.3125rem);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

@media (min-width: 600px) {
  .info-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .info-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 2.5rem 1rem;
  }
}

/* Chat — product feature section */
.chat-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
  flex-shrink: 0;
}

.page-chat .chat-intro {
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.chat-intro .section-headline {
  margin-bottom: 0.5rem;
}

.chat-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.chat-subtitle {
  font-size: clamp(1.0625rem, 2.5vw, 1.3125rem);
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.chat-panel {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  background: var(--white);
  border-radius: 18px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1 1 auto;
  min-height: 6rem;
  overflow-y: auto;
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  margin-bottom: 1.5rem;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.message {
  display: flex;
  align-items: flex-end;
}

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

.bubble {
  max-width: 78%;
  padding: 0.75rem 1rem;
  font-size: 1.0625rem;
  line-height: 1.47059;
  letter-spacing: -0.022em;
  word-break: break-word;
}

.message.bot .bubble {
  color: var(--text);
  background: var(--gray-bg);
  border-radius: 1.125rem 1.125rem 1.125rem 0.3125rem;
}

.message.user .bubble {
  color: var(--white);
  background: var(--link);
  border-radius: 1.125rem 1.125rem 0.3125rem 1.125rem;
}

.message.is-entering .bubble {
  animation: bubble-in 0.62s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.message.bot.is-entering .bubble {
  transform-origin: left bottom;
}

.message.user.is-entering .bubble {
  transform-origin: right bottom;
}

@keyframes bubble-in {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Quick questions — apple.com link pills */
.quick-questions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.quick-questions button {
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 400;
  padding: 0;
  border: none;
  background: none;
  color: var(--link);
  cursor: pointer;
  letter-spacing: -0.022em;
  transition: color 0.2s var(--ease);
}

.quick-questions button:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.quick-questions button::after {
  content: " ›";
}

/* Chat input */
.chat-input {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-shrink: 0;
}

.chat-input input {
  flex: 1;
  font-family: inherit;
  font-size: 1.0625rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: var(--gray-bg);
  color: var(--text);
  letter-spacing: -0.022em;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.chat-input input::placeholder {
  color: var(--text-subtle);
}

.chat-input input:focus {
  border-color: var(--link);
  background: var(--white);
}

.chat-input button {
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 400;
  padding: 0.75rem 1.375rem;
  border: none;
  border-radius: 980px;
  background: var(--link);
  color: var(--white);
  cursor: pointer;
  letter-spacing: -0.022em;
  transition: background 0.2s var(--ease);
  white-space: nowrap;
}

.chat-input button:hover {
  background: var(--link-hover);
}

.chat-input button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Footer — apple.com site footer */
.footer {
  margin-top: auto;
  background: transparent;
  border-top: 1px solid var(--border);
  padding: 1.75rem 22px calc(var(--bottom-watermark-offset) + env(safe-area-inset-bottom, 0px));
}

.page-chat .footer {
  border-top-color: rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  padding-top: 1rem;
  padding-bottom: calc(var(--bottom-watermark-offset) + env(safe-area-inset-bottom, 0px));
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-subtle);
  letter-spacing: -0.01em;
}

/* Typing indicator */
.typing .bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  min-width: 3.5rem;
  padding: 0.875rem 1.125rem;
}

.typing .bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-subtle);
  animation: blink 1.2s infinite;
}

.typing .bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing .bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

@media (min-width: 601px) {
  :root {
    --bottom-watermark-offset: 1.5rem;
    --bottom-switch-offset: 5rem;
  }

  .page-chat .section-inner {
    padding-left: max(22px, var(--page-nav-gutter));
    padding-right: max(22px, var(--page-nav-gutter));
  }
}

@media (max-width: 600px) {
  .page-nav {
    display: none;
  }
}

@media (max-width: 480px) {
  .nav-inner {
    padding: 0 16px;
  }

  .page-tab {
    font-size: 0.75rem;
    padding: 0.3125rem 0.625rem;
  }

  .page-nav-btn {
    width: 48px;
    height: 48px;
  }

  .page-nav-btn svg {
    width: 14px;
    height: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .message.is-entering .bubble {
    animation: none;
  }
}
