/* Fonts: Inter (UI) and JetBrains Mono NL (IDs, passwords), self-hosted,
   Latin subset, SIL OFL 1.1 (see fonts/LICENSE-*.txt). */
@font-face { font-family: "Inter"; src: url("fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono NL"; src: url("fonts/JetBrainsMonoNL-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap; }

/* Theme: light by default, dark when the OS prefers it, or forced with
   data-theme="light|dark" on <html> (set by theme.js). */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f1f3f7;
  --border: #d9dee7;
  --border-hover: #b8c0ce;
  --text: #1a1f2b;
  --muted: #5b6578;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --focus: rgba(37,99,235,.25);
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --danger-text: #b91c1c;
  --ok-text: #15803d;
  --warn-text: #a16207;
  --danger-bg: rgba(220,38,38,.08);
  --danger-line: rgba(220,38,38,.45);
  --ok-bg: rgba(22,163,74,.12);
  --warn-bg: rgba(217,119,6,.14);
  --bad-bg: rgba(220,38,38,.10);
  --me-bubble: rgba(37,99,235,.12);
  --shadow: 0 12px 40px rgba(16,24,40,.12);
  --overlay: rgba(255,255,255,.82);
  --stage: #e6e9ef;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #0f1115; --panel: #171a21; --panel-2: #1f232c; --border: #2a2f3a; --border-hover: #3a4150;
    --text: #e6e8ee; --muted: #8b93a5; --accent: #3b82f6; --accent-2: #2563eb; --focus: rgba(59,130,246,.25);
    --danger: #ef4444; --ok: #22c55e; --warn: #f59e0b;
    --danger-text: #fca5a5; --ok-text: #86efac; --warn-text: #fcd34d;
    --danger-bg: rgba(239,68,68,.12); --danger-line: rgba(239,68,68,.5);
    --ok-bg: rgba(34,197,94,.15); --warn-bg: rgba(245,158,11,.15); --bad-bg: rgba(239,68,68,.15);
    --me-bubble: rgba(59,130,246,.22); --shadow: 0 20px 60px rgba(0,0,0,.35);
    --overlay: rgba(15,17,21,.75); --stage: #000;
    color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #0f1115; --panel: #171a21; --panel-2: #1f232c; --border: #2a2f3a; --border-hover: #3a4150;
  --text: #e6e8ee; --muted: #8b93a5; --accent: #3b82f6; --accent-2: #2563eb; --focus: rgba(59,130,246,.25);
  --danger: #ef4444; --ok: #22c55e; --warn: #f59e0b;
  --danger-text: #fca5a5; --ok-text: #86efac; --warn-text: #fcd34d;
  --danger-bg: rgba(239,68,68,.12); --danger-line: rgba(239,68,68,.5);
  --ok-bg: rgba(34,197,94,.15); --warn-bg: rgba(245,158,11,.15); --bad-bg: rgba(239,68,68,.15);
  --me-bubble: rgba(59,130,246,.22); --shadow: 0 20px 60px rgba(0,0,0,.35);
  --overlay: rgba(15,17,21,.75); --stage: #000;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-weight: normal; }
.mono { font-variant-numeric: tabular-nums; }
.code, #partner-id, #partner-pw { font-family: "JetBrains Mono NL", ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow); position: relative; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 650; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), #8b5cf6); }
.card p { margin: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 550; }
input, select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font: inherit; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
#partner-id, #partner-pw { font-size: 18px; letter-spacing: .06em; }
button { background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; font: inherit; cursor: pointer; }
button:hover { border-color: var(--border-hover); }
button[type=submit] { background: var(--accent); border-color: var(--accent); color: #fff; padding: 11px; font-weight: 600; }
button[type=submit]:hover { background: var(--accent-2); }
button:disabled { opacity: .6; cursor: default; }
button.danger { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-text); }
.status { min-height: 1.4em; color: var(--muted); }
.status.error { color: var(--danger-text); }

#session-view { display: flex; flex-direction: column; height: 100%; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar select { padding: 6px 8px; }
.spacer { flex: 1; }
.toggle { flex-direction: row; align-items: center; gap: 6px; font-weight: normal; color: var(--muted); }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok-text); }
.pill.warn { background: var(--warn-bg); color: var(--warn-text); }
.pill.bad { background: var(--bad-bg); color: var(--danger-text); }

#stage { flex: 1; position: relative; overflow: auto; background: var(--stage); }
#screen { background: #000; }
#toast { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); background: var(--panel);
  border: 1px solid var(--border); padding: 8px 14px; border-radius: 8px; max-width: 90%; box-shadow: var(--shadow); }

/* ---- session layout ---- */
.body { flex: 1; display: flex; min-height: 0; }
#stage { min-width: 0; }
#surface { position: relative; outline: none; }
#surface canvas, #surface video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#surface video { object-fit: fill; background: #000; }
#surface.pixelated canvas, #surface.pixelated video { image-rendering: pixelated; }
#drop-hint { position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 12px;
  display: grid; place-items: center; background: var(--overlay); font-size: 18px; pointer-events: none; }
#toast { display: flex; gap: 10px; align-items: center; }
#toast button { padding: 4px 10px; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent);
  color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

#side { width: 320px; max-width: 45vw; display: flex; flex-direction: column; background: var(--panel);
  border-left: 1px solid var(--border); min-height: 0; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px;
  border-bottom: 1px solid var(--border); }
.side-head button { padding: 2px 8px; }
#messages { list-style: none; margin: 0; padding: 12px; flex: 1; overflow-y: auto; display: flex;
  flex-direction: column; gap: 8px; }
#messages li { max-width: 85%; padding: 7px 10px; border-radius: 10px; background: var(--panel-2);
  white-space: pre-wrap; word-break: break-word; }
#messages li.me { align-self: flex-end; background: var(--me-bubble); }
#messages li.sys { align-self: center; background: none; color: var(--muted); font-size: 12px; text-align: center; }
#chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
#chat-form input { flex: 1; min-width: 0; }
#transfers { display: flex; flex-direction: column; gap: 6px; padding: 0 12px; }
#transfers:not(:empty) { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.transfer { font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.transfer .row { display: flex; justify-content: space-between; gap: 8px; }
.transfer .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer progress { width: 100%; height: 6px; accent-color: var(--accent); }
.transfer.done .state { color: var(--ok-text); }
.transfer.failed .state { color: var(--danger-text); }
@media (max-width: 700px) { #side { position: absolute; right: 0; top: 0; bottom: 0; max-width: 100vw; width: 100%; z-index: 5; } .body { position: relative; } }

/* theme switch */
.theme-btn { padding: 4px 9px; font-size: 13px; line-height: 1.2; }
.card .theme-btn { position: absolute; top: 14px; right: 14px; }
