/* ===========================================================================
   Porthole — the viewer chrome stays quiet so the shared app is the page.
   =========================================================================== */
:root {
  --bg:#080b10; --panel:#0e1620; --panel-2:#0b111a; --raised:#142033;
  --line:#1c2a3d; --line-2:#253649;
  --fg:#dce6f5; --muted:#7d8ba0; --dim:#5b6879;
  --accent:#56d4bc; --accent-2:#8ab4ff; --accent-d:#04120f;
  --ok:#7ee787; --warn:#ffa657; --danger:#ff7b9c;
  --radius:10px; --radius-l:16px; --shadow:0 20px 60px rgba(0,0,0,.5);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
.hidden { display: none !important; }
h1, h2 { font-weight: 650; letter-spacing: -.01em; }

button {
  font: inherit; cursor: pointer; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: transparent; color: var(--fg);
  transition: border-color .12s, background .12s, color .12s;
}
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-d); border-color: var(--accent); font-weight: 650; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.danger { color: var(--danger); border-color: rgba(255,123,156,.5); }
.danger:hover { background: rgba(255,123,156,.12); }
button.sm { padding: 6px 11px; font-size: 12.5px; }
.wide { width: 100%; padding: 12px; margin-top: 18px; }
.icon-btn {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; color: var(--muted); font-size: 16px; line-height: 1; flex: none;
}
.icon-btn:hover { color: var(--fg); border-color: var(--accent); }
.mark { width: 34px; height: 34px; flex: none; }
.mark.sm { width: 22px; height: 22px; }

/* ------------------------------- join ----------------------------------- */
.join { height: 100%; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 28px 20px; }
.join-inner { display: grid; grid-template-columns: 400px 340px; gap: 26px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 26px; box-shadow: var(--shadow); }
.brand { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 20px; }
.brand h1 { margin: 0; font-size: 27px; }
.tagline { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }

.field { margin-top: 14px; }
.field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.field input {
  width: 100%; padding: 10px 12px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--fg); font: inherit;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input::placeholder { color: var(--dim); }
.adv { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.adv summary { cursor: pointer; color: var(--muted); font-size: 12.5px; user-select: none; }
.hint { color: var(--dim); font-size: 12px; margin: 12px 0 0; }
.err { display: none; color: var(--danger); background: rgba(255,123,156,.1); border: 1px solid rgba(255,123,156,.45); border-radius: var(--radius); padding: 9px 11px; margin-top: 14px; font-size: 13px; }
.err.show { display: block; }
.foot { color: var(--dim); font-size: 11.5px; }

.explain { padding: 20px 4px; }
.explain h2 { margin: 0 0 12px; font-size: 14px; }
.explain ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 13px; }
.explain li { color: var(--muted); font-size: 12.8px; line-height: 1.55; padding-left: 16px; position: relative; }
.explain li::before { content: "→"; position: absolute; left: 0; color: var(--accent); }
.explain b { color: var(--fg); font-weight: 600; }

/* ------------------------------- stage ---------------------------------- */
.stage { height: 100%; display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.bar-l { display: flex; align-items: center; gap: 9px; min-width: 0; }
.bar-r { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.room { font-family: var(--mono); font-size: 13px; background: var(--panel-2); border: 1px solid var(--line); padding: 3px 9px; border-radius: 7px; }

.pill { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.pill.online   { color: var(--ok);     background: rgba(126,231,135,.13); border-color: rgba(126,231,135,.3); }
.pill.retrying { color: var(--warn);   background: rgba(255,166,87,.13);  border-color: rgba(255,166,87,.35); }
.pill.offline  { color: var(--danger); background: rgba(255,123,156,.13); border-color: rgba(255,123,156,.35); }
.pill.ro       { color: var(--accent-2); background: rgba(138,180,255,.12); border-color: rgba(138,180,255,.3); }

.addr { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; max-width: 640px; }
.addr input {
  flex: 1; min-width: 0; padding: 7px 12px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 999px; color: var(--fg);
  font-family: var(--mono); font-size: 12.5px;
}
.addr input:focus { outline: none; border-color: var(--accent); }
.stats { color: var(--dim); font-size: 11.5px; font-family: var(--mono); white-space: nowrap; }

.viewport { position: relative; flex: 1; min-height: 0; background: #fff; }
#frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.overlay { position: absolute; inset: 0; background: rgba(8,11,16,.88); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; }
.ov-inner { display: flex; align-items: center; gap: 11px; background: var(--panel); border: 1px solid var(--line-2); padding: 14px 20px; border-radius: var(--radius); font-size: 13.5px; box-shadow: var(--shadow); max-width: 80%; text-align: center; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg) } }

/* ------------------------------- toasts --------------------------------- */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--raised); border: 1px solid var(--line-2); padding: 10px 15px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); animation: rise .18s ease-out; max-width: min(88vw, 520px); transition: opacity .2s; }
.toast.ok { border-color: rgba(126,231,135,.45); }
.toast.warn { border-color: rgba(255,166,87,.5); }
.toast.error { border-color: rgba(255,123,156,.55); }
@keyframes rise { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

@media (max-width: 900px) {
  .join-inner { grid-template-columns: 1fr; max-width: 420px; }
  .explain { display: none; }
  .addr { max-width: none; }
  .stats { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
