
:root {
  --bg: #060a08; --panel: rgba(8, 15, 11, .88); --panel2: #0d1a13; --line: #16301f;
  --text: #cfe8d8; --muted: #5f8a70; --dim: #3a5a47;
  --ok: #3dff8c; --ok-ink: #04140b; --ok-soft: rgba(61, 255, 140, .1);
  --pub: #ffb454; --danger: #ff6b6b;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.55 var(--mono); -webkit-text-size-adjust: 100%; overflow: hidden; }
body::after { content: ""; position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .16) 0 1px, transparent 1px 3px), radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .45) 100%); }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
#login, #app { position: relative; z-index: 1; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font-size: 16px; } /* évite le zoom automatique sur iOS */
:focus-visible { outline: 1px solid var(--ok); outline-offset: 2px; }
::selection { background: var(--ok); color: var(--ok-ink); }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; } ::-webkit-scrollbar-track { background: transparent; }

/* ---------- Boutons / champs ---------- */
.btn { background: var(--ok); color: var(--ok-ink); border: 1px solid var(--ok); border-radius: 6px; padding: 0 18px; min-height: 46px; font-weight: 700; letter-spacing: .01em; }
.btn:hover:not(:disabled) { box-shadow: 0 0 0 3px var(--ok-soft), 0 0 18px rgba(61, 255, 140, .35); }
.btn:disabled { opacity: .5; cursor: default; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 0 16px; min-height: 46px; color: var(--text); }
.ghost:hover { border-color: var(--dim); background: var(--panel2); }
.pfield { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: rgba(4, 10, 7, .9); border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; min-height: 46px; }
.pfield:focus-within { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.pfield .ps { color: var(--ok); white-space: nowrap; flex: none; }
.pfield input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; padding: 11px 0; caret-color: var(--ok); }
.pfield input::placeholder { color: var(--dim); }
.err { color: var(--danger); min-height: 1.5em; margin: 10px 0 0; font-size: .9rem; }

/* ---------- Accueil ---------- */
#login { height: 100%; overflow-y: auto; display: grid; place-items: center; padding: 24px; padding-top: max(24px, env(safe-area-inset-top)); }
.term { width: min(560px, 100%); }
.term h1 { font-size: clamp(1.7rem, 6.4vw, 2.6rem); line-height: 1.12; margin: 0 0 22px; letter-spacing: -0.03em; font-weight: 700; color: var(--ok); text-shadow: 0 0 22px rgba(61, 255, 140, .35); }
.cur { display: inline-block; width: .55em; height: 1.02em; margin-left: .12em; background: var(--ok); vertical-align: -0.14em; animation: blink 1.05s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.boot { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 4px; color: var(--muted); font-size: .88rem; }
.boot li { animation: line .35s ease both; }
.boot li:nth-child(1) { animation-delay: .15s; } .boot li:nth-child(2) { animation-delay: .4s; } .boot li:nth-child(3) { animation-delay: .65s; } .boot li:nth-child(4) { animation-delay: .9s; }
@keyframes line { from { opacity: 0; transform: translateX(-6px); } }
.tag-ok, .tag-warn { font-weight: 700; margin-right: 8px; }
.tag-ok { color: var(--ok); } .tag-warn { color: var(--pub); }
.term .row1 { display: flex; gap: 8px; }

/* ---------- Application ---------- */
#app { height: 100dvh; display: grid; grid-template-columns: clamp(240px, 25vw, 290px) minmax(0, 1fr); }
aside { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.brand { padding: 18px 18px 2px; font-weight: 700; font-size: 1.2rem; color: var(--ok); letter-spacing: -0.02em; text-shadow: 0 0 16px rgba(61, 255, 140, .3); }
.brand .cur { width: .5em; height: .95em; }
.me { padding: 2px 18px 14px; color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.me b { color: var(--text); font-weight: 600; }
.cap { padding: 6px 18px; color: var(--dim); font-size: .75rem; }
#roomList { list-style: none; margin: 0; padding: 0 10px; flex: 1; overflow-y: auto; }
#roomList li { display: flex; align-items: center; gap: 2px; margin-bottom: 2px; }
.room { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; background: none; border: 0; border-radius: 6px; padding: 0 10px; min-height: 42px; text-align: left; color: var(--muted); }
.room:hover { background: var(--panel2); color: var(--text); }
.room[aria-current="true"] { background: var(--ok-soft); color: var(--ok); box-shadow: inset 2px 0 0 var(--ok); }
.room .sig { color: var(--ok); flex: none; width: 1ch; text-align: center; }
.room.pub .sig { color: var(--pub); }
.room .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--ok); color: var(--ok-ink); border-radius: 4px; font-size: .72rem; font-weight: 700; padding: 0 6px; }
.x { background: none; border: 0; color: var(--dim); border-radius: 6px; width: 38px; height: 38px; font-size: 1.1rem; flex: none; }
.x:hover { background: var(--panel2); color: var(--danger); }
.side-actions { padding: 12px; display: grid; gap: 8px; border-top: 1px solid var(--line); }
.opt { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; padding: 2px 2px 4px; }
.opt input { width: 16px; height: 16px; accent-color: var(--ok); flex: none; }
.side-actions .btn { padding: 10px 14px; line-height: 1.35; }
.panic { color: var(--danger); border-color: #3b1d22; }
.panic:hover { border-color: var(--danger); background: rgba(255, 107, 107, .08); }

main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding-top: env(safe-area-inset-top); }
header { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
#menu { display: none; background: none; border: 1px solid var(--line); border-radius: 6px; width: 44px; height: 44px; flex: none; font-size: 1.1rem; }
.hd { min-width: 0; flex: 1; }
.hd h2 { margin: 0; font-size: 1rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd h2::before { content: "# "; color: var(--dim); }
.chip { display: block; font-size: .75rem; color: var(--ok); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.pub { color: var(--pub); }
.chip small { color: var(--muted); font-size: inherit; }
#membersBtn { flex: none; min-height: 40px; padding: 0 12px; border-radius: 6px; background: none; border: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
#membersBtn:hover { border-color: var(--dim); color: var(--text); }
#members { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); max-height: 30vh; overflow-y: auto; }
#members span { border: 1px solid var(--line); border-radius: 4px; padding: 0 9px; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }

#msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; transition: filter .15s; }
#msgs.veil { filter: blur(10px); }
.empty { margin: auto; color: var(--muted); text-align: center; max-width: 40ch; font-size: .9rem; }
.line { display: flex; gap: 10px; align-items: baseline; animation: line .25s ease both; }
.line time { flex: none; color: var(--dim); font-size: .75rem; }
.line .body { min-width: 0; overflow-wrap: anywhere; }
.line .nick { font-weight: 700; }
.line.mine .nick { color: var(--ok); }
.line .tg { color: var(--dim); font-size: .78rem; }
.line .co { color: var(--dim); margin: 0 7px 0 4px; }
.line .bubble { white-space: pre-wrap; }
.line.mine .bubble { color: #e9fff1; }
.line.bad .bubble { color: var(--danger); font-style: italic; }
.sys { color: var(--dim); font-size: .8rem; padding: 3px 0; }
.compose { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.compose .ps { max-width: 28vw; overflow: hidden; text-overflow: ellipsis; }

dialog { background: #08110c; color: var(--text); border: 1px solid var(--dim); border-radius: 8px; padding: 22px; width: min(440px, calc(100% - 28px)); margin: auto; box-shadow: 0 0 60px rgba(61, 255, 140, .08); font-family: var(--mono); }
dialog::backdrop { background: rgba(2, 5, 3, .78); }
dialog h3 { margin: 0 0 8px; font-size: 1.05rem; color: var(--ok); }
dialog p { margin: 0 0 14px; color: var(--muted); font-size: .85rem; }
dialog label { display: block; font-size: .8rem; color: var(--muted); margin: 12px 0 5px; }
dialog input { width: 100%; background: rgba(4, 10, 7, .9); border: 1px solid var(--line); border-radius: 6px; padding: 12px; caret-color: var(--ok); }
dialog input:focus { border-color: var(--ok); outline: 0; box-shadow: 0 0 0 3px var(--ok-soft); }
.row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #14100a; border: 1px solid var(--pub); color: var(--pub); padding: 8px 14px; border-radius: 6px; font-size: .85rem; max-width: calc(100% - 28px); z-index: 60; }
#scrim { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  aside { position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 330px); z-index: 30; transform: translateX(-102%); transition: transform .2s ease; background: #08110c; }
  #app.open aside { transform: none; }
  #app.open #scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(2, 5, 3, .75); }
  #menu { display: block; }
  #msgs { padding: 12px; }
  header, .compose, #members { padding-left: 12px; padding-right: 12px; }
  .line { gap: 8px; }
}
@media (max-width: 480px) {
  .compose .ps .who { display: none; }
  .line time { font-size: .7rem; }
  .term .row1 { flex-direction: column; }
}
@media (max-width: 380px) { .btn.send { padding: 0 12px; } #membersBtn { padding: 0 9px; } }
@media (max-height: 480px) and (orientation: landscape) { header { padding-top: 5px; padding-bottom: 5px; } .compose { padding-top: 8px; } .term h1 { margin-bottom: 12px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
