:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --panel: #ffffff;
  --panel-soft: #faf8f2;
  --ink: #202124;
  --muted: #6b6f76;
  --line: #ded9cd;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #d8f3ee;
  --warm: #c6533f;
  --shadow: 0 20px 60px rgba(32, 33, 36, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 36%),
    linear-gradient(315deg, rgba(198, 83, 63, 0.1), transparent 34%),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(250, 248, 242, 0.86);
  backdrop-filter: blur(14px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-row h1,
.brand-row p,
.chat-header h2,
.chat-header p {
  margin: 0;
}

.brand-row h1 {
  font-size: 22px;
  line-height: 1.1;
}

.brand-row p,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.new-chat-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.new-chat-button:hover {
  background: var(--accent-strong);
}

.settings-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-weight: 750;
}

.settings-button:hover,
.settings-button[aria-expanded="true"] {
  border-color: rgba(15, 118, 110, 0.34);
  background: var(--accent-soft);
}

.match-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.match-panel[hidden] {
  display: none;
}

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

.field label,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.field input,
.field select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
}

.avatar-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.avatar-upload:hover {
  border-color: rgba(15, 118, 110, 0.34);
  background: var(--accent-soft);
}

.avatar-preview {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.google-signin {
  min-height: 40px;
}

.google-button-mount {
  min-height: 40px;
}

.google-button {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}

.google-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.google-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.settings-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.match-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 10px 0 2px;
}

.match-stats div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.match-stats dt {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-stats dd {
  margin: 0;
  font-size: 16px;
  font-weight: 850;
}

.conversation-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
}

.sidebar-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.conversation-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.conversation-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.72);
}

.conversation-item.active {
  border-color: rgba(15, 118, 110, 0.28);
  background: var(--accent-soft);
}

.conversation-item.signed-in-partner {
  border-color: rgba(22, 163, 74, 0.55);
}

.conversation-item.signed-in-partner .conversation-avatar {
  border-color: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.16);
}

.conversation-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-preview {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 100vh;
  padding: 26px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 20px;
}

.chat-header h2 {
  overflow-wrap: anywhere;
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1.05;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-button.danger:hover {
  border-color: var(--warm);
  color: var(--warm);
}

.message-stream {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 4px 24px;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  max-width: min(680px, 88%);
  gap: 9px;
}

.message.user {
  align-self: flex-end;
  grid-template-columns: minmax(0, 1fr) 34px;
}

.message.assistant {
  align-self: flex-start;
}

.message.user .message-avatar {
  grid-column: 2;
  grid-row: 1;
}

.message.user .message-content {
  grid-column: 1;
  grid-row: 1;
}

.message-avatar {
  width: 34px;
  height: 34px;
}

.message-content {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.message-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.message.user .message-meta {
  text-align: right;
}

.message-bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 15px;
  background: var(--panel);
  box-shadow: var(--shadow);
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.user .message-bubble {
  border-color: transparent;
  background: var(--ink);
  color: #fff;
}

.empty-state {
  display: grid;
  margin: auto;
  max-width: 560px;
  gap: 14px;
  text-align: center;
}

.empty-state h3 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.waiting-state {
  justify-items: center;
}

.waiting-orbit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
}

.waiting-orbit span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  animation: waiting-pulse 1.2s ease-in-out infinite;
}

.waiting-orbit span:nth-child(2) {
  animation-delay: 0.16s;
}

.waiting-orbit span:nth-child(3) {
  animation-delay: 0.32s;
}

.waiting-timers {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  width: min(360px, 100%);
  margin: 0;
}

.waiting-timers div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.waiting-timers dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.waiting-timers dd {
  margin: 0;
  font-size: 20px;
  font-weight: 850;
}

@keyframes waiting-pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0) scale(0.9);
  }

  40% {
    opacity: 1;
    transform: translateY(-8px) scale(1);
  }
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.composer textarea {
  width: 100%;
  max-height: 180px;
  min-height: 44px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.5;
}

.send-button {
  min-width: 78px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--warm);
  color: #fff;
  font-weight: 800;
}

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

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

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 440px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-panel {
    min-height: calc(100vh - 440px);
    padding: 18px;
  }

  .message {
    max-width: 96%;
  }

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

  .send-button {
    width: 100%;
  }
}
