:root {
  color-scheme: dark;
  --bg: #0c0d11;
  --panel: #15171d;
  --panel-2: #1c1f27;
  --line: #272b35;
  --text: #e8eaf0;
  --muted: #9aa1b1;
  --accent: #6c8cff;
  --accent-ink: #0b0e1a;
  --danger: #e05252;
  --ok: #43c07d;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

/* Plusieurs blocs ont un display explicite : sans ça, [hidden] ne cacherait rien. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.02em;
}
h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}
.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.error {
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

/* ---------------------------------------------------------- connexion --- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* -------------------------------------------------------------- layout --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 17px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.me {
  color: var(--muted);
  font-weight: 600;
  margin-right: 4px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  padding: 16px 20px 40px;
  max-width: 1180px;
  margin: 0 auto;
}
.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }
}

/* ------------------------------------------------------------ composer --- */

.composer {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drops {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 520px) {
  .drops {
    grid-template-columns: 1fr;
  }
}

.drop {
  position: relative;
  display: block;
  padding: 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}
.drop:hover,
.drop.over {
  border-color: var(--accent);
  background: #1f2330;
}
.drop.filled {
  border-style: solid;
  border-color: var(--ok);
}
.drop-inner {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.drop-inner span {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clear-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--line);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.clear-btn:hover {
  background: var(--danger);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px) {
  .row {
    grid-template-columns: 1fr;
  }
}

label {
  font-size: 13px;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input:not([type]),
textarea,
select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
textarea {
  resize: vertical;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}
.check input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------- grille pos --- */

.posgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  width: 132px;
  aspect-ratio: 16 / 9;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
}
.posgrid button {
  border: 1px solid transparent;
  border-radius: 5px;
  background: #2a2f3b;
  cursor: pointer;
  transition: background 120ms ease;
}
.posgrid button:hover {
  background: #3a4152;
}
.posgrid button.on {
  background: var(--accent);
}
.posgrid.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ------------------------------------------------------------ boutons --- */

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.primary {
  padding: 10px 16px;
  border: none;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  transition: filter 120ms ease;
}
.primary:hover {
  filter: brightness(1.1);
}
.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}
.primary.big {
  padding: 13px 30px;
  font-size: 15px;
}
.ghost {
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--text);
}
.ghost:hover {
  background: var(--panel-2);
}
.ghost.danger {
  color: var(--danger);
  border-color: #4a2626;
}
.ghost.danger:hover {
  background: #2a1616;
}

.send-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.feedback {
  font-size: 13px;
  font-weight: 600;
}
.feedback.ok {
  color: var(--ok);
}
.feedback.ko {
  color: var(--danger);
}

/* ------------------------------------------------------------ aperçu --- */

.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 9px;
  border: 1px solid var(--line);
  /* Damier : montre bien que le fond est transparent chez le destinataire. */
  background-color: #101218;
  background-image:
    linear-gradient(45deg, #171a22 25%, transparent 25%),
    linear-gradient(-45deg, #171a22 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #171a22 75%),
    linear-gradient(-45deg, transparent 75%, #171a22 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  overflow: hidden;
}
.screen-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
}
.screen .pv {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.screen .pv img,
.screen .pv video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 80%;
  object-fit: contain;
  border-radius: 3px;
}
.screen .pv .t,
.screen .pv-banner .t {
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
  paint-order: stroke fill;
  -webkit-text-stroke: 3px rgba(0, 0, 0, 0.85);
}
.screen .pv-banner {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: 92%;
}
.screen .pv-banner.top {
  top: 5%;
}
.screen .pv-banner.bottom {
  bottom: 7%;
}
.screen .pv .over-text {
  position: absolute;
  left: 50%;
  bottom: 6%;
  transform: translateX(-50%);
  max-width: 96%;
}

/* -------------------------------------------------------------- potes --- */

.count {
  display: inline-block;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 11px;
  text-align: center;
}
.peers {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.peers li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--panel-2);
}
.peers li.off {
  opacity: 0.5;
}
.peers .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}
.peers li.off .dot {
  background: var(--muted);
}
.peers .name {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.peers .tag {
  font-size: 11px;
  color: var(--muted);
}

/* ------------------------------------------------------------ dialogue --- */

.dialog {
  width: min(520px, calc(100vw - 32px));
  color: var(--text);
}
.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}
.dialog .field {
  margin: 12px 0;
}
