:root {
  color-scheme: light;
  --app-height: 100vh;
  --app-width: 100vw;
  --sand: #f2ebe1;
  --sand-2: #ece3d6;
  --cream: #fcf9f4;
  --chat-bg: var(--cream);
  --ink: #3d332b;
  --ink-soft: #7a6e62;
  --ink-faint: #a89a8b;
  --clay: #b87e5e;
  --clay-deep: #9c6347;
  --rose: #c98f86;
  --line: rgba(61, 51, 43, 0.1);
  --line-soft: rgba(61, 51, 43, 0.06);
  --ok: #7ba77c;
  --warn: #9b4c18;
  --warn-bg: #fff0df;
  --shadow-soft: 0 4px 16px rgba(61, 51, 43, 0.05);
  --shadow-clay: 0 6px 18px rgba(156, 99, 71, 0.3);
  --font-ui: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-voice: "Spectral", Georgia, serif;
  --viewport-top: 0px;
  --keyboard-offset: 0px;
}

@supports (height: 100dvh) {
  :root {
    --app-height: 100dvh;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background: var(--sand);
}

body {
  width: 100%;
  max-width: 100%;
  overflow-wrap: anywhere;
}

body {
  color: var(--ink);
  background:
    radial-gradient(110% 90% at 50% -10%, #f7f1e8 0%, transparent 56%),
    linear-gradient(180deg, var(--sand) 0%, var(--sand-2) 100%);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  width: min(1120px, 100%);
  max-width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(30px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  overflow-x: hidden;
}

.app-shell > * {
  max-width: 100%;
}

.member-summary {
  display: flex;
  align-items: center;
  min-width: 0;
}

.member-summary > div {
  min-width: 0;
}

.coach-avatar {
  position: relative;
  flex: 0 0 auto;
  border-radius: 999px;
  background: url("/assets/nathalie-hero.jpg") center / cover;
  box-shadow:
    inset 0 0 0 1px rgba(252, 249, 244, 0.5),
    0 0 0 3px rgba(184, 126, 94, 0.14);
}

.coach-avatar::after {
  content: none;
}

.coach-avatar {
  width: 44px;
  height: 44px;
  background-position: 50% 34%;
  background-size: 185%;
}

.coach-avatar.small {
  width: 42px;
  height: 42px;
}

.coach-avatar.large {
  width: 58px;
  height: 58px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1.4px;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  color: var(--ink);
  font-family: var(--font-voice);
  font-size: 31px;
  font-weight: 500;
  line-height: 1.16;
}

.status-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  background: rgba(252, 249, 244, 0.62);
}

.status-ok {
  border-color: rgba(123, 167, 124, 0.4);
  color: #4f7f54;
  background: rgba(123, 167, 124, 0.11);
}

.status-pending {
  color: var(--clay-deep);
  background: rgba(184, 126, 94, 0.1);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
}

.hidden {
  display: none !important;
}

.gate-shell {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 0.82fr);
  min-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(252, 249, 244, 0.48);
  box-shadow: 0 20px 80px rgba(61, 51, 43, 0.08);
}

.gate-hero {
  position: relative;
  min-height: 560px;
  background:
    linear-gradient(180deg, rgba(61, 51, 43, 0.08), rgba(242, 235, 225, 0.95) 88%),
    url("/assets/nathalie-hero.jpg") center / cover;
}

.gate-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 260px;
  background: linear-gradient(180deg, transparent, var(--sand) 92%);
}

.gate-hero-label {
  position: absolute;
  top: 44px;
  right: 0;
  left: 0;
  z-index: 1;
  color: #fbf3ea;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 3px;
  text-align: center;
  text-shadow: 0 1px 8px rgba(61, 40, 28, 0.5);
  text-transform: uppercase;
}

.gate-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 48px;
  background: linear-gradient(180deg, rgba(252, 249, 244, 0.94), rgba(242, 235, 225, 0.9));
}

.gate-start-panel {
  align-items: stretch;
  justify-content: flex-end;
}

.gate-start-panel .supporting-copy {
  margin-bottom: 30px;
}

.gate-start-button {
  width: 100%;
  min-height: 56px;
}

.gate-email-panel {
  position: relative;
}

.back-link {
  align-self: flex-start;
  min-height: auto;
  margin-top: 18px;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--clay-deep);
  background: transparent;
  box-shadow: none;
  font-size: 14px;
}

.back-link:hover {
  filter: none;
  text-decoration: underline;
}

.supporting-copy {
  max-width: 33ch;
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-family: var(--font-voice);
  font-size: 18px;
  font-style: italic;
  line-height: 1.5;
}

.gate-form {
  margin-top: 30px;
}

label {
  display: block;
  margin-bottom: 9px;
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.row {
  display: grid;
  gap: 12px;
}

input,
textarea {
  width: 100%;
  min-height: 54px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 15px 16px;
  color: var(--ink);
  background: var(--cream);
  font: 500 16px/1.2 var(--font-ui);
}

textarea {
  resize: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-faint);
}

input:focus,
textarea:focus {
  border-color: var(--clay);
  outline: 0;
  box-shadow: 0 0 0 4px rgba(184, 126, 94, 0.12);
}

button {
  max-width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  padding: 0 18px;
  color: #fbf3ea;
  background: linear-gradient(160deg, #bc835f, var(--clay-deep));
  box-shadow: var(--shadow-clay);
  cursor: pointer;
  font: 600 16px/1 var(--font-ui);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

button:hover {
  filter: brightness(0.98);
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.input-help {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  color: var(--ink-faint);
  font-size: 12.5px;
}

.input-help::before {
  content: "✶";
  color: var(--clay);
  font-size: 12px;
}

.notice {
  border-radius: 14px;
  margin-top: 16px;
  padding: 12px 14px;
  line-height: 1.45;
}

.notice-warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.chat-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--chat-bg);
  box-shadow: none;
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  min-width: 0;
  min-height: calc(100vh - 48px);
  background: var(--chat-bg);
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding: 16px 28px;
  background: var(--chat-bg);
}

.member-summary {
  gap: 12px;
}

.member-summary strong {
  display: block;
  font-family: var(--font-voice);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.15;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-menu {
  position: relative;
  flex: 0 0 auto;
}

.chat-menu-button {
  display: grid;
  grid-template-columns: repeat(3, 4px);
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0;
  background: rgba(252, 249, 244, 0.7);
  box-shadow: none;
}

.chat-menu-button span {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--ink-soft);
}

.chat-menu-button:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px rgba(184, 126, 94, 0.14);
}

.chat-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  width: 210px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  background: var(--cream);
  box-shadow: 0 14px 40px rgba(61, 51, 43, 0.12);
}

.chat-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  font-size: 14px;
  text-decoration: none;
  text-align: left;
  white-space: normal;
}

.chat-menu-item:hover,
.chat-menu-item:focus-visible {
  background: rgba(61, 51, 43, 0.06);
  filter: none;
  outline: 0;
}

.chat-menu-item.danger {
  color: #8c3e2f;
}

.chat-menu-item:disabled {
  opacity: 0.55;
}

.guide-page {
  min-height: 100vh;
}

.install-guide-shell {
  width: min(860px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding:
    max(22px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(32px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.install-guide-header {
  display: grid;
  gap: 18px;
  padding: 10px 0 26px;
}

.install-guide-header .member-summary {
  align-items: center;
}

.install-guide-header h1 {
  margin: 0;
  font-family: var(--font-voice);
  font-size: clamp(38px, 8vw, 64px);
  font-weight: 500;
  line-height: 1;
}

.install-guide-header p {
  max-width: 640px;
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--font-voice);
  font-size: clamp(21px, 4vw, 31px);
  font-style: italic;
  line-height: 1.32;
}

.install-steps {
  display: grid;
  gap: 18px;
}

.install-step {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(220px, 0.82fr);
  align-items: center;
  gap: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: rgba(252, 249, 244, 0.78);
  box-shadow: var(--shadow-soft);
}

.install-step span {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  margin-bottom: 18px;
  color: #fbf3ea;
  background: var(--clay);
  font-weight: 700;
}

.install-step h2 {
  margin: 0;
  font-family: var(--font-voice);
  font-size: clamp(27px, 5vw, 38px);
  font-weight: 500;
  line-height: 1.08;
}

.install-step p {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.45;
}

.install-step img {
  width: 100%;
  max-height: 360px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  object-fit: cover;
  object-position: center;
}

.install-guide-footer {
  display: flex;
  justify-content: center;
  padding: 28px 0 0;
}

.install-guide-footer .gate-start-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(360px, 100%);
  max-width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  padding: 0 18px;
  color: #fbf3ea;
  background: linear-gradient(160deg, #bc835f, var(--clay-deep));
  box-shadow: var(--shadow-clay);
  font: 600 16px/1 var(--font-ui);
  letter-spacing: 0.2px;
  text-decoration: none;
  white-space: nowrap;
}

.install-guide-footer .gate-start-button:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px rgba(184, 126, 94, 0.18), var(--shadow-clay);
}

.member-email {
  max-width: 220px;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.secondary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(252, 249, 244, 0.62);
  box-shadow: none;
  font-size: 13px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding: 26px max(28px, calc((100% - 676px) / 2)) 16px;
}

.chat-message {
  max-width: min(86%, 620px);
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.chat-message.assistant {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 20px 20px 20px 7px;
  padding: 13px 16px;
  color: var(--ink);
  background: var(--cream);
  box-shadow: var(--shadow-soft);
  font-family: var(--font-voice);
  font-size: 16.5px;
}

.chat-message.user {
  align-self: flex-end;
  border-radius: 20px 20px 7px 20px;
  padding: 12px 16px;
  color: #fbf3ea;
  background: linear-gradient(160deg, #bc835f, #a86a48);
  box-shadow: 0 4px 14px rgba(156, 99, 71, 0.22);
  font-family: var(--font-ui);
  font-size: 15.5px;
}

.chat-message.pending {
  color: var(--ink-faint);
  font-style: italic;
}

.chat-message p {
  margin: 0;
}

.chat-message h3,
.chat-message h4,
.chat-message h5,
.chat-message h6 {
  margin: 16px 0 8px;
  font-family: inherit;
  font-size: 1.02em;
  font-weight: 700;
  line-height: 1.35;
}

.chat-message h3:first-child,
.chat-message h4:first-child,
.chat-message h5:first-child,
.chat-message h6:first-child {
  margin-top: 0;
}

.chat-message p + p,
.chat-message p + ul,
.chat-message p + ol,
.chat-message p + h3,
.chat-message p + h4,
.chat-message p + h5,
.chat-message p + h6,
.chat-message ul + p,
.chat-message ol + p,
.chat-message ul + h3,
.chat-message ul + h4,
.chat-message ul + h5,
.chat-message ul + h6,
.chat-message ol + h3,
.chat-message ol + h4,
.chat-message ol + h5,
.chat-message ol + h6 {
  margin-top: 10px;
}

.chat-message ul,
.chat-message ol {
  margin: 0;
  padding-left: 22px;
}

.chat-message li + li {
  margin-top: 5px;
}

.chat-message code {
  border-radius: 4px;
  padding: 1px 4px;
  background: rgba(61, 51, 43, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

.empty-session-welcome {
  display: grid;
  justify-items: center;
  align-self: center;
  width: min(690px, 100%);
  margin: auto auto 8px;
  padding: 28px 18px 14px;
  text-align: center;
  animation: welcomeIn 720ms cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

.welcome-orb {
  position: relative;
  display: grid;
  place-items: center;
  width: 162px;
  height: 162px;
  margin-bottom: 54px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(184, 126, 94, 0.14) 0 42%, rgba(184, 126, 94, 0.07) 43% 100%);
}

.welcome-orb::before,
.welcome-orb::after,
.welcome-orb span {
  content: "";
  position: absolute;
  border-radius: inherit;
}

.welcome-orb::before {
  inset: 40px;
  border: 1.5px solid rgba(184, 126, 94, 0.22);
}

.welcome-orb::after {
  inset: 62px;
  background: rgba(184, 126, 94, 0.3);
}

.welcome-orb span {
  inset: 0;
  background: radial-gradient(circle, rgba(184, 126, 94, 0.1), transparent 68%);
  filter: blur(10px);
  opacity: 0.82;
}

.loading-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 48px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--chat-bg);
  box-shadow: none;
}

.loading-shell .welcome-orb {
  margin: 0;
}

.empty-session-welcome h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-voice);
  font-size: clamp(34px, 7vw, 58px);
  font-weight: 500;
  line-height: 1.05;
}

.empty-session-welcome p {
  max-width: 550px;
  margin: 20px 0 0;
  color: var(--ink-soft);
  font-family: var(--font-voice);
  font-size: clamp(22px, 4vw, 33px);
  font-style: italic;
  line-height: 1.36;
}

.chat-messages.has-empty-welcome {
  gap: 16px;
  justify-content: center;
}

.chat-messages.has-empty-welcome .empty-session-welcome {
  margin: 0 auto 8px;
}

.chat-messages.has-empty-welcome .prompt-strip {
  align-self: center;
}

.prompt-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-self: flex-start;
  gap: 10px;
  width: min(620px, 86%);
  max-width: 100%;
  overflow: visible;
  padding: 0;
}

.prompt-strip::-webkit-scrollbar {
  height: 0;
}

.prompt-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--cream);
  box-shadow: none;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.12;
  padding: 10px 17px;
  text-align: center;
  white-space: normal;
}

.prompt-chip.accent {
  border-color: rgba(184, 126, 94, 0.4);
  color: var(--clay-deep);
  background: rgba(184, 126, 94, 0.07);
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: min(620px, calc(100% - 56px));
  max-width: 100%;
  min-width: 0;
  margin: 0 auto 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 8px 8px 20px;
  background: var(--cream);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.chat-composer label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.chat-composer textarea {
  flex: 1;
  min-height: 38px;
  max-height: min(160px, calc(var(--app-height) * 0.25));
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 9px 4px 7px;
  background: transparent;
  box-shadow: none;
  font-size: 15px;
  line-height: 1.35;
  overflow-y: auto;
}

.chat-composer textarea:focus {
  box-shadow: none;
}

.send-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  box-shadow: none;
  padding: 0;
}

.send-button {
  width: 42px;
  min-height: 42px;
  font-size: 24px;
  line-height: 1;
}

.debug-drawer {
  margin-top: 18px;
}

.debug-drawer summary {
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 2px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 14px 0;
  padding: 18px;
  background: var(--cream);
}

.panel h2 {
  margin-bottom: 16px;
  font-size: 22px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

pre {
  overflow: auto;
  min-height: 72px;
  border-radius: 12px;
  margin: 16px 0 0;
  padding: 16px;
  color: #f5f2ed;
  background: #2b241f;
  font-size: 13px;
  line-height: 1.55;
}

.results {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.contact {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.contact strong {
  display: block;
}

.meta {
  color: var(--ink-soft);
  font-size: 14px;
}

@media (prefers-reduced-motion: no-preference) {
  .coach-avatar {
    animation: breathe 7.5s ease-in-out infinite alternate;
  }

  .welcome-orb {
    animation: orbPulse 4.8s ease-in-out infinite;
  }

  .welcome-orb::before {
    animation: orbRingPulse 4.8s ease-in-out infinite;
  }

  .welcome-orb span {
    animation: orbGlowPulse 4.8s ease-in-out infinite;
  }
}

@keyframes breathe {
  from {
    transform: scale(0.98);
    opacity: 0.92;
  }

  to {
    transform: scale(1.02);
    opacity: 1;
  }
}

@keyframes welcomeIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes orbPulse {
  0%,
  100% {
    transform: scale(0.985);
  }

  50% {
    transform: scale(1.025);
  }
}

@keyframes orbRingPulse {
  0%,
  100% {
    opacity: 0.72;
    transform: scale(0.96);
  }

  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

@keyframes orbGlowPulse {
  0%,
  100% {
    opacity: 0.56;
  }

  50% {
    opacity: 0.92;
  }
}

@media (max-width: 840px) {
  html,
  body {
    width: 100%;
  }

  .chat-menu-button {
    position: relative;
  }

  .chat-menu-button.has-install-guide-badge::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 9px;
    height: 9px;
    border: 2px solid var(--cream);
    border-radius: 999px;
    background: #d94b3f;
  }

  .install-guide-menu-item.has-install-guide-badge::after {
    content: "";
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 999px;
    margin-left: auto;
    background: #d94b3f;
  }

  .install-guide-shell {
    padding:
      max(18px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .install-step {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
  }

  .install-step img {
    max-height: none;
  }

  .app-shell {
    width: 100%;
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .gate-shell {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: auto;
    border-radius: 18px;
  }

  .gate-hero {
    min-height: 258px;
  }

  .gate-hero::after {
    height: 170px;
  }

  .gate-panel {
    width: 100%;
    min-width: 0;
    min-height: 374px;
    padding: 26px 20px 22px;
    text-align: left;
  }

  .gate-start-panel {
    min-height: 210px;
  }

  h2 {
    font-size: 28px;
  }

  .supporting-copy {
    max-width: none;
    font-size: 17px;
  }

  .chat-shell {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: calc(100vh - 34px);
    border-radius: 0;
    border-right: 0;
    border-left: 0;
    margin: 0;
    overflow-x: hidden;
  }

  .loading-shell {
    min-height: calc(100vh - 34px);
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .conversation-panel {
    width: 100%;
    min-width: 0;
    min-height: calc(100vh - 34px);
    grid-template-rows: auto minmax(260px, 1fr) auto;
  }

  .chat-topbar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding:
      calc(14px + env(safe-area-inset-top))
      max(18px, env(safe-area-inset-right))
      14px
      max(18px, env(safe-area-inset-left));
  }

  .topbar-actions {
    gap: 8px;
  }

  .member-email {
    display: none;
  }

  .secondary-button {
    width: auto;
    min-height: 36px;
    padding: 0 12px;
  }

  .chat-messages {
    width: 100%;
    max-width: 100%;
    padding: 18px 16px 12px;
  }

  .chat-message {
    max-width: 86%;
  }

  .chat-message.assistant {
    font-size: 16.5px;
  }

  .empty-session-welcome {
    width: 100%;
    padding: 18px 12px 10px;
  }

  .welcome-orb {
    width: 132px;
    height: 132px;
    margin-bottom: 38px;
  }

  .welcome-orb::before {
    inset: 32px;
  }

  .welcome-orb::after {
    inset: 50px;
  }

  .prompt-strip {
    width: 100%;
  }

  .prompt-chip {
    min-height: 56px;
    padding: 10px 14px;
  }

  .chat-composer {
    width: min(620px, calc(100% - 28px));
    margin-bottom: 18px;
    border-radius: 22px;
    padding: 6px 6px 6px 8px;
  }

  .chat-composer textarea {
    font-size: 15px;
  }

  body.chat-active {
    width: 100%;
    overflow: hidden;
    background: var(--cream);
  }

  body.chat-active .app-shell {
    position: fixed;
    top: var(--viewport-top);
    right: auto;
    left: 0;
    height: var(--app-height);
    width: var(--app-width);
    max-width: 100%;
    min-height: 0;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
  }

  body.chat-active .chat-shell {
    width: var(--app-width);
    max-width: 100%;
    height: var(--app-height);
    min-height: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
  }

  body.chat-active .conversation-panel {
    height: 100%;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
  }

  body.chat-active .chat-messages {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
  }

  body.chat-active .chat-messages.streaming-response-anchor {
    padding-bottom: max(160px, calc(var(--app-height) * 0.5));
  }

  body.chat-active.keyboard-open .chat-messages {
    padding-bottom: 30px;
    scroll-padding-bottom: 30px;
  }

  body.chat-active.keyboard-open .chat-messages.streaming-response-anchor {
    padding-bottom: max(180px, calc(var(--app-height) * 0.56));
  }

  body.chat-active .chat-composer {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    margin:
      0
      max(14px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  body.chat-active.keyboard-open .chat-composer {
    margin-bottom: max(86px, calc(env(safe-area-inset-bottom) + 72px));
  }

  body.keyboard-open .prompt-strip {
    display: none;
  }
}

@media (display-mode: standalone) and (max-width: 840px) {
  body.chat-active .chat-topbar {
    padding-top: max(54px, calc(14px + env(safe-area-inset-top)));
  }
}

@media (max-width: 430px) {
  .gate-hero {
    min-height: 230px;
  }

  .coach-avatar.large {
    width: 56px;
    height: 56px;
  }

  .gate-panel {
    padding: 24px 18px 20px;
  }

  h2 {
    font-size: 27px;
  }

  .chat-message {
    max-width: 90%;
  }

  .empty-session-welcome h1 {
    font-size: 34px;
  }

  .empty-session-welcome p {
    max-width: 310px;
    font-size: 22px;
  }

  .prompt-chip {
    flex-basis: 100%;
    padding: 10px 15px;
  }

  .chat-composer {
    gap: 8px;
    padding: 6px 6px 6px 18px;
  }

  .send-button {
    width: 40px;
    min-height: 40px;
  }
}
