:root {
  --bg: #14111a; --panel: #1e1a26; --panel2: #29233a; --text: #f1ecf7; --muted: #a49cb3;
  --accent: #c2477a; --accent2: #e2709c; --danger: #d9534f; --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button, input, textarea { font: inherit; color: inherit; }
.view { display: none; height: 100dvh; flex-direction: column; padding-top: var(--safe-t); }
.view.active { display: flex; }
#v-memory.active, #v-sheet.active, #v-home.active { overflow-y: auto; }
h1, h2, h3 { margin: 0; font-weight: 600; } h1 { font-size: 1.4rem; } h2 { font-size: 1.1rem; }
h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 18px; }
.muted { color: var(--muted); font-size: .85rem; } .pad { padding: 0 16px; }
.err { color: var(--danger); min-height: 1.2em; margin: 0; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 12px; border-bottom: 1px solid var(--panel2); background: var(--bg); position: sticky; top: 0; z-index: 2; }
.bar .title { flex: 1; min-width: 0; } .bar .title h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

button { border: 0; border-radius: 12px; padding: 10px 14px; cursor: pointer; background: var(--panel2); }
button.primary { background: var(--accent); } button.primary:active { background: var(--accent2); }
button.ghost { background: transparent; font-size: 1.3rem; padding: 6px 10px; }
button.danger { background: transparent; color: var(--danger); }
button.wide { margin: 16px; } button:disabled { opacity: .5; }
.round { width: 46px; height: 46px; border-radius: 50%; padding: 0; flex: none; font-size: 1.1rem; }
.round.listening { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(217,83,79,.25); } }

.card { background: var(--panel); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.narrow { margin: auto; width: min(360px, 90vw); }
label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
input, textarea { background: var(--panel2); border: 1px solid transparent; border-radius: 12px; padding: 11px 12px; outline: none; resize: vertical; }
input:focus, textarea:focus { border-color: var(--accent); }

.list { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; }
.item { background: var(--panel); border-radius: 14px; padding: 14px; display: flex; align-items: center; gap: 10px; }
.item .grow { flex: 1; min-width: 0; } .item button { padding: 6px 10px; font-size: .85rem; }
.profile { cursor: pointer; } .profile strong { display: block; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--accent), #6b3fa0); font-weight: 700; }

.messages { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border-bottom-left-radius: 6px; }
.msg.error { align-self: center; color: var(--danger); background: transparent; font-size: .9rem; }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; } @keyframes blink { 50% { opacity: 0; } }

.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(10px + var(--safe-b));
  border-top: 1px solid var(--panel2); background: var(--bg); }
.composer textarea, .composer input { flex: 1; max-height: 140px; resize: none; border-radius: 22px; }

.menu { position: absolute; right: 12px; top: calc(60px + var(--safe-t)); background: var(--panel); border-radius: 14px;
  display: flex; flex-direction: column; padding: 6px; z-index: 5; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.menu button { background: transparent; text-align: left; }
.banner { margin: 0 12px 6px; padding: 10px 12px; background: var(--panel2); border-radius: 12px; font-size: .88rem; cursor: pointer; }
.sheet { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
