:root {
  --bg: #08070c;
  --surface: #110f18;
  --surface-2: #17141f;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .12);
  --text: #ecebf2;
  --muted: #8d899c;
  --accent: #5b21b6;
  --accent-hover: #4c1d95;
  --accent-light: #a78bfa;
  --accent-soft: rgba(91, 33, 182, .18);
  --danger: #f4a3b4;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- Éléments communs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  height: 42px; padding: 0 1.1rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: transparent; cursor: pointer; font-weight: 500; font-size: .95rem; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-icon { width: 42px; padding: 0; }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }

.input {
  width: 100%; height: 44px; padding: 0 .9rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent-light); box-shadow: 0 0 0 3px var(--accent-soft); }

.logo { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.logo-mark .icon { width: 16px; height: 16px; }
.accent { color: var(--accent-light); }
.error { color: var(--danger); font-size: .88rem; min-height: 1.3em; }
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent-light);
  display: grid; place-items: center; font-weight: 600; text-transform: uppercase;
}
.avatar.sm { width: 30px; height: 30px; font-size: .8rem; }

.header {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  height: 64px; padding: 0 clamp(1rem, 4vw, 2.5rem); background: rgba(8, 7, 12, .8); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

/* --- Accueil */
.hero { position: relative; text-align: center; padding: clamp(5rem, 14vh, 9rem) 1rem 4rem; }
.hero::before { /* halo discret derrière le titre */
  content: ""; position: absolute; inset: 0 0 auto; height: 520px; pointer-events: none;
  background: radial-gradient(ellipse 50% 60% at 50% 0%, rgba(91, 33, 182, .28), transparent 70%);
}
.hero > * { position: relative; }
.badge { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--muted); font-size: .82rem; }
.badge .icon { width: 14px; height: 14px; color: var(--accent-light); }
.hero h1 { font-size: clamp(2.3rem, 6vw, 4rem); line-height: 1.08; letter-spacing: -.04em; font-weight: 700; max-width: 16ch; margin: 1.4rem auto 1.2rem; }
.hero p { color: var(--muted); font-size: clamp(1rem, 1.8vw, 1.12rem); max-width: 52ch; margin: 0 auto 2rem; }
.cta { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }

/* Aperçu de l'interface */
.preview { max-width: 640px; margin: 4.5rem auto 0; text-align: left; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.preview-head { display: flex; align-items: center; gap: .7rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .92rem; }
.preview-head .dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; margin-left: auto; }
.preview-body { display: flex; flex-direction: column; gap: .5rem; padding: 1.2rem; }

.section { max-width: 1040px; margin: 0 auto; padding: 5rem 1rem; }
.section h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); letter-spacing: -.03em; font-weight: 700; text-align: center; margin-bottom: .5rem; }
.section > p { text-align: center; color: var(--muted); margin-bottom: 3rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem; transition: border-color .2s; }
.card:hover { border-color: var(--border-strong); }
.card .card-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-light); margin-bottom: 1rem; }
.card h3 { font-size: 1.02rem; font-weight: 600; margin-bottom: .3rem; }
.card p { color: var(--muted); font-size: .94rem; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; max-width: 1040px; margin: 0 auto; color: var(--muted); padding: 2rem 1rem; border-top: 1px solid var(--border); font-size: .88rem; }

/* --- Pop-up connexion / inscription */
dialog {
  border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); color: var(--text);
  padding: 0; width: min(400px, calc(100% - 2rem)); margin: auto; box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(4, 3, 8, .75); backdrop-filter: blur(4px); }
dialog[open] { animation: pop .2s ease-out; }
.dialog-inner { position: relative; padding: 1.8rem; }
.dialog-inner h2 { font-size: 1.3rem; letter-spacing: -.02em; font-weight: 600; }
.dialog-inner .sub { color: var(--muted); margin: .2rem 0 1.4rem; font-size: .92rem; }
.close { position: absolute; top: .9rem; right: .9rem; width: 34px; height: 34px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin-bottom: 1.3rem; }
.tabs button { border: 0; background: none; height: 36px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; transition: background .15s, color .15s; }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.form { display: grid; gap: .9rem; }
.form label span { display: block; font-size: .83rem; color: var(--muted); margin-bottom: .35rem; }

/* --- Discussions */
.app-body { display: flex; flex-direction: column; height: 100dvh; }
.me { display: flex; align-items: center; gap: .6rem; font-weight: 500; font-size: .92rem; }
.app { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(260px, 330px) 1fr; }
.sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.sidebar h1 { font-size: 1rem; font-weight: 600; padding: 1.2rem 1.1rem .5rem; }
.new-conv { display: flex; gap: .5rem; padding: .4rem 1rem 0; }
.sidebar .error { padding: .3rem 1.1rem; }
.conv-list { list-style: none; padding: 0 .5rem 1rem; overflow-y: auto; flex: 1; }
.conv { display: flex; gap: .75rem; align-items: center; width: 100%; padding: .65rem; border: 0; border-radius: 10px; background: none; cursor: pointer; text-align: left; transition: background .15s; }
.conv:hover { background: var(--surface); }
.conv.active { background: var(--surface-2); }
.conv-meta { min-width: 0; flex: 1; display: grid; }
.conv-name { font-weight: 500; }
.conv-last { color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { color: var(--muted); font-size: .74rem; align-self: flex-start; }
.hint { color: var(--muted); padding: 1rem 1.1rem; font-size: .9rem; }

.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: .7rem; height: 60px; padding: 0 1.1rem; border-bottom: 1px solid var(--border); font-weight: 600; }
.messages { flex: 1; overflow-y: auto; padding: 1.2rem; display: flex; flex-direction: column; gap: .4rem; }
.msg { max-width: min(75%, 540px); padding: .55rem .85rem; border-radius: 14px 14px 14px 4px; background: var(--surface-2); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; animation: rise .15s ease-out; }
.msg.mine { align-self: flex-end; background: var(--accent); color: #fff; border-radius: 14px 14px 4px 14px; }
.msg time { display: block; font-size: .68rem; opacity: .6; margin-top: .1rem; text-align: right; }
.composer { display: flex; gap: .5rem; padding: .9rem 1rem; border-top: 1px solid var(--border); }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 2rem; font-size: .95rem; }
.empty .logo-mark { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 1rem; }
.empty .logo-mark .icon { width: 24px; height: 24px; }
.back { display: none; }
[hidden] { display: none !important; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .app.open .sidebar, .app:not(.open) .chat { display: none; }
  .back { display: inline-flex; }
  .me .name, .me .label, .composer .label { display: none; }
  .me .btn { width: 42px; padding: 0; }
  .composer .btn { width: 44px; padding: 0; }
}

@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
