:root {
  --accent: #1f6feb;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1b2430;
  --muted: #6b7686;
  --line: #dfe4ea;
  --danger: #d1242f;
  --ok: #1a7f37;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column;
}
.hidden { display: none !important; }
.muted { color: var(--muted); margin-top: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; font-size: 17px; }
.logo { color: var(--accent); }
.status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: #aab3bf; }
.status.ok .dot { background: var(--ok); }
.status.warn .dot { background: #d4a72c; }

.view { flex: 1; min-height: 0; }
#view-home { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 420px)); gap: 24px; justify-content: center; align-content: start; padding: 40px 20px; }
#view-wait, #view-end { display: grid; place-items: start center; padding: 40px 20px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card h2 { margin: 0 0 4px; font-size: 20px; }
.card.center { text-align: center; max-width: 480px; width: 100%; }
form label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0; }
input:not([type=checkbox]) {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
.code-input { font-size: 22px !important; letter-spacing: 6px; text-align: center; font-variant-numeric: tabular-nums; }
.consent { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 14px 0; font-size: 13px; }
.consent .check { display: flex; gap: 8px; margin: 0; font-weight: 500; }
.consent ul { margin: 6px 0 0 18px; padding-left: 8px; color: var(--muted); }
.error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 8px 0 0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #b9c2cd; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, white); }
.btn.danger.active, .banner .btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.active { background: color-mix(in srgb, var(--accent) 12%, white); border-color: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.small { padding: 5px 10px; font-size: 13px; }
form .btn[type=submit] { width: 100%; margin-top: 6px; }
.composer .btn[type=submit] { width: auto; margin: 0; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.row.end { justify-content: flex-end; }

.big-code { font-size: 46px; font-weight: 700; letter-spacing: 10px; margin: 8px 0 16px; font-variant-numeric: tabular-nums; color: var(--accent); }
.link-row { display: flex; gap: 8px; } .link-row input { margin: 0; font-size: 13px; }
.waiting { margin: 22px 0 8px; color: var(--muted); display: flex; gap: 8px; justify-content: center; align-items: center; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Sesión */
.session { display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px; gap: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.banner { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 8px; background: #fff1f0; border: 1px solid #ffccc7; font-weight: 600; }
.screen { position: relative; flex: 1; min-height: 240px; background: #0f141a; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; }
#remote-video { width: 100%; height: 100%; object-fit: contain; background: #0f141a; }
.screen-empty { color: #9aa6b4; text-align: center; padding: 20px; }
.big-icon { font-size: 44px; opacity: .6; }
.fs { position: absolute; top: 10px; right: 10px; opacity: .85; }
.pip { position: absolute; right: 12px; bottom: 12px; width: 220px; max-width: 35%; border-radius: 8px; border: 2px solid #fff3; background: #000; }

.chat { display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; position: relative; }
.chat-head { padding: 10px 14px; font-weight: 650; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 7px 11px; border-radius: 12px; background: var(--bg); word-wrap: break-word; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: color-mix(in srgb, var(--accent) 14%, white); }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: 12px; text-align: center; padding: 2px; }
.file { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.file .name { font-weight: 600; }
.file progress { width: 100%; height: 6px; }
.file a { font-weight: 600; color: var(--accent); }
.composer { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); align-items: center; }
.composer input { margin: 0; }
.attach { cursor: pointer; margin: 0 !important; font-size: 16px !important; }
.drop-hint { position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 12%, white); border: 2px dashed var(--accent); display: grid; place-items: center; font-weight: 650; color: var(--accent); z-index: 5; }

dialog { border: none; border-radius: var(--radius); padding: 22px; max-width: 420px; box-shadow: 0 10px 40px #0004; }
dialog h3 { margin-top: 0; }

@media (max-width: 860px) {
  .session { grid-template-columns: 1fr; grid-template-rows: minmax(300px, 1fr) 380px; }
  .chat { border-left: none; border-top: 1px solid var(--line); }
}
input[type=file] { display: none !important; }

.row-inline { display: flex; gap: 8px; align-items: center; }
.banner.control { background: #fff7e6; border-color: #ffd591; }
.banner select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); font: inherit; font-size: 13px; }
.screen:focus { outline: none; }
.screen.controlling { box-shadow: 0 0 0 3px var(--accent); }
.screen.controlling:focus { box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px color-mix(in srgb, var(--accent) 30%, transparent); }
.screen:fullscreen { border-radius: 0; }
.pip { pointer-events: none; }
#dlg-text { white-space: pre-line; }
.msg.sys a { color: var(--accent); font-weight: 600; }
