:root {
  --bg: #14111a; --panel: #1d1927; --line: #2c2639; --text: #ece8f4; --muted: #9a93ad;
  --accent: #c0457a; --mine: #5a2a47; --theirs: #262033; --err: #ff7a8a;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.error { color: var(--err); min-height: 1.2em; }

.screen { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(420px, 100%); display: grid; gap: 12px; }
.card h1, .card h2 { margin: 0; }
label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: center; }
input, textarea { background: #120f18; border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 10px 12px; font: inherit; }
input:focus, textarea:focus { outline: 2px solid var(--accent); }
button { font: inherit; cursor: pointer; }
button.primary { background: var(--accent); border: 0; color: #fff; border-radius: 10px; padding: 10px 16px; }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px; }
.tabs { display: flex; gap: 8px; }
.tabs button { flex: 1; background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.tabs button.active { color: var(--text); border-color: var(--accent); }
.only-register { display: none; }
.register .only-register { display: grid; }
.register p.only-register { display: block; }

.chat { height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; border-inline: 1px solid var(--line); }
.chat header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--panel); border-bottom: 1px solid var(--line); }
.lock { display: block; color: var(--muted); font-size: .75rem; }
button.icon, label.icon { background: none; border: 0; color: var(--text); font-size: 1.3rem; padding: 6px 10px; cursor: pointer; }
.list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; }
#messages { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 16px; background: var(--theirs); align-self: flex-start; word-break: break-word; white-space: pre-wrap; position: relative; }
.msg.mine { background: var(--mine); align-self: flex-end; }
.msg .meta { display: flex; gap: 8px; justify-content: flex-end; font-size: .7rem; color: var(--muted); margin-top: 4px; white-space: normal; }
.msg .meta button { background: none; border: 0; color: var(--muted); padding: 0; font-size: .75rem; text-decoration: underline; }
.msg img, .msg video { max-width: 100%; max-height: 60vh; border-radius: 10px; display: block; }
.msg .ph { color: var(--muted); font-size: .85rem; }
.status { padding: 4px 14px; color: var(--muted); font-size: .8rem; background: var(--panel); }
.composer { display: flex; gap: 6px; align-items: flex-end; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; max-height: 140px; border-radius: 18px; }
.composer .send { border-radius: 50%; width: 44px; height: 44px; padding: 0; }

dialog { background: transparent; border: 0; padding: 0; color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 0; }
dialog menu button { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; }
dialog menu button.primary { background: var(--accent); border-color: var(--accent); }
.code { display: block; background: #120f18; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: .95rem; letter-spacing: .04em; word-break: break-all; }
.notice { background: #231c2d; border-radius: 10px; padding: 10px; }
a { color: var(--accent); }

/* Admin */
.admin { max-width: 860px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.admin .item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.admin .item .head { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: .85rem; }
.admin .item .body { white-space: pre-wrap; word-break: break-word; }
.admin img, .admin video { max-width: 100%; max-height: 50vh; border-radius: 10px; }
.admin button { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; justify-self: start; }
.admin button.primary { background: var(--accent); border-color: var(--accent); }

/* Médias masqués par défaut */
.tile { width: 160px; height: 160px; display: grid; place-items: center; background: #120f18; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 1rem; cursor: pointer; }
.tile:disabled { cursor: progress; }
.hidebtn { display: block; margin-top: 6px; background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 4px 10px; font-size: .8rem; cursor: pointer; }

/* Emoji */
.emoji-panel { background: var(--panel); border-top: 1px solid var(--line); padding: 6px 8px 8px; }
.emoji-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.emoji-tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; font-size: 1.3rem; padding: 4px; cursor: pointer; }
.emoji-tabs button.active { border-bottom-color: var(--accent); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 2px; max-height: 200px; overflow-y: auto; }
.emoji-grid button { background: none; border: 0; font-size: 1.6rem; line-height: 1; padding: 6px 0; border-radius: 8px; cursor: pointer; }
.emoji-grid button:active { background: var(--line); }
.msg .big { font-size: 2.6rem; line-height: 1.15; }
