.app {
  min-height: 100svh;
  width: 100%;
  overflow-x: clip;
  background: var(--surface-page);
  color: var(--text-strong);
}

.onboarding,
.shell {
  min-height: 100svh;
  min-width: 0;
}

.onboarding {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
  max-width: 460px;
  margin: 0 auto;
}

.onboarding__chrome,
.appbar,
.chat-appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand-lockup,
.appbar__leading,
.chat-appbar__leading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-lockup__text,
.appbar__title,
.chat-appbar__title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-lockup__text strong,
.appbar__title h2,
.chat-appbar__title strong {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.brand-lockup__text span,
.appbar__title span,
.chat-appbar__title span,
.surface-badge,
.panel__label,
.status-panel__time,
.panel__foot,
.status-text,
.empty-state,
.message-bubble time,
.message-bubble__sender,
.mini-pill,
.chat-overview,
.nav-button span {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--border-subtle);
  background: var(--surface-muted);
  color: var(--text-strong);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 2px;
}

.brand-mark svg,
.icon-button svg,
.nav-button svg,
.search-field__icon svg,
.chat-overview__pin svg,
.send-button svg,
.summary-chip svg,
.mini-panel__icon svg,
.profile-meta svg,
.chat-overview svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.brand-mark__image {
  display: block;
  width: 18px;
  height: 18px;
}

.brand-mark--small .brand-mark__image {
  width: 16px;
  height: 16px;
}

.brand-mark--small {
  width: 32px;
  height: 32px;
  border-radius: 2px;
}

.surface-badge,
.summary-chip,
.status-chip,
.mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: var(--surface-base);
}

.onboarding__hero,
.onboarding__panel,
.pane {
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: var(--surface-base);
}

.onboarding__hero,
.onboarding__panel {
  padding: 14px;
}

.onboarding__hero {
  display: grid;
  gap: 14px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.onboarding__hero h1,
.panel__heading h2 {
  margin: 0;
  letter-spacing: -0.04em;
}

.onboarding__hero h1 {
  font-size: clamp(2rem, 9vw, 3.2rem);
  line-height: 0.96;
}

.onboarding__summary {
  margin: 0;
  max-width: 24rem;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.55;
}

.summary-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-chip {
  appearance: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  color: var(--text-soft);
  font-weight: 600;
}

.summary-chip--active {
  border-color: var(--border-contrast);
  background: var(--text-strong);
  color: #fff;
}

.panel__heading {
  display: grid;
  gap: 4px;
}

.panel__label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.onboarding__form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 12px;
  color: var(--text-muted);
}

.field input,
.search-field input,
.composer textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  background: var(--surface-base);
  color: var(--text-strong);
  padding: 11px 12px;
  outline: none;
}

.field input::placeholder,
.search-field input::placeholder,
.composer textarea::placeholder {
  color: #aaa095;
}

.text-action,
.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.send-button,
.nav-button,
.mini-panel {
  appearance: none;
  cursor: pointer;
  border: 0;
  font: inherit;
}

.text-action {
  justify-self: start;
  background: transparent;
  color: var(--text-muted);
  padding: 0;
}

.primary-button {
  min-height: 42px;
  border-radius: 2px;
  background: var(--text-strong);
  color: #fff;
  font-weight: 700;
}

.secondary-button,
.ghost-button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 2px;
}

.secondary-button {
  background: var(--text-strong);
  color: #fff;
  font-weight: 700;
}

.ghost-button {
  border: 1px solid var(--border-subtle);
  background: var(--surface-base);
  color: var(--text-soft);
}

.primary-button:disabled,
.send-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.panel__foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.status-text {
  margin: 14px 0 0;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  padding-bottom: calc(66px + env(safe-area-inset-bottom));
}

.pane {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: 8px;
  min-width: 0;
  width: 100%;
  min-height: 100svh;
  border-radius: 0;
  overflow: hidden;
}

.pane--list {
  padding: 12px 12px 0;
}

.pane--chat {
  padding: 12px;
  border-left: 0;
}

.pane--hidden {
  display: none;
}

.appbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar-strip::-webkit-scrollbar {
  display: none;
}

.toolbar-strip__group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.toolbar-strip__group--actions {
  margin-left: auto;
}

.toolbar-strip--utility {
  justify-content: flex-start;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: var(--surface-base);
  color: var(--text-soft);
}

.icon-button--ghost {
  background: var(--surface-muted);
}

.icon-button--soft {
  width: 30px;
  height: 30px;
  border-radius: 2px;
  background: var(--surface-muted);
}

.status-chip {
  color: var(--text-soft);
  min-height: 28px;
  padding: 0 8px;
  background: var(--surface-muted);
}

.text-action--quiet {
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.4;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: #b6a292;
}

.status-chip--connecting .status-dot,
.status-chip--idle .status-dot {
  background: #d08a44;
}

.status-chip--connected .status-dot {
  background: #698869;
}

.status-chip--fallback .status-dot {
  background: #6c84ab;
}

.search-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: var(--surface-muted);
}

.search-field__icon {
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

.search-field input {
  border: 0;
  padding: 10px 0;
  background: transparent;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.quick-grid--triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-panel {
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding: 11px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: var(--surface-base);
  text-align: left;
}

.mini-panel__icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

.mini-panel strong {
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.mini-panel span {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.conversation-list {
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
  min-width: 0;
  padding-bottom: 12px;
}

.conversation-list--saved {
  gap: 10px;
}

.conversation-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: var(--surface-base);
  text-align: left;
}

.search-results,
.saved-section,
.saved-section__body {
  display: grid;
  gap: 8px;
}

.search-results--discovery,
.search-results--matches {
  align-content: start;
}

.saved-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.saved-section__header strong {
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.saved-section__header span {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.search-result {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: var(--surface-base);
  text-align: left;
}

.search-result__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-result__topline strong {
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result__topline time,
.search-result span {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.search-result p {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.conversation-row--active {
  background: var(--surface-selected);
  border-color: var(--border-strong);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.avatar--header {
  width: 30px;
  height: 30px;
}

.conversation-row__body,
.conversation-row__topline,
.conversation-row__meta,
.conversation-row__tail {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.conversation-row__body {
  display: grid;
  gap: 3px;
}

.conversation-row__topline {
  justify-content: space-between;
}

.conversation-row__topline strong {
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-row__topline time {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.conversation-row__meta {
  justify-content: space-between;
}

.conversation-row__meta span {
  min-width: 0;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-row__tail {
  flex: none;
  justify-content: flex-end;
}

.conversation-row__tail em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 2px;
  background: var(--text-strong);
  color: #fff;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
}

.row-pin {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--text-muted);
}

.chat-appbar__title strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-overview {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.chat-overview span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-overview__pin {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 2px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
}

.message-stream {
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
  min-width: 0;
  padding: 2px 0 10px;
}

.message-stream--empty {
  align-content: center;
  justify-items: center;
}

.empty-state {
  margin: 0;
  text-align: center;
}

.empty-state--inline {
  padding: 10px 4px;
  text-align: left;
}

.empty-panel,
.profile-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: var(--surface-base);
}

.empty-panel strong,
.profile-card__body strong {
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.empty-panel p,
.profile-card__body span {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.empty-panel--chat {
  align-self: center;
}

.empty-panel__actions,
.stack-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty-panel--soft {
  background: var(--surface-muted);
}

.profile-card__hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.avatar--profile {
  width: 40px;
  height: 40px;
  border-radius: 2px;
}

.profile-card__body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.profile-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.profile-meta div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.profile-meta dt,
.profile-meta dd {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-meta dt {
  color: var(--text-muted);
}

.profile-meta dd {
  color: var(--text-soft);
}

.message-bubble {
  display: grid;
  gap: 4px;
  max-width: 78%;
}

.message-bubble--mine {
  justify-self: end;
}

.message-bubble__sender {
  margin: 0;
}

.message-bubble__body {
  padding: 9px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: var(--surface-muted);
}

.message-bubble--mine .message-bubble__body {
  background: var(--surface-chat-mine);
}

.message-bubble__body p {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.54;
  white-space: pre-wrap;
  word-break: break-word;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.composer-shortcuts {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.composer__field {
  display: block;
}

.composer textarea {
  min-height: 44px;
  max-height: 120px;
  resize: none;
}

.send-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 2px;
  background: var(--text-strong);
  color: #fff;
}

.bottom-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.98);
}

.bottom-bar--shell {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
}

.nav-button {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 42px;
  padding: 6px 4px;
  border-radius: 2px;
  background: transparent;
  color: var(--text-muted);
}

.nav-button span {
  display: none;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 600;
}

.nav-button--active {
  background: var(--surface-muted);
  color: var(--text-strong);
}

.nav-button--active span {
  display: block;
}

.nav-button--active::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 22%;
  width: 56%;
  height: 2px;
  border-radius: 2px;
  background: var(--text-strong);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.97);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
  z-index: 30;
}

@media (max-width: 899px) {
  .onboarding__chrome,
  .appbar,
  .chat-appbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .status-panel__time {
    white-space: nowrap;
  }

  .chat-appbar__leading {
    gap: 10px;
  }

  .mini-pill {
    padding: 0 10px;
  }

  .quick-grid--triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .onboarding {
    max-width: 500px;
    grid-template-columns: minmax(0, 1fr);
    padding: 18px;
  }

  .shell {
    max-width: 1320px;
    margin: 0 auto;
    grid-template-columns: 64px minmax(272px, 340px) minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
    padding: 10px;
    padding-bottom: 10px;
  }

  .pane {
    min-height: calc(100svh - 20px);
    margin: 0;
    border-radius: 2px;
  }

  .pane--list {
    padding-bottom: 10px;
  }

  .pane--chat {
    display: grid;
  }

  .pane--search .search-results--discovery,
  .pane--search .search-results--matches,
  .pane--saved .conversation-list--saved {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 8px;
  }

  .pane--search .saved-section,
  .pane--saved .saved-section {
    align-content: start;
    padding: 8px;
    border: 1px solid var(--border-subtle);
    border-radius: 2px;
    background: var(--surface-muted);
  }

  .pane--me .profile-card {
    max-width: 420px;
  }

  .pane--hidden {
    display: grid;
  }

  .bottom-bar--shell {
    position: sticky;
    inset: 0 auto auto 0;
    width: auto;
    height: calc(100svh - 20px);
    padding: 8px 6px;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 6px;
    border: 1px solid var(--border-subtle);
    border-radius: 2px;
    background: var(--surface-base);
  }

  .toast {
    right: 24px;
    left: auto;
    max-width: 360px;
  }

  .bottom-bar {
    justify-content: stretch;
  }

  .nav-button {
    min-height: 48px;
    padding: 7px 4px;
    border-radius: 2px;
    gap: 2px;
  }

  .bottom-bar--shell .nav-button span {
    display: none;
    font-size: 10px;
  }

  .bottom-bar--shell .nav-button--active span {
    display: block;
  }

  .appbar__title span,
  .chat-appbar__title span {
    display: none;
  }

  .appbar,
  .chat-appbar {
    min-height: 40px;
  }

  .toolbar-strip {
    overflow: visible;
    flex-wrap: wrap;
    gap: 4px;
  }

  .conversation-list {
    gap: 4px;
  }

  .search-results,
  .saved-section,
  .saved-section__body {
    gap: 4px;
  }
}
