:root {
  --bg: #f6f4f1;
  --panel: #ffffff;
  --text: #1d1d1f;
  --muted: #7a7670;
  --line: #e7e2db;
  --her: #ffffff;
  --her-text: #1d1d1f;
  --me: #2f6f62;
  --me-text: #ffffff;
  --accent: #2f6f62;
  --danger: #b3261e;
  --shadow: 0 1px 1px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --panel: #171a20; --text: #ecebe8; --muted: #8d8a85; --line: #262a31;
    --her: #1e222a; --her-text: #ecebe8; --me: #3d8b7b; --me-text: #fff; --accent: #5fb3a1;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --panel: #171a20; --text: #ecebe8; --muted: #8d8a85; --line: #262a31;
  --her: #1e222a; --her-text: #ecebe8; --me: #3d8b7b; --me-text: #fff; --accent: #5fb3a1; --shadow: none;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

.screen { height: 100dvh; display: flex; flex-direction: column; }

/* login */
#login { align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card h1 { font-size: 22px; font-weight: 600; margin: 4px 0 8px; }
.login-dot { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto;
  background: radial-gradient(circle at 35% 35%, #8fd3c3, var(--accent)); }
.login-card input { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font-size: 17px; }
.login-card button { padding: 14px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 600; }
.error { color: var(--danger); min-height: 1.4em; margin: 0; font-size: 14px; }

/* header */
header { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--bg); }
.who { display: flex; align-items: center; gap: 10px; text-align: left; padding: 4px; min-width: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 35%, #8fd3c3, var(--accent)); }
.who-text { display: flex; flex-direction: column; min-width: 0; }
.name { font-weight: 600; font-size: 17px; }
.status { font-size: 13px; color: var(--muted); min-height: 1.2em; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; font-size: 20px; color: var(--muted); }
.banner { padding: 10px 16px; font-size: 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.banner button { color: var(--accent); font-weight: 600; margin-left: 6px; }

/* listă */
main { flex: 1; overflow-y: auto; padding: 12px 16px 8px; overscroll-behavior: contain; }
.older { text-align: center; margin-bottom: 8px; }
.older button { color: var(--muted); font-size: 13px; padding: 6px 10px; }
.day { text-align: center; font-size: 12px; color: var(--muted); margin: 14px 0 8px; }
.msg { display: flex; flex-direction: column; margin: 2px 0; max-width: 100%; }
.msg.me { align-items: flex-end; }
.msg.her { align-items: flex-start; }
.bubble { position: relative; max-width: min(78%, 560px); padding: 8px 12px; border-radius: 18px; white-space: pre-wrap;
  overflow-wrap: anywhere; box-shadow: var(--shadow); user-select: text; }
.her .bubble { background: var(--her); color: var(--her-text); border-bottom-left-radius: 6px; }
.me .bubble { background: var(--me); color: var(--me-text); border-bottom-right-radius: 6px; }
.msg.cont.her .bubble { border-top-left-radius: 6px; }
.msg.cont.me .bubble { border-top-right-radius: 6px; }
.msg.gap { margin-top: 10px; }
.bubble img.drawing { display: block; width: 220px; max-width: 100%; height: auto; border-radius: 12px; background: #fff; }
.bubble.svg { padding: 6px; }
.meta { font-size: 11px; color: var(--muted); margin: 2px 6px 0; }
.pending .bubble { opacity: .6; }
.failed .bubble { outline: 1px solid var(--danger); }
.reaction { position: absolute; bottom: -10px; font-size: 14px; background: var(--panel); border-radius: 12px;
  padding: 0 4px; box-shadow: var(--shadow); line-height: 20px; }
.her .reaction { right: -8px; }
.me .reaction { left: -8px; }
.msg.has-reaction { margin-bottom: 12px; }

.typing { display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--her); border-radius: 18px;
  border-bottom-left-radius: 6px; margin: 4px 0; box-shadow: var(--shadow); }
.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; }
.typing.thinking span { animation-duration: 2.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* compunere */
#composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
#input { flex: 1; resize: none; max-height: 140px; padding: 10px 14px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; font-size: 16px; line-height: 1.35; }
#input:focus { outline: none; border-color: var(--accent); }
#send { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 17px; flex: none; }

/* panou */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; z-index: 10; }
.sheet-card { width: 100%; max-height: 88dvh; background: var(--panel); border-radius: 18px 18px 0 0; display: flex;
  flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.tabs { display: flex; align-items: center; gap: 4px; padding: 8px 8px 0 12px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 10px; color: var(--muted); border-bottom: 2px solid transparent; font-size: 15px; }
.tab.active { color: var(--text); border-color: var(--accent); }
#sheet-close { margin-left: auto; }
.tab-body { overflow-y: auto; padding: 14px 16px 24px; font-size: 15px; }
.tab-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
.tab-body p { margin: 6px 0; white-space: pre-wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 14px 0 6px; }
.wide { width: 100%; padding: 12px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; margin: 4px 0; }
.wide.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.dec { border-bottom: 1px solid var(--line); padding: 8px 0; font-size: 14px; }
.dec .t { color: var(--muted); font-size: 12px; }
.dec .a { font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv span:nth-child(odd) { color: var(--muted); }

.picker { position: fixed; z-index: 20; display: flex; gap: 2px; background: var(--panel); border-radius: 24px; padding: 4px;
  box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.picker button { font-size: 24px; width: 42px; height: 42px; border-radius: 50%; }
.picker button:active { background: var(--line); }
