:root {
    --wall: #08080a; --surface: #141418; --ink: #f4f4f6; --muted: #8d8d96;
    --cream: #ffffff; --brass: #3a3a44; --brass-dark: #26262e; --line: #26262e;
    --ok: #8fd4a0; --err: #ff8a7a;
  }
  
  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body { margin: 0; background: var(--wall); color: var(--ink); font-family: "Instrument Sans", system-ui, sans-serif; font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
  a { color: inherit; }
  button, input, textarea { font: inherit; }

  header { position: absolute; inset: 0 0 auto 0; display: flex; justify-content: space-between; align-items: center; padding: 22px 28px; z-index: 2; }
  .brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
  .brand img { height: 30px; width: auto; opacity: .9; }
  .brand span { font-size: 17px; font-weight: 600; letter-spacing: .01em; color: var(--ink); }
  .user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
  .user img { width: 26px; height: 26px; border-radius: 50%; }
  .user button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; }
  .user button:hover { color: var(--ink); }

  /* --- la salle --- */
  .room { min-height: 100svh; display: grid; place-items: center; padding: 96px 16px 56px; position: relative; overflow: hidden; }
  .halo { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
  .halo i { position: absolute; width: 60vmin; height: 60vmin; border-radius: 50%; filter: blur(90px); opacity: .55; mix-blend-mode: screen; }
  .halo i:nth-child(1) { background: #5b3df5; left: 18%; top: 14%; }
  .halo i:nth-child(2) { background: #0ea5c7; left: 52%; top: 10%; }
  .halo i:nth-child(3) { background: #d9338f; left: 36%; top: 36%; width: 50vmin; height: 50vmin; }
  .halo i:nth-child(4) { background: #ff9f43; left: 62%; top: 42%; width: 36vmin; height: 36vmin; opacity: .35; }
  .halo::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, transparent 30%, var(--wall) 78%); }
  .piece { position: relative; width: min(900px, 100%); text-align: center; }
  .frame { display: inline-block; padding: 6px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.22); border-radius: 6px;
    backdrop-filter: blur(6px); box-shadow: 0 40px 100px rgba(0,0,0,.75); }
  .frame .mat { padding: 0; background: transparent; border-radius: 3px; overflow: hidden; }
  .frame img { display: block; width: 100%; max-height: 72svh; height: auto; object-fit: contain; background: #111114; min-height: 200px; }
  .frame img:not([src]), .frame img[src=""] { visibility: hidden; }
  .plaque { display: inline-block; margin-top: 30px; padding: 12px 22px; min-width: 240px; max-width: 380px;
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); color: var(--ink); border-radius: 8px; backdrop-filter: blur(8px); }
  .plaque .t { font-size: 20px; font-weight: 600; letter-spacing: -.01em; min-height: 28px; }
  .plaque .t:empty::before { content: "Sans titre"; font-weight: 400; opacity: .5; }
  .plaque .r { font-size: 13.5px; margin-top: 2px; color: var(--muted); }
  .plaque .r span:empty::before { content: "—"; }
  .hint { margin-top: 46px; color: var(--muted); font-size: 13px; }
  .hint a { text-decoration: none; border-bottom: 1px solid #3a3a44; padding-bottom: 2px; }
  .hint a:hover { color: var(--ink); }

  /* --- la réponse --- */
  .answer { max-width: 560px; margin: 0 auto; padding: 72px 20px 56px; }
  h1 { font-weight: 600; font-size: clamp(32px, 5vw, 44px); line-height: 1.08; margin: 0 0 14px; letter-spacing: -.025em; }
  .lead { color: var(--muted); margin: 0 0 36px; max-width: 46ch; }
  form { display: flex; flex-direction: column; gap: 16px; }
  label { display: block; font-weight: 600; margin-bottom: 10px; }
  .field { display: flex; gap: 12px; }
  .field input { flex: 1; min-width: 0; background: var(--surface); border: 1px solid #2e2e38; border-radius: 10px; color: var(--ink); font-size: 18px; padding: 14px 16px; }
  .field input::placeholder { color: #5c5c66; }
  .field input:focus { border-color: #fff; outline: 0; box-shadow: 0 0 0 4px rgba(255,255,255,.08); }
  .btn { padding: 14px 22px; }
  .btn { background: #fff; color: #0a0a0c; border: 0; padding: 12px 20px; border-radius: 10px; font-weight: 600; cursor: pointer; white-space: nowrap; }
  .btn:hover { background: #e9e9ee; }
  .btn:disabled { opacity: .5; cursor: default; }
  .btn.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
  .btn.quiet:hover { border-color: var(--muted); background: transparent; }
  :focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
  textarea { width: 100%; min-height: 200px; resize: vertical; background: var(--surface); color: var(--ink); border: 1px solid #2e2e38; border-radius: 10px; padding: 14px 16px; line-height: 1.6; }
  textarea:focus { border-color: #fff; outline: 0; }
  .msg { padding: 14px 16px; border-left: 2px solid var(--line); color: var(--ink); background: rgba(255,255,255,.025); }
  .msg.ok { border-left-color: var(--ok); }
  .msg.err { border-left-color: var(--err); }
  .meta { font-size: 13px; color: var(--muted); margin: 28px 0 0; }
  .hidden { display: none; }
  .google { display: inline-flex; align-items: center; gap: 12px; }
  .google svg { width: 18px; height: 18px; }

  /* --- administration --- */
  .admin { max-width: 760px; margin: 0 auto; padding: 0 20px 120px; border-top: 1px solid var(--line); }
  .admin h2 { font-weight: 600; font-size: 24px; margin: 48px 0 18px; }
  .admin form { margin-bottom: 36px; }
  .admin .field input { font-family: "Instrument Sans", sans-serif; font-size: 16px; }
  .sol { border-top: 1px solid var(--line); padding: 18px 0; white-space: pre-wrap; }
  .sol b { display: block; margin-bottom: 8px; font-weight: 600; }
  .sol .btn { margin-top: 12px; }

  @media (prefers-reduced-motion: no-preference) {
    .halo i { animation: drift 22s ease-in-out infinite alternate; }
    .halo i:nth-child(2) { animation-duration: 27s; animation-delay: -8s; }
    .halo i:nth-child(3) { animation-duration: 31s; animation-delay: -15s; }
    .halo i:nth-child(4) { animation-duration: 19s; animation-delay: -4s; }
    @keyframes drift { from { transform: translate(-6%, -4%) scale(1); } to { transform: translate(8%, 6%) scale(1.15); } }
  }

  /* --- menu --- */
  .burger { background: none; border: 0; cursor: pointer; padding: 8px; margin-left: 6px; color: var(--ink); display: inline-flex; }
  .burger svg { width: 24px; height: 24px; }
  .menu { position: fixed; inset: 0; background: var(--wall); z-index: 20; display: none; flex-direction: column; justify-content: center; padding: 40px 28px; }
  .menu.open { display: flex; }
  .menu nav { max-width: 560px; margin: 0 auto; width: 100%; }
  .menu a { display: block; font-weight: 600; letter-spacing: -.02em; font-size: clamp(30px, 6vw, 44px); line-height: 1.25; text-decoration: none; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .menu a { color: var(--muted); }
  .menu a:hover, .menu a[aria-current] { color: var(--ink); }
  .menu .close { position: absolute; top: 18px; right: 22px; }
  .menu .who { color: var(--muted); font-size: 14px; margin-top: 22px; }
  body.menu-open { overflow: hidden; }

  /* --- pages secondaires --- */
  .page { max-width: 680px; margin: 0 auto; padding: 120px 20px 120px; }
  .page h1 { margin-bottom: 8px; }
  .page .sub { color: var(--muted); margin: 0 0 40px; }
  .page h2 { font-weight: 600; font-size: 22px; margin: 40px 0 10px; letter-spacing: -.01em; }
  .page p, .page li { color: #c4c4cc; max-width: 68ch; }
  .page ul { padding-left: 20px; }
  .page details { border-top: 1px solid var(--line); padding: 16px 0; }
  .page details:last-of-type { border-bottom: 1px solid var(--line); }
  .page summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
  .page summary::-webkit-details-marker { display: none; }
  .page summary::after { content: "+"; color: var(--muted); font-size: 20px; line-height: 1; }
  .page details[open] summary::after { content: "–"; }
  .page details p { margin: 12px 0 0; }
  .kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 20px; margin: 24px 0; }
  .kv dt { color: var(--muted); }
  .kv dd { margin: 0; }
  .danger { border: 1px solid #5a3a36; border-radius: 4px; padding: 18px; margin-top: 48px; }
  .danger .btn { border-color: var(--err); color: var(--err); background: transparent; }
  footer { max-width: 680px; margin: 0 auto; padding: 0 20px 48px; color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; text-align: center; }
  footer a { text-decoration: none; }
  footer a:hover { color: var(--ink); }

  /* --- connexion e-mail --- */
  .or { color: var(--muted); font-size: 14px; margin: 22px 0 12px; }
  .stack { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
  .stack input { background: var(--surface); border: 1px solid #2e2e38; border-radius: 10px; color: var(--ink); font-size: 16px; padding: 13px 15px; }
  .stack input:focus { border-color: #fff; outline: 0; box-shadow: 0 0 0 4px rgba(255,255,255,.08); }
  .stack input::placeholder { color: #5c5c66; }
  .tabs { display: flex; gap: 4px; background: var(--surface); border-radius: 10px; padding: 4px; margin-bottom: 4px; }
  .tab { flex: 1; background: transparent; border: 0; color: var(--muted); padding: 9px; border-radius: 7px; cursor: pointer; font-weight: 500; }
  .tab.active { background: #fff; color: #0a0a0c; font-weight: 600; }
  .row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 4px; }
  .linkish { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
  .linkish:hover { color: var(--ink); }

  .plaque .e { font-size: 12px; color: var(--muted); letter-spacing: .02em; margin-bottom: 2px; }
  .story { white-space: pre-wrap; color: #d6d6dc; font-size: 17px; line-height: 1.7; max-width: 62ch; border-left: 2px solid #2e2e38; padding-left: 20px; }
  select { background: var(--surface); border: 1px solid #2e2e38; border-radius: 10px; color: var(--ink); font-size: 16px; padding: 13px 15px; }
  /* --- archives --- */
  .editions { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 32px; }
  .ed { display: block; text-decoration: none; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
  .ed img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; filter: saturate(.85); }
  .ed.open img { filter: none; }
  .ed .b { padding: 14px 16px; }
  .ed .n { font-weight: 600; font-size: 17px; }
  .ed .s { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
  .ed:hover { border-color: #4a4a56; }
  .ed.soon { border-style: dashed; display: grid; place-items: center; min-height: 220px; color: var(--muted); }

  /* --- indices (fil) --- */
  .feed { max-width: 560px; margin: 0 auto; padding: 0 20px 100px; }
  .feed h2 { font-weight: 600; font-size: 20px; margin: 0 0 18px; letter-spacing: -.01em; }
  .post { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); }
  .post time { color: var(--muted); font-size: 12.5px; padding-top: 4px; font-variant-numeric: tabular-nums; }
  .post p { margin: 0; color: #d6d6dc; white-space: pre-wrap; line-height: 1.6; }
  .next { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 14px; margin: 0; }
  @media (max-width: 640px) { .post { grid-template-columns: 52px 1fr; gap: 10px; } }

  /* --- capsule de réponse + bouton verre --- */
  .capsule { display: flex; align-items: stretch; padding: 6px; border-radius: 999px; background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 20px 50px rgba(0,0,0,.45); transition: border-color .2s, box-shadow .2s; }
  .capsule:focus-within { border-color: rgba(255,255,255,.35); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 0 0 5px rgba(255,255,255,.06), 0 20px 50px rgba(0,0,0,.45); }
  .capsule input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--ink); font-size: 19px; padding: 12px 18px; }
  .capsule input::placeholder { color: #6a6a74; }
  .glass { position: relative; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; padding: 12px 24px; font-weight: 600; color: #fff; cursor: pointer; white-space: nowrap;
    background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,.10)); backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 -1px 0 rgba(0,0,0,.25), 0 8px 24px rgba(0,0,0,.35); transition: transform .15s, background .2s; }
  .glass::before { content: ""; position: absolute; inset: 1px; border-radius: inherit; background: radial-gradient(120% 80% at 30% 0%, rgba(255,255,255,.35), transparent 60%); pointer-events: none; }
  .glass:hover { background: linear-gradient(180deg, rgba(255,255,255,.38), rgba(255,255,255,.16)); }
  .glass:active { transform: scale(.98); }
  .glass:disabled { opacity: .5; cursor: default; }
  #who:empty { display: none; }

  /* --- dialog de connexion --- */
  dialog { border: 1px solid rgba(255,255,255,.12); border-radius: 18px; background: #121216; color: var(--ink); padding: 0; width: min(420px, calc(100% - 32px)); box-shadow: 0 40px 100px rgba(0,0,0,.7); }
  dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(6px); }
  .dlg { padding: 28px 28px 0; position: relative; display: flex; flex-direction: column; gap: 12px; margin: 0; }
  .dlg h3 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
  .dlg .btn { width: 100%; justify-content: center; }
  .dlg .or { margin: 10px 0 0; }
  .dlg-body { padding: 10px 28px 28px; max-width: none; }
  .dlg-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.06); color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
  .dlg-close:hover { color: var(--ink); background: rgba(255,255,255,.12); }

  /* --- zoom / visionneuse --- */
  button.frame { cursor: zoom-in; font: inherit; color: inherit; text-align: inherit; }
  .zoom-hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
  .viewer { position: fixed; inset: 0; background: #000; z-index: 30; display: none; flex-direction: column; }
  .viewer.open { display: flex; }
  .viewer-stage { flex: 1; overflow: hidden; display: grid; place-items: center; touch-action: none; cursor: grab; }
  .viewer-stage:active { cursor: grabbing; }
  .viewer-stage img { max-width: 100%; max-height: 100%; transform-origin: center center; will-change: transform; user-select: none; -webkit-user-drag: none; }
  .viewer-close { position: absolute; top: 14px; right: 14px; z-index: 2; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; backdrop-filter: blur(8px); }
  .viewer-help { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 12.5px; margin: 0; pointer-events: none; }

  /* --- essai raté : ligne rouge + compte à rebours --- */
  .tried .line { height: 2px; background: linear-gradient(90deg, var(--err), transparent); border-radius: 2px; margin-bottom: 14px; }
  .tried p { margin: 0; }
  .tried .count { color: var(--muted); font-size: 14px; margin-top: 6px; }
  .tried .count b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
  @media (prefers-reduced-motion: no-preference) {
    .shake { animation: shake .45s cubic-bezier(.36,.07,.19,.97) both; }
    @keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }
  }

  /* --- enveloppe --- */
  .envelope { position: fixed; z-index: 25; pointer-events: none; display: none; }
  .envelope[aria-hidden="false"] { display: block; }
  .env-body { position: absolute; inset: 0; border-radius: 999px; background: #f4f1ea; color: #1a1a1c; display: flex; align-items: center; justify-content: center; gap: 12px;
    font-weight: 500; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.6); transition: border-radius .35s, transform .35s, inset .35s; }
  .env-body::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 50%; background: linear-gradient(180deg, #e9e4d8, #f4f1ea); clip-path: polygon(0 0, 100% 0, 50% 100%); opacity: 0; transition: opacity .3s; }
  .env-text { max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: opacity .25s; }
  .env-stamp { position: absolute; right: 14px; bottom: 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: #b8322a; border: 2px solid #b8322a; border-radius: 4px; padding: 2px 6px; transform: rotate(-8deg) scale(0); transition: transform .3s cubic-bezier(.2,1.6,.4,1); }
  .envelope.fold .env-body { border-radius: 8px; inset: 10% 20%; }
  .envelope.fold .env-body::after { opacity: 1; }
  .envelope.fold .env-text { opacity: .35; }
  .envelope.fly { transition: transform .7s cubic-bezier(.4,0,.2,1), opacity .3s .5s; transform: translate(var(--dx), var(--dy)) scale(.5); opacity: 0; }
  .envelope.stamped { opacity: 1; transition: none; transform: translate(var(--dx), var(--dy)) scale(.7); }
  .envelope.stamped .env-stamp { transform: rotate(-8deg) scale(1); }
  .envelope.back { transition: transform .65s cubic-bezier(.2,.8,.3,1); transform: translate(0, 0) scale(1); }

  /* --- bonne réponse : la salle s'éclaire, la plaque se grave --- */
  .flash { position: fixed; inset: 0; z-index: 24; background: #fff; opacity: 0; pointer-events: none; transition: opacity .9s ease; }
  .flash.on { opacity: 1; }
  .plaque.engrave .t { animation: engrave 1.2s ease-out both; }
  @keyframes engrave { from { letter-spacing: .4em; opacity: 0; filter: blur(4px); } to { letter-spacing: -.01em; opacity: 1; filter: none; } }

  /* ===== mobile (toujours en dernier) ===== */
  @media (max-width: 640px) {
    body { font-size: 15.5px; }
    header { padding: 14px 12px 14px 16px; }
    .brand span { display: none; }
    .user span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .room { padding: 72px 12px 40px; min-height: auto; }
    .frame { padding: 4px; }
    .frame img { max-height: 62svh; }
    .halo i { filter: blur(60px); width: 70vmin; height: 70vmin; }
    .viewer-help { display: none; }
    .plaque { margin-top: 22px; min-width: 0; width: 100%; padding: 10px 16px; }
    .plaque .t { font-size: 18px; }
    .hint { margin-top: 28px; }
    .answer { padding: 48px 16px 40px; }
    h1 { font-size: 30px; }
    .lead { margin-bottom: 26px; }
    .field { flex-direction: column; align-items: stretch; }
    .capsule { flex-direction: column; border-radius: 22px; gap: 6px; }
    .capsule input { font-size: 17px; padding: 12px 14px; }
    .glass { width: 100%; padding: 14px; }
    .field input { font-size: 17px; }
    .btn { width: 100%; padding: 15px 18px; }
    .google { justify-content: center; }
    .row { gap: 12px 18px; }
    .linkish { padding: 8px 0; }
    .stack { max-width: none; }
    .feed { padding: 0 16px 72px; }
    .page { padding: 88px 16px 72px; }
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv dt { margin-top: 12px; font-size: 13px; }
    footer { padding: 0 16px 36px; gap: 10px 18px; }
    .menu { padding: 32px 20px; }
    .editions { grid-template-columns: 1fr; }
  }
  @media (max-width: 380px) { h1 { font-size: 27px; } .plaque .t { font-size: 17px; } }
  @media (hover: none) { .ed:hover { border-color: var(--line); } }
