/* My Gentleman — thème nuit, prune & champagne */
:root {
  --bg: #1b1320;
  --surface: #241a2b;
  --card: #2e2236;
  --line: #3d2f46;
  --text: #f3ece4;
  --muted: #a99bb0;
  --accent: #e7c27d;
  --accent-ink: #2a1c10;
  --wine: #7a2e4d;
  --wine-2: #8f3a5c;
  --in: #30243a;
  --danger: #e06c6c;
  --ok: #7fc8a0;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: .01em; }
h2 { font-size: 1.1rem; margin: 1.4em 0 .4em; }
.muted { color: var(--muted); }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.brand { font-family: var(--serif); color: var(--text); font-size: 1.25rem; }
.brand em { color: var(--accent); }
.brand small { font: 600 .65rem/1 var(--font); text-transform: uppercase; letter-spacing: .15em; color: var(--muted); margin-left: .4em; }
.brand--lg { font-size: 2.2rem; display: block; text-align: center; margin: 8vh 0 1.5rem; }

/* --- Formulaires & boutons --- */
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; margin-top: .3rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .9rem; }
label.check { display: flex; gap: .6rem; align-items: flex-start; color: var(--text); }
label.check input { width: auto; margin-top: .2rem; accent-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  font: 600 .95rem var(--font); padding: .75rem 1.2rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
}
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--ghost { background: transparent; }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { padding: .35rem .8rem; font-size: .8rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; margin-bottom: 1rem; }
.form h1 { margin-top: 0; }
.form .btn { width: 100%; margin-top: .4rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.stack { display: grid; gap: .7rem; margin: 2rem 0; }
.error { color: var(--danger); margin: .3rem 0 .8rem; }
.flash { padding: .8rem 1rem; border-radius: 10px; margin: 0 0 1rem; background: var(--card); border-left: 3px solid var(--accent); }
.flash--error { border-left-color: var(--danger); }
.danger h2 { color: var(--danger); margin-top: 0; }
details summary { cursor: pointer; color: var(--accent); margin-bottom: .8rem; }

/* --- Pages publiques --- */
.public__main { max-width: 440px; margin: 0 auto; padding: 1rem 1.2rem 3rem; }
.welcome { text-align: center; }
.welcome__lead { font-family: var(--serif); font-size: 1.6rem; line-height: 1.3; }

/* --- Application --- */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.2rem; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar__admin { font-size: .8rem; border: 1px solid var(--line); padding: .25rem .7rem; border-radius: 999px; }
.app__main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem calc(90px + var(--safe-b)); }
.page-title { font-size: 1.6rem; margin: .3rem 0 1rem; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: space-around; padding: .5rem 0 calc(.5rem + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line); }
.tabbar a { display: grid; justify-items: center; gap: 2px; font-size: .72rem; color: var(--muted); min-width: 80px; }
.tabbar a.is-active { color: var(--accent); }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

.avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex: none; background: var(--wine); }
.avatar--sm { width: 36px; height: 36px; }
.avatar--xl { width: 120px; height: 120px; }
.avatar--initial { display: inline-grid; place-items: center; font: 600 1.2rem var(--serif); color: var(--accent); }

/* Liste des discussions */
.inbox { list-style: none; margin: 0; padding: 0; }
.inbox__item { display: flex; gap: .9rem; align-items: center; padding: .75rem .3rem; color: var(--text); border-bottom: 1px solid var(--line); }
.inbox__body { flex: 1; min-width: 0; }
.inbox__top, .inbox__bottom { display: flex; justify-content: space-between; gap: .6rem; align-items: center; }
.inbox__top time { font-size: .75rem; color: var(--muted); }
.inbox__preview { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox__preview.is-typing { color: var(--ok); font-style: italic; }
.badge { background: var(--accent); color: var(--accent-ink); font: 700 .72rem/1 var(--font); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; }

/* Catalogue */
.filters { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.filters select, .filters input { margin: 0; padding: .55rem .6rem; font-size: .88rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; }
.profile-card { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3/4; background: var(--card); color: var(--text); }
.profile-card__photo, .profile-card__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.profile-card__img.avatar--initial { font-size: 4rem; }
.profile-card__info { position: absolute; inset: auto 0 0 0; padding: 2.5rem .8rem .8rem; display: grid; gap: .15rem; background: linear-gradient(transparent, rgba(15,8,18,.92)); font-size: .82rem; }
.profile-card__info strong { font: 600 1.1rem var(--serif); }
.chip { display: inline-block; justify-self: start; font-size: .72rem; padding: .2rem .55rem; border-radius: 999px; background: var(--wine); color: var(--text); margin-right: .3rem; }
.chip--soft { background: var(--card); color: var(--muted); }

/* Fiche */
.persona { margin: -1rem -1rem 0; }
.persona__hero { aspect-ratio: 4/5; max-height: 70vh; overflow: hidden; background: var(--card); }
.persona__img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.persona__img.avatar--initial { display: grid; font-size: 6rem; }
.persona__body { padding: 0 1.2rem; }
.persona__body h1 { margin: 1rem 0 .2rem; font-size: 2rem; }
.persona__tagline { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 1.1rem; margin-top: 0; }
.persona form { margin: 1rem 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 1.5rem 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }

/* --- Chat --- */
.chatpage { overflow: hidden; }
.chat { display: flex; flex-direction: column; height: 100dvh; max-width: 900px; margin: 0 auto; background:
  radial-gradient(circle at 20% 10%, rgba(122,46,77,.18), transparent 40%),
  radial-gradient(circle at 80% 90%, rgba(231,194,125,.07), transparent 40%), var(--bg); }
.chat__head { display: flex; align-items: center; gap: .4rem; padding: .55rem .6rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.chat__back svg { width: 28px; height: 28px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.chat__who { display: flex; gap: .7rem; align-items: center; flex: 1; color: var(--text); min-width: 0; }
.chat__who .avatar { width: 42px; height: 42px; }
.chat__who span { display: grid; min-width: 0; }
.chat__who small { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat__who small.is-live { color: var(--ok); }
.chat__menu { position: relative; }
.chat__menu summary { list-style: none; font-size: 1.5rem; padding: 0 .6rem; color: var(--muted); margin: 0; }
.chat__menu summary::-webkit-details-marker { display: none; }
.chat__menu form { position: absolute; right: 0; top: 2.2rem; z-index: 3; }
.chat__menu button { white-space: nowrap; background: var(--card); color: var(--danger); border: 1px solid var(--line); padding: .7rem 1rem; border-radius: 10px; font: inherit; cursor: pointer; }
.chat__scroll { flex: 1; overflow-y: auto; padding: .8rem .7rem 1rem; display: flex; flex-direction: column; overscroll-behavior: contain; }
.chat__notice { align-self: center; max-width: 340px; text-align: center; font-size: .75rem; color: var(--muted); background: rgba(231,194,125,.07); border: 1px solid rgba(231,194,125,.15); border-radius: 10px; padding: .5rem .8rem; margin-bottom: 1rem; }
#list { display: flex; flex-direction: column; gap: 3px; }
.day { align-self: center; font-size: .74rem; color: var(--muted); background: var(--surface); padding: .25rem .7rem; border-radius: 8px; margin: .8rem 0 .4rem; text-transform: capitalize; }
.bubble { position: relative; max-width: min(78%, 520px); padding: .45rem .6rem .35rem; border-radius: 12px; word-wrap: break-word; animation: pop .18s ease-out; }
.bubble p { margin: 0; white-space: normal; }
.bubble p a { color: inherit; text-decoration: underline; }
.bubble--in { align-self: flex-start; background: var(--in); border-top-left-radius: 4px; }
.bubble--out { align-self: flex-end; background: var(--wine); border-top-right-radius: 4px; }
.bubble--in + .bubble--out, .bubble--out + .bubble--in, .day + .bubble { margin-top: 6px; }
.bubble img { display: block; width: 100%; max-width: 280px; max-height: 360px; object-fit: cover; border-radius: 8px; margin-bottom: .3rem; cursor: zoom-in; }
.bubble--photo { padding: 3px; }
.bubble--photo .meta { position: absolute; right: 8px; bottom: 6px; background: rgba(0,0,0,.45); padding: 0 5px; border-radius: 6px; }
.meta { float: right; display: inline-flex; align-items: center; gap: 3px; font-size: .68rem; color: rgba(243,236,228,.6); margin: .35rem 0 -.1rem .7rem; }
.tick { width: 15px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tick--read { stroke: var(--accent); }
.is-pending { opacity: .7; }
.is-failed { outline: 1px solid var(--danger); }
.fail { color: #ffb3b3; }
.typing { display: inline-flex; gap: 4px; padding: .7rem .8rem; margin-top: 6px; }
.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: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

.composer { display: flex; align-items: flex-end; gap: .45rem; padding: .5rem .6rem calc(.5rem + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line); }
.composer__photo, .composer__send { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; border: 0; }
.composer__photo { color: var(--muted); background: transparent; margin: 0; }
.composer__photo svg, .composer__send svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.composer__send { background: var(--accent); color: var(--accent-ink); }
.composer__send svg { fill: currentColor; stroke: none; }
.composer__field { flex: 1; background: var(--card); border-radius: 22px; padding: 0 .3rem; }
.composer textarea { border: 0; background: transparent; margin: 0; resize: none; padding: .65rem .7rem; max-height: 140px; line-height: 1.35; }
.composer textarea:focus { outline: none; }
.composer__preview { position: relative; padding: .5rem .5rem 0; }
.composer__preview img { max-height: 120px; border-radius: 10px; display: block; }
.composer__preview button { position: absolute; top: .6rem; left: .6rem; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
.lightbox { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.92); display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; }
.lightbox[hidden], [hidden] { display: none !important; }

/* --- Admin --- */
.admin { background: #160f1a; }
.admin__bar { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; padding: .9rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.admin__bar nav { display: flex; gap: .3rem; flex-wrap: wrap; }
.admin__bar nav a { color: var(--muted); padding: .4rem .8rem; border-radius: 8px; font-size: .9rem; }
.admin__bar nav a.is-active { background: var(--card); color: var(--text); }
.admin__main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; margin: 0 0 1.2rem; }
fieldset.panel legend { font: 600 1rem var(--serif); color: var(--accent); padding: 0 .4rem; }
.panel h2 { margin-top: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 1rem; }
.fields .wide { grid-column: 1 / -1; }
.help { display: block; color: var(--muted); font-size: .78rem; margin: -.6rem 0 1rem; }
.sticky-actions { position: sticky; bottom: 0; padding: 1rem 0; background: linear-gradient(transparent, #160f1a 40%); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: grid; }
.stat b { font: 600 1.8rem var(--serif); color: var(--accent); }
.stat span { color: var(--muted); font-size: .85rem; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; font-size: .8rem; }
.table tr.is-off { opacity: .5; }
.table form { margin: 0; }
.conn { color: var(--muted); font-size: .9rem; }
.photo-row { display: flex; gap: 1.2rem; align-items: center; }
.gen-form { display: grid; grid-template-columns: 1fr 100px auto auto; gap: .8rem; align-items: end; }
.gen-form .wide { margin: 0; } .gen-form label { margin: 0; } .gen-form .check { align-self: center; }
.admin-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; margin-top: 1rem; }
.admin-gallery figure { margin: 0; background: var(--card); border-radius: 10px; overflow: hidden; border: 2px solid transparent; }
.admin-gallery figure.is-main { border-color: var(--accent); }
.admin-gallery img, .admin-gallery .ph { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: grid; place-items: center; color: var(--muted); }
.ph--err { color: var(--danger) !important; }
.admin-gallery figcaption { display: flex; gap: .3rem; padding: .4rem; }

@media (max-width: 640px) {
  .filters { grid-template-columns: 1fr 1fr; } .filters input { grid-column: 1 / -1; }
  .gen-form { grid-template-columns: 1fr; }
  .admin__main { padding: 1rem; }
  .table { display: block; overflow-x: auto; }
}
@media (min-width: 900px) { .chat { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
