.chat-gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.chat-gate-card {
  width: min(440px, 100%);
  padding: clamp(20px, 5vw, 36px);
  background: #fffef8;
  border: 1px solid #dce3d7;
  border-radius: 18px;
}
.chat-gate-card .brand { display: inline-flex; margin-bottom: 22px; }
.chat-gate-card h1 { margin: 0; font-size: 26px; }
.chat-gate-card p { margin: 10px 0 22px; }
.chat-gate-card .toolbar { margin-bottom: 14px; }
.chat-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(780px, 100%);
  height: 100dvh;
  margin: 0 auto;
  border-inline: 1px solid #dce3d7;
  background: #eeefe9;
  color: #23382b;
}
.chat-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px clamp(12px, 4vw, 26px);
  background: #fffef8;
  border-bottom: 1px solid #dce3d7;
}
.chat-heading > div:nth-child(2) { min-width: 0; }
.chat-heading h1, .chat-heading p { margin: 0; overflow-wrap: anywhere; }
.chat-heading h1 { font-size: 18px; }
.chat-heading p { font-size: 12px; color: #536559; }
.chat-heading .chat-signature { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-avatar {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: #d8e6d5;
  color: #234733;
  border-radius: 10px;
  font-weight: 700;
  overflow: hidden;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-profile-title { display: flex; align-items: center; gap: 12px; }
.chat-profile-title .chat-avatar { width: 60px; height: 60px; }
.chat-profile-title p { margin: 2px 0 0; }
.chat-profile-detail { white-space: pre-wrap; overflow-wrap: anywhere; margin: 16px 0 0; }
.small-avatar { width: 30px; height: 30px; border-radius: 8px; }
.chat-tools { margin-left: auto; display: flex; gap: 4px; white-space: nowrap; }
.chat-tools .btn { min-height: 40px; padding-inline: 7px; }
.chat-log { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 0 clamp(12px, 4vw, 26px) 16px; }
.chat-note, .chat-empty, .chat-turn time { display: block; text-align: center; color: #536559; font-size: 13px; margin: 16px 0; }
.chat-turn time { font-size: 12px; margin: 16px 0 10px; }
.chat-message { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0; }
.chat-message.mine { justify-content: flex-end; }
.chat-message > div {
  max-width: min(82%, 520px);
  padding: 9px 13px;
  border-radius: 3px 12px 12px 12px;
  background: #fff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-message.mine > div { border-radius: 12px 3px 12px 12px; background: #cce7c2; }
.chat-media-message > .chat-media-card { padding: 8px; max-width: min(82%, 360px); overflow: hidden; }
.chat-media-card figure { margin: 0; }
.chat-media-card figure > a { display: block; border-radius: 7px; overflow: hidden; }
.chat-media-card img, .chat-media-card video { display: block; width: 100%; max-height: 420px; object-fit: contain; border-radius: 7px; background: #e8ede6; }
.chat-media-card img { min-width: min(220px, 50vw); }
.chat-media-card video { min-width: min(260px, 50vw); }
.chat-media-card audio { display: block; width: min(300px, 62vw); max-width: 100%; }
.chat-media-card figcaption { padding: 8px 4px 2px; font-size: 14px; }
.chat-media-status { margin: 2px 4px; color: #536559; font-size: 13px; }
.chat-media-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #83a77b; }
.chat-media-card a:focus-visible { outline: 3px solid #467550; outline-offset: 2px; }
.chat-compose {
  padding: 10px clamp(12px, 4vw, 26px) max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid #dce3d7;
  background: #fffef8;
}
.chat-compose .studio-consent { margin: 0 0 8px; font-size: 13px; }
.chat-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.chat-entry.with-photo { grid-template-columns: auto minmax(0, 1fr) auto; }
.chat-message.mine > .chat-user-photo { padding: 5px; }
.chat-user-photo img { display: block; width: auto; max-width: 100%; max-height: 230px; border-radius: 7px; }
.chat-photo-draft { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chat-photo-draft img { width: 54px; height: 54px; object-fit: cover; border-radius: 7px; }
.chat-entry textarea {
  width: 100%;
  min-height: 44px;
  max-height: 22dvh;
  resize: vertical;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 16px;
}
.chat-entry .btn { min-height: 44px; }
.chat-error { color: #973d32; margin: 0 0 8px; font-size: 13px; }
.chat-modes { display: flex; gap: 6px; margin-bottom: 8px; }
.chat-modes .btn { min-width: 60px; min-height: 36px; }
.chat-modes .btn[aria-pressed="true"] { background: #dcebd5; border-color: #a8c1a3; color: #234733; }
.family-voice-status { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 8px; }
.family-voice-status span { font-size: 13px; color: #536559; }
.family-voice-panel .studio-voice-subtitle { max-height: 16dvh; overflow: auto; margin-bottom: 8px; }
.family-voice-actions { display: flex; gap: 8px; }
.family-voice-actions .btn { min-height: 44px; }
.memory-workbench { display: grid; gap: 16px; }
.memory-workbench form { display: grid; gap: 8px; }
.memory-workbench form > .btn { justify-self: start; }
.memory-workbench .field { min-width: 0; }
.memory-group h3 { font-size: 16px; margin: 18px 0 8px; }
.memory-group h3 span { font-size: 13px; font-weight: normal; color: #536559; }
.memory-card { padding: 12px 14px; margin-bottom: 8px; border: 1px solid #dce3d7; border-radius: 10px; overflow-wrap: anywhere; }
.memory-card summary { cursor: pointer; font-size: 13px; }
.memory-card blockquote { margin: 8px 0; padding-left: 10px; border-left: 2px solid #a6c1a9; white-space: pre-wrap; font-size: 14px; color: #536559; }
.memory-card .toolbar { margin-top: 8px; }
.memory-fact { font-weight: 600; margin: 0 0 8px; }
