.hidden {
  display: none !important;
}

/* —— Home: persona picker —— */
.home-view {
  width: min(640px, 100%);
  min-height: 100%;
  margin: 0 auto;
  background: var(--bg-panel, #10161e);
  border-left: 1px solid var(--border, rgba(148, 163, 184, 0.18));
  border-right: 1px solid var(--border, rgba(148, 163, 184, 0.18));
  display: flex;
  flex-direction: column;
}

.home-inner {
  padding: 28px 18px 40px;
  flex: 1;
}

.home-header h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.home-sub {
  margin: 0 0 22px;
  color: var(--text-muted, #8b9aab);
  font-size: 0.88rem;
  line-height: 1.5;
}

.persona-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.persona-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(148, 163, 184, 0.18));
  background: var(--bg-elevated, #141a22);
  color: inherit;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.persona-card-main {
  display: flex;
  flex: 1;
  gap: 14px;
  align-items: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.persona-card-actions { display: flex; gap: 6px; }
.persona-card-actions button { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; font-size: .75rem; padding: 4px; }
.persona-card-actions button:hover { color: var(--accent-hover); }

.persona-card:hover {
  border-color: rgba(91, 141, 239, 0.45);
  background: #182231;
}

.persona-card-avatar {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: #1e293b;
  border: 1px solid var(--border-strong, rgba(148, 163, 184, 0.28));
  flex-shrink: 0;
}

.persona-card-body {
  flex: 1;
  min-width: 0;
}

.persona-card-title {
  font-weight: 600;
  font-size: 1.02rem;
  margin-bottom: 2px;
}

.persona-card-rel {
  font-size: 0.78rem;
  color: #9dbcf5;
  margin-bottom: 6px;
}

.persona-card-bio {
  font-size: 0.82rem;
  color: var(--text-muted, #8b9aab);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.persona-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.persona-card-tags span {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-muted, #8b9aab);
  border: 1px solid var(--border, rgba(148, 163, 184, 0.18));
}

.home-status {
  margin: 18px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted, #8b9aab);
  text-align: center;
}

.back-btn {
  align-self: flex-start;
  margin-top: 2px;
  flex-shrink: 0;
}

.chat-view.hidden {
  display: none !important;
}

:root {
  /* Serious / product UI — slate + steel blue */
  --bg: #0b0f14;
  --bg-elevated: #141a22;
  --bg-panel: #10161e;
  --bg-bubble-user: #1e3a5f;
  --bg-bubble-ai: #1a222d;
  --text: #e8eef4;
  --text-muted: #8b9aab;
  --accent: #5b8def;
  --accent-hover: #7aa4f5;
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.28);
  --danger: #e07a7a;
  --danger-bg: rgba(224, 122, 122, 0.1);
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "SF Pro Text", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, #18243d 0, #0b0f14 55%);
}

.auth-card {
  width: min(100%, 390px);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(22, 29, 41, 0.94);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

.auth-brand { color: var(--accent-hover); font-weight: 700; letter-spacing: .04em; }
.auth-card h1 { margin: 28px 0 8px; }
.auth-sub { color: var(--text-muted); line-height: 1.6; }
.auth-form { display: grid; gap: 12px; margin-top: 22px; }
.auth-form input { width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #0b0f14; color: var(--text); }
.auth-submit { padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: white; cursor: pointer; font-weight: 700; }
.danger-btn { padding: 8px 10px; border: 1px solid #8d4040; border-radius: 8px; background: transparent; color: #ff9b9b; cursor: pointer; }
.auth-error { min-height: 1.3em; color: #ff9b9b; }
.auth-toggle, .logout-btn { border: 0; background: transparent; color: var(--accent-hover); cursor: pointer; }
.logout-btn { margin-top: 12px; font-size: .8rem; }
.account-actions { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.account-label { color: var(--text-muted); font-size: .78rem; }
.account-sessions ul { display: grid; gap: 7px; padding: 0; margin: 8px 0; list-style: none; }
.account-sessions li { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--text-muted); font-size: .72rem; }
.account-sessions li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-sessions li button { border: 0; background: transparent; color: var(--accent-hover); cursor: pointer; }
.recent-section { margin-top: 34px; }
.recent-section h2 { font-size: 1rem; font-weight: 600; color: var(--text-muted); }
.conversation-list { display: grid; gap: 8px; }
.conversation-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elevated); color: var(--text); cursor: pointer; text-align: left; }
.conversation-card:hover { border-color: var(--accent); }
.conversation-open { flex: 1; min-width: 0; display: flex; justify-content: space-between; gap: 16px; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; font: inherit; }
.conversation-summary { min-width: 0; display: grid; gap: 4px; }
.conversation-summary small { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.conversation-delete { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; font-size: .75rem; }
.conversation-delete:hover { color: var(--danger); }
.conversation-card span, .conversation-empty { color: var(--text-muted); font-size: .78rem; }
.memory-panel input, .memory-panel textarea { width: 100%; box-sizing: border-box; padding: 10px 12px; margin: 5px 0; border: 1px solid var(--border); border-radius: 8px; background: #0b0f14; color: var(--text); font: inherit; }
.memory-panel textarea { resize: vertical; min-height: 110px; }
.memory-panel hr { width: 100%; border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.register-only:not(:required) { display: none; }

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #0b0f14;
  color: var(--text);
}

body {
  display: flex;
  justify-content: center;
}

.app {
  width: min(560px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.persona-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 22, 30, 0.96);
  position: sticky;
  top: 0;
  z-index: 5;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: #1e293b;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}

.persona-meta {
  flex: 1;
  min-width: 0;
}

.persona-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.persona-name-row h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(91, 141, 239, 0.12);
  color: #9dbcf5;
  border: 1px solid rgba(91, 141, 239, 0.28);
  font-weight: 500;
}

.persona-bio {
  margin: 4px 0 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.persona-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.persona-tags span {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.icon-btn,
.media-btn,
.send-btn,
.close-btn,
.memory-add button {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 6px 10px;
}

.icon-btn:hover,
.media-btn:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: rgba(91, 141, 239, 0.08);
}

.chat-shell {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: #0b0f14;
}

.msg {
  max-width: 86%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg.user {
  align-self: flex-end;
}

.msg.assistant,
.msg.system {
  align-self: flex-start;
}

.bubble {
  padding: 10px 13px;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: 0.93rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: var(--bg-bubble-user);
  border: 1px solid rgba(91, 141, 239, 0.25);
  border-bottom-right-radius: 4px;
  color: #f0f5fb;
}

.msg.assistant .bubble {
  background: var(--bg-bubble-ai);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.voice-message {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: min(280px, 78vw);
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  background: var(--bg-bubble-ai);
}

.voice-icon {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: rgba(213, 155, 211, 0.16);
  color: var(--accent-hover);
  font-size: 1rem;
}

.voice-message-main {
  min-width: 0;
  flex: 1;
}

.voice-message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 24px;
}

.voice-status {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.voice-audio {
  display: block;
  width: min(250px, 68vw);
  height: 32px;
  margin-top: 4px;
}

.voice-audio[hidden] {
  display: none;
}

.voice-text-toggle,
.voice-retry {
  border: 0;
  padding: 2px 0;
  background: transparent;
  color: var(--accent-hover);
  cursor: pointer;
  font-size: 0.7rem;
  white-space: nowrap;
}

.voice-retry {
  margin-top: 5px;
}

.voice-text-toggle:hover,
.voice-retry:hover {
  color: #fff;
}

.voice-transcript {
  max-width: 290px;
  margin-top: 4px;
  padding: 8px 11px;
  border: 1px solid rgba(213, 155, 211, 0.2);
  border-radius: 10px;
  background: rgba(34, 29, 45, 0.72);
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.system .bubble {
  background: var(--danger-bg);
  border: 1px solid rgba(224, 122, 122, 0.35);
  color: #f0c4c4;
  font-size: 0.85rem;
}

.msg-meta {
  font-size: 0.66rem;
  color: var(--text-muted);
  padding: 0 4px;
}

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

.media-card {
  margin-top: 6px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  max-width: 280px;
}

.media-card img,
.media-card video {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
}

.composer {
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(12px + var(--safe-bottom));
  background: var(--bg-panel);
}

.media-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.status-pill {
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--text-muted);
  max-width: 45%;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#messageInput {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
  line-height: 1.4;
}

#messageInput:focus {
  outline: none;
  border-color: rgba(91, 141, 239, 0.55);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.12);
}

.send-btn {
  min-width: 72px;
  height: 44px;
  background: #2d5a9e;
  border: 1px solid rgba(91, 141, 239, 0.4);
  font-weight: 600;
  color: #fff;
}

.send-btn:hover {
  background: #3568b5;
  border-color: var(--accent);
  color: #fff;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.typing {
  opacity: 0.7;
  font-style: italic;
}

.status-message .bubble {
  color: var(--muted);
  font-size: 0.92rem;
  font-style: italic;
}

.status-message .bubble::after {
  content: "";
  display: inline-block;
  width: 1.1em;
  animation: status-dots 1.2s steps(4, end) infinite;
}

@keyframes status-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75%, 100% { content: "..."; }
}

.message-retry {
  margin-top: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.memory-dialog {
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0;
  width: min(400px, 92vw);
}

.memory-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.memory-panel {
  padding: 16px;
}

.memory-panel h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
}

#memoryList {
  margin: 0 0 12px;
  padding-left: 18px;
  max-height: 220px;
  overflow: auto;
  color: var(--text-muted);
  font-size: 0.88rem;
}
#memoryList li { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
#memoryList li span { display: grid; gap: 3px; }
#memoryList li .memory-actions { display: flex; gap: 5px; }
#memoryList li small { color: #b98cb3; font-size: .65rem; }
.memory-delete, .memory-edit { border: 0; background: transparent; color: #b98b9f; cursor: pointer; font-size: .7rem; }

.memory-add {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.memory-add input {
  flex: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
}

.close-btn {
  width: 100%;
}

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 40px 16px;
  line-height: 1.65;
}

.empty-hint strong {
  color: var(--text);
  font-weight: 600;
}

/* Luna visual system: warm night, soft glass, relationship-first hierarchy. */
:root {
  --bg: #0d0b13;
  --bg-panel: #12101a;
  --bg-elevated: #1a1725;
  --bg-bubble-user: #76577d;
  --bg-bubble-ai: #211d2c;
  --text: #f6eff8;
  --text-muted: #a69bad;
  --accent: #d59bd3;
  --accent-hover: #efbfe4;
  --border: rgba(238, 204, 237, .14);
  --border-strong: rgba(238, 204, 237, .28);
  --radius: 18px;
}

body { background: radial-gradient(circle at 50% -10%, #392238 0, #0d0b13 48%); }
.auth-view { background: radial-gradient(circle at 30% 10%, #412943 0, #0d0b13 55%); }
.auth-card { border-color: rgba(238, 204, 237, .2); background: rgba(25, 19, 31, .86); backdrop-filter: blur(18px); }
.auth-brand { color: var(--accent-hover); letter-spacing: .12em; font-size: .76rem; }
.auth-submit { background: linear-gradient(135deg, #b974ae, #8b6099); box-shadow: 0 10px 28px rgba(164, 98, 157, .22); }
.home-view, .app { background: linear-gradient(180deg, rgba(20,16,27,.96), rgba(13,11,19,.98)); border-color: var(--border); }
.home-inner { padding: 34px 20px 46px; }
.eyebrow { color: #cdaacb; letter-spacing: .14em; font-size: .62rem; font-weight: 700; margin-bottom: 14px; }
.home-header h1 { font-size: clamp(1.55rem, 6vw, 2.2rem); line-height: 1.18; letter-spacing: -.04em; }
.home-sub { font-size: .95rem; margin-bottom: 20px; }
.account-actions { justify-content: flex-start; gap: 14px; }
.home-hero { display: flex; gap: 14px; align-items: center; padding: 17px; border: 1px solid var(--border); border-radius: 22px; background: linear-gradient(135deg, rgba(111,72,113,.28), rgba(35,28,48,.45)); box-shadow: inset 0 1px rgba(255,255,255,.04); margin: 26px 0 28px; }
.home-hero strong, .home-hero span { display: block; }
.home-hero strong { font-size: .94rem; }
.home-hero span { color: var(--text-muted); font-size: .78rem; margin-top: 5px; line-height: 1.45; }
.hero-orb { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: #ffe1f5; background: radial-gradient(circle at 35% 25%, #f8c9ed, #9b5d98); box-shadow: 0 0 24px rgba(211,133,200,.35); }
.section-label { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 11px; }
.section-label span { font-weight: 700; font-size: .95rem; }
.section-label small { color: var(--text-muted); font-size: .72rem; }
.home-tabs { display: flex; gap: 7px; margin: 24px 0 16px; padding: 4px; border: 1px solid var(--border); border-radius: 15px; background: rgba(255,255,255,.035); }
.home-tabs button { flex: 1; border: 0; border-radius: 11px; background: transparent; color: var(--text-muted); padding: 8px 4px; cursor: pointer; font: inherit; font-size: .76rem; }
.home-tabs button.active { color: var(--text); background: rgba(213,155,211,.16); box-shadow: inset 0 0 0 1px rgba(213,155,211,.15); }
.today-panel { padding: 19px; border: 1px solid rgba(213,155,211,.22); border-radius: 23px; background: radial-gradient(circle at 90% 0, rgba(205,125,194,.24), transparent 42%), linear-gradient(145deg, rgba(50,31,53,.9), rgba(26,21,36,.9)); box-shadow: 0 16px 34px rgba(0,0,0,.16); }
.today-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.today-quiet { color: #bda7ba; font-size: .65rem; text-align: right; }
.today-panel h2 { margin: 30px 0 7px; max-width: 420px; font-size: 1.35rem; line-height: 1.25; letter-spacing: -.04em; }
.today-panel p { margin: 0; color: var(--text-muted); font-size: .8rem; line-height: 1.55; }
.today-memory { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06); color: #e4c8df; font-size: .76rem; }
.today-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 20px; }
.today-actions button { border: 1px solid rgba(238,204,237,.2); border-radius: 999px; padding: 8px 12px; background: rgba(255,255,255,.06); color: var(--text); cursor: pointer; font: inherit; font-size: .72rem; }
.today-actions button:first-child { background: linear-gradient(135deg, #bd7db5, #81578e); border-color: transparent; }
.us-panel { padding: 6px 0 18px; }
.timeline-list { display: grid; gap: 0; position: relative; padding-left: 18px; }
.timeline-list::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 1px; background: rgba(213,155,211,.25); }
.timeline-item { position: relative; display: flex; gap: 12px; padding: 0 0 17px; cursor: pointer; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -16px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: #d59bd3; box-shadow: 0 0 0 4px rgba(213,155,211,.12); }
.timeline-body { min-width: 0; flex: 1; padding: 11px 13px; border: 1px solid var(--border); border-radius: 15px; background: rgba(28,23,38,.72); }
.timeline-body small { color: #bda7ba; font-size: .65rem; }
.timeline-body p { margin: 6px 0 0; color: var(--text); font-size: .78rem; line-height: 1.5; }
.timeline-body img { display: block; width: min(180px, 100%); max-height: 180px; object-fit: cover; border-radius: 11px; margin-top: 9px; }
.timeline-empty { padding: 40px 12px; text-align: center; color: var(--text-muted); font-size: .8rem; }
.time-row { display: flex; gap: 10px; }
.time-row label { flex: 1; display: grid; gap: 6px; color: var(--text-muted); font-size: .75rem; }
.time-row input { min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: #14111d; color: var(--text); font: inherit; }
.legal-links { display: flex; justify-content: center; gap: 12px; margin: 14px 0 0; font-size: .68rem; }
.legal-links a { color: #bda7ba; }
.memory-panel h3 { margin: 20px 0 8px; font-size: .86rem; }
.persona-grid { gap: 14px; }
.persona-card { padding: 16px; border-radius: 20px; background: rgba(28,23,38,.8); border-color: var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.persona-card:hover { border-color: rgba(213,155,211,.55); background: #251d2d; transform: translateY(-1px); }
.persona-card-avatar { width: 62px; height: 62px; border-radius: 18px; font-size: 30px; background: linear-gradient(145deg, #4d3257, #211928); border-color: rgba(238,204,237,.22); }
.persona-card-avatar img, .avatar img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: inherit; }
.persona-card-title { font-size: 1.05rem; }
.persona-card-rel { color: #e6b7df; }
.persona-card-tags span, .persona-tags span { border-radius: 999px; }
.recent-section { margin-top: 38px; }
.recent-section h2 { color: var(--text); font-size: .95rem; }
.conversation-card { border-radius: 15px; background: rgba(27,23,36,.7); }
.persona-header { padding: 16px 15px 14px; background: rgba(18,16,26,.88); backdrop-filter: blur(16px); }
.avatar { border-radius: 16px; background: linear-gradient(145deg, #4d3257, #211928); border-color: rgba(238,204,237,.24); }
.badge { border-radius: 999px; background: rgba(213,155,211,.13); color: #edc2e5; border-color: rgba(213,155,211,.3); }
.icon-btn { border-radius: 999px; background: rgba(255,255,255,.04); }
.messages { padding: 22px 15px 12px; background: radial-gradient(circle at 50% 0, rgba(94,58,93,.12), transparent 42%), #0d0b13; gap: 13px; }
.msg { max-width: 84%; }
.bubble { font-size: .95rem; line-height: 1.65; padding: 11px 14px; }
.msg.user .bubble { border-color: rgba(238,204,237,.15); background: linear-gradient(135deg, #79587f, #63486c); }
.msg.assistant .bubble { background: rgba(34,29,45,.94); border-color: var(--border); }
.media-card { border-radius: 18px; border-color: rgba(238,204,237,.2); box-shadow: 0 14px 30px rgba(0,0,0,.25); }
.media-edit-btn { display: block; margin: 0 8px 8px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.05); color: #d8b5d4; cursor: pointer; font-size: .68rem; }
.media-edit-btn:hover { background: rgba(213,155,211,.14); color: var(--text); }
.composer { padding: 12px 13px calc(13px + var(--safe-bottom)); background: rgba(18,16,26,.94); backdrop-filter: blur(16px); }
#messageInput { border-radius: 18px; background: #1b1724; border-color: var(--border); min-height: 46px; }
#messageInput:focus { border-color: rgba(213,155,211,.65); box-shadow: 0 0 0 3px rgba(213,155,211,.12); }
.send-btn { min-width: 68px; border-radius: 16px; background: linear-gradient(135deg, #bd7db5, #81578e); border-color: rgba(255,255,255,.12); }
.voice-btn { width: 42px; height: 44px; border: 1px solid var(--border); border-radius: 16px; background: #1b1724; color: #e9bde4; cursor: pointer; font-size: 1.2rem; }
.voice-input-btn { width: 42px; height: 44px; border: 1px solid var(--border); border-radius: 16px; background: #1b1724; color: #e9bde4; cursor: pointer; font-size: .72rem; font-weight: 600; }
.voice-input-btn:hover, .voice-input-btn.is-recording { border-color: rgba(213,155,211,.7); background: rgba(213,155,211,.16); color: #fff; }
.voice-input-btn.is-recording { box-shadow: 0 0 0 3px rgba(213,155,211,.12); }
.speak-btn { align-self: flex-start; border: 0; background: transparent; color: #bb9ab7; font-size: .68rem; cursor: pointer; padding: 1px 4px; }
.speak-btn:hover { color: var(--accent-hover); }
.message-text-row { display: flex; align-items: flex-end; gap: 7px; max-width: 100%; }
.message-text-row .bubble { min-width: 0; }
.message-voice-btn { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; gap: 4px; min-height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.045); color: #cda9c9; cursor: pointer; font-size: .68rem; white-space: nowrap; }
.message-voice-btn:hover, .message-voice-btn.is-active { border-color: rgba(213,155,211,.62); background: rgba(213,155,211,.14); color: var(--text); }
.message-voice-btn .voice-btn-icon { font-size: .95rem; line-height: 1; }
.message-voice-btn .voice-btn-label { line-height: 1; }
.voice-message { background: rgba(34,29,45,.94); border-color: var(--border); box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.voice-icon { background: rgba(213,155,211,.16); color: #edc2e5; }
.voice-status { color: #c5aec2; }
.voice-text-toggle, .voice-retry { color: #d29dca; }
.voice-transcript { border-color: rgba(238,204,237,.18); background: rgba(27,23,36,.78); color: #d8c0d4; }
.message-actions { display: flex; flex-wrap: wrap; gap: 3px; padding: 0 4px; opacity: .72; }
.message-actions button { border: 0; padding: 2px 5px; color: #b99fb6; background: transparent; font-size: .65rem; cursor: pointer; }
.message-actions button:hover { color: var(--accent-hover); }
.message-actions button:disabled { opacity: .35; cursor: default; }
.status-message .bubble { color: #c5aec2; }
.memory-dialog { border-color: rgba(238,204,237,.25); border-radius: 20px; background: #1a1725; }
.memory-dialog::backdrop { background: rgba(7,5,10,.72); backdrop-filter: blur(5px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin-top: 4px; }
.dialog-x { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; }
.gallery-dialog { width: min(680px, 94vw); }
.gallery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-height: 62vh; overflow: auto; }
.gallery-card { overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: #13101b; }
.gallery-card img { display: block; width: 100%; aspect-ratio: 1 / 1.18; object-fit: cover; }
.gallery-card-footer { display: flex; align-items: center; gap: 8px; padding: 8px 10px; color: var(--text-muted); }
.gallery-card-footer small { flex: 1; }
.gallery-card-footer button { border: 0; background: transparent; color: #d29dca; cursor: pointer; font-size: .75rem; }
.gallery-empty { grid-column: 1 / -1; min-height: 160px; display: grid; place-items: center; color: var(--text-muted); text-align: center; }
.onboarding-dialog { width: min(460px, 94vw); }
.onboarding-dialog h2 { margin: 8px 0; letter-spacing: -.03em; }
.field-label { display: grid; gap: 6px; margin: 14px 0; color: var(--text-muted); font-size: .78rem; }
.field-label select { padding: 11px 12px; border: 1px solid var(--border); border-radius: 12px; background: #14111d; color: var(--text); font: inherit; }
.check-row { display: flex; gap: 8px; align-items: flex-start; margin: 13px 0; color: var(--text-muted); font-size: .78rem; line-height: 1.45; }
.check-row input { accent-color: var(--accent); margin-top: 3px; }
.reference-preview { min-height: 0; margin: 6px 0 10px; }
.reference-preview img { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: 16px; border: 1px solid var(--border-strong); }
.field-label small { color: #887b8e; font-size: .68rem; }
@media (min-width: 700px) { .home-view, .app { width: min(720px, 100%); } .persona-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Reference-inspired product shell: editorial dark canvas, persistent space
   navigation, portrait-first companions, and one clear daily CTA. */
:root {
  --bg: #09080e;
  --bg-panel: #100d17;
  --bg-elevated: #171321;
  --text: #fbf6fc;
  --text-muted: #a49aae;
  --accent: #d993d1;
  --accent-hover: #ffd2f0;
  --border: rgba(238, 204, 237, .14);
  --border-strong: rgba(238, 204, 237, .28);
  --sidebar: #0b0a11;
}

body { display: block; min-height: 100dvh; background: radial-gradient(circle at 50% -18%, rgba(115, 54, 111, .42), transparent 38%), #09080e; }
.home-view { width: 100%; max-width: none; min-height: 100dvh; margin: 0; display: flex; flex-direction: row; overflow: hidden; border: 0; background: #0d0b13; }
.app-sidebar { width: 244px; flex: 0 0 244px; display: flex; flex-direction: column; gap: 25px; padding: 28px 18px 20px; border-right: 1px solid rgba(238, 204, 237, .1); background: linear-gradient(180deg, rgba(18, 13, 25, .98), rgba(9, 8, 14, .98)); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 10px; }
.sidebar-brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid rgba(255, 213, 245, .35); border-radius: 12px; background: linear-gradient(145deg, #e4a5d8, #754879); color: #fff3fc; box-shadow: 0 0 24px rgba(213, 137, 203, .24); }
.sidebar-brand strong { display: block; font-size: .78rem; letter-spacing: .16em; }
.sidebar-brand span { display: block; margin-top: 3px; color: #8d8198; font-size: .56rem; letter-spacing: .13em; }
.sidebar-nav { display: grid; gap: 5px; }
.home-nav-trigger { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: #9e93a7; cursor: pointer; font: inherit; font-size: .82rem; text-align: left; transition: .18s ease; }
.home-nav-trigger span { width: 18px; color: #84738d; font-size: 1rem; text-align: center; }
.home-nav-trigger:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.home-nav-trigger.active { border-color: rgba(226, 157, 216, .18); background: linear-gradient(90deg, rgba(190, 112, 181, .21), rgba(190, 112, 181, .04)); color: #fff1fc; box-shadow: inset 3px 0 #d792ce; }
.home-nav-trigger.active span { color: #f0b9e4; }
.sidebar-rule { height: 1px; background: rgba(238, 204, 237, .1); }
.sidebar-explore { display: grid; gap: 5px; }
.sidebar-explore p { margin: 0 12px 5px; color: #746879; font-size: .58rem; font-weight: 700; letter-spacing: .16em; }
.sidebar-topic { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 0; background: transparent; color: #958a9e; cursor: pointer; font: inherit; font-size: .76rem; text-align: left; }
.sidebar-topic:hover { color: var(--text); }
.sidebar-topic i { width: 6px; height: 6px; border-radius: 50%; background: #bd7ab2; box-shadow: 0 0 9px rgba(213, 137, 203, .75); }
.sidebar-bottom { display: grid; gap: 8px; margin-top: auto; }
.sidebar-account { display: flex; align-items: center; gap: 9px; width: 100%; padding: 10px; border: 1px solid rgba(238, 204, 237, .12); border-radius: 14px; background: rgba(255,255,255,.035); color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.sidebar-account:hover { border-color: rgba(238, 204, 237, .28); background: rgba(213, 155, 211, .1); }
.sidebar-account > span:nth-child(2) { min-width: 0; flex: 1; }
.sidebar-account strong, .sidebar-account small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account strong { font-size: .72rem; }
.sidebar-account small { max-width: 150px; margin-top: 3px; color: #988b9f; font-size: .62rem; }
.sidebar-account b { color: #a38aa2; font-size: 1.1rem; font-weight: 400; }
.sidebar-user-dot { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 10px; background: linear-gradient(145deg, #c783bd, #5c3c62); color: #ffeaf8; font-size: .72rem; }
.sidebar-logout { border: 0; background: transparent; color: #806f84; cursor: pointer; font: inherit; font-size: .68rem; text-align: left; padding: 4px 10px; }
.sidebar-logout:hover { color: #f2b4dd; }
.home-inner { width: calc(100% - 244px); min-width: 0; max-width: 1240px; margin: 0 auto; overflow-y: auto; padding: 34px clamp(24px, 4vw, 62px) 70px; background: radial-gradient(circle at 85% 0, rgba(92, 43, 92, .15), transparent 33%), linear-gradient(180deg, #100c17, #0c0a11 70%); }
.home-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 25px; padding-bottom: 8px; }
.home-header-copy { min-width: 0; }
.home-header h1 { max-width: 650px; margin: 0 0 8px; font-size: clamp(1.9rem, 3.7vw, 3.3rem); line-height: 1.08; letter-spacing: -.06em; }
.home-sub { max-width: 510px; margin: 0; color: #aa9eae; font-size: .95rem; }
.account-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; justify-content: flex-end; }
.account-actions .logout-btn { margin: 0; padding: 9px 13px; border: 1px solid rgba(238, 204, 237, .14); border-radius: 999px; background: rgba(255,255,255,.035); color: #d8bed6; font-size: .7rem; }
.account-actions .logout-btn:hover { border-color: rgba(238, 204, 237, .35); background: rgba(213, 155, 211, .12); color: #fff; }
.home-tabs { display: none; }
.today-panel { margin: 31px 0 39px; padding: clamp(22px, 3vw, 36px); border: 1px solid rgba(238, 179, 228, .22); border-radius: 28px; background: radial-gradient(circle at 82% 24%, rgba(208, 116, 197, .3), transparent 27%), radial-gradient(circle at 0% 100%, rgba(82, 52, 107, .36), transparent 45%), linear-gradient(120deg, #2b1b35, #171121 74%); box-shadow: 0 24px 70px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.06); }
.today-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 24px; }
.today-top { align-items: center; }
.today-panel .eyebrow { margin: 0; color: #d5a8cf; }
.today-quiet { color: #b5a1b5; font-size: .64rem; }
.today-panel h2 { max-width: 650px; margin: 27px 0 10px; font-size: clamp(1.45rem, 3vw, 2.35rem); line-height: 1.12; letter-spacing: -.05em; }
.today-panel p { max-width: 560px; color: #b5a7b6; font-size: .85rem; }
.today-memory { max-width: 560px; }
.today-actions { margin-top: 25px; }
.today-actions button { padding: 10px 15px; font-size: .73rem; }
.today-actions button:first-child { box-shadow: 0 8px 22px rgba(178, 104, 172, .3); }
.today-visual { display: grid; justify-items: center; gap: 12px; padding: 12px 0; color: #d9bed9; text-align: center; }
.today-visual-orbit { display: grid; width: 140px; height: 140px; place-items: center; border: 1px solid rgba(249, 204, 240, .35); border-radius: 50%; background: radial-gradient(circle at 35% 25%, #f0bee4, #875384 45%, #24162d 72%); box-shadow: 0 0 0 14px rgba(213, 143, 205, .07), 0 0 0 28px rgba(213, 143, 205, .035), 0 18px 48px rgba(0,0,0,.3); }
.today-visual-orbit span { color: #fff4fd; font-size: 2.6rem; text-shadow: 0 0 24px #ffe4fa; }
.today-visual small, .today-visual strong { display: block; }
.today-visual small { color: #9a829d; font-size: .58rem; letter-spacing: .15em; }
.today-visual strong { margin-top: 4px; color: #f6dfef; font-size: .82rem; line-height: 1.45; }
.home-hero { margin: 0 0 18px; padding: 18px 20px; border-color: rgba(238, 204, 237, .13); background: linear-gradient(90deg, rgba(213, 155, 211, .12), rgba(255,255,255,.025)); }
.feature-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 40px; }
.feature-strip > div { display: grid; grid-template-columns: 28px 1fr; column-gap: 8px; align-items: center; padding: 13px 14px; border: 1px solid rgba(238, 204, 237, .1); border-radius: 15px; background: rgba(255,255,255,.025); }
.feature-strip span { grid-row: span 2; display: grid; width: 25px; height: 25px; place-items: center; border-radius: 9px; background: rgba(213, 155, 211, .16); color: #eeb9e1; }
.feature-strip strong { color: #f1e1ef; font-size: .74rem; }
.feature-strip small { margin-top: 3px; color: #96899b; font-size: .62rem; }
.section-label { margin-bottom: 16px; }
.section-label span { font-size: 1.15rem; letter-spacing: -.03em; }
.section-label small { font-size: .7rem; }
.persona-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.persona-card, .persona-create-card { position: relative; min-width: 0; min-height: 0; overflow: hidden; padding: 0; border: 1px solid rgba(238, 204, 237, .12); border-radius: 20px; background: linear-gradient(180deg, rgba(33, 25, 43, .92), rgba(21, 16, 29, .98)); box-shadow: 0 14px 28px rgba(0,0,0,.16); transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.persona-card:hover, .persona-create-card:hover { transform: translateY(-4px); border-color: rgba(236, 174, 225, .45); box-shadow: 0 22px 42px rgba(0,0,0,.3); }
.persona-card-main { display: flex; flex-direction: column; width: 100%; height: 100%; gap: 0; }
.persona-card-avatar { width: 100%; height: 205px; border: 0; border-radius: 0; background: radial-gradient(circle at 50% 20%, #a66da1, #3c294b 48%, #1b1325); color: #f9d8f0; font-size: 3.8rem; }
.persona-card-avatar img { border-radius: 0; }
.persona-card-body { width: 100%; padding: 13px 14px 16px; text-align: left; }
.persona-card-title { margin: 0 0 4px; font-size: .98rem; letter-spacing: -.02em; }
.persona-card-rel { margin-bottom: 0; color: #dcaed4; font-size: .67rem; }
.persona-card-bio { margin-top: 8px; color: #9b8e9f; font-size: .69rem; line-height: 1.45; }
.persona-card-actions { position: absolute; top: 10px; right: 10px; z-index: 2; padding: 4px 7px; border-radius: 999px; background: rgba(8, 6, 12, .62); backdrop-filter: blur(8px); }
.persona-card-actions button { color: #f2d5eb; }
.persona-create-card { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 290px; padding: 20px; color: #edc6e7; cursor: pointer; font: inherit; text-align: left; }
.persona-create-icon { display: grid; width: 44px; height: 44px; place-items: center; border: 1px dashed rgba(237, 183, 226, .5); border-radius: 14px; color: #efb8e3; font-size: 1.55rem; }
.persona-create-card strong, .persona-create-card small { display: block; }
.persona-create-card strong { font-size: .78rem; }
.persona-create-card small { margin-top: 5px; color: #9d8fa1; font-size: .65rem; line-height: 1.4; }
.recent-section { margin-top: 46px; }
.recent-section h2 { margin: 0 0 14px; font-size: 1.15rem; letter-spacing: -.03em; }
.conversation-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.conversation-card { padding: 13px 15px; border-radius: 15px; background: rgba(255,255,255,.025); }
.conversation-card:hover { border-color: rgba(236, 174, 225, .4); background: rgba(213, 155, 211, .08); }
.conversation-summary small { max-width: 270px; }
.us-panel { padding-top: 8px; }
.chat-view { width: min(900px, 100%); min-height: 100dvh; height: 100dvh; border: 0; background: #0d0b13; }

@media (max-width: 1080px) {
  .persona-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-inner { padding-left: 32px; padding-right: 32px; }
}

@media (max-width: 760px) {
  .app-sidebar { width: 72px; flex-basis: 72px; align-items: center; padding: 18px 9px; gap: 18px; }
  .sidebar-brand { padding: 0; }
  .sidebar-brand > div:last-child, .sidebar-explore, .sidebar-rule, .sidebar-account > span:nth-child(2), .sidebar-account b, .sidebar-logout { display: none; }
  .sidebar-brand-mark { width: 38px; height: 38px; }
  .sidebar-nav { width: 100%; }
  .home-nav-trigger { justify-content: center; padding: 12px 0; }
  .home-nav-trigger span { width: auto; font-size: 1.15rem; }
  .home-nav-trigger { font-size: 0; }
  .sidebar-bottom { width: 100%; }
  .sidebar-account { justify-content: center; padding: 8px 0; }
  .home-inner { width: calc(100% - 72px); padding: 24px 17px 42px; }
  .home-header { display: block; }
  .home-header h1 { font-size: clamp(1.7rem, 8vw, 2.3rem); }
  .account-actions { justify-content: flex-start; margin-top: 16px; }
  .today-layout { grid-template-columns: 1fr; }
  .today-visual { display: none; }
  .feature-strip { grid-template-columns: 1fr; margin-bottom: 30px; }
  .persona-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .persona-card-avatar { height: 155px; }
  .persona-card-body { padding: 11px 11px 13px; }
  .persona-card-bio { display: none; }
  .persona-create-card { min-height: 230px; padding: 13px; }
  .conversation-list { grid-template-columns: 1fr; }
  .chat-view { width: 100%; }
}

@media (max-width: 460px) {
  .app-sidebar { width: 58px; flex-basis: 58px; }
  .home-inner { width: calc(100% - 58px); padding-left: 13px; padding-right: 13px; }
  .home-header .eyebrow { font-size: .52rem; }
  .home-header h1 { font-size: 1.72rem; }
  .today-panel { padding: 19px 16px; border-radius: 22px; }
  .today-panel h2 { margin-top: 24px; font-size: 1.4rem; }
  .today-actions button { padding: 8px 10px; }
  .persona-card-avatar { height: 135px; }
  .persona-card-title { font-size: .84rem; }
  .persona-card-rel { font-size: .61rem; }
}

/* Second pass: make the conversation surface feel like the same product,
   rather than a separate utility screen. The home shell stays portrait-led;
   chat gets more breathing room on desktop and a compact composer on mobile. */
.auth-view {
  grid-template-columns: minmax(0, 470px) minmax(250px, 330px);
  gap: clamp(34px, 7vw, 96px);
  place-content: center;
  align-items: center;
  padding: clamp(24px, 6vw, 72px);
  background:
    radial-gradient(circle at 19% 23%, rgba(226, 151, 214, .24), transparent 17%),
    radial-gradient(circle at 82% 74%, rgba(115, 83, 156, .22), transparent 25%),
    #09080e;
}
.auth-view::before {
  content: "LUNA\A YOUR PRIVATE\A COMPANION SPACE";
  white-space: pre;
  color: #f5e5f3;
  font-size: clamp(1.7rem, 4vw, 3.6rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -.065em;
  text-shadow: 0 18px 55px rgba(213, 137, 203, .2);
}
.auth-view::after {
  content: "记住你的故事 · 听见她的声音 · 把每一天过成你们的瞬间";
  position: absolute;
  left: calc(50% - min(520px, 44vw));
  bottom: 12%;
  max-width: 320px;
  color: #9d8fa3;
  font-size: .72rem;
  line-height: 1.7;
}
.auth-card {
  position: relative;
  width: min(100%, 420px);
  padding: 38px;
  border-radius: 28px;
  background: linear-gradient(155deg, rgba(33, 24, 42, .94), rgba(16, 12, 23, .93));
  box-shadow: 0 30px 90px rgba(0, 0, 0, .42), inset 0 1px rgba(255,255,255,.07);
}
.auth-card::before {
  content: "✦";
  position: absolute;
  top: 24px;
  right: 28px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 213, 245, .3);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(228,165,216,.8), rgba(117,72,121,.8));
  color: #fff4fd;
  box-shadow: 0 0 25px rgba(213,137,203,.22);
}
.auth-card h1 { margin-top: 34px; font-size: clamp(1.6rem, 4vw, 2.1rem); letter-spacing: -.05em; }
.auth-form { margin-top: 26px; }
.auth-form input, .memory-panel input, .memory-panel textarea {
  border-radius: 14px;
  background: rgba(8, 7, 13, .58);
  border-color: rgba(238, 204, 237, .14);
}
.auth-form input:focus, .memory-panel input:focus, .memory-panel textarea:focus, .field-label select:focus {
  outline: none;
  border-color: rgba(224, 159, 216, .72);
  box-shadow: 0 0 0 3px rgba(213, 155, 211, .12);
}
.auth-submit { border-radius: 14px; min-height: 46px; }
.auth-toggle { font-size: .75rem; }

.chat-view {
  position: relative;
  isolation: isolate;
  width: min(1180px, 100%);
  max-width: 1180px;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  border: 1px solid rgba(238, 204, 237, .1);
  background: #0b0910;
  box-shadow: 0 0 90px rgba(70, 31, 70, .16);
}
.chat-view::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% -18%, rgba(116, 61, 116, .24), transparent 34%);
}
.persona-header {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 88px;
  padding: 17px clamp(18px, 4vw, 42px);
  border-bottom-color: rgba(238, 204, 237, .11);
  background: rgba(13, 10, 19, .78);
  backdrop-filter: blur(24px);
}
.persona-header .back-btn { min-width: 52px; }
.avatar { width: 54px; height: 54px; border-radius: 18px; box-shadow: 0 10px 24px rgba(0,0,0,.24); }
.persona-name-row h1 { font-size: 1.08rem; letter-spacing: -.025em; }
.persona-bio { margin-top: 5px; max-width: 620px; }
.header-actions { flex-direction: row; gap: 7px; }
.header-actions .icon-btn { min-height: 34px; padding: 7px 11px; font-size: .7rem; }
.icon-btn, .back-btn { border-color: rgba(238, 204, 237, .14); background: rgba(255,255,255,.045); }
.icon-btn:hover, .media-btn:hover { border-color: rgba(224, 159, 216, .58); background: rgba(213,155,211,.12); }
.chat-shell { min-height: 0; background: radial-gradient(circle at 50% 0, rgba(101, 55, 103, .13), transparent 42%); }
.messages {
  width: min(940px, 100%);
  margin: 0 auto;
  padding: 38px clamp(18px, 5vw, 70px) 28px;
  gap: 16px;
  background: transparent;
}
.msg { max-width: min(720px, 86%); gap: 6px; }
.bubble { padding: 12px 16px; border-radius: 19px; font-size: .94rem; line-height: 1.7; }
.msg.user .bubble { border-bottom-right-radius: 6px; background: linear-gradient(135deg, #815d88, #5c4169); box-shadow: 0 10px 24px rgba(0,0,0,.16); }
.msg.assistant .bubble { border-bottom-left-radius: 6px; background: rgba(31, 25, 42, .9); box-shadow: 0 10px 24px rgba(0,0,0,.12); }
.msg-meta { color: #82758b; }
.voice-message { min-width: min(310px, 78vw); padding: 11px 13px; border-radius: 19px 19px 19px 6px; background: rgba(31,25,42,.92); }
.voice-audio { width: min(330px, 65vw); }
.voice-transcript { max-width: 340px; border-radius: 13px; }
.media-card { max-width: min(420px, 76vw); border-radius: 22px; }
.media-card img, .media-card video { max-height: 480px; }
.composer {
  border-top: 0;
  padding: 13px clamp(18px, 5vw, 70px) calc(18px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(11, 9, 16, .45), rgba(11, 9, 16, .94) 34%);
}
.chat-form {
  width: min(940px, 100%);
  margin: 0 auto;
  align-items: center;
  gap: 7px;
  padding: 7px;
  border: 1px solid rgba(238, 204, 237, .14);
  border-radius: 22px;
  background: rgba(26, 20, 35, .92);
  box-shadow: 0 18px 42px rgba(0,0,0,.24), inset 0 1px rgba(255,255,255,.04);
}
#messageInput { min-height: 44px; max-height: 140px; padding: 11px 13px; border: 0; background: transparent; }
#messageInput:focus { border-color: transparent; box-shadow: none; }
.voice-btn, .voice-input-btn, .send-btn { height: 42px; border-radius: 15px; }
.send-btn { min-width: 74px; }

.memory-dialog {
  max-height: min(86vh, 760px);
  box-shadow: 0 28px 90px rgba(0,0,0,.5), inset 0 1px rgba(255,255,255,.05);
}
.memory-panel { padding: 22px; }

@media (max-width: 760px) {
  .auth-view { display: grid; grid-template-columns: 1fr; gap: 18px; padding: 22px 16px; }
  .auth-view::before, .auth-view::after { display: none; }
  .auth-card { width: 100%; padding: 28px 22px; }
  .persona-header { grid-template-columns: auto auto minmax(0, 1fr); min-height: 78px; gap: 9px; padding: 12px 13px; }
  .persona-header .persona-meta { min-width: 0; }
  .persona-header .persona-bio { display: none; }
  .header-actions { grid-column: 1 / -1; grid-row: 2; justify-content: flex-end; padding-left: 0; }
  .header-actions .icon-btn { flex: 1; }
  .messages { padding: 22px 13px 18px; }
  .msg { max-width: 92%; }
  .composer { padding: 9px 10px calc(10px + var(--safe-bottom)); }
  .chat-form { border-radius: 18px; padding: 5px; }
  .send-btn { min-width: 58px; }
  .voice-btn, .voice-input-btn { width: 38px; padding: 0; }
}

@media (max-width: 460px) {
  .persona-header { grid-template-columns: auto minmax(0, 1fr); }
  .persona-header .avatar { width: 46px; height: 46px; }
  .persona-header .persona-meta { grid-column: 2; grid-row: 1; }
  .persona-header .back-btn { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .header-actions { grid-column: 1 / -1; grid-row: 3; }
  .messages { padding-left: 10px; padding-right: 10px; }
  .bubble { padding: 10px 13px; font-size: .9rem; }
  .voice-message { min-width: 0; width: min(100%, 310px); }
  .voice-audio { width: min(250px, 60vw); }
  .chat-form { gap: 4px; }
  #messageInput { padding-left: 8px; padding-right: 4px; font-size: .88rem; }
}

/* TTS is an explicit composer extension; text replies remain the default. */

/* 20260716 Stitch sanctuary system.
   Adapted from the supplied Stitch screens: near-black canvas, lavender
   primary, purple navigation container, editorial headlines and restrained
   glass surfaces. Existing IDs/classes stay intact so the product behavior
   and API integrations are unchanged. */
:root {
  --stitch-background: #131313;
  --stitch-lowest: #0e0e0e;
  --stitch-low: #1c1b1b;
  --stitch-container: #201f1f;
  --stitch-high: #2a2a2a;
  --stitch-highest: #353534;
  --stitch-primary: #d3bcfc;
  --stitch-secondary: #d7baff;
  --stitch-secondary-container: #5d2d9f;
  --stitch-on-primary: #38265b;
  --stitch-on-background: #e5e2e1;
  --stitch-variant: #cbc4d0;
  --stitch-outline: #948e99;
  --stitch-tertiary: #ffb4ac;
  --luna-canvas: var(--stitch-background);
  --luna-sidebar: var(--stitch-lowest);
  --luna-surface: rgba(32, 31, 31, .62);
  --luna-surface-2: rgba(42, 42, 42, .58);
  --luna-surface-3: var(--stitch-highest);
  --luna-text: var(--stitch-on-background);
  --luna-muted: var(--stitch-variant);
  --luna-subtle: #948e99;
  --luna-line: rgba(255, 255, 255, .08);
  --luna-line-strong: rgba(255, 255, 255, .16);
  --luna-pink: var(--stitch-primary);
  --luna-pink-bright: var(--stitch-secondary);
  --luna-pink-soft: rgba(211, 188, 252, .12);
  --luna-green: #9ad6b0;
  --luna-danger: var(--stitch-tertiary);
  --luna-sidebar-width: 288px;
}

html,
body {
  background: var(--stitch-background);
  color: var(--stitch-on-background);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
}

body {
  background:
    radial-gradient(circle at 55% -10%, rgba(93, 45, 159, .16), transparent 32%),
    var(--stitch-background);
}

h1, h2, h3,
.home-header h1,
.today-panel h2,
.persona-card-title,
.section-label span,
.memory-panel h2,
.memory-panel h3 {
  font-family: "Playfair Display", Georgia, serif;
}

button,
input,
textarea,
select { font-family: "Manrope", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible { outline-color: var(--stitch-primary); }

/* Auth */
.auth-view {
  background:
    radial-gradient(circle at 12% 18%, rgba(93, 45, 159, .22), transparent 25%),
    radial-gradient(circle at 84% 78%, rgba(211, 188, 252, .08), transparent 24%),
    var(--stitch-background);
}

.auth-card {
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 20px;
  background: rgba(19, 19, 19, .78);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .48), inset 0 1px rgba(255, 255, 255, .04);
  backdrop-filter: blur(22px);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--stitch-primary);
  font-size: .78rem;
  letter-spacing: .12em;
}

.auth-brand small { color: var(--stitch-outline); font-size: .52rem; letter-spacing: .08em; }
.auth-brand-mark { display: grid; width: 29px; height: 29px; place-items: center; border: 1px solid rgba(211, 188, 252, .35); border-radius: 50%; background: linear-gradient(135deg, var(--stitch-secondary-container), #453268); color: #f4ecff; }
.auth-card h1 { color: var(--stitch-on-background); }
.auth-form input,
.memory-panel input,
.memory-panel textarea,
.field-label select,
.time-row input { border-color: rgba(255, 255, 255, .1); border-radius: 8px; background: var(--stitch-lowest); color: var(--stitch-on-background); }
.auth-submit { background: linear-gradient(110deg, var(--stitch-secondary-container), #453268); color: #f3eaff; box-shadow: 0 8px 24px rgba(93, 45, 159, .28); }
.auth-toggle,
.legal-links a { color: var(--stitch-primary); }

/* Shared application shell */
.product-shell {
  grid-template-columns: var(--luna-sidebar-width) minmax(0, 1fr);
  background: var(--stitch-background);
}

.app-sidebar {
  width: var(--luna-sidebar-width);
  padding: 30px 24px 24px;
  gap: 24px;
  border-right: 1px solid rgba(255, 255, 255, .06);
  background: rgba(14, 14, 14, .86);
  box-shadow: 18px 0 50px rgba(0, 0, 0, .18);
  backdrop-filter: blur(26px);
}

.sidebar-top { gap: 22px; }
.sidebar-brand { gap: 12px; padding: 0 4px; }
.sidebar-brand-mark { width: 40px; height: 40px; flex-basis: 40px; border-radius: 50%; border-color: rgba(211, 188, 252, .35); background: linear-gradient(135deg, var(--stitch-secondary-container), #453268); color: #f4ecff; box-shadow: 0 0 26px rgba(93, 45, 159, .28); }
.sidebar-brand strong { color: var(--stitch-primary); font-family: "Playfair Display", Georgia, serif; font-size: 1.08rem; letter-spacing: -.01em; }
.sidebar-brand span { color: var(--stitch-outline); font-size: .54rem; letter-spacing: .12em; }
.sidebar-new { min-height: 46px; border: 1px solid rgba(211, 188, 252, .22); border-radius: 10px; background: linear-gradient(110deg, rgba(93, 45, 159, .9), rgba(69, 50, 104, .9)); color: #f1e9ff; box-shadow: 0 8px 22px rgba(93, 45, 159, .2); }
.sidebar-new:hover { border-color: rgba(211, 188, 252, .5); background: linear-gradient(110deg, #6b36b3, #503d73); }
.sidebar-new-icon { color: var(--stitch-secondary); }
.sidebar-new kbd { color: rgba(237, 220, 255, .72); }
.sidebar-nav { gap: 4px; }
.home-nav-trigger { min-height: 44px; gap: 13px; padding: 0 14px; border-radius: 10px; color: var(--stitch-variant); }
.home-nav-trigger span { width: 20px; color: var(--stitch-outline); }
.home-nav-trigger strong { font-size: .83rem; font-weight: 500; }
.home-nav-trigger:hover { color: var(--stitch-on-background); background: rgba(255, 255, 255, .06); transform: translateX(2px); }
.home-nav-trigger.active { color: #cba8ff; background: var(--stitch-secondary-container); box-shadow: 0 0 18px rgba(93, 45, 159, .3); }
.home-nav-trigger.active span { color: var(--stitch-secondary); }
.sidebar-history { padding-top: 18px; border-top-color: rgba(255, 255, 255, .07); }
.sidebar-section-heading { padding: 0 12px 10px; color: var(--stitch-variant); font-size: .68rem; letter-spacing: .06em; }
.sidebar-section-heading small { color: var(--stitch-outline); font-size: .52rem; letter-spacing: .1em; }
.sidebar-history .conversation-open { padding: 10px 12px; color: var(--stitch-variant); }
.sidebar-history .conversation-card:hover { background: rgba(255, 255, 255, .05); }
.sidebar-history .conversation-summary strong { font-size: .74rem; }
.sidebar-history .conversation-summary small { color: var(--stitch-outline); }
.sidebar-bottom { padding-top: 14px; border-top-color: rgba(255, 255, 255, .07); }
.sidebar-action,
.sidebar-account { min-height: 38px; border-radius: 9px; color: var(--stitch-variant); }
.sidebar-action > span:first-child { color: var(--stitch-secondary); }
.sidebar-action:hover,
.sidebar-account:hover { background: rgba(255, 255, 255, .06); color: var(--stitch-on-background); }
.sidebar-account { min-height: 50px; border-color: rgba(255, 255, 255, .08); background: rgba(32, 31, 31, .56); }
.sidebar-user-dot { background: rgba(93, 45, 159, .42); color: var(--stitch-secondary); }
.sidebar-account strong { color: var(--stitch-on-background); }
.sidebar-account small,
.sidebar-logout { color: var(--stitch-outline); }
.sidebar-logout:hover { color: var(--stitch-tertiary); }
.shell-main { background: var(--stitch-background); }

/* Sanctuary home */
.home-view {
  background:
    radial-gradient(circle at 62% -12%, rgba(93, 45, 159, .17), transparent 30%),
    var(--stitch-background);
}
.workspace-topbar { display: none; }
.home-inner { width: min(1200px, 100%); padding: 68px 48px 96px; }
.home-header h1 { max-width: 800px; margin-bottom: 12px; color: var(--stitch-on-background); font-size: clamp(2.5rem, 5vw, 4rem); font-weight: 700; letter-spacing: -.04em; line-height: 1.05; }
.home-header .eyebrow,
.eyebrow { color: var(--stitch-secondary); font-size: .66rem; letter-spacing: .15em; }
.home-sub { max-width: 620px; color: var(--stitch-variant); font-size: 1rem; line-height: 1.7; }
.home-tabs { display: none; }
.today-panel { margin: 48px 0 50px; padding: 34px; border: 1px solid rgba(255, 255, 255, .07); border-radius: 20px; background: linear-gradient(135deg, rgba(32, 31, 31, .72), rgba(28, 27, 27, .32)); box-shadow: 0 14px 45px rgba(0, 0, 0, .2); backdrop-filter: blur(18px); }
.today-panel::after { right: -60px; bottom: -170px; border-color: rgba(211, 188, 252, .12); box-shadow: 0 0 0 36px rgba(93, 45, 159, .05), 0 0 0 72px rgba(93, 45, 159, .025); }
.today-panel .eyebrow { color: var(--stitch-secondary); }
.today-quiet { border-color: rgba(255, 255, 255, .1); color: var(--stitch-variant); background: rgba(255, 255, 255, .035); }
.today-panel h2 { color: var(--stitch-on-background); font-size: clamp(1.9rem, 3.6vw, 2.8rem); }
.today-panel p { color: var(--stitch-variant); font-size: .9rem; }
.today-memory { border-color: rgba(211, 188, 252, .15); background: rgba(93, 45, 159, .12); color: var(--stitch-secondary); }
.today-actions button { border-color: rgba(211, 188, 252, .22); border-radius: 9px; background: rgba(255, 255, 255, .05); color: var(--stitch-on-background); }
.today-actions button:first-child { background: var(--stitch-secondary-container); color: #eadcff; }
.today-visual-orbit { border-color: rgba(211, 188, 252, .34); background: radial-gradient(circle at 35% 28%, #d3bcfc, #5d2d9f 48%, #1d1630 76%); box-shadow: 0 0 0 14px rgba(93, 45, 159, .11), 0 0 0 28px rgba(93, 45, 159, .04); }
.today-visual small { color: var(--stitch-outline); }
.today-visual strong { color: var(--stitch-variant); }
.home-hero { border-color: rgba(255, 255, 255, .07); border-radius: 14px; background: rgba(32, 31, 31, .48); }
.hero-orb,
.feature-strip span { background: rgba(93, 45, 159, .28); color: var(--stitch-secondary); }
.home-hero strong { color: var(--stitch-on-background); }
.home-hero span,
.feature-strip small { color: var(--stitch-outline); }
.feature-strip { gap: 14px; margin-bottom: 48px; }
.feature-strip > div { min-height: 78px; border-color: rgba(255, 255, 255, .07); border-radius: 12px; background: rgba(32, 31, 31, .36); }
.feature-strip strong { color: var(--stitch-on-background); }
.section-label span { color: var(--stitch-on-background); font-size: 1.4rem; }
.section-label small { color: var(--stitch-outline); }
.persona-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.persona-card,
.persona-create-card { border-color: rgba(255, 255, 255, .08); border-radius: 18px; background: rgba(32, 31, 31, .56); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
.persona-card:hover,
.persona-create-card:hover { border-color: rgba(211, 188, 252, .4); background: rgba(42, 42, 42, .7); }
#personaGrid > .persona-card:first-of-type { grid-column: span 8; }
#personaGrid > .persona-create-card { grid-column: span 4; }
#personaGrid > .persona-card:not(:first-of-type) { grid-column: span 4; }
.persona-card-avatar { height: 226px; background: linear-gradient(145deg, #2d2141, #171717); }
#personaGrid > .persona-card:first-of-type .persona-card-avatar { height: 330px; }
.persona-card-body { padding: 16px 18px 18px; }
.persona-card-title { color: var(--stitch-on-background); font-size: 1.08rem; }
.persona-card-rel { border-color: rgba(211, 188, 252, .2); color: var(--stitch-secondary); }
.persona-card-bio { color: var(--stitch-variant); font-size: .78rem; line-height: 1.55; }
.persona-create-card { min-height: 290px; border-color: var(--stitch-outline); background: rgba(28, 27, 27, .38); }
.persona-create-icon { width: 64px; height: 64px; border-radius: 50%; border: 0; background: rgba(93, 45, 159, .2); color: var(--stitch-secondary); font-size: 1.8rem; }
.persona-create-card strong { color: var(--stitch-on-background); font-family: "Playfair Display", Georgia, serif; font-size: 1.15rem; }
.persona-create-card small { max-width: 25ch; color: var(--stitch-variant); font-size: .72rem; text-align: center; }
.home-status { color: var(--stitch-outline); }
.us-panel { padding-top: 8px; }
.timeline-list::before { background: rgba(211, 188, 252, .25); }
.timeline-dot { background: var(--stitch-primary); box-shadow: 0 0 0 4px rgba(211, 188, 252, .12); }
.timeline-body { border-color: rgba(255, 255, 255, .08); border-radius: 14px; background: rgba(32, 31, 31, .55); }
.timeline-body small { color: var(--stitch-outline); }
.timeline-body p { color: var(--stitch-on-background); }

/* Conversation */
.chat-view { width: 100%; max-width: none; min-height: 100dvh; border: 0; background: var(--stitch-background); box-shadow: none; }
.chat-view::before { background: radial-gradient(circle at 60% -18%, rgba(93, 45, 159, .2), transparent 34%); }
.persona-header { min-height: 82px; padding: 16px 38px; border-bottom-color: rgba(255, 255, 255, .07); background: rgba(14, 14, 14, .76); }
.avatar { width: 52px; height: 52px; border-radius: 50%; border-color: rgba(211, 188, 252, .3); background: linear-gradient(135deg, #5d2d9f, #201f1f); }
.persona-name-row h1 { color: var(--stitch-on-background); font-family: "Playfair Display", Georgia, serif; font-size: 1.22rem; }
.persona-bio { color: var(--stitch-variant); }
.badge { border-color: rgba(211, 188, 252, .25); background: rgba(93, 45, 159, .28); color: var(--stitch-secondary); }
.icon-btn { border-color: rgba(255, 255, 255, .1); border-radius: 9px; background: rgba(255, 255, 255, .04); color: var(--stitch-variant); }
.icon-btn:hover { border-color: rgba(211, 188, 252, .45); background: rgba(93, 45, 159, .2); color: var(--stitch-on-background); }
.chat-shell { background: radial-gradient(circle at 50% 0, rgba(93, 45, 159, .1), transparent 42%), var(--stitch-background); }
.chat-welcome-line { width: min(920px, 100%); padding-top: 28px; color: var(--stitch-outline); font-size: .62rem; letter-spacing: .1em; }
.chat-welcome-dot { background: var(--luna-green); }
.chat-welcome-rule { background: rgba(255, 255, 255, .08); }
.messages { width: min(920px, 100%); padding: 34px 38px 30px; gap: 18px; }
.msg { max-width: min(720px, 88%); }
.bubble { border: 1px solid rgba(255, 255, 255, .06); border-radius: 14px; color: var(--stitch-on-background); font-size: .96rem; line-height: 1.72; }
.msg.assistant .bubble { background: rgba(32, 31, 31, .72); }
.msg.user .bubble { border-color: rgba(211, 188, 252, .16); border-radius: 14px 14px 4px 14px; background: var(--stitch-secondary-container); color: #f0e8ff; }
.msg.system .bubble { background: rgba(255, 180, 172, .1); color: var(--stitch-tertiary); }
.message-voice-btn { border-color: rgba(255, 255, 255, .1); background: transparent; color: var(--stitch-variant); }
.message-voice-btn:hover,
.message-voice-btn.is-active { border-color: rgba(211, 188, 252, .42); background: rgba(93, 45, 159, .2); color: var(--stitch-secondary); }
.msg-meta,
.message-actions button { color: var(--stitch-outline); }
.media-card { border-color: rgba(255, 255, 255, .08); border-radius: 16px; background: var(--stitch-lowest); }
.voice-message { border-color: rgba(255, 255, 255, .08); border-radius: 14px; background: rgba(32, 31, 31, .72); }
.voice-icon { background: rgba(93, 45, 159, .28); color: var(--stitch-secondary); }
.voice-status { color: var(--stitch-variant); }
.voice-text-toggle,
.voice-retry { color: var(--stitch-primary); }
.voice-transcript { border-color: rgba(255, 255, 255, .08); background: rgba(28, 27, 27, .74); color: var(--stitch-variant); }
.composer { padding: 14px 38px calc(22px + var(--safe-bottom)); background: linear-gradient(180deg, rgba(19, 19, 19, .28), rgba(19, 19, 19, .98) 35%); }
.composer-context,
.composer-meta { width: min(920px, 100%); color: var(--stitch-outline); }
.chat-form { width: min(920px, 100%); min-height: 58px; border-color: rgba(255, 255, 255, .12); border-radius: 14px; background: rgba(32, 31, 31, .86); box-shadow: 0 16px 38px rgba(0, 0, 0, .28); }
.chat-form:focus-within { border-color: rgba(211, 188, 252, .48); box-shadow: 0 16px 38px rgba(0, 0, 0, .28), 0 0 0 3px rgba(93, 45, 159, .18); }
#messageInput { color: var(--stitch-on-background); }
#messageInput::placeholder { color: var(--stitch-outline); }
.voice-input-btn { border-color: rgba(255, 255, 255, .1); border-radius: 9px; background: transparent; color: var(--stitch-variant); }
.voice-input-btn:hover,
.voice-input-btn.is-recording { border-color: rgba(211, 188, 252, .42); background: rgba(93, 45, 159, .2); color: var(--stitch-secondary); }
.send-btn { min-width: 62px; border-radius: 9px; background: linear-gradient(110deg, var(--stitch-secondary-container), #453268); color: #f0e8ff; }
.send-btn:hover { background: linear-gradient(110deg, #6b36b3, #503d73); }

/* Memory, gallery and account surfaces */
.memory-dialog { width: min(1080px, calc(100vw - 42px)); max-height: min(88dvh, 860px); border-color: rgba(255, 255, 255, .1); border-radius: 18px; background: var(--stitch-background); box-shadow: 0 30px 100px rgba(0, 0, 0, .58); }
.memory-dialog::backdrop { background: rgba(0, 0, 0, .76); backdrop-filter: blur(8px); }
.memory-panel { max-height: min(88dvh, 860px); padding: 34px; }
.memory-panel h2 { color: var(--stitch-on-background); font-size: clamp(1.8rem, 3vw, 2.5rem); }
.dialog-kicker { margin-bottom: 10px; color: var(--stitch-secondary); font-size: .64rem; letter-spacing: .15em; }
.memory-panel h3 { color: var(--stitch-on-background); }
#memoryList { max-height: 48dvh; color: var(--stitch-variant); }
#memoryList li { min-height: 56px; margin: 10px 0; padding: 13px 15px; border: 1px solid rgba(255, 255, 255, .06); border-radius: 12px; background: rgba(32, 31, 31, .55); }
#memoryList li small { color: var(--stitch-primary); }
.memory-delete,
.memory-edit { color: var(--stitch-primary); }
.gallery-dialog { width: min(1120px, calc(100vw - 42px)); }
.gallery-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); max-height: 68dvh; gap: 16px; }
.gallery-card { border-color: rgba(255, 255, 255, .08); border-radius: 12px; background: rgba(32, 31, 31, .62); }
.gallery-card img { aspect-ratio: 1 / 1.18; }
.gallery-card-footer { color: var(--stitch-variant); }
.gallery-card-footer button { color: var(--stitch-primary); }
.dialog-x { color: var(--stitch-variant); }
.close-btn,
.memory-add button { border-color: rgba(255, 255, 255, .12); border-radius: 9px; background: var(--stitch-high); color: var(--stitch-on-background); }

@media (max-width: 1100px) {
  .home-inner { padding-left: 34px; padding-right: 34px; }
  #personaGrid > .persona-card:first-of-type { grid-column: span 7; }
  #personaGrid > .persona-create-card { grid-column: span 5; }
  #personaGrid > .persona-card:not(:first-of-type) { grid-column: span 5; }
}

@media (max-width: 820px) {
  .product-shell { display: block; }
  .app-sidebar { width: 288px; transform: translateX(-105%); }
  .product-shell.sidebar-open .app-sidebar { transform: translateX(0); }
  .workspace-topbar { display: flex; min-height: 62px; padding: 0 20px; border-bottom: 1px solid rgba(255, 255, 255, .07); background: rgba(14, 14, 14, .78); }
  .workspace-topbar .topbar-menu { display: block; color: var(--stitch-variant); }
  .topbar-actions { display: none; }
  .home-inner { height: calc(100dvh - 62px); padding: 42px 24px 72px; }
  .home-header h1 { font-size: clamp(2.3rem, 9vw, 3.4rem); }
  .persona-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #personaGrid > .persona-card:first-of-type,
  #personaGrid > .persona-create-card,
  #personaGrid > .persona-card:not(:first-of-type) { grid-column: span 1; }
  #personaGrid > .persona-card:first-of-type .persona-card-avatar,
  .persona-card-avatar { height: clamp(190px, 38vw, 260px); }
  .persona-create-card { min-height: 260px; }
  .persona-header { padding: 13px 20px; }
  .messages { padding-left: 22px; padding-right: 22px; }
  .composer { padding-left: 20px; padding-right: 20px; }
  .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .auth-card { padding: 28px 22px; border-radius: 16px; }
  .auth-brand { flex-wrap: wrap; }
  .auth-brand small { flex-basis: 100%; margin-left: 38px; }
  .home-inner { padding: 34px 16px 54px; }
  .home-header h1 { font-size: 2.35rem; }
  .home-sub { font-size: .88rem; }
  .today-panel { margin-top: 34px; padding: 22px 18px; border-radius: 16px; }
  .today-layout { grid-template-columns: 1fr; }
  .today-visual { display: none; }
  .feature-strip { margin-right: -16px; overflow-x: auto; padding-right: 16px; scrollbar-width: none; }
  .feature-strip::-webkit-scrollbar { display: none; }
  .feature-strip > div { min-width: 176px; }
  .persona-grid { gap: 10px; }
  .persona-card-avatar,
  #personaGrid > .persona-card:first-of-type .persona-card-avatar { height: 154px; }
  .persona-card-body { padding: 11px 12px 13px; }
  .persona-card-title { font-size: .9rem; }
  .persona-card-bio { display: none; }
  .persona-create-card { min-height: 202px; padding: 12px; }
  .persona-create-card strong { font-size: .88rem; }
  .persona-create-card small { display: none; }
  .persona-header { grid-template-columns: auto minmax(0, 1fr) auto; min-height: 64px; padding: 10px 12px; }
  .chat-header-leading .back-btn { padding: 0 7px; }
  .avatar { width: 42px; height: 42px; }
  .persona-name-row h1 { font-size: 1rem; }
  .header-actions .icon-btn { min-width: 38px; padding: 0 7px; }
  .chat-welcome-line { padding: 18px 14px 0; }
  .messages { padding: 24px 12px 22px; gap: 15px; }
  .msg { max-width: 94%; }
  .bubble { font-size: .9rem; }
  .composer { padding: 10px 10px calc(12px + var(--safe-bottom)); }
  .chat-form { min-height: 52px; border-radius: 12px; padding: 5px; }
  .voice-input-btn { width: 42px; padding: 0; }
  .send-btn { min-width: 52px; padding: 0 9px; }
  .memory-dialog,
  .gallery-dialog { inset: auto 10px calc(10px + var(--safe-bottom)); width: calc(100vw - 20px); max-width: calc(100vw - 20px); margin: 0; border-radius: 16px; }
  .memory-panel { max-height: calc(100dvh - 24px - var(--safe-bottom)); padding: 22px 16px calc(22px + var(--safe-bottom)); }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 64dvh; gap: 10px; }
}
.voice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: auto;
  min-width: 64px;
  padding: 0 10px;
  color: #e9bde4;
  font-size: .72rem;
  font-weight: 600;
}
.voice-btn-icon { font-size: 1.05rem; line-height: 1; }
.voice-btn-label { line-height: 1; }

@media (max-width: 760px) {
  .voice-btn { width: 40px; min-width: 40px; padding: 0; }
  .voice-btn-label { display: none; }
}

/* Mobile layout: use the full viewport, turn the desktop rail into a bottom
   tab bar, and keep chat controls reachable above the safe area/keyboard. */
@media (max-width: 760px) {
  html, body { min-height: 100%; overflow: hidden; }
  body { -webkit-tap-highlight-color: transparent; }
  .auth-view { overflow-y: auto; }

  .home-view {
    height: 100dvh;
    min-height: 100dvh;
    flex-direction: column;
  }
  .home-inner {
    order: 1;
    width: 100%;
    height: calc(100dvh - 70px);
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: 22px 16px 34px;
  }
  .app-sidebar {
    order: 2;
    width: 100%;
    height: calc(66px + var(--safe-bottom));
    min-height: calc(66px + var(--safe-bottom));
    flex: 0 0 calc(66px + var(--safe-bottom));
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 7px 8px var(--safe-bottom);
    border: 0;
    border-top: 1px solid rgba(238, 204, 237, .13);
    background: rgba(13, 10, 19, .96);
    box-shadow: 0 -12px 30px rgba(0, 0, 0, .22);
    z-index: 20;
  }
  .sidebar-brand,
  .sidebar-explore,
  .sidebar-rule,
  .sidebar-logout { display: none; }
  .sidebar-nav {
    display: flex;
    align-items: stretch;
    flex: 1;
    width: auto;
    gap: 3px;
  }
  .home-nav-trigger {
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    padding: 5px 2px;
    border-radius: 12px;
    font-size: .62rem;
    line-height: 1.1;
    text-align: center;
  }
  .home-nav-trigger span {
    width: auto;
    font-size: 1.08rem;
    line-height: 1;
  }
  .home-nav-trigger.active {
    box-shadow: inset 0 2px #d792ce;
  }
  .sidebar-bottom {
    display: flex;
    align-items: center;
    width: 38px;
    margin: 0 0 0 4px;
  }
  .sidebar-account {
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 5px;
    border-radius: 12px;
  }
  .sidebar-account > span:nth-child(2),
  .sidebar-account b { display: none; }
  .sidebar-user-dot { width: 27px; height: 27px; }

  .home-header { display: block; }
  .home-header h1 { font-size: clamp(1.65rem, 8vw, 2.15rem); }
  .home-sub { margin-bottom: 0; font-size: .86rem; }
  .account-actions { justify-content: flex-start; margin-top: 15px; }
  .account-actions .logout-btn { min-height: 36px; padding: 8px 12px; }
  .today-panel { margin: 24px 0 28px; padding: 20px 17px; border-radius: 22px; }
  .today-layout { grid-template-columns: 1fr; }
  .today-visual { display: none; }
  .today-panel h2 { margin-top: 25px; font-size: 1.45rem; }
  .today-actions button { min-height: 36px; }
  .home-hero { margin-bottom: 18px; padding: 15px; }
  .feature-strip { display: flex; gap: 8px; margin: 0 -2px 30px; overflow-x: auto; padding: 1px 2px 5px; scroll-snap-type: x proximity; scrollbar-width: none; }
  .feature-strip::-webkit-scrollbar { display: none; }
  .feature-strip > div { flex: 0 0 178px; min-height: 65px; scroll-snap-align: start; padding: 11px; }
  .section-label { align-items: flex-start; gap: 10px; }
  .section-label small { text-align: right; }
  .persona-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .persona-card-avatar { height: clamp(132px, 39vw, 178px); }
  .persona-card-body { padding: 11px 11px 13px; }
  .persona-card-title { font-size: .88rem; }
  .persona-card-bio { display: none; }
  .persona-create-card { min-height: 220px; padding: 14px; }
  .conversation-list { grid-template-columns: 1fr; }

  .chat-view {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
  }
  .persona-header {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 66px;
    padding: 9px 10px;
  }
  .persona-header .back-btn {
    min-width: 43px;
    padding: 7px 7px;
    font-size: .68rem;
  }
  .persona-header .avatar { width: 43px; height: 43px; border-radius: 14px; font-size: 20px; }
  .persona-header .persona-meta { min-width: 0; flex: 1 1 auto; }
  .persona-header .persona-bio { display: none; }
  .persona-name-row { gap: 5px; flex-wrap: nowrap; }
  .persona-name-row h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
  .persona-tags { display: none; }
  .header-actions {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 4px;
    margin-left: auto;
  }
  .header-actions .icon-btn { min-height: 32px; padding: 6px 7px; font-size: .64rem; }
  .chat-shell { min-height: 0; }
  .messages {
    min-height: 0;
    padding: 18px 11px 16px;
    gap: 11px;
    overscroll-behavior-y: contain;
  }
  .msg { max-width: 93%; }
  .bubble { padding: 10px 12px; font-size: .92rem; line-height: 1.6; }
  .message-text-row { align-items: flex-end; gap: 5px; }
  .message-voice-btn { min-height: 29px; padding: 0 7px; font-size: .63rem; }
  .media-card { max-width: min(86vw, 390px); }
  .media-card img, .media-card video { max-height: 58dvh; }
  .composer { padding: 8px 9px calc(8px + var(--safe-bottom)); }
  .chat-form { gap: 5px; padding: 5px; border-radius: 18px; }
  #messageInput { min-height: 42px; max-height: 120px; padding: 10px 9px; font-size: 16px; }
  .voice-input-btn, .send-btn { height: 40px; border-radius: 14px; }
  .voice-input-btn { width: 40px; padding: 0; }
  .send-btn { min-width: 57px; padding: 0 9px; font-size: .78rem; }

  .memory-dialog {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    margin: auto;
  }
  .memory-panel { max-height: calc(100dvh - 20px); overflow-y: auto; padding: 18px 15px; }
  .gallery-dialog { width: calc(100vw - 20px); }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 62dvh; }
  .time-row { gap: 7px; }
}

@media (max-width: 380px) {
  .home-inner { padding-left: 12px; padding-right: 12px; }
  .home-header h1 { font-size: 1.55rem; }
  .persona-card-avatar { height: 128px; }
  .persona-card-title { font-size: .82rem; }
  .persona-card-rel { font-size: .61rem; }
  .persona-header { gap: 5px; padding-left: 7px; padding-right: 7px; }
  .persona-header .back-btn { min-width: 40px; padding-left: 5px; padding-right: 5px; }
  .persona-header .avatar { width: 39px; height: 39px; }
  .header-actions .icon-btn { padding-left: 5px; padding-right: 5px; }
}

/* Motion and interaction polish. Keep it transform/opacity based so it stays
   smooth on phones, and give every animated state a reduced-motion fallback. */
@keyframes luna-rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes luna-soft-rise {
  from { opacity: 0; transform: translateY(7px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes luna-dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes luna-orb-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 14px rgba(213, 143, 205, .07), 0 0 0 28px rgba(213, 143, 205, .035), 0 18px 48px rgba(0,0,0,.3); }
  50% { transform: scale(1.035); box-shadow: 0 0 0 18px rgba(213, 143, 205, .08), 0 0 0 34px rgba(213, 143, 205, .045), 0 22px 54px rgba(0,0,0,.34); }
}

@keyframes luna-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes luna-active-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(213, 155, 211, 0); }
  50% { box-shadow: 0 0 0 4px rgba(213, 155, 211, .12); }
}

@keyframes luna-voice-wave {
  0%, 100% { transform: scaleY(.58); opacity: .72; }
  50% { transform: scaleY(1); opacity: 1; }
}

.auth-view:not(.hidden) .auth-card,
.home-view:not(.hidden) .home-header,
.home-view:not(.hidden) .today-panel,
.home-view:not(.hidden) .home-hero,
.home-view:not(.hidden) .section-label,
.home-view:not(.hidden) .recent-section,
.chat-view:not(.hidden) .persona-header {
  animation: luna-rise-in .48s cubic-bezier(.2, .75, .25, 1) both;
}

.home-view:not(.hidden) .feature-strip > div,
.home-view:not(.hidden) .persona-card,
.home-view:not(.hidden) .persona-create-card,
.home-view:not(.hidden) .conversation-card {
  animation: luna-soft-rise .42s cubic-bezier(.2, .75, .25, 1) both;
}

.home-view:not(.hidden) .feature-strip > div:nth-child(2),
.home-view:not(.hidden) .persona-grid > :nth-child(2),
.home-view:not(.hidden) .conversation-list > :nth-child(2) { animation-delay: 55ms; }
.home-view:not(.hidden) .feature-strip > div:nth-child(3),
.home-view:not(.hidden) .persona-grid > :nth-child(3),
.home-view:not(.hidden) .conversation-list > :nth-child(3) { animation-delay: 105ms; }
.home-view:not(.hidden) .persona-grid > :nth-child(4),
.home-view:not(.hidden) .conversation-list > :nth-child(4) { animation-delay: 150ms; }

.today-visual-orbit { animation: luna-orb-breathe 6s ease-in-out infinite; }
.hero-orb { animation: luna-float 4.8s ease-in-out infinite; }
.message-voice-btn.is-active,
.voice-btn.is-active { animation: luna-active-pulse 1.5s ease-in-out infinite; }
.message-voice-btn.is-active .voice-btn-icon,
.voice-btn.is-active .voice-btn-icon { display: inline-block; font-size: 0; width: 16px; height: 14px; border-radius: 3px; background: linear-gradient(to top, currentColor 0 100%) 0 50% / 3px 54% no-repeat, linear-gradient(to top, currentColor 0 100%) 5px 50% / 3px 100% no-repeat, linear-gradient(to top, currentColor 0 100%) 10px 50% / 3px 72% no-repeat; animation: luna-voice-wave .72s ease-in-out infinite; }

.msg {
  animation: luna-soft-rise .28s cubic-bezier(.2, .75, .25, 1) both;
  will-change: transform, opacity;
}
.msg.status-message { animation-duration: .2s; }
.media-card,
.voice-message { animation: luna-soft-rise .34s cubic-bezier(.2, .75, .25, 1) both; }
.media-card img { transition: filter .25s ease, transform .35s ease; }
.message-actions { transition: opacity .2s ease, transform .2s ease; }
.message-actions button,
.message-voice-btn,
.voice-input-btn,
.send-btn,
.icon-btn,
.today-actions button,
.sidebar-account,
.home-nav-trigger,
.account-actions .logout-btn,
.persona-card,
.conversation-card { transition: transform .18s ease, border-color .18s ease, background-color .18s ease, box-shadow .18s ease, color .18s ease; }

@media (hover: hover) and (pointer: fine) {
  .media-card:hover img { transform: scale(1.018); filter: saturate(1.06) contrast(1.02); }
  .message-actions { opacity: .48; transform: translateY(2px); }
  .msg:hover .message-actions { opacity: .9; transform: translateY(0); }
  .persona-card:hover,
  .persona-create-card:hover,
  .conversation-card:hover { box-shadow: 0 22px 42px rgba(0,0,0,.3); }
  .today-actions button:hover,
  .account-actions .logout-btn:hover,
  .sidebar-account:hover,
  .icon-btn:hover { transform: translateY(-1px); }
}

button:not(:disabled):active { transform: translateY(1px) scale(.985); }
.chat-form:focus-within {
  border-color: rgba(213, 155, 211, .36);
  box-shadow: 0 18px 42px rgba(0,0,0,.24), 0 0 0 3px rgba(213, 155, 211, .08), inset 0 1px rgba(255,255,255,.04);
}
.memory-dialog[open] { animation: luna-dialog-in .24s cubic-bezier(.2, .75, .25, 1) both; }
.memory-dialog[open]::backdrop { animation: luna-backdrop-in .24s ease both; }
@keyframes luna-backdrop-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
  .msg, .media-card, .voice-message { will-change: auto; }
}

/* 20260716 UI polish: quieter chrome, clearer hierarchy, and better touch
   targets without changing the product's warm-night visual language. */
:root {
  --canvas: #08070d;
  --surface-0: #0e0b15;
  --surface-1: #15101d;
  --surface-2: #1c1526;
  --surface-3: #251a30;
  --accent: #d994d1;
  --accent-bright: #ffd1ef;
  --accent-dim: rgba(217, 148, 209, .14);
  --hairline: rgba(244, 218, 241, .12);
  --hairline-strong: rgba(244, 218, 241, .22);
  --shadow-soft: 0 18px 50px rgba(0, 0, 0, .2);
  --shadow-deep: 0 28px 90px rgba(0, 0, 0, .4);
}

html {
  background: var(--canvas);
  color-scheme: dark;
}

body {
  min-width: 320px;
  overflow-x: hidden;
  color: #fbf6fc;
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  color: #fff8fe;
  background: rgba(204, 125, 194, .48);
}

button,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(255, 209, 239, .9);
  outline-offset: 3px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 148, 209, .34) transparent;
}

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(217, 148, 209, .28);
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: rgba(217, 148, 209, .48); }

/* Home shell */
.home-view {
  isolation: isolate;
  position: relative;
  background: var(--surface-0);
}

.home-view::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .55;
  background:
    radial-gradient(circle at 78% 5%, rgba(196, 103, 185, .16), transparent 23%),
    radial-gradient(circle at 24% 88%, rgba(100, 73, 151, .1), transparent 27%),
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px);
  background-size: auto, auto, 72px 72px, 72px 72px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
}

.app-sidebar,
.home-inner {
  position: relative;
  z-index: 0;
}

.app-sidebar {
  border-right-color: var(--hairline);
  box-shadow: 18px 0 50px rgba(0, 0, 0, .12);
}

.sidebar-brand-mark {
  transition: transform .25s ease, box-shadow .25s ease;
}

.sidebar-brand:hover .sidebar-brand-mark {
  transform: rotate(-6deg) scale(1.04);
  box-shadow: 0 0 30px rgba(213, 137, 203, .36);
}

.home-inner {
  background: linear-gradient(180deg, rgba(16, 12, 23, .88), rgba(10, 8, 15, .96) 84%);
}

.home-header,
.today-panel,
.home-hero,
.feature-strip,
.section-label,
.persona-grid,
.recent-section,
.us-panel {
  position: relative;
  z-index: 1;
}

.home-header h1,
.today-panel h2,
.recent-section h2 {
  text-wrap: balance;
}

.today-panel {
  isolation: isolate;
  overflow: hidden;
  box-shadow: var(--shadow-soft), inset 0 1px rgba(255, 255, 255, .06);
}

.today-panel::before {
  position: absolute;
  top: -120px;
  right: 13%;
  width: 280px;
  height: 280px;
  content: "";
  border: 1px solid rgba(255, 206, 241, .13);
  border-radius: 50%;
  box-shadow: 0 0 0 24px rgba(232, 156, 220, .035), 0 0 0 52px rgba(232, 156, 220, .022);
  pointer-events: none;
}

.today-panel > * { position: relative; z-index: 1; }

.today-quiet {
  padding: 6px 9px;
  border: 1px solid rgba(244, 218, 241, .12);
  border-radius: 999px;
  background: rgba(255, 255, 255, .045);
}

.today-actions button,
.account-actions .logout-btn {
  min-height: 38px;
}

.today-actions button:not(:first-child) {
  background: rgba(255, 255, 255, .045);
}

.feature-strip > div {
  transition: transform .2s ease, border-color .2s ease, background-color .2s ease;
}

.feature-strip > div:hover {
  transform: translateY(-2px);
  border-color: var(--hairline-strong);
  background: rgba(217, 148, 209, .07);
}

.section-label small {
  max-width: 32ch;
  line-height: 1.45;
}

.persona-card,
.persona-create-card {
  border-color: var(--hairline);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .14);
}

.persona-card-main {
  position: relative;
  isolation: isolate;
}

.persona-card-avatar {
  position: relative;
  overflow: hidden;
  height: 218px;
}

.persona-card-avatar::after {
  position: absolute;
  inset: 42% 0 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(10, 7, 15, .36));
}

.persona-card-avatar img {
  position: relative;
  z-index: 0;
  transition: transform .45s cubic-bezier(.2, .75, .25, 1), filter .3s ease;
}

.persona-card:hover .persona-card-avatar img {
  transform: scale(1.045);
  filter: saturate(1.05) contrast(1.02);
}

.persona-card-body {
  position: relative;
  z-index: 1;
  min-height: 96px;
  background: linear-gradient(180deg, rgba(28, 20, 38, .22), rgba(21, 16, 29, .5));
}

.persona-card-rel {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid rgba(217, 148, 209, .16);
  border-radius: 999px;
  background: rgba(217, 148, 209, .07);
}

.persona-create-card {
  border-style: dashed;
  background: linear-gradient(145deg, rgba(217, 148, 209, .06), rgba(255, 255, 255, .018));
}

.persona-create-card:hover .persona-create-icon {
  transform: rotate(90deg);
  background: rgba(217, 148, 209, .12);
}

.persona-create-icon { transition: transform .25s ease, background-color .25s ease; }

.conversation-card {
  border-color: var(--hairline);
  background: rgba(255, 255, 255, .028);
}

.conversation-open {
  min-height: 46px;
  align-items: center;
}

.conversation-summary strong { color: #f7eaf5; }

.home-status {
  min-height: 1.4em;
  position: relative;
  z-index: 1;
}

/* Chat surface */
.chat-view {
  isolation: isolate;
  background: var(--canvas);
}

.chat-view::before {
  opacity: .8;
  background:
    radial-gradient(circle at 78% 4%, rgba(215, 135, 204, .16), transparent 23%),
    radial-gradient(circle at 20% 80%, rgba(83, 60, 133, .1), transparent 27%);
}

.persona-header {
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
}

.persona-header .back-btn {
  min-height: 36px;
}

.avatar {
  position: relative;
  overflow: hidden;
}

.avatar::after {
  position: absolute;
  inset: 0;
  content: "";
  border: 1px solid rgba(255, 222, 248, .16);
  border-radius: inherit;
  pointer-events: none;
}

.persona-name-row h1 { font-weight: 700; }

.persona-bio { color: #b6a8b8; }

.badge {
  letter-spacing: .02em;
  box-shadow: inset 0 1px rgba(255, 255, 255, .06);
}

.messages {
  position: relative;
  isolation: isolate;
  overscroll-behavior-y: contain;
}

.messages::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  background: radial-gradient(circle at 50% 0, rgba(232, 160, 221, .07), transparent 28%);
}

.msg { position: relative; z-index: 1; }

.bubble {
  letter-spacing: .005em;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .1);
}

.msg.user .bubble {
  background: linear-gradient(145deg, #86608e, #62466f 88%);
}

.msg.assistant .bubble {
  background: linear-gradient(145deg, rgba(37, 29, 49, .96), rgba(29, 23, 40, .96));
}

.message-text-row { align-items: flex-end; }

.message-voice-btn {
  flex-shrink: 0;
  min-height: 32px;
  border-color: rgba(236, 185, 227, .18);
  background: rgba(255, 255, 255, .055);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .1);
}

.message-voice-btn:hover,
.message-voice-btn.is-active {
  transform: translateY(-1px);
  border-color: rgba(236, 185, 227, .52);
}

.message-actions {
  min-height: 24px;
  align-items: center;
}

.message-actions button {
  min-height: 24px;
  border-radius: 6px;
}

.message-actions button:hover { background: rgba(217, 148, 209, .08); }

.media-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(244, 218, 241, .18);
  background: #100b16;
}

.media-card img,
.media-card video {
  background: #100b16;
}

.media-edit-btn {
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.media-edit-btn:hover { transform: translateY(-1px); }

.voice-message {
  border-color: rgba(244, 218, 241, .16);
  background: linear-gradient(145deg, rgba(37, 29, 49, .96), rgba(28, 22, 39, .96));
}

.voice-text-toggle,
.voice-retry,
.speak-btn { min-height: 24px; }

.composer {
  position: relative;
  z-index: 3;
  padding-top: 15px;
}

.chat-form {
  border-color: rgba(244, 218, 241, .17);
  background: linear-gradient(145deg, rgba(31, 23, 42, .96), rgba(22, 17, 30, .96));
}

.chat-form:focus-within {
  border-color: rgba(229, 161, 219, .58);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .26), 0 0 0 4px rgba(213, 155, 211, .08), inset 0 1px rgba(255, 255, 255, .06);
}

#messageInput::placeholder { color: #8f8296; }

.voice-input-btn,
.send-btn {
  min-height: 42px;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .12);
}

.voice-input-btn:hover { transform: translateY(-1px); }

.send-btn {
  background: linear-gradient(135deg, #c781ba, #81568e);
}

.send-btn:hover {
  background: linear-gradient(135deg, #d694c8, #9567a1);
  box-shadow: 0 8px 20px rgba(179, 103, 170, .25);
}

.composer-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: min(940px, 100%);
  margin: 0 auto;
  padding: 7px 10px 0;
  color: #7d7084;
  font-size: .62rem;
  line-height: 1.3;
}

.composer-meta span:last-child { color: #a98da6; }

/* Dialogs and account surfaces */
.memory-dialog {
  overflow: hidden;
  border-color: rgba(244, 218, 241, .2);
  background: linear-gradient(160deg, #21172d, #120e1a);
}

.memory-panel {
  max-height: min(86vh, 760px);
  overflow-y: auto;
}

.memory-panel h2 { font-size: 1.25rem; letter-spacing: -.04em; }

.memory-panel h3 {
  color: #f4e4f1;
  letter-spacing: -.02em;
}

.field-label select,
.time-row input,
.memory-panel input,
.memory-panel textarea {
  min-height: 42px;
}

.check-row { padding: 4px 0; }

.gallery-card {
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.gallery-card:hover {
  transform: translateY(-2px);
  border-color: rgba(236, 174, 225, .42);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .2);
}

@media (hover: hover) and (pointer: fine) {
  .message-actions { opacity: .52; }
  .msg:hover .message-actions,
  .message-actions:focus-within { opacity: 1; }
}

@media (max-width: 760px) {
  .home-inner {
    height: calc(100dvh - (66px + var(--safe-bottom)));
    padding-bottom: 30px;
  }

  .today-quiet { max-width: 48%; line-height: 1.35; }
  .persona-card-avatar { height: auto; aspect-ratio: .82; }
  .persona-card-body { min-height: 86px; }

  .persona-header .back-btn,
  .header-actions .icon-btn,
  .voice-input-btn,
  .send-btn { min-height: 40px; }

  .composer-meta {
    padding: 6px 7px 0;
    font-size: .58rem;
  }

  .composer-meta span:last-child { display: none; }

  .memory-dialog {
    inset: auto 10px calc(10px + var(--safe-bottom));
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    margin: 0;
    border-radius: 22px;
  }

  .memory-panel {
    max-height: calc(100dvh - 20px - var(--safe-bottom));
    padding-bottom: calc(18px + var(--safe-bottom));
  }
}

@media (max-width: 380px) {
  .composer-meta { padding-left: 4px; padding-right: 4px; }
  .message-voice-btn .voice-btn-label { display: none; }
  .message-voice-btn { width: 32px; padding: 0; }
}

/* 20260716 GPT-inspired product shell.
   The interaction model borrows the useful parts of modern AI chat apps:
   persistent history, one focused workspace, a quiet top bar, and a centered
   composer. The colors, copy, and relationship surfaces remain Luna-specific. */
:root {
  --luna-canvas: #0f0f10;
  --luna-surface: #171719;
  --luna-surface-2: #202023;
  --luna-surface-3: #2a2a2e;
  --luna-sidebar: #141416;
  --luna-text: #f4f2f4;
  --luna-muted: #a7a4aa;
  --luna-subtle: #77747b;
  --luna-line: rgba(255, 255, 255, .1);
  --luna-line-strong: rgba(255, 255, 255, .17);
  --luna-pink: #d89acb;
  --luna-pink-bright: #f3c6e7;
  --luna-pink-soft: rgba(216, 154, 203, .13);
  --luna-green: #84c99b;
  --luna-danger: #e68e9a;
  --luna-radius: 14px;
  --luna-sidebar-width: 266px;
}

html,
body {
  background: var(--luna-canvas);
  color: var(--luna-text);
}

body {
  display: block;
  min-height: 100dvh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select { font: inherit; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(243, 198, 231, .92);
  outline-offset: 2px;
}

::selection { color: #fff; background: rgba(216, 154, 203, .4); }

/* Authentication keeps the same design language before the app shell opens. */
.auth-view {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0, rgba(216, 154, 203, .17), transparent 34%),
    var(--luna-canvas);
}

.auth-view::before,
.auth-view::after { display: none; }

.auth-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--luna-line);
  border-radius: 18px;
  background: rgba(23, 23, 25, .94);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .4);
}

.auth-brand {
  color: var(--luna-pink-bright);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.auth-card h1 { margin-top: 28px; font-size: 1.65rem; letter-spacing: -.045em; }
.auth-sub { color: var(--luna-muted); line-height: 1.6; }
.auth-form { gap: 10px; }
.auth-form input,
.memory-panel input,
.memory-panel textarea,
.field-label select,
.time-row input {
  min-height: 44px;
  border: 1px solid var(--luna-line);
  border-radius: 10px;
  background: #111113;
  color: var(--luna-text);
}

.auth-form input:focus,
.memory-panel input:focus,
.memory-panel textarea:focus,
.field-label select:focus,
.time-row input:focus {
  border-color: rgba(243, 198, 231, .62);
  box-shadow: 0 0 0 3px var(--luna-pink-soft);
  outline: 0;
}

.auth-submit {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--luna-pink-bright);
  color: #241c25;
  font-weight: 700;
}

.auth-toggle,
.logout-btn { color: var(--luna-pink-bright); }

/* App shell */
.product-shell {
  position: relative;
  display: grid;
  grid-template-columns: var(--luna-sidebar-width) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--luna-canvas);
}

.product-shell.hidden { display: none !important; }

.sidebar-overlay {
  display: none;
  border: 0;
  background: transparent;
}

.app-sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  width: var(--luna-sidebar-width);
  min-width: 0;
  height: 100dvh;
  flex-direction: column;
  gap: 18px;
  padding: 16px 12px 12px;
  border: 0;
  border-right: 1px solid var(--luna-line);
  background: var(--luna-sidebar);
  box-shadow: 12px 0 40px rgba(0, 0, 0, .12);
  transition: transform .24s ease;
}

.sidebar-top { display: grid; gap: 17px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 2px;
}

.sidebar-brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border: 1px solid rgba(243, 198, 231, .28);
  border-radius: 9px;
  background: linear-gradient(145deg, #d99bce, #755071);
  color: #fff8fd;
  font-size: .9rem;
  box-shadow: 0 0 20px rgba(216, 154, 203, .15);
}

.sidebar-brand strong,
.sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: .75rem; letter-spacing: .18em; }
.sidebar-brand span { margin-top: 3px; color: var(--luna-subtle); font-size: .52rem; letter-spacing: .1em; }

.sidebar-new {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--luna-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .045);
  color: var(--luna-text);
  cursor: pointer;
  text-align: left;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.sidebar-new:hover { border-color: var(--luna-line-strong); background: rgba(255, 255, 255, .08); transform: translateY(-1px); }
.sidebar-new-icon { color: var(--luna-pink-bright); font-size: 1.1rem; line-height: 1; }
.sidebar-new kbd { margin-left: auto; color: var(--luna-subtle); font-size: .58rem; }

.sidebar-nav { display: grid; gap: 2px; }

.home-nav-trigger {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--luna-muted);
  cursor: pointer;
  text-align: left;
  transition: color .18s ease, background .18s ease;
}

.home-nav-trigger span { width: 18px; color: var(--luna-subtle); font-size: 1rem; text-align: center; }
.home-nav-trigger strong { font-size: .78rem; font-weight: 500; }
.home-nav-trigger:hover { color: var(--luna-text); background: rgba(255, 255, 255, .055); }
.home-nav-trigger.active { color: var(--luna-text); background: rgba(255, 255, 255, .09); }
.home-nav-trigger.active span { color: var(--luna-pink-bright); }

.sidebar-history {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--luna-line);
  padding-top: 16px;
}

.sidebar-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px 8px;
  color: var(--luna-muted);
  font-size: .67rem;
}

.sidebar-section-heading small { color: var(--luna-subtle); font-size: .56rem; }
.sidebar-history .conversation-list { display: grid; gap: 2px; overflow-y: auto; padding: 0 2px 12px; }
.sidebar-history .conversation-empty { padding: 14px 8px; color: var(--luna-subtle); font-size: .68rem; line-height: 1.5; }
.sidebar-history .conversation-card { min-width: 0; padding: 0; border: 0; border-radius: 8px; background: transparent; }
.sidebar-history .conversation-card:hover { background: rgba(255, 255, 255, .055); }
.sidebar-history .conversation-open { display: flex; min-width: 0; width: 100%; align-items: center; gap: 8px; padding: 9px 8px; border: 0; background: transparent; color: var(--luna-muted); text-align: left; }
.sidebar-history .conversation-open:hover { color: var(--luna-text); }
.sidebar-history .conversation-summary { min-width: 0; gap: 3px; }
.sidebar-history .conversation-summary strong { overflow: hidden; color: inherit; font-size: .72rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-history .conversation-summary small { max-width: 155px; overflow: hidden; color: var(--luna-subtle); font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-history .conversation-open > span { margin-left: auto; color: var(--luna-subtle); font-size: .55rem; white-space: nowrap; }
.sidebar-history .conversation-delete { display: none; }

.sidebar-bottom { display: grid; gap: 4px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--luna-line); }
.sidebar-action,
.sidebar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--luna-muted);
  cursor: pointer;
  font-size: .7rem;
  text-align: left;
}

.sidebar-action:hover,
.sidebar-account:hover { background: rgba(255, 255, 255, .055); color: var(--luna-text); }
.sidebar-action > span:first-child { width: 18px; color: var(--luna-pink-bright); text-align: center; }
.sidebar-account { min-height: 46px; border: 1px solid var(--luna-line); background: rgba(255, 255, 255, .035); }
.sidebar-account > span:nth-child(2) { min-width: 0; flex: 1; }
.sidebar-account strong, .sidebar-account small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account strong { color: var(--luna-text); font-size: .7rem; }
.sidebar-account small { margin-top: 2px; color: var(--luna-subtle); font-size: .6rem; }
.sidebar-account b { color: var(--luna-subtle); font-size: 1rem; font-weight: 400; }
.sidebar-user-dot { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 8px; background: #403141; color: var(--luna-pink-bright); font-size: .68rem; }
.sidebar-logout { padding: 4px 9px; border: 0; background: transparent; color: var(--luna-subtle); cursor: pointer; font-size: .62rem; text-align: left; }
.sidebar-logout:hover { color: var(--luna-danger); }

.shell-main { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--luna-canvas); }

/* Home / welcome workspace */
.home-view {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  background:
    radial-gradient(circle at 82% 0, rgba(216, 154, 203, .1), transparent 25%),
    var(--luna-canvas);
}

.home-view.hidden { display: none !important; }

.workspace-topbar {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 28px;
  border-bottom: 1px solid var(--luna-line);
  background: rgba(15, 15, 16, .84);
  backdrop-filter: blur(18px);
}

.topbar-left,
.chat-header-leading,
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-menu { display: none; border: 0; background: transparent; color: var(--luna-muted); cursor: pointer; font-size: 1rem; }
.topbar-menu:hover { color: var(--luna-text); }
.topbar-context span, .topbar-context strong { display: block; }
.topbar-context span { color: var(--luna-subtle); font-size: .55rem; letter-spacing: .12em; }
.topbar-context strong { margin-top: 3px; font-size: .78rem; letter-spacing: -.01em; }
.topbar-action { min-height: 32px; padding: 0 10px; border: 1px solid var(--luna-line); border-radius: 8px; background: transparent; color: var(--luna-muted); cursor: pointer; font-size: .68rem; }
.topbar-action:hover { border-color: var(--luna-line-strong); color: var(--luna-text); background: rgba(255, 255, 255, .05); }

.home-inner {
  width: min(1040px, 100%);
  min-height: 0;
  margin: 0 auto;
  overflow-y: auto;
  padding: 48px clamp(24px, 5vw, 72px) 72px;
}

.home-header { display: block; padding: 0; }
.home-header h1 { max-width: 740px; margin: 0 0 12px; color: var(--luna-text); font-size: clamp(2rem, 4vw, 3.25rem); font-weight: 650; letter-spacing: -.07em; line-height: 1.03; }
.home-header .eyebrow { margin-bottom: 18px; color: var(--luna-pink-bright); font-size: .62rem; }
.home-sub { max-width: 570px; margin: 0; color: var(--luna-muted); font-size: .92rem; line-height: 1.6; }
.home-tabs { display: none; }

.today-panel {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin: 42px 0 46px;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid rgba(216, 154, 203, .28);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(57, 38, 56, .92), rgba(27, 24, 31, .96));
  box-shadow: 0 24px 60px rgba(0, 0, 0, .24);
}

.today-panel::after { position: absolute; right: -50px; bottom: -120px; width: 360px; height: 360px; content: ""; border: 1px solid rgba(243, 198, 231, .13); border-radius: 50%; box-shadow: 0 0 0 28px rgba(216, 154, 203, .035), 0 0 0 58px rgba(216, 154, 203, .02); pointer-events: none; }
.today-panel > * { position: relative; z-index: 1; }
.today-top { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.today-panel .eyebrow { margin: 0; color: #e2b7d9; font-size: .57rem; }
.today-quiet { max-width: 50%; padding: 6px 9px; border: 1px solid var(--luna-line); border-radius: 999px; color: var(--luna-muted); font-size: .6rem; text-align: right; }
.today-layout { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 22px; align-items: center; }
.today-panel h2 { max-width: 620px; margin: 38px 0 11px; color: #fff5fd; font-size: clamp(1.55rem, 3vw, 2.25rem); font-weight: 600; letter-spacing: -.055em; line-height: 1.12; }
.today-panel p { max-width: 540px; margin: 0; color: #bdaebe; font-size: .82rem; line-height: 1.6; }
.today-memory { max-width: 540px; margin-top: 15px; padding: 10px 12px; border: 1px solid rgba(243, 198, 231, .12); border-radius: 10px; background: rgba(255, 255, 255, .05); color: #e7cfe1; font-size: .74rem; }
.today-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 25px; }
.today-actions button { min-height: 36px; padding: 0 13px; border: 1px solid rgba(243, 198, 231, .18); border-radius: 9px; background: rgba(255, 255, 255, .06); color: var(--luna-text); cursor: pointer; font-size: .7rem; }
.today-actions button:first-child { border-color: transparent; background: var(--luna-pink-bright); color: #291d28; font-weight: 700; }
.today-actions button:hover { transform: translateY(-1px); border-color: rgba(243, 198, 231, .42); }
.today-visual { display: grid; justify-items: center; gap: 12px; color: #dbc5d8; text-align: center; }
.today-visual-orbit { display: grid; width: 134px; height: 134px; place-items: center; border: 1px solid rgba(243, 198, 231, .34); border-radius: 50%; background: radial-gradient(circle at 35% 28%, #edc4e2, #88577f 46%, #211928 74%); box-shadow: 0 0 0 13px rgba(216, 154, 203, .06), 0 0 0 27px rgba(216, 154, 203, .025); }
.today-visual-orbit span { color: #fff7fd; font-size: 2.4rem; text-shadow: 0 0 24px #ffe6f7; }
.today-visual small, .today-visual strong { display: block; }
.today-visual small { color: var(--luna-subtle); font-size: .54rem; letter-spacing: .15em; }
.today-visual strong { margin-top: 4px; color: #ead7e6; font-size: .76rem; line-height: 1.45; }

.chat-home-panel { display: block; }
.home-hero { display: flex; align-items: center; gap: 13px; margin: 0 0 14px; padding: 15px 17px; border: 1px solid var(--luna-line); border-radius: 13px; background: rgba(255, 255, 255, .035); }
.hero-orb { display: grid; width: 35px; height: 35px; flex: 0 0 35px; place-items: center; border-radius: 10px; background: var(--luna-pink-soft); color: var(--luna-pink-bright); }
.home-hero strong, .home-hero span { display: block; }
.home-hero strong { font-size: .78rem; }
.home-hero span { margin-top: 4px; color: var(--luna-muted); font-size: .7rem; }
.feature-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 42px; }
.feature-strip > div { display: grid; grid-template-columns: 25px 1fr; gap: 5px 8px; align-items: center; min-height: 70px; padding: 12px; border: 1px solid var(--luna-line); border-radius: 11px; background: rgba(255, 255, 255, .025); }
.feature-strip span { grid-row: span 2; display: grid; width: 25px; height: 25px; place-items: center; border-radius: 7px; background: var(--luna-pink-soft); color: var(--luna-pink-bright); font-size: .75rem; }
.feature-strip strong { font-size: .7rem; font-weight: 600; }
.feature-strip small { color: var(--luna-subtle); font-size: .59rem; line-height: 1.35; }
.section-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.section-label span { color: var(--luna-text); font-size: 1.05rem; font-weight: 650; letter-spacing: -.035em; }
.section-label small { color: var(--luna-subtle); font-size: .65rem; }

.persona-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.persona-card, .persona-create-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--luna-line); border-radius: 14px; background: var(--luna-surface); box-shadow: none; transition: transform .2s ease, border-color .2s ease, background .2s ease; }
.persona-card:hover, .persona-create-card:hover { transform: translateY(-3px); border-color: var(--luna-line-strong); background: #222225; }
.persona-card-main { display: flex; width: 100%; min-height: 100%; flex-direction: column; gap: 0; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; }
.persona-card-avatar { position: relative; width: 100%; height: 210px; overflow: hidden; border: 0; border-radius: 0; background: linear-gradient(145deg, #4c334a, #201a24); color: var(--luna-pink-bright); }
.persona-card-avatar::after { position: absolute; inset: 45% 0 0; content: ""; background: linear-gradient(to bottom, transparent, rgba(15, 15, 16, .5)); pointer-events: none; }
.persona-card-avatar img { width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
.persona-card:hover .persona-card-avatar img { transform: scale(1.045); }
.persona-card-body { min-height: 94px; padding: 12px 13px 14px; }
.persona-card-title { margin-bottom: 5px; color: var(--luna-text); font-size: .82rem; font-weight: 650; }
.persona-card-rel { display: inline-flex; margin: 0; padding: 2px 7px; border: 1px solid rgba(216, 154, 203, .15); border-radius: 999px; color: var(--luna-pink-bright); font-size: .57rem; }
.persona-card-bio { margin-top: 8px; color: var(--luna-subtle); font-size: .62rem; line-height: 1.45; }
.persona-card-tags { display: none; }
.persona-card-actions { position: absolute; top: 8px; right: 8px; z-index: 3; display: flex; gap: 2px; padding: 3px; border-radius: 7px; background: rgba(15, 15, 16, .74); }
.persona-card-actions button { padding: 3px 5px; border: 0; background: transparent; color: var(--luna-muted); cursor: pointer; font-size: .59rem; }
.persona-card-actions button:hover { color: var(--luna-text); }
.persona-create-card { display: flex; min-height: 304px; align-items: center; justify-content: center; gap: 10px; padding: 18px; border-style: dashed; color: var(--luna-muted); cursor: pointer; text-align: left; }
.persona-create-icon { display: grid; width: 36px; height: 36px; place-items: center; border: 1px dashed rgba(243, 198, 231, .42); border-radius: 10px; color: var(--luna-pink-bright); font-size: 1.2rem; transition: transform .2s ease; }
.persona-create-card:hover .persona-create-icon { transform: rotate(90deg); }
.persona-create-card strong, .persona-create-card small { display: block; }
.persona-create-card strong { color: var(--luna-text); font-size: .68rem; }
.persona-create-card small { max-width: 14ch; margin-top: 4px; color: var(--luna-subtle); font-size: .59rem; line-height: 1.4; }
.home-status { min-height: 1.4em; margin: 20px 0 0; color: var(--luna-muted); font-size: .7rem; }

.us-panel { padding-top: 2px; }
.timeline-list { padding-left: 17px; }
.timeline-list::before { background: var(--luna-line-strong); }
.timeline-body { border-color: var(--luna-line); border-radius: 11px; background: var(--luna-surface); }
.timeline-body p { color: var(--luna-text); }

/* Chat workspace: a quieter, centered transcript and a single composer. */
.chat-view {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  background: var(--luna-canvas);
}

.chat-view.hidden { display: none !important; }
.persona-header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; min-height: 62px; align-items: center; gap: 13px; padding: 0 28px; border-bottom: 1px solid var(--luna-line); background: rgba(15, 15, 16, .84); backdrop-filter: blur(18px); }
.chat-header-leading { min-width: 0; }
.chat-header-leading .topbar-menu { display: block; }
.icon-btn { min-height: 32px; padding: 0 9px; border: 1px solid var(--luna-line); border-radius: 8px; background: transparent; color: var(--luna-muted); cursor: pointer; font-size: .67rem; }
.icon-btn:hover { border-color: var(--luna-line-strong); color: var(--luna-text); background: rgba(255, 255, 255, .05); }
.avatar { width: 38px; height: 38px; border: 1px solid rgba(243, 198, 231, .25); border-radius: 11px; background: linear-gradient(145deg, #553951, #231c27); color: var(--luna-pink-bright); box-shadow: none; }
.avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.persona-meta { min-width: 0; }
.persona-name-row { gap: 7px; }
.persona-name-row h1 { overflow: hidden; color: var(--luna-text); font-size: .86rem; font-weight: 650; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.badge { padding: 3px 7px; border: 1px solid rgba(216, 154, 203, .22); border-radius: 999px; background: var(--luna-pink-soft); color: var(--luna-pink-bright); font-size: .54rem; }
.persona-bio { margin: 3px 0 0; overflow: hidden; color: var(--luna-subtle); font-size: .63rem; text-overflow: ellipsis; white-space: nowrap; }
.persona-tags { display: none; }
.header-actions { display: flex; flex-direction: row; gap: 6px; }
.header-actions .icon-btn { min-width: 42px; }

.chat-shell { display: flex; min-height: 0; flex: 1; flex-direction: column; overflow: hidden; background: radial-gradient(circle at 50% 0, rgba(216, 154, 203, .05), transparent 30%); }
.chat-welcome-line { display: flex; width: min(768px, 100%); align-items: center; gap: 7px; margin: 0 auto; padding: 22px 24px 0; color: var(--luna-subtle); font-size: .58rem; }
.chat-welcome-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--luna-green); box-shadow: 0 0 0 4px rgba(132, 201, 155, .1); }
.chat-welcome-rule { height: 1px; flex: 1; background: var(--luna-line); }
.messages { width: min(768px, 100%); min-height: 0; flex: 1; margin: 0 auto; padding: 25px 24px 32px; gap: 23px; background: transparent; }
.messages::before { display: none; }
.msg { max-width: 100%; gap: 7px; }
.msg.assistant { width: 100%; align-self: flex-start; }
.msg.user { max-width: min(78%, 620px); align-self: flex-end; }
.message-text-row { align-items: flex-end; gap: 8px; }
.msg.assistant .message-text-row { align-items: flex-start; }
.bubble { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--luna-text); font-size: .91rem; line-height: 1.75; }
.msg.assistant .bubble { background: transparent; }
.msg.user .bubble { padding: 10px 14px; border: 1px solid var(--luna-line); border-radius: 16px 16px 4px 16px; background: var(--luna-surface-3); color: #f8f7f8; line-height: 1.6; }
.msg.system .bubble { padding: 10px 13px; border-radius: 10px; background: rgba(230, 142, 154, .1); color: #f2c8cd; }
.message-voice-btn { align-self: flex-end; min-height: 28px; padding: 0 8px; border: 1px solid var(--luna-line); border-radius: 999px; background: transparent; color: var(--luna-muted); font-size: .61rem; }
.message-voice-btn:hover, .message-voice-btn.is-active { border-color: rgba(243, 198, 231, .44); background: var(--luna-pink-soft); color: var(--luna-pink-bright); transform: none; }
.msg-meta { color: var(--luna-subtle); font-size: .56rem; }
.msg.user .msg-meta { text-align: right; }
.message-actions { gap: 2px; padding: 0; }
.message-actions button { min-height: 24px; padding: 2px 5px; border: 0; border-radius: 5px; background: transparent; color: var(--luna-subtle); font-size: .59rem; }
.message-actions button:hover { background: rgba(255, 255, 255, .06); color: var(--luna-muted); }
.status-message .bubble { color: var(--luna-muted); font-style: normal; }
.media-card { max-width: min(450px, 100%); margin-top: 4px; border: 1px solid var(--luna-line); border-radius: 14px; background: #111113; box-shadow: 0 14px 36px rgba(0, 0, 0, .22); }
.media-card img, .media-card video { max-height: 500px; object-fit: contain; }
.media-edit-btn { margin: 0 8px 8px; border-color: var(--luna-line); background: rgba(255, 255, 255, .05); color: var(--luna-muted); }
.voice-message { min-width: min(300px, 100%); border-color: var(--luna-line); border-radius: 14px; background: var(--luna-surface); box-shadow: none; }
.voice-icon { background: var(--luna-pink-soft); color: var(--luna-pink-bright); }
.voice-status { color: var(--luna-muted); }
.voice-text-toggle, .voice-retry { color: var(--luna-pink-bright); }
.voice-transcript { border-color: var(--luna-line); background: #1d1d20; color: var(--luna-muted); }

.composer { position: relative; z-index: 3; padding: 14px 24px calc(18px + var(--safe-bottom)); border-top: 0; background: linear-gradient(180deg, rgba(15, 15, 16, .2), rgba(15, 15, 16, .97) 28%); }
.composer-context, .composer-meta { display: flex; width: min(768px, 100%); justify-content: space-between; gap: 12px; margin: 0 auto; color: var(--luna-subtle); font-size: .58rem; }
.composer-context { padding: 0 10px 7px; }
.composer-context strong { color: var(--luna-muted); font-weight: 600; }
.chat-form { display: flex; width: min(768px, 100%); min-height: 54px; align-items: flex-end; gap: 7px; margin: 0 auto; padding: 6px; border: 1px solid var(--luna-line-strong); border-radius: 15px; background: var(--luna-surface-2); box-shadow: 0 12px 30px rgba(0, 0, 0, .2); }
.chat-form:focus-within { border-color: rgba(243, 198, 231, .45); box-shadow: 0 12px 32px rgba(0, 0, 0, .25), 0 0 0 3px var(--luna-pink-soft); }
#messageInput { min-height: 40px; max-height: 160px; padding: 10px 11px; border: 0; background: transparent; color: var(--luna-text); font-size: .9rem; line-height: 1.5; }
#messageInput::placeholder { color: var(--luna-subtle); }
#messageInput:focus { outline: 0; box-shadow: none; }
.voice-input-btn, .send-btn { height: 40px; min-height: 40px; border-radius: 10px; }
.voice-input-btn { width: 54px; border: 1px solid var(--luna-line); background: transparent; color: var(--luna-muted); cursor: pointer; font-size: .63rem; }
.voice-input-btn:hover, .voice-input-btn.is-recording { border-color: rgba(243, 198, 231, .45); background: var(--luna-pink-soft); color: var(--luna-pink-bright); }
.send-btn { min-width: 58px; border: 0; background: var(--luna-pink-bright); color: #291d28; cursor: pointer; font-size: .68rem; font-weight: 700; }
.send-btn:hover { background: #ffe0f3; box-shadow: none; }
.send-btn:disabled { opacity: .45; cursor: not-allowed; }
.composer-meta { justify-content: flex-start; padding: 7px 10px 0; }
.composer-meta span:last-child { display: none; }

/* Dialogs remain compact and panel-like, rather than taking over the workspace. */
.memory-dialog { width: min(500px, calc(100vw - 28px)); max-height: min(88dvh, 760px); overflow: hidden; border: 1px solid var(--luna-line-strong); border-radius: 16px; background: var(--luna-surface); color: var(--luna-text); box-shadow: 0 30px 100px rgba(0, 0, 0, .48); }
.memory-dialog::backdrop { background: rgba(0, 0, 0, .68); backdrop-filter: blur(5px); }
.memory-panel { max-height: min(88dvh, 760px); overflow-y: auto; padding: 22px; }
.memory-panel h2 { margin: 0 0 14px; font-size: 1.15rem; letter-spacing: -.04em; }
.memory-panel h3 { color: var(--luna-text); font-size: .82rem; }
.memory-panel hr { border-color: var(--luna-line); }
.memory-panel input, .memory-panel textarea, .field-label select, .time-row input { background: #111113; color: var(--luna-text); }
.check-row { color: var(--luna-muted); }
.close-btn, .memory-add button { min-height: 40px; border-color: var(--luna-line); border-radius: 9px; background: var(--luna-surface-3); color: var(--luna-text); }
.danger-btn { border-color: rgba(230, 142, 154, .45); color: var(--luna-danger); }
.gallery-dialog { width: min(760px, calc(100vw - 28px)); }
.gallery-grid { gap: 12px; }
.gallery-card { border-color: var(--luna-line); border-radius: 12px; background: #111113; }
.gallery-card-footer { color: var(--luna-muted); }
.gallery-card-footer button { color: var(--luna-pink-bright); }
.legal-links a { color: var(--luna-muted); }

@media (max-width: 1080px) {
  .persona-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  :root { --luna-sidebar-width: 276px; }
  .product-shell { display: block; }
  .app-sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-105%); border-right: 1px solid var(--luna-line-strong); box-shadow: 24px 0 60px rgba(0, 0, 0, .34); }
  .product-shell.sidebar-open .app-sidebar { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; z-index: 19; display: block; width: 100%; height: 100%; padding: 0; opacity: 0; pointer-events: none; background: rgba(0, 0, 0, .56); transition: opacity .24s ease; }
  .product-shell.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .workspace-topbar { padding: 0 18px; }
  .workspace-topbar .topbar-menu { display: block; }
  .topbar-actions { display: none; }
  .home-inner { padding: 38px 24px 56px; }
  .persona-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .persona-card-avatar { height: clamp(160px, 32vw, 215px); }
  .persona-create-card { min-height: 270px; }
  .persona-header { padding: 0 18px; }
  .persona-header .topbar-menu { display: block; }
  .messages, .chat-welcome-line { width: min(768px, 100%); }
  .messages { padding-left: 18px; padding-right: 18px; }
  .composer { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 560px) {
  .auth-card { padding: 28px 22px; }
  .home-inner { padding: 30px 16px 42px; }
  .home-header h1 { font-size: 2.05rem; }
  .home-sub { font-size: .83rem; }
  .today-panel { margin-top: 30px; padding: 20px 17px; border-radius: 17px; }
  .today-layout { grid-template-columns: 1fr; }
  .today-visual { display: none; }
  .today-panel h2 { margin-top: 28px; font-size: 1.55rem; }
  .today-quiet { max-width: 48%; font-size: .55rem; }
  .feature-strip { display: flex; gap: 8px; margin-right: -16px; margin-bottom: 32px; overflow-x: auto; padding-right: 16px; scrollbar-width: none; }
  .feature-strip::-webkit-scrollbar { display: none; }
  .feature-strip > div { min-width: 170px; }
  .section-label { align-items: flex-start; }
  .section-label small { max-width: 18ch; text-align: right; line-height: 1.4; }
  .persona-grid { gap: 9px; }
  .persona-card-avatar { height: 145px; }
  .persona-card-body { min-height: 80px; padding: 10px; }
  .persona-card-title { font-size: .76rem; }
  .persona-card-bio { display: none; }
  .persona-create-card { min-height: 225px; padding: 12px; }
  .persona-create-card small { display: none; }
  .persona-header { grid-template-columns: minmax(0, 1fr) auto; min-height: 58px; gap: 8px; padding: 0 10px; }
  .chat-header-leading { gap: 5px; }
  .chat-header-leading .back-btn { padding: 0 7px; }
  .avatar { width: 34px; height: 34px; border-radius: 9px; }
  .persona-bio { display: none; }
  .persona-name-row h1 { font-size: .8rem; }
  .header-actions .icon-btn { min-width: 38px; padding: 0 6px; font-size: .6rem; }
  .chat-welcome-line { padding: 16px 14px 0; }
  .messages { padding: 21px 14px 26px; gap: 20px; }
  .msg.user { max-width: 88%; }
  .bubble { font-size: .88rem; }
  .msg.user .bubble { padding: 9px 12px; }
  .message-voice-btn .voice-btn-label { display: none; }
  .message-voice-btn { width: 29px; padding: 0; }
  .composer { padding: 10px 10px calc(12px + var(--safe-bottom)); }
  .composer-context { padding: 0 5px 6px; font-size: .55rem; }
  .chat-form { min-height: 50px; gap: 4px; padding: 5px; border-radius: 13px; }
  #messageInput { min-height: 38px; padding: 9px 7px; font-size: 16px; }
  .voice-input-btn { width: 42px; padding: 0; font-size: .58rem; }
  .send-btn { min-width: 50px; padding: 0 8px; }
  .composer-meta { padding: 6px 5px 0; font-size: .55rem; }
  .memory-dialog { inset: auto 10px calc(10px + var(--safe-bottom)); width: calc(100vw - 20px); max-width: calc(100vw - 20px); margin: 0; border-radius: 16px; }
  .memory-panel { max-height: calc(100dvh - 24px - var(--safe-bottom)); padding: 18px 15px calc(18px + var(--safe-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* 20260716 mobile pass: the desktop rail becomes a real bottom navigation on
   sanctuary pages, while chat keeps a swipe-friendly drawer. All fixed
   controls respect the iOS safe area and the keyboard never hides the input. */
@media (max-width: 760px) {
  :root { --luna-sidebar-width: 288px; --safe-bottom: env(safe-area-inset-bottom, 0px); }

  html,
  body { width: 100%; min-width: 320px; height: 100%; overflow: hidden; }

  body { background: var(--stitch-background, #131313); -webkit-tap-highlight-color: transparent; }
  .product-shell { position: relative; display: block; width: 100%; height: 100dvh; min-height: 0; overflow: hidden; }
  .shell-main { width: 100%; height: 100dvh; min-height: 0; }

  /* Home content sits between the compact top bar and the fixed bottom rail. */
  .home-view:not(.hidden) { display: flex; width: 100%; height: 100dvh; min-height: 0; flex-direction: column; }
  .workspace-topbar { display: flex; flex: 0 0 58px; width: 100%; min-height: 58px; height: 58px; padding: 0 16px; border-bottom: 1px solid rgba(255,255,255,.08); background: rgba(14,14,14,.92); backdrop-filter: blur(18px); }
  .workspace-topbar .topbar-menu { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid rgba(255,255,255,.08); border-radius: 10px; color: var(--stitch-variant, #cbc4d0); font-size: 0; }
  .workspace-topbar .topbar-menu::after { content: "☰"; font-size: 1rem; }
  .topbar-context span { font-size: .5rem; letter-spacing: .12em; }
  .topbar-context strong { margin-top: 2px; font-size: .76rem; }
  .home-inner { width: 100%; height: auto; min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior-y: contain; padding: 28px 16px calc(94px + var(--safe-bottom)); }
  .home-header h1 { max-width: 100%; font-size: clamp(2.2rem, 11vw, 3rem); line-height: 1.04; }
  .home-sub { max-width: 34rem; margin-bottom: 0; font-size: .86rem; line-height: 1.6; }
  .today-panel { margin: 30px 0 34px; padding: 20px 17px; border-radius: 17px; }
  .today-layout { grid-template-columns: 1fr; }
  .today-visual { display: none; }
  .today-panel h2 { margin-top: 25px; font-size: 1.5rem; line-height: 1.2; }
  .today-quiet { max-width: 48%; font-size: .55rem; line-height: 1.35; }
  .today-actions { gap: 7px; }
  .today-actions button { min-height: 42px; padding: 0 11px; }
  .home-hero { margin-bottom: 16px; padding: 14px; }
  .feature-strip { display: flex; gap: 8px; margin: 0 -2px 30px; overflow-x: auto; padding: 1px 2px 6px; scroll-snap-type: x proximity; scrollbar-width: none; }
  .feature-strip::-webkit-scrollbar { display: none; }
  .feature-strip > div { flex: 0 0 178px; min-height: 68px; scroll-snap-align: start; padding: 11px; }
  .section-label { align-items: flex-start; gap: 10px; }
  .section-label span { font-size: 1.1rem; }
  .section-label small { max-width: 22ch; line-height: 1.4; text-align: right; }
  .persona-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #personaGrid > .persona-card:first-of-type,
  #personaGrid > .persona-create-card,
  #personaGrid > .persona-card:not(:first-of-type) { grid-column: span 1; }
  .persona-card-avatar,
  #personaGrid > .persona-card:first-of-type .persona-card-avatar { height: auto; aspect-ratio: .82; }
  .persona-card-body { min-height: 82px; padding: 10px 10px 12px; }
  .persona-card-title { font-size: .86rem; }
  .persona-card-rel { max-width: 100%; overflow: hidden; font-size: .58rem; text-overflow: ellipsis; white-space: nowrap; }
  .persona-card-bio { display: none; }
  .persona-create-card { min-height: 215px; padding: 13px; }
  .persona-create-icon { width: 48px; height: 48px; font-size: 1.35rem; }
  .persona-create-card strong { font-size: .88rem; text-align: center; }
  .persona-create-card small { display: none; }

  /* Bottom rail on home: five high-value destinations plus profile. */
  .app-sidebar { position: fixed; inset: auto 0 0 0; z-index: 40; display: flex; width: 100%; height: calc(70px + var(--safe-bottom)); min-height: calc(70px + var(--safe-bottom)); flex-direction: row; align-items: stretch; gap: 0; padding: 7px 8px var(--safe-bottom); border: 0; border-top: 1px solid rgba(255,255,255,.09); background: rgba(14,14,14,.96); box-shadow: 0 -14px 34px rgba(0,0,0,.28); transform: none; backdrop-filter: blur(20px); }
  .sidebar-top { display: contents; }
  .sidebar-brand,
  .sidebar-new,
  .sidebar-history,
  .sidebar-action,
  .sidebar-logout { display: none; }
  .sidebar-nav { display: flex; align-items: stretch; flex: 1 1 auto; width: auto; gap: 3px; }
  .home-nav-trigger[data-action] { display: none; }
  .home-nav-trigger { display: flex; flex: 1 1 0; min-width: 0; min-height: 52px; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 4px 2px; border-radius: 11px; color: var(--stitch-outline, #948e99); text-align: center; }
  .home-nav-trigger span { width: auto; font-size: 1.05rem; line-height: 1; }
  .home-nav-trigger strong { overflow: hidden; max-width: 100%; font-size: .55rem; font-weight: 600; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
  .home-nav-trigger.active { color: var(--stitch-secondary, #d7baff); background: rgba(93,45,159,.27); box-shadow: inset 0 2px var(--stitch-primary, #d3bcfc); }
  .sidebar-bottom { display: flex; align-items: center; width: 42px; margin: 0 0 0 4px; padding: 0; border: 0; }
  .sidebar-account { display: flex; justify-content: center; width: 42px; height: 42px; min-height: 42px; padding: 5px; border-radius: 11px; background: rgba(32,31,31,.72); }
  .sidebar-account > span:nth-child(2),
  .sidebar-account b { display: none; }
  .sidebar-user-dot { width: 28px; height: 28px; }
  .sidebar-overlay { position: fixed; inset: 0; z-index: 39; display: block; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; pointer-events: none; background: rgba(0,0,0,.64); transition: opacity .2s ease; }

  /* Opening the menu switches the rail into a full-height navigation drawer. */
  .product-shell.sidebar-open .app-sidebar { inset: 0 auto 0 0; width: min(86vw, 300px); height: 100dvh; min-height: 100dvh; flex-direction: column; gap: 22px; padding: 26px 18px calc(18px + var(--safe-bottom)); border-right: 1px solid rgba(255,255,255,.1); border-top: 0; box-shadow: 24px 0 64px rgba(0,0,0,.44); transform: translateX(0); }
  .product-shell.sidebar-open .sidebar-top { display: grid; gap: 22px; }
  .product-shell.sidebar-open .sidebar-brand,
  .product-shell.sidebar-open .sidebar-new,
  .product-shell.sidebar-open .sidebar-history,
  .product-shell.sidebar-open .sidebar-action,
  .product-shell.sidebar-open .sidebar-logout { display: flex; }
  .product-shell.sidebar-open .sidebar-brand { align-items: center; }
  .product-shell.sidebar-open .sidebar-new { width: 100%; }
  .product-shell.sidebar-open .sidebar-nav { display: grid; width: 100%; gap: 4px; }
  .product-shell.sidebar-open .home-nav-trigger { min-height: 44px; flex-direction: row; justify-content: flex-start; gap: 13px; padding: 0 14px; border-radius: 10px; text-align: left; }
  .product-shell.sidebar-open .home-nav-trigger span { width: 20px; font-size: 1rem; }
  .product-shell.sidebar-open .home-nav-trigger strong { max-width: none; font-size: .83rem; }
  .product-shell.sidebar-open .home-nav-trigger[data-action] { display: flex; }
  .product-shell.sidebar-open .sidebar-history { min-height: 0; flex: 1; flex-direction: column; width: 100%; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.07); }
  .product-shell.sidebar-open .sidebar-bottom { display: grid; align-items: stretch; width: 100%; height: auto; margin: auto 0 0; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.07); }
  .product-shell.sidebar-open .sidebar-account { justify-content: flex-start; width: 100%; height: auto; min-height: 50px; padding: 0 9px; }
  .product-shell.sidebar-open .sidebar-account > span:nth-child(2),
  .product-shell.sidebar-open .sidebar-account b { display: block; }
  .product-shell.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .product-shell.chat-active:not(.sidebar-open) .app-sidebar { pointer-events: none; transform: translateX(-105%); }

  /* Chat consumes the full phone viewport; only the transcript scrolls. */
  .chat-view { width: 100%; height: 100dvh; min-height: 100dvh; border: 0; }
  .persona-header { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; min-height: 64px; padding: 9px 10px; }
  .chat-header-leading { min-width: 0; gap: 5px; }
  .chat-header-leading .topbar-menu { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid rgba(255,255,255,.09); border-radius: 9px; color: var(--stitch-variant, #cbc4d0); font-size: 0; }
  .chat-header-leading .topbar-menu::after { content: "☰"; font-size: .95rem; }
  .persona-header .back-btn { min-width: 43px; min-height: 36px; padding: 7px; font-size: .66rem; }
  .persona-header .avatar { width: 43px; height: 43px; border-radius: 50%; }
  .persona-header .persona-meta { min-width: 0; flex: 1 1 auto; }
  .persona-header .persona-bio,
  .persona-tags { display: none; }
  .persona-name-row { min-width: 0; gap: 5px; flex-wrap: nowrap; }
  .persona-name-row h1 { min-width: 0; overflow: hidden; font-size: .94rem; text-overflow: ellipsis; white-space: nowrap; }
  .header-actions { flex: 0 0 auto; flex-direction: row; gap: 4px; margin-left: auto; }
  .header-actions .icon-btn { min-height: 34px; min-width: 38px; padding: 6px 7px; font-size: .62rem; }
  .chat-shell { min-height: 0; flex: 1 1 auto; }
  .chat-welcome-line { width: 100%; flex: 0 0 auto; padding: 16px 14px 0; font-size: .55rem; }
  .messages { width: 100%; min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior-y: contain; padding: 18px 11px 16px; gap: 11px; }
  .msg { max-width: 93%; }
  .bubble { padding: 10px 12px; font-size: .92rem; line-height: 1.6; }
  .message-text-row { align-items: flex-end; gap: 5px; }
  .message-voice-btn { min-height: 30px; padding: 0 7px; font-size: .61rem; }
  .media-card { max-width: min(86vw, 390px); }
  .media-card img,
  .media-card video { max-height: 56dvh; }
  .composer { flex: 0 0 auto; padding: 8px 9px calc(9px + var(--safe-bottom)); }
  .composer-context { padding: 0 5px 6px; font-size: .55rem; }
  .composer-context span:last-child,
  .composer-meta { display: none; }
  .chat-form { width: 100%; min-height: 52px; align-items: flex-end; gap: 5px; padding: 5px; border-radius: 14px; }
  #messageInput { min-width: 0; min-height: 42px; max-height: 120px; flex: 1 1 auto; padding: 10px 9px; font-size: 16px; line-height: 1.45; }
  .voice-input-btn,
  .send-btn { height: 40px; min-height: 40px; border-radius: 10px; }
  .voice-input-btn { width: 40px; min-width: 40px; padding: 0; font-size: 0; }
  .voice-input-btn::after { content: "♩"; font-size: 1rem; }
  .send-btn { min-width: 54px; padding: 0 8px; font-size: .72rem; }

  /* Dialogs become bottom sheets with a comfortable scroll area. */
  .memory-dialog,
  .gallery-dialog,
  .onboarding-dialog { position: fixed; inset: auto 10px calc(10px + var(--safe-bottom)); width: calc(100vw - 20px); max-width: calc(100vw - 20px); max-height: calc(100dvh - 20px - var(--safe-bottom)); margin: 0; border-radius: 16px; }
  .memory-panel { max-height: calc(100dvh - 20px - var(--safe-bottom)); overflow-y: auto; padding: 20px 15px calc(20px + var(--safe-bottom)); }
  .memory-panel h2 { font-size: 1.7rem; }
  #memoryList { max-height: 42dvh; }
  #memoryList li { align-items: flex-start; padding: 12px; }
  .memory-add { flex-wrap: wrap; }
  .memory-add input { min-width: 0; flex: 1 1 180px; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 60dvh; gap: 10px; }
  .gallery-card-footer { flex-wrap: wrap; gap: 5px; padding: 8px; }
  .gallery-card-footer small { flex-basis: 100%; }
  .gallery-card-footer button { min-height: 30px; padding: 3px 5px; font-size: .62rem; }
  .field-label { margin: 12px 0; }
  .time-row { gap: 7px; }
}

@media (max-width: 380px) {
  .home-inner { padding-left: 12px; padding-right: 12px; }
  .home-header h1 { font-size: 2.05rem; }
  .persona-grid { gap: 8px; }
  .persona-card-body { padding-left: 9px; padding-right: 9px; }
  .persona-card-title { font-size: .8rem; }
  .persona-card-rel { font-size: .55rem; }
  .persona-header { gap: 4px; padding-left: 7px; padding-right: 7px; }
  .persona-header .back-btn { min-width: 40px; padding-left: 5px; padding-right: 5px; }
  .persona-header .avatar { width: 39px; height: 39px; }
  .header-actions .icon-btn { padding-left: 5px; padding-right: 5px; }
  .send-btn { min-width: 49px; }
}

/* 20260716 desktop sanctuary chat recreation.
   This block mirrors the supplied Stitch Desktop Sanctuary: a 256px-ish
   navigation rail, an 800px central transcript, a 320px Resonance rail, and
   the anchored glass composer. Dynamic message content still comes from the
   existing chat service. */
#chatView.chat-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: 80px minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  border: 0;
  border-radius: 0;
  background: #121212;
  box-shadow: none;
}

#chatView .persona-header {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  min-height: 80px;
  height: 80px;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  border: 0;
  border-bottom: 1px solid rgba(73, 69, 79, .34);
  border-radius: 0;
  background: rgba(19, 19, 19, .68);
  box-shadow: none;
  backdrop-filter: blur(18px);
}

#chatView .chat-header-leading { display: none; }
#chatView .chat-session-meta { min-width: 0; flex: 1; }
#chatView .chat-session-title-row { display: flex; align-items: center; gap: 10px; }
#chatView .chat-session-title { margin: 0; color: #e5e2e1; font: 600 24px/32px "Playfair Display", Georgia, serif; letter-spacing: -.015em; }
#chatView .chat-session-subtitle { margin: 1px 0 0; color: #cbc4d0; font: 600 12px/16px "Manrope", sans-serif; letter-spacing: .04em; }
#chatView .persona-name-row,
#chatView .persona-bio,
#chatView .persona-tags,
#chatView #personaAvatar { display: none; }
#chatView .header-actions { display: flex; flex: 0 0 auto; gap: 16px; margin-left: auto; }
#chatView .chat-header-icon { display: grid; width: 40px; height: 40px; min-width: 40px; min-height: 40px; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #cbc4d0; font-size: 1.25rem; }
#chatView .chat-header-icon:hover { background: rgba(53, 53, 52, .42); color: #d3bcfc; }

#chatView .chat-shell {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background: #121212;
}
#chatView .chat-welcome-line { display: none; }
#chatView .messages {
  width: 100%;
  max-width: 800px;
  min-height: 0;
  flex: 1;
  margin: 0 auto;
  overflow-y: auto;
  padding: 32px 32px 104px;
  gap: 24px;
  background: transparent;
}
#chatView .msg { display: flex; max-width: 85%; align-items: flex-end; gap: 12px; }
#chatView .msg.assistant { width: auto; align-self: flex-start; }
#chatView .msg.user { width: auto; max-width: 85%; align-self: flex-end; justify-content: flex-end; }
#chatView .message-avatar { display: grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center; align-self: flex-end; overflow: hidden; border-radius: 50%; background: #2a2a2a; color: #d3bcfc; font-size: .85rem; }
#chatView .message-avatar img { width: 100%; height: 100%; object-fit: cover; }
#chatView .message-content { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
#chatView .message-text-row { display: flex; max-width: 100%; align-items: flex-end; gap: 8px; }
#chatView .bubble { max-width: 100%; padding: 12px 20px; border: 1px solid rgba(211, 188, 252, .1); border-radius: 16px 16px 16px 4px; background: #2a2a2a; box-shadow: 0 2px 8px rgba(0,0,0,.16); color: #e5e2e1; font: 450 15px/22px "Manrope", sans-serif; letter-spacing: 0; }
#chatView .msg.user .message-content { align-items: flex-end; }
#chatView .msg.user .bubble { border: 0; border-radius: 16px 16px 4px 16px; background: #5d2d9f; color: #ebdcff; }
#chatView .msg-meta { margin: 0 4px; color: rgba(203, 196, 208, .52); font: 600 10px/16px "Manrope", sans-serif; letter-spacing: .04em; }
#chatView .msg.user .msg-meta { margin-right: 4px; text-align: right; }
#chatView .message-voice-btn { width: 0; min-width: 0; min-height: 0; height: 0; padding: 0; overflow: hidden; border: 0; opacity: 0; }
#chatView .msg:hover .message-voice-btn,
#chatView .message-voice-btn:focus-visible { width: auto; min-width: 30px; min-height: 30px; height: 30px; padding: 0 7px; opacity: 1; border: 1px solid rgba(211,188,252,.24); }
#chatView .message-actions { min-height: 20px; padding: 0 4px; opacity: 0; }
#chatView .msg:hover .message-actions,
#chatView .message-actions:focus-within { opacity: 1; }
#chatView .status-message .bubble { color: #cbc4d0; }
#chatView .media-card { max-width: 420px; margin-top: 4px; border-color: rgba(255,255,255,.08); border-radius: 12px; background: #1c1b1b; }
#chatView .media-card img { max-height: 460px; }
#chatView .empty-hint { margin: auto; color: #cbc4d0; }

#chatView .composer {
  grid-column: 1;
  grid-row: 3;
  position: relative;
  z-index: 10;
  padding: 14px 24px 18px;
  border: 0;
  border-top: 1px solid rgba(73, 69, 79, .25);
  border-radius: 16px 16px 0 0;
  background: rgba(19, 19, 19, .96);
  box-shadow: 0 -8px 26px rgba(0,0,0,.18);
}
#chatView .composer-context,
#chatView .composer-meta { display: none; }
#chatView .chat-form { width: 100%; min-height: 56px; align-items: center; gap: 8px; padding: 0 12px; border: 0; border-bottom: 1px solid #49454f; border-radius: 8px; background: rgba(32, 31, 31, .5); box-shadow: none; }
#chatView .chat-form:focus-within { border-bottom-color: #d3bcfc; box-shadow: 0 2px 8px rgba(211,188,252,.1); }
#chatView #messageInput { min-width: 0; min-height: 52px; flex: 1 1 auto; padding: 14px 8px 13px 12px; border: 0; background: transparent; color: #e5e2e1; font: 400 15px/22px "Manrope", sans-serif; }
#chatView #messageInput::placeholder { color: #cbc4d0; opacity: .78; }
#chatView #messageInput:focus { outline: 0; box-shadow: none; }
#chatView .composer-tools { display: flex; flex: 0 0 auto; gap: 4px; }
#chatView .composer-tool { display: grid; width: 32px; height: 32px; min-width: 32px; min-height: 32px; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #cbc4d0; cursor: pointer; font-size: 1.1rem; }
#chatView .composer-tool:hover { background: rgba(53,53,52,.42); }
#chatView .composer-voice { color: #cbc4d0; font-size: 1.25rem; }
#chatView .composer-suggest { color: #ffb4ac; }
#chatView .composer-send { color: #d3bcfc; font-size: 1.25rem; }
#chatView .composer-send:disabled { opacity: .45; }

/* Emotional Resonance rail from the Stitch conversation screen. */
#chatView .resonance-panel {
  grid-column: 2;
  grid-row: 1 / 4;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  padding: 28px 24px 24px;
  border-left: 1px solid rgba(73, 69, 79, .34);
  background: rgba(19, 19, 19, .65);
}
#chatView .resonance-panel > h2 { margin: 0 0 2px; color: #e5e2e1; font: 600 24px/32px "Playfair Display", Georgia, serif; }
#chatView .resonance-card { position: relative; overflow: hidden; padding: 20px; border: 1px solid rgba(255,255,255,.05); border-radius: 12px; background: rgba(28,27,27,.5); }
#chatView .resonance-label { margin: 0; color: #cbc4d0; font: 600 10px/16px "Manrope", sans-serif; letter-spacing: .12em; text-transform: uppercase; }
#chatView .resonance-score { display: flex; align-items: flex-end; gap: 8px; margin-top: 3px; }
#chatView .resonance-score strong { color: #d3bcfc; font: 700 34px/42px "Playfair Display", Georgia, serif; }
#chatView .resonance-score span { margin-bottom: 7px; color: #cbc4d0; font: 400 15px/22px "Manrope", sans-serif; }
#chatView .resonance-progress { height: 4px; margin-top: 16px; overflow: hidden; border-radius: 999px; background: #353534; }
#chatView .resonance-progress i { display: block; width: 84%; height: 100%; border-radius: inherit; background: #ffb4ac; box-shadow: 0 0 10px rgba(255,180,172,.5); }
#chatView .resonance-card-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
#chatView .resonance-card-heading > span { color: #cbc4d0; font-size: 1rem; }
#chatView .mood-graph { display: block; width: 100%; height: 96px; overflow: visible; }
#chatView .mood-fill { fill: url(#moodGradient); opacity: .2; }
#chatView .mood-line { fill: none; stroke: #d3bcfc; stroke-width: 2; opacity: .8; }
#chatView .mood-graph circle { fill: #d3bcfc; }
#chatView .mood-graph .mood-current { fill: #ffb4ac; filter: drop-shadow(0 0 4px rgba(255,180,172,.8)); }
#chatView .mood-days { display: flex; justify-content: space-between; margin-top: 8px; color: rgba(203,196,208,.52); font: 600 10px/16px "Manrope", sans-serif; }
#chatView .resonance-profile-card { margin-top: auto; text-align: center; }
#chatView .resonance-avatar { display: grid; width: 64px; height: 64px; margin: 0 auto 16px; place-items: center; overflow: hidden; border: 2px solid rgba(211,188,252,.2); border-radius: 50%; background: #2a2a2a; color: #d3bcfc; font-size: 1.5rem; }
#chatView .resonance-avatar img { width: 100%; height: 100%; object-fit: cover; }
#chatView .resonance-profile-card h3 { margin: 0; color: #e5e2e1; font: 600 20px/28px "Playfair Display", Georgia, serif; }
#chatView .resonance-role { margin: 3px 0 12px; color: #d3bcfc; font: 600 10px/16px "Manrope", sans-serif; }
#chatView .resonance-profile-card > p:last-child { margin: 0; color: rgba(203,196,208,.8); font: 400 12px/18px "Manrope", sans-serif; }

/* The chat reference has a focused four-item rail instead of the full
   sanctuary management navigation. Home keeps the complete product nav. */
.product-shell.chat-active .app-sidebar .home-nav-trigger[data-nav-key="characters"],
.product-shell.chat-active .app-sidebar .home-nav-trigger[data-nav-key="gallery"],
.product-shell.chat-active .app-sidebar .home-nav-trigger[data-nav-key="memory"],
.product-shell.chat-active .app-sidebar .home-nav-trigger[data-action="pricing"],
.product-shell.chat-active .app-sidebar .sidebar-history,
.product-shell.chat-active .app-sidebar .sidebar-bottom { display: none; }

@media (max-width: 980px) and (min-width: 761px) {
  #chatView.chat-view { grid-template-columns: minmax(0, 1fr) 270px; }
  #chatView .resonance-panel { padding-left: 18px; padding-right: 18px; }
  #chatView .messages { padding-left: 24px; padding-right: 24px; }
}

@media (max-width: 760px) {
  #chatView.chat-view { display: flex; height: 100dvh; min-height: 100dvh; flex-direction: column; }
  #chatView .persona-header { display: flex; flex: 0 0 64px; width: 100%; min-height: 64px; height: 64px; gap: 7px; padding: 9px 10px; }
  #chatView .chat-header-leading { display: flex; align-items: center; gap: 5px; }
  #chatView .chat-header-leading .topbar-menu { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid rgba(255,255,255,.09); border-radius: 9px; font-size: 0; }
  #chatView .chat-header-leading .topbar-menu::after { content: "☰"; font-size: .95rem; }
  #chatView .chat-header-leading .back-btn { display: grid; min-width: 34px; min-height: 34px; place-items: center; padding: 0; font-size: 1.1rem; }
  #chatView .chat-session-title { font-size: 1.02rem; line-height: 1.2; white-space: nowrap; }
  #chatView .chat-session-subtitle { overflow: hidden; font-size: .52rem; text-overflow: ellipsis; white-space: nowrap; }
  #chatView .header-actions { gap: 2px; }
  #chatView .chat-header-icon { width: 34px; height: 34px; min-width: 34px; min-height: 34px; font-size: 1.05rem; }
  #chatView .chat-shell { flex: 1 1 auto; min-height: 0; }
  #chatView .messages { width: 100%; max-width: none; padding: 18px 11px 22px; gap: 15px; }
  #chatView .msg { max-width: 94%; gap: 8px; }
  #chatView .message-avatar { width: 28px; height: 28px; flex-basis: 28px; }
  #chatView .bubble { padding: 10px 13px; font-size: .9rem; line-height: 1.6; }
  #chatView .message-voice-btn { width: auto; min-width: 29px; min-height: 29px; height: 29px; padding: 0 6px; opacity: 1; border: 1px solid rgba(211,188,252,.2); }
  #chatView .message-voice-btn .voice-btn-label { display: none; }
  #chatView .composer { flex: 0 0 auto; padding: 8px 9px calc(9px + var(--safe-bottom)); border-radius: 14px 14px 0 0; }
  #chatView .chat-form { min-height: 52px; gap: 5px; padding: 5px; border-radius: 12px; }
  #chatView #messageInput { min-height: 42px; max-height: 120px; padding: 10px 8px; font-size: 16px; }
  #chatView .composer-tool { width: 34px; height: 34px; min-width: 34px; min-height: 34px; }
  #chatView .composer-send { font-size: 1.1rem; }
  #chatView .resonance-panel { display: none; }
}

/* 20260716 Stitch pixel alignment pass.
   The supplied Desktop Sanctuary is a centered 16:10 application card. The
   chat is intentionally kept inside that card on desktop and becomes a
   true edge-to-edge workspace only on phones. */
.material-symbols-outlined {
  display: inline-block;
  font-family: "Material Symbols Outlined";
  font-size: 20px;
  font-style: normal;
  font-weight: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "liga";
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

@media (min-width: 761px) {
  html,
  body { min-height: 100%; }

  body {
    display: flex;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 32px;
    background: #0e0e0e;
  }

  .product-shell {
    display: grid;
    width: min(1440px, calc(100vw - 64px));
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 10;
    grid-template-columns: 256px minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid rgba(73, 69, 79, .32);
    border-radius: 16px;
    background: #121212;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .58);
  }

  .shell-main { height: 100%; min-height: 0; }

  /* Exact Stitch chat rail: brand, four destinations, then the CTA. */
  .product-shell.chat-active .app-sidebar {
    width: 256px;
    height: 100%;
    min-height: 0;
    padding: 24px 16px;
    border-right: 1px solid rgba(73, 69, 79, .3);
    border-radius: 0;
    background: #1c1b1b;
    box-shadow: none;
  }

  .product-shell.chat-active .app-sidebar .sidebar-top {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 0;
  }

  .product-shell.chat-active .app-sidebar .sidebar-brand {
    order: 1;
    margin: 0 0 48px;
    padding: 0 16px;
    gap: 12px;
  }

  .product-shell.chat-active .sidebar-brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    border: 0;
    border-radius: 50%;
    background: #b39ddb;
    color: #38265b;
    box-shadow: none;
  }

  .product-shell.chat-active .sidebar-brand-mark .material-symbols-outlined { font-size: 20px; }
  .product-shell.chat-active .sidebar-brand strong { color: #d3bcfc; font: 700 16px/20px "Playfair Display", Georgia, serif; letter-spacing: -.02em; }
  .product-shell.chat-active .sidebar-brand span:not(.material-symbols-outlined) { margin-top: 1px; color: #cbc4d0; font: 400 9px/12px "Manrope", sans-serif; letter-spacing: 0; }

  .product-shell.chat-active .app-sidebar .sidebar-nav {
    order: 2;
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 8px;
  }

  .product-shell.chat-active .app-sidebar .home-nav-trigger {
    min-height: 48px;
    gap: 16px;
    padding: 0 16px;
    border: 0;
    border-right: 2px solid transparent;
    border-radius: 8px;
    color: #cbc4d0;
  }

  .product-shell.chat-active .app-sidebar .home-nav-trigger span { width: 20px; color: #cbc4d0; font-size: 20px; }
  .product-shell.chat-active .app-sidebar .home-nav-trigger strong { color: inherit; font: 400 14px/20px "Manrope", sans-serif; }
  .product-shell.chat-active .app-sidebar .home-nav-trigger:hover { background: rgba(53, 53, 52, .3); color: #e5e2e1; transform: none; }
  .product-shell.chat-active .app-sidebar .home-nav-trigger.active { border-right-color: #d3bcfc; background: rgba(53, 53, 52, .3); box-shadow: none; color: #d3bcfc; }
  .product-shell.chat-active .app-sidebar .home-nav-trigger.active span { color: #d3bcfc; }
  .product-shell.chat-active .app-sidebar .sidebar-new { order: 3; width: 100%; min-height: 44px; margin-top: auto; padding: 0 16px; justify-content: center; border: 0; border-radius: 999px; background: linear-gradient(90deg, #5d2d9f, #b39ddb); color: #38265b; box-shadow: 0 10px 28px rgba(93, 45, 159, .2); }
  .product-shell.chat-active .app-sidebar .sidebar-new-icon { color: #38265b; font-size: 20px; }
  .product-shell.chat-active .app-sidebar .sidebar-new kbd { display: none; }

  #chatView.chat-view {
    grid-template-columns: minmax(0, 800px) 320px;
    grid-template-rows: 80px minmax(0, 1fr);
    justify-content: center;
    min-height: 0;
    height: 100%;
    background: #121212;
  }

  #chatView .persona-header {
    height: 80px;
    min-height: 80px;
    padding: 0 32px;
    background: rgba(28, 27, 27, .4);
  }

  #chatView .chat-session-subtitle { font-weight: 400; letter-spacing: .05em; }
  #chatView .chat-session-title { font-size: 24px; font-weight: 600; }
  #chatView .chat-header-icon { border-radius: 50%; }
  #chatView .chat-header-icon .material-symbols-outlined { font-size: 20px; }

  #chatView .chat-shell {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    border-right: 1px solid rgba(73, 69, 79, .25);
    background: radial-gradient(circle at center, rgba(35, 15, 69, .2) 0%, #121212 100%);
  }

  #chatView .messages { max-width: 800px; padding: 32px 32px 112px; gap: 24px; }
  #chatView .bubble { padding: 12px 20px; font-size: 15px; line-height: 22px; }
  #chatView .msg-meta { font-size: 10px; line-height: 16px; }

  /* The reference composer floats over the lower edge of the center column. */
  #chatView .composer {
    position: absolute;
    right: auto;
    bottom: 0;
    left: calc((100% - 1120px) / 2);
    z-index: 10;
    width: 800px;
    grid-column: auto;
    grid-row: auto;
    padding: 24px;
    border: 0;
    border-radius: 16px 16px 0 0;
    background: rgba(28, 27, 27, .4);
    box-shadow: none;
  }

  #chatView .chat-form { min-height: 56px; padding: 0; border: 0; border-bottom: 1px solid rgba(73, 69, 79, .5); border-radius: 8px; background: rgba(32, 31, 31, .5); }
  #chatView #messageInput { min-height: 56px; padding: 16px 96px 16px 56px; font-size: 16px; line-height: 24px; }
  #chatView .composer-voice { position: absolute; bottom: 36px; left: 36px; z-index: 1; }
  #chatView .composer-tools { position: absolute; right: 32px; bottom: 36px; }
  #chatView .composer-tool { width: 32px; height: 32px; min-width: 32px; min-height: 32px; border-radius: 0; }
  #chatView .composer-tool .material-symbols-outlined { font-size: 20px; }
  #chatView .composer-send .material-symbols-outlined { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

  #chatView .resonance-panel {
    grid-column: 2;
    grid-row: 1 / 3;
    padding: 24px;
    border-left: 0;
    background: rgba(28, 27, 27, .4);
  }
}

@media (min-width: 761px) and (max-width: 1280px) {
  #chatView.chat-view { grid-template-columns: minmax(0, 1fr) 320px; }
  #chatView .composer { right: 320px; left: 0; width: calc(100% - 320px); }
}

@media (max-width: 760px) {
  body { display: block; min-height: 100dvh; overflow: hidden; padding: 0; }
  .product-shell { width: 100%; height: 100dvh; min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  #chatView .composer { position: relative; right: auto; bottom: auto; left: auto; width: 100%; }
}

/* Exact controls from the supplied conversation markup. */
#chatView .bubble .message-voice-btn {
  display: inline-flex;
  width: 28px;
  min-width: 28px;
  height: 24px;
  min-height: 24px;
  margin-left: 8px;
  align-items: center;
  justify-content: center;
  padding: 0;
  vertical-align: middle;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(203, 196, 208, .5);
  opacity: 1;
  overflow: visible;
}

#chatView .bubble .message-voice-btn:hover,
#chatView .bubble .message-voice-btn.is-active { border: 0; background: transparent; color: #d3bcfc; }
#chatView .bubble .message-voice-btn .material-symbols-outlined { font-size: 18px; }
#chatView .bubble .message-voice-btn .voice-btn-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

#chatView .typing-indicator { display: inline-flex; height: 16px; align-items: center; gap: 2px; }
#chatView .typing-indicator span { display: inline-block; width: 6px; height: 6px; margin: 0; border-radius: 50%; background: #cbc4d0; animation: serenity-blink 1.4s infinite both; }
#chatView .typing-indicator span:nth-child(2) { animation-delay: .2s; }
#chatView .typing-indicator span:nth-child(3) { animation-delay: .4s; }
#chatView .status-message .bubble { display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px; }
#chatView .status-message .message-avatar { opacity: .5; }
@keyframes serenity-blink { 0% { opacity: .2; transform: scale(.8); } 20% { opacity: 1; transform: scale(1); } 100% { opacity: .2; transform: scale(.8); } }

#chatView .composer-attach { position: absolute; bottom: 36px; left: 36px; z-index: 1; color: #cbc4d0; }
#chatView .composer-mic { color: #cbc4d0; }
#chatView .composer-mic.is-recording { color: #d3bcfc; background: rgba(93, 45, 159, .2); }
#chatView .composer-tools { gap: 8px; }
#chatView .resonance-score-card::after { position: absolute; top: -40px; right: -40px; width: 128px; height: 128px; content: ""; border-radius: 50%; background: rgba(211, 188, 252, .1); filter: blur(24px); pointer-events: none; }

@media (max-width: 760px) {
  #chatView .composer-attach { position: static; bottom: auto; left: auto; }
  #chatView .composer-tools { gap: 2px; }
  #chatView .bubble .message-voice-btn { width: 26px; min-width: 26px; height: 24px; min-height: 24px; margin-left: 4px; }
}
