/* ---- themes -------------------------------------------------------------- */
:root {
  --radius: 18px;
  --bubble-me: var(--accent);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
[data-theme="midnight"] {
  --bg: #0b0f1a; --bg2: #131a2b; --panel: #1a2236;
  --text: #eef2ff; --muted: #8a93ad; --accent: #5b8cff; --accent-text: #fff;
  --bubble-them: #222c44; --ok: #54e08a;
}
[data-theme="rose"] {
  --bg: #1a0f15; --bg2: #271219; --panel: #2e1620;
  --text: #ffeef4; --muted: #c98ba2; --accent: #ff5d8f; --accent-text: #fff;
  --bubble-them: #3a1f2b; --ok: #ff9ec4;
}
[data-theme="sunrise"] {
  --bg: #1b150c; --bg2: #2a2010; --panel: #322714;
  --text: #fff6e8; --muted: #cbab7c; --accent: #ffb347; --accent-text: #2a1c06;
  --bubble-them: #3a2d18; --ok: #ffd27a;
}
[data-theme="forest"] {
  --bg: #0a140f; --bg2: #11201a; --panel: #16291f;
  --text: #e9fff2; --muted: #80ab93; --accent: #34d399; --accent-text: #05291b;
  --bubble-them: #1d342a; --ok: #7be8b8;
}
[data-theme="rainbow"] {
  --bg: #0b0b14; --bg2: #16121f; --panel: #1d1730;
  --text: #ffffff; --muted: #b8a8d8;
  --accent: #b06bff; --accent-text: #fff; --bubble-them: #2a2140; --ok: #ff7ad9;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  overscroll-behavior: none; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---- login --------------------------------------------------------------- */
#login { align-items: center; justify-content: center;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg2), var(--bg)); }
.login-card { text-align: center; width: min(360px, 86vw); }
.login-logo { font-size: 56px; }
.login-card h1 { margin: 8px 0 0; font-size: 30px; letter-spacing: .5px; }
.login-sub { color: var(--muted); margin: 2px 0 26px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form input, #anniv-date {
  background: var(--panel); border: 1px solid #ffffff14; color: var(--text);
  padding: 14px 16px; border-radius: 14px; font-size: 16px; outline: none;
}
#login-form button, .send-btn, .ghost-btn, .danger-btn {
  border: none; cursor: pointer; font-size: 16px; border-radius: 14px;
}
#login-form button {
  background: var(--accent); color: var(--accent-text); padding: 14px; font-weight: 600;
}
.login-error { color: #ff6b6b; min-height: 18px; margin: 4px 0 0; font-size: 14px; }

/* ---- chat ---------------------------------------------------------------- */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg2); border-bottom: 1px solid #ffffff0d;
}
.peer { display: flex; align-items: center; gap: 12px; }
.peer-avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-size: 18px;
}
.peer-name { font-weight: 600; }
.peer-status { font-size: 12px; color: var(--muted); }
.peer-status.online { color: var(--ok); }
.icon-btn { background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; opacity: .8; }

.anniv-banner {
  text-align: center; font-size: 13px; color: var(--accent-text);
  background: var(--accent); padding: 6px; opacity: .92;
}

.messages { flex: 1; overflow-y: auto; padding: 16px 14px 6px; display: flex; flex-direction: column; gap: 4px; }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); margin: 14px 0 8px; }
.bubble {
  max-width: 78%; padding: 10px 14px; border-radius: var(--radius); font-size: 16px;
  line-height: 1.35; word-wrap: break-word; position: relative; animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.bubble.them { align-self: flex-start; background: var(--bubble-them); border-bottom-left-radius: 6px; }
.bubble.me   { align-self: flex-end;  background: var(--bubble-me); color: var(--accent-text); border-bottom-right-radius: 6px; }
.bubble .time { display: block; font-size: 10px; opacity: .6; margin-top: 3px; text-align: right; }
.bubble .react { position: absolute; bottom: -10px; right: 8px; font-size: 14px; filter: drop-shadow(0 1px 2px #0008); }
.bubble.emoji-only { background: none !important; font-size: 46px; padding: 2px 6px; }

.typing { display: flex; gap: 4px; padding: 4px 24px 8px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2){ animation-delay:.2s } .typing span:nth-child(3){ animation-delay:.4s }
@keyframes blink { 0%,60%,100%{opacity:.25} 30%{opacity:1} }

.composer { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--bg2); }
#msg-input { flex: 1; background: var(--panel); border: 1px solid #ffffff14; color: var(--text);
  padding: 12px 16px; border-radius: 22px; font-size: 16px; outline: none; }
.send-btn { width: 46px; background: var(--accent); color: var(--accent-text); font-size: 18px; }

/* ---- settings modal ------------------------------------------------------ */
.modal { position: fixed; inset: 0; background: #0009; display: grid; place-items: center; z-index: 20; }
.modal-card { background: var(--panel); width: min(380px, 90vw); border-radius: 20px; padding: 22px; }
.modal-card h2 { margin: 0 0 16px; }
.field { display: block; font-size: 13px; color: var(--muted); margin: 16px 0 8px; }
.theme-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.swatch.active { border-color: var(--text); }
.ghost-btn { background: #ffffff12; color: var(--text); padding: 12px 16px; }
.danger-btn { background: #ff4d4d22; color: #ff7a7a; padding: 12px 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .ghost-btn { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin-top: 16px; }
.hint code { background: #ffffff14; padding: 1px 5px; border-radius: 5px; }

/* ---- fx canvas ----------------------------------------------------------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
