:root {
  color-scheme: light;
  --canvas: oklch(96.5% 0.008 165);
  --surface: oklch(99.2% 0.004 165);
  --surface-muted: oklch(92.8% 0.012 165);
  --surface-deep: oklch(88.5% 0.018 165);
  --ink: oklch(22% 0.018 165);
  --ink-soft: oklch(43% 0.018 165);
  --ink-faint: oklch(58% 0.014 165);
  --accent: oklch(39% 0.075 163);
  --accent-hover: oklch(34% 0.075 163);
  --accent-soft: oklch(90% 0.032 163);
  --signal: oklch(58% 0.14 34);
  --signal-soft: oklch(93% 0.035 34);
  --danger: oklch(49% 0.14 28);
  --danger-soft: oklch(94% 0.03 28);
  --divider: oklch(83% 0.014 165);
  --focus: oklch(56% 0.11 163);
  --shadow-input: 0 5px 22px oklch(24% 0.02 165 / 0.1);
  --shadow-sheet: 0 24px 80px oklch(20% 0.02 165 / 0.24);
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-pill: 999px;
  --ui: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --voice: "Songti SC", STSong, "Noto Serif CJK SC", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  font-family: var(--ui);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--canvas);
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  touch-action: manipulation;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--surface);
  text-decoration: none;
  transition-property: transform;
  transition-duration: 140ms;
}

.skip-link:focus {
  transform: translateY(0);
}

.boot {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: var(--ink-soft);
  font-size: 14px;
}

.boot-mark,
.onboarding-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--surface);
  font-family: var(--voice);
  font-size: 19px;
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 250px minmax(440px, 1fr) 300px;
  max-width: 1680px;
  margin: 0 auto;
  background: var(--surface);
}

.relationship-rail {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: calc(28px + env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface-muted);
  border-right: 1px solid var(--divider);
}

.identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 8px 28px;
}

.identity-avatar {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  object-fit: cover;
  outline: 1px solid oklch(25% 0.03 165 / 0.14);
  outline-offset: -1px;
  background: var(--surface-deep);
}

.identity-avatar.fallback {
  color: var(--accent);
  font-family: var(--voice);
  font-size: 15px;
  font-weight: 600;
}

.product-name {
  display: block;
  font-family: var(--voice);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
}

.anchor-label {
  display: block;
  max-width: 154px;
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.primary-nav {
  display: grid;
  gap: 4px;
}

.primary-nav button,
.bottom-nav button {
  min-height: 44px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.primary-nav button {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-align: left;
  transition-property: background-color, color, transform;
  transition-duration: 140ms;
}

.primary-nav button[aria-current="page"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px oklch(25% 0.02 165 / 0.1);
}

.primary-nav svg,
.bottom-nav svg,
.icon-button svg,
.text-button svg,
.context-note svg,
.primary-button svg,
.send-button svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
}

.rail-footer {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 14px 10px 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--accent);
}

.connection-dot.offline {
  background: var(--signal);
}

.workspace {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}

.view {
  height: 100%;
  min-height: 0;
  animation: view-enter 160ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.chat-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.moments-view,
.us-view {
  overflow-y: auto;
  padding-bottom: 72px;
  overscroll-behavior: contain;
}

.view-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: calc(18px + env(safe-area-inset-top)) clamp(22px, 4vw, 54px) 16px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.view-header h1,
.sheet h2,
.section-heading h2,
.data-section h2,
.profile-band h2 {
  margin: 0;
  font-family: var(--voice);
  font-weight: 600;
  letter-spacing: 0;
  text-wrap: balance;
}

.view-header h1 {
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.15;
}

.eyebrow,
.section-label {
  margin: 0 0 5px;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
  text-transform: uppercase;
}

.header-actions,
.composer-actions,
.data-actions,
.sheet footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.send-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition-property: transform, background-color, color;
  transition-duration: 120ms;
}

.icon-button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
}

.send-button {
  border: 0;
  background: var(--accent);
  color: var(--surface);
}

.icon-button[aria-pressed="true"] {
  background: var(--signal-soft);
  color: var(--signal);
}

.message-list {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 32px clamp(22px, 7vw, 92px) 26px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.message {
  max-width: min(680px, 86%);
  animation: message-enter 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.message.user {
  align-self: flex-end;
  padding: 11px 15px;
  border-radius: var(--radius-md) var(--radius-md) var(--radius-xs) var(--radius-md);
  background: var(--accent-soft);
}

.message.assistant {
  align-self: flex-start;
  padding-left: 18px;
  position: relative;
  font-family: var(--voice);
  font-size: 17px;
  line-height: 1.75;
}

.message.assistant::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--signal);
}

.message p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.message-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--ink-faint);
  font-family: var(--ui);
  font-size: 11px;
}

.empty-state,
.error-state {
  align-self: center;
  width: min(520px, 100%);
  margin: auto;
  padding: 36px 0;
  text-align: center;
}

.empty-state h2,
.error-state h2 {
  margin: 0 0 10px;
  font-family: var(--voice);
  font-size: 24px;
  font-weight: 600;
}

.empty-state p,
.error-state p {
  margin: 0 auto 20px;
  max-width: 42ch;
  color: var(--ink-soft);
  line-height: 1.7;
  text-wrap: pretty;
}

.composer {
  margin: 0 clamp(18px, 6vw, 76px) calc(18px + env(safe-area-inset-bottom));
  padding: 12px 12px 9px 16px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-input);
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 160px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.55;
}

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

.composer-actions {
  justify-content: flex-end;
  min-height: 42px;
  margin-top: 4px;
}

.draft-status {
  margin-right: auto;
  color: var(--ink-faint);
  font-size: 11px;
}

.text-button,
.primary-button,
.danger-button,
.link-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition-property: transform, background-color, color, border-color;
  transition-duration: 120ms;
}

.text-button {
  padding: 0 13px;
  border: 1px solid var(--divider);
  background: var(--surface);
  color: var(--ink);
}

.text-button.secondary {
  color: var(--ink-soft);
}

.text-button.danger {
  border-color: oklch(74% 0.07 28);
  color: var(--danger);
}

.primary-button {
  min-width: 112px;
  padding: 0 17px;
  border: 0;
  background: var(--accent);
  color: var(--surface);
}

.danger-button {
  padding: 0 17px;
  border: 0;
  background: var(--danger);
  color: var(--surface);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent);
}

.timeline,
.memory-section,
.settings-section,
.data-section,
.profile-band {
  width: min(760px, calc(100% - 44px));
  margin-inline: auto;
}

.timeline {
  padding-top: 18px;
}

.moment {
  padding: 28px 4px 30px;
  border-bottom: 1px solid var(--divider);
}

.moment-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink-faint);
  font-size: 12px;
}

.moment-copy {
  max-width: 60ch;
  margin: 13px 0 20px;
  font-family: var(--voice);
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.75;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.moment-actions {
  display: flex;
  gap: 4px;
}

.moment-actions button {
  min-width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.moment-actions button[data-liked="true"] {
  color: var(--signal);
  background: var(--signal-soft);
}

.comments {
  margin: 14px 0 0 46px;
  display: grid;
  gap: 9px;
}

.comment {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.comment-form {
  display: flex;
  gap: 8px;
}

.comment-form input {
  min-width: 0;
  flex: 1;
}

.profile-band {
  display: grid;
  grid-template-columns: minmax(180px, 0.75fr) 1.25fr;
  gap: 40px;
  padding: 34px 0 38px;
  border-bottom: 1px solid var(--divider);
}

.profile-band h2 {
  font-size: 25px;
  line-height: 1.35;
}

.profile-question {
  margin: 19px 0 0;
  color: var(--ink-soft);
  font-family: var(--voice);
  font-size: 18px;
  line-height: 1.65;
  text-wrap: pretty;
}

.memory-section,
.settings-section,
.data-section {
  padding: 34px 0 40px;
  border-bottom: 1px solid var(--divider);
}

.section-heading,
.data-section {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2,
.data-section h2 {
  font-size: 22px;
}

.count {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.memory-list {
  margin-top: 22px;
}

.memory-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 18px 0;
  border-top: 1px solid var(--divider);
}

.memory-kind {
  color: var(--ink-faint);
  font-size: 12px;
}

.memory-row h3 {
  margin: 0 0 5px;
  font-size: 15px;
  font-weight: 650;
}

.memory-row p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.memory-actions {
  display: flex;
  gap: 3px;
}

.memory-actions button {
  min-width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.settings-list {
  margin-top: 18px;
  border-top: 1px solid var(--divider);
}

.setting-row {
  min-height: 62px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--divider);
}

.setting-row strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.setting-row small {
  display: block;
  margin-top: 3px;
  color: var(--ink-faint);
  line-height: 1.45;
}

.toggle {
  width: 48px;
  height: 28px;
  position: relative;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-deep);
  cursor: pointer;
  transition-property: background-color, transform;
  transition-duration: 140ms;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: 0 1px 3px oklch(20% 0.02 165 / 0.2);
  transition-property: transform;
  transition-duration: 140ms;
}

.toggle[aria-pressed="true"] {
  background: var(--accent);
}

.toggle[aria-pressed="true"]::after {
  transform: translateX(20px);
}

.setting-select,
.setting-time {
  min-height: 40px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.setting-select {
  padding: 0 32px 0 10px;
}

.setting-time {
  width: 94px;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}

.time-pair {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-faint);
}

.data-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.legal-links {
  flex-basis: 100%;
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 10px;
  font-size: 12px;
}

.legal-links a {
  color: var(--ink-faint);
  text-underline-offset: 3px;
}

.context-panel {
  min-width: 0;
  padding: calc(30px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  background: var(--canvas);
  border-left: 1px solid var(--divider);
}

.context-panel header {
  min-height: 42px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.context-list {
  margin: 12px 0 30px;
}

.context-list div {
  padding: 16px 0;
  border-bottom: 1px solid var(--divider);
}

.context-list dt {
  color: var(--ink-faint);
  font-size: 11px;
}

.context-list dd {
  margin: 6px 0 0;
  font-family: var(--voice);
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.context-note {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  padding-top: 8px;
  color: var(--ink-soft);
}

.context-note p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
}

.context-note svg {
  color: var(--accent);
}

.mobile-header,
.bottom-nav,
.mobile-only {
  display: none;
}

.onboarding {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--canvas);
}

.onboarding-header {
  width: min(1040px, calc(100% - 48px));
  min-height: 84px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--divider);
}

.onboarding-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.onboarding-header .onboarding-mark {
  width: 44px;
  height: 44px;
  font-size: 14px;
}

.onboarding-conversation {
  width: min(720px, calc(100% - 48px));
  min-height: 0;
  justify-self: center;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  padding: 42px 0 calc(24px + env(safe-area-inset-bottom));
}

.onboarding-messages {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 4px 4px 30px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.onboarding-turn {
  max-width: 82%;
  animation: message-enter 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.onboarding-turn.assistant {
  align-self: flex-start;
  position: relative;
  padding-left: 18px;
  font-family: var(--voice);
  font-size: clamp(20px, 2.5vw, 27px);
  line-height: 1.6;
}

.onboarding-turn.system {
  align-self: center;
  max-width: min(620px, 92%);
  padding: 14px 18px;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
}

.onboarding-turn.system .onboarding-speaker {
  margin-bottom: 8px;
  color: var(--signal);
}

.onboarding-turn.assistant::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--signal);
}

.onboarding-turn.user {
  align-self: flex-end;
  padding: 11px 15px;
  border-radius: var(--radius-md) var(--radius-md) var(--radius-xs) var(--radius-md);
  background: var(--accent-soft);
  font-size: 16px;
  line-height: 1.65;
}

.onboarding-turn p {
  margin: 0;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.onboarding-speaker {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-faint);
  font-family: var(--ui);
  font-size: 11px;
}

.onboarding-answer {
  padding: 14px 0 6px;
  border-top: 1px solid var(--divider);
}

.onboarding-reply {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.onboarding-reply input,
.onboarding-reply textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  outline: 0;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.55;
  resize: none;
}

.onboarding-reply input:focus,
.onboarding-reply textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px oklch(56% 0.11 163 / 0.16);
}

.onboarding-reply .send-button {
  width: 48px;
  height: 48px;
}

.onboarding-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.onboarding-choice {
  min-height: 58px;
  padding: 10px 14px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition-property: transform, border-color, background-color;
  transition-duration: 120ms;
}

.onboarding-choice strong,
.onboarding-choice small {
  display: block;
}

.onboarding-choice strong {
  font-weight: 600;
}

.onboarding-choice small {
  margin-top: 3px;
  color: var(--ink-faint);
  line-height: 1.4;
}

.onboarding-footer {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

#onboarding-progress {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.progress-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-deep);
}

.progress-dot.complete,
.progress-dot.current {
  background: var(--accent);
}

.progress-dot.current {
  transform: scale(1.35);
}

.sheet label {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

input,
textarea,
select {
  max-width: 100%;
}

.sheet input,
.sheet textarea {
  width: 100%;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 11px 12px;
  line-height: 1.5;
  resize: vertical;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.sheet {
  width: min(620px, calc(100% - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sheet);
  overscroll-behavior: contain;
}

.sheet::backdrop {
  background: oklch(16% 0.018 165 / 0.46);
}

.sheet > form {
  display: grid;
  gap: 20px;
  max-height: inherit;
  overflow-y: auto;
  padding: 24px;
}

.sheet header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.sheet h2 {
  font-size: 24px;
}

.sheet footer {
  justify-content: flex-end;
  padding-top: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.form-grid label:first-child,
.form-grid label:nth-child(2),
.form-grid label:nth-child(3) {
  grid-column: 1 / -1;
}

.sheet.compact {
  width: min(480px, calc(100% - 28px));
}

.sheet.destructive {
  border-top: 4px solid var(--danger);
}

.sheet.destructive p,
.field-note {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

.field-note {
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--surface);
  box-shadow: 0 8px 30px oklch(20% 0.02 165 / 0.24);
  font-size: 13px;
}

.legal-page {
  overflow: auto;
  background: var(--canvas);
}

.legal-document {
  width: min(720px, calc(100% - 40px));
  margin: 0 auto;
  padding: calc(54px + env(safe-area-inset-top)) 0 calc(80px + env(safe-area-inset-bottom));
}

.legal-document > a {
  color: var(--accent);
  text-underline-offset: 3px;
}

.legal-document header {
  margin: 42px 0 36px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--divider);
}

.legal-document h1 {
  margin: 6px 0 12px;
  font-family: var(--voice);
  font-size: clamp(34px, 7vw, 54px);
  font-weight: 600;
  letter-spacing: 0;
}

.legal-document h2 {
  margin: 34px 0 10px;
  font-family: var(--voice);
  font-size: 22px;
  font-weight: 600;
}

.legal-document p,
.legal-document li {
  color: var(--ink-soft);
  line-height: 1.8;
  text-wrap: pretty;
}

@keyframes view-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes message-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (hover: hover) {
  .primary-nav button:hover,
  .icon-button:hover,
  .moment-actions button:hover,
  .memory-actions button:hover {
    background: var(--surface-muted);
    color: var(--accent);
  }

  .text-button:hover {
    border-color: var(--ink-faint);
  }

  .primary-button:hover,
  .send-button:hover,
  .onboarding-choice:hover {
    background: var(--accent-hover);
    color: var(--surface);
  }
}

.primary-nav button:active,
.bottom-nav button:active,
.icon-button:active,
.send-button:active,
.text-button:active,
.primary-button:active,
.danger-button:active,
.toggle:active,
.moment-actions button:active,
.memory-actions button:active {
  transform: scale(0.96);
}

.onboarding-choice:active {
  transform: scale(0.98);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 224px minmax(440px, 1fr);
  }

  .context-panel {
    position: fixed;
    z-index: 40;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 88vw);
    transform: translateX(100%);
    box-shadow: var(--shadow-sheet);
    transition-property: transform;
    transition-duration: 180ms;
  }

  .context-panel.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-grid;
  }

  .mobile-header {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(8px + env(safe-area-inset-top)) 18px 8px;
    border-bottom: 1px solid var(--divider);
  }

  .workspace {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .view {
    height: auto;
  }

  .view-header {
    padding-top: 15px;
  }
}

@media (max-width: 639px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding-bottom: calc(62px + env(safe-area-inset-bottom));
  }

  .relationship-rail {
    display: none;
  }

  .workspace {
    min-height: 0;
  }

  .mobile-header {
    min-height: 58px;
    padding-inline: 15px;
  }

  .mobile-header .product-name {
    font-size: 16px;
  }

  .mobile-header .anchor-label {
    max-width: 260px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .view-header {
    min-height: 66px;
    padding: 12px 16px;
  }

  .view-header .eyebrow {
    display: none;
  }

  .view-header h1 {
    font-size: 21px;
  }

  .message-list {
    padding: 22px 16px 18px;
  }

  .message {
    max-width: 92%;
  }

  .message.assistant {
    font-size: 16px;
  }

  .composer {
    margin: 0 10px calc(9px + env(safe-area-inset-bottom));
    padding-left: 13px;
  }

  .bottom-nav {
    position: fixed;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(62px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 4px 10px env(safe-area-inset-bottom);
    border-top: 1px solid var(--divider);
    background: var(--surface);
  }

  .bottom-nav button {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 3px;
    color: var(--ink-faint);
    font-size: 10px;
  }

  .bottom-nav button[aria-current="page"] {
    color: var(--accent);
  }

  .timeline,
  .memory-section,
  .settings-section,
  .data-section,
  .profile-band {
    width: calc(100% - 32px);
  }

  .moment {
    padding-block: 22px;
  }

  .comments {
    margin-left: 0;
  }

  .profile-band {
    grid-template-columns: 1fr;
    gap: 4px;
    padding-block: 25px;
  }

  .memory-section,
  .settings-section,
  .data-section {
    padding-block: 27px;
  }

  .memory-row {
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
  }

  .memory-kind {
    grid-column: 1 / -1;
  }

  .setting-row {
    min-height: 70px;
  }

  .data-section {
    display: block;
  }

  .data-actions {
    justify-content: flex-start;
    margin-top: 18px;
  }

  .onboarding {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .onboarding-header {
    width: calc(100% - 28px);
    min-height: 66px;
  }

  .onboarding-header .onboarding-mark {
    width: 38px;
    height: 38px;
    font-size: 12px;
  }

  .onboarding-header .product-name {
    font-size: 16px;
  }

  .onboarding-header .anchor-label {
    margin-top: 1px;
  }

  .onboarding-header .link-button {
    min-height: 40px;
    font-size: 12px;
  }

  .onboarding-conversation {
    width: calc(100% - 28px);
    padding: 24px 0 calc(10px + env(safe-area-inset-bottom));
  }

  .onboarding-messages {
    gap: 18px;
    padding-bottom: 22px;
  }

  .onboarding-turn {
    max-width: 92%;
  }

  .onboarding-turn.assistant {
    font-size: 20px;
  }

  .onboarding-choices {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid label {
    grid-column: 1 !important;
  }

  .sheet {
    width: 100%;
    max-width: none;
    max-height: 88dvh;
    margin: auto 0 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .toast {
    bottom: calc(76px + 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;
    transition-duration: 0.01ms !important;
  }
}
