:root {
  --bg: #fff3f8;
  --panel: #ffffff;
  --pink: #f06ba8;
  --pink-deep: #d94a8c;
  --her: #ffffff;
  --him: #f06ba8;
  --him-text: #ffffff;
  --text: #3b2140;
  --muted: #9b7a92;
  --border: #ffd3e6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1219;
    --panel: #2a1a24;
    --her: #352230;
    --him: #d94a8c;
    --text: #fbe9f2;
    --muted: #c49bb5;
    --border: #4a2b3e;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.avatar { width: 44px; height: 44px; border-radius: 50%; }
.who { flex: 1; min-width: 0; }
.who h1 { margin: 0; font-size: 18px; }
.who p { margin: 0; font-size: 13px; color: var(--muted); }
.help {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
}

#chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bubble {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 18px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop .18s ease-out;
}
.bubble.her { align-self: flex-start; background: var(--her); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.bubble.him { align-self: flex-end; background: var(--him); color: var(--him-text); border-bottom-right-radius: 6px; }
.bubble em { color: var(--muted); }
.bubble.him em { color: inherit; opacity: .85; }
.notice { align-self: center; font-size: 13px; color: var(--muted); text-align: center; padding: 4px 8px; }
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: var(--her); border: 1px solid var(--border); border-radius: 18px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--pink); animation: blink 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .3 } 50% { opacity: 1 } }
@keyframes pop { from { transform: scale(.94); opacity: 0 } to { transform: none; opacity: 1 } }

#composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--border);
}
#input {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
#input:focus { outline: 2px solid var(--pink); outline-offset: 0; }
#send {
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: var(--pink); color: #fff;
  font-size: 18px; cursor: pointer;
}
#send:disabled { opacity: .5; }

.lock {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
  z-index: 10;
}
.lock[hidden] { display: none; }
.lock-card {
  width: min(340px, 100%);
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 20px;
}
.lock-avatar { width: 88px; height: 88px; border-radius: 50%; }
.lock-card h2 { margin: 12px 0 4px; font-size: 20px; }
.lock-card p { margin: 0 0 12px; color: var(--muted); }
.lock-card input {
  width: 100%;
  padding: 12px;
  font-size: 22px;
  letter-spacing: .3em;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
}
.lock-card input:focus { outline: 2px solid var(--pink); }
.lock-error { min-height: 1.4em; margin: 8px 0 !important; color: var(--pink-deep) !important; font-size: 14px; }
.lock-card button { width: 100%; padding: 12px; border: 0; border-radius: 14px; background: var(--pink); color: #fff; font: inherit; font-size: 17px; cursor: pointer; }
.lock-card button:disabled { opacity: .6; }

dialog {
  max-width: min(420px, calc(100vw - 32px));
  border: 0;
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  padding: 20px;
}
dialog::backdrop { background: rgba(40, 10, 30, .45); }
dialog h2 { margin-top: 0; }
.lines { padding-left: 18px; }
.lines li { margin: 8px 0; }
.lines a { color: var(--pink-deep); }
.small { font-size: 13px; color: var(--muted); }
.close { width: 100%; padding: 10px; border: 0; border-radius: 12px; background: var(--pink); color: #fff; font: inherit; cursor: pointer; }
