/* LAB SIMOH — autonome */
:root {
  --bg: #0a0a0b;
  --panel: #121214;
  --line: #2a2a2e;
  --text: #f2efe8;
  --muted: #9a958c;
  --gold: #c4a574;
  --gold-dim: #8a7350;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: radial-gradient(1200px 700px at 20% 0%, #1a1814 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
body { display: flex; flex-direction: column; min-height: 100%; }
header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--line);
}
.header-actions {
  display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; justify-content: flex-end;
}
.back-bbs {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.72rem; letter-spacing: 0.06em;
  color: #111; background: var(--gold); text-decoration: none;
  padding: 0.4rem 0.75rem; border: 0;
}
.back-bbs:hover { background: #d4b484; }
.back-bbs--soft {
  background: transparent; color: var(--gold);
  border: 1px solid var(--gold-dim);
}
.back-bbs--soft:hover { background: rgba(196,165,116,0.15); color: var(--text); }
.brand { letter-spacing: 0.18em; font-size: 0.78rem; color: var(--gold); text-transform: uppercase; }
.brand strong { display: block; font-size: 1.15rem; letter-spacing: 0.08em; color: var(--text); margin-top: 0.2rem; font-weight: 500; }
.badge {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.68rem; color: var(--muted);
  border: 1px solid var(--line); padding: 0.35rem 0.6rem; border-radius: 999px;
}
main {
  flex: 1; display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
  gap: 0; min-height: 0;
}

/* —— Mobile / téléphone —— */
@media (max-width: 860px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }
  body {
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  header {
    padding: 0.55rem 0.75rem;
    gap: 0.5rem;
    flex-shrink: 0;
  }
  .brand { font-size: 0.65rem; letter-spacing: 0.12em; }
  .brand strong { font-size: 0.95rem; margin-top: 0.05rem; }
  .badge { display: none; }
  .back-bbs {
    font-size: 0.7rem;
    padding: 0.45rem 0.65rem;
    min-height: 2.4rem;
    display: inline-flex;
    align-items: center;
  }
  main {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(140px, 22dvh) minmax(0, 1fr);
  }
  .stage {
    min-height: 0;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .stage .caption {
    left: 0.75rem; right: 0.75rem; bottom: 0.5rem;
    padding-top: 1.5rem;
  }
  .stage .caption h1 { font-size: 1.05rem; }
  .stage .caption p { font-size: 0.85rem; }
  .chat {
    min-height: 0;
    overflow: hidden;
  }
  .header-actions .langbar {
    width: 100%;
    justify-content: flex-start;
    margin-bottom: 0.15rem;
  }
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .langbar button {
    min-height: 2.4rem;
    min-width: 2.8rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
  }
  .log {
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.85rem 0.85rem;
    gap: 0.75rem;
  }
  .bubble {
    max-width: 100%;
    width: 100%;
    font-size: 17px;
    line-height: 1.6;
    padding: 0.9rem 0.95rem;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .bubble .who {
    font-size: 0.72rem;
    margin-bottom: 0.4rem;
  }
  .bubble a {
    color: var(--gold);
    text-decoration: underline;
    overflow-wrap: anywhere;
  }
  .services {
    flex-shrink: 0;
    gap: 0.4rem;
    padding: 0.65rem 0.75rem;
  }
  .services button {
    flex: 1 1 calc(50% - 0.4rem);
    min-height: 2.6rem;
    font-size: 0.92rem;
    padding: 0.55rem 0.5rem;
  }
  .meta {
    flex-shrink: 0;
    padding: 0.35rem 0.75rem;
    font-size: 0.72rem;
  }
  #unlockSound {
    min-height: 2.2rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
  }
  .composer {
    flex-shrink: 0;
    padding: 0.65rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0));
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
  }
  .composer textarea {
    min-height: 3rem;
    font-size: 1.05rem;
    padding: 0.75rem;
  }
  .composer button {
    min-width: 5.5rem;
    min-height: 3rem;
    font-size: 0.95rem;
  }
  footer { display: none; }
}

@media (max-width: 420px) {
  .bubble { font-size: 18px; line-height: 1.62; }
  .services button {
    flex: 1 1 100%;
    font-size: 1.02rem;
  }
  .composer textarea { font-size: 17px; }
}
.stage {
  position: relative; background: #000;
  border-right: 1px solid var(--line);
  overflow: hidden; min-height: 320px;
  height: 100%;
}
.stage video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center center;
  display: block;
  background: #000;
  /* pas de filter CSS — peut blanchir la vidéo sur Safari */
}
.stage .caption { z-index: 2; }
.stage .caption {
  position: absolute; left: 1rem; right: 1rem; bottom: 1rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  padding: 2.5rem 0 0.2rem; pointer-events: none;
}
.stage .caption h1 {
  margin: 0; font-size: 1.35rem; font-weight: 500; letter-spacing: 0.04em;
}
.stage .caption p {
  margin: 0.25rem 0 0; color: var(--gold); font-style: italic; font-size: 0.95rem;
}
.stage.speaking::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 1px rgba(196,165,116,0.35);
  pointer-events: none;
}
.chat {
  display: flex; flex-direction: column; min-height: 0; background: var(--panel);
}
.log {
  flex: 1; overflow: auto; padding: 1.25rem 1.4rem;
  display: flex; flex-direction: column; gap: 0.9rem;
}
.bubble {
  max-width: 92%;
  padding: 0.75rem 0.95rem;
  line-height: 1.45; font-size: 0.98rem;
  border: 1px solid var(--line);
}
.bubble.user {
  align-self: flex-end;
  background: #1a1a1d;
  border-color: #333;
}
.bubble.simoh {
  align-self: flex-start;
  background: #151310;
  border-color: #3a3228;
}
.bubble .who {
  display: block; font-size: 0.68rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--gold-dim); margin-bottom: 0.35rem;
  font-family: ui-monospace, Menlo, monospace;
}
.composer {
  border-top: 1px solid var(--line);
  padding: 0.9rem 1rem 1.1rem;
  display: grid; grid-template-columns: 1fr auto; gap: 0.55rem;
}
.composer textarea {
  resize: none; min-height: 3.2rem; max-height: 8rem;
  background: #0c0c0e; color: var(--text);
  border: 1px solid var(--line); padding: 0.7rem 0.8rem;
  font: inherit; line-height: 1.4;
}
.composer textarea:focus { outline: 1px solid var(--gold-dim); }
.composer button {
  background: var(--gold); color: #111; border: 0;
  padding: 0 1.1rem; font: inherit; letter-spacing: 0.06em;
  cursor: pointer; min-width: 6.5rem;
}
.composer button:disabled { opacity: 0.45; cursor: wait; }
.meta {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 1rem 0.55rem;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.65rem; color: var(--muted);
}
.meta label { display: flex; gap: 0.4rem; align-items: center; cursor: pointer; }
footer {
  padding: 0.55rem 1.5rem; border-top: 1px solid var(--line);
  font-size: 0.72rem; color: var(--muted);
  font-family: ui-monospace, Menlo, monospace;
}

.keyrow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem;
  padding: 0.65rem 1rem; border-bottom: 1px solid var(--line);
  background: #18160f;
}
.keyrow label {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold); width: 100%;
}
.keyrow input {
  flex: 1; min-width: 12rem; background: #0c0c0e; color: var(--text);
  border: 1px solid var(--gold-dim); padding: 0.55rem 0.7rem; font: inherit; font-size: 0.9rem;
}
.keyrow button {
  background: var(--gold); color: #111; border: 0;
  padding: 0.55rem 1rem; cursor: pointer; font: inherit; font-size: 0.85rem;
}

#unlockSound {
  background: var(--gold); color: #111; border: 0;
  padding: 0.35rem 0.7rem; cursor: pointer; font: inherit; font-size: 0.75rem;
}
.stage { cursor: pointer; }

.services {
  display: flex; flex-wrap: wrap; gap: 0.45rem;
  padding: 0.75rem 1rem; border-top: 1px solid var(--line);
  background: #0e0e10;
}
.services button {
  background: transparent; color: var(--text);
  border: 1px solid var(--gold-dim);
  padding: 0.45rem 0.85rem; cursor: pointer;
  font: inherit; font-size: 0.88rem; letter-spacing: 0.04em;
}
.services button:hover,
.services button.active {
  background: var(--gold); color: #111; border-color: var(--gold);
}
.bubble.access {
  align-self: flex-start;
  border-color: #4a4030;
  background: #1a1610;
  font-size: 0.9rem;
  color: var(--gold);
}

.chat-top {
  display: flex; justify-content: flex-end;
  padding: 0.55rem 1rem 0;
  border-bottom: 1px solid var(--line);
  background: #0e0e10;
}
.langbar {
  display: flex; gap: 0.25rem; align-items: center;
}
.header-actions .langbar { order: -1; }
.langbar button {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line);
  padding: 0.28rem 0.55rem; cursor: pointer;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.68rem; letter-spacing: 0.06em;
}
.langbar button.active {
  color: #111; background: var(--gold); border-color: var(--gold);
}
.chat-top { display: none; }
#unlockSound.on {
  background: #2a261c; color: var(--gold);
  border: 1px solid var(--gold-dim);
}
