:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --accent: #2f5fd0;
  --border: #e2e2e0;
  --danger: #b3261e;
  --ok: #1e7a3c;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .brand { font-weight: 600; text-decoration: none; color: var(--text); }
.site-header nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.site-header nav form { margin: 0; }
.site-header .who { color: var(--muted); }

main { max-width: 48rem; margin: 0 auto; padding: 1.5rem 1rem; }

h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.75rem; }
.meta, .empty { color: var(--muted); }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: 0.6rem 0.8rem; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.messages .success { border-color: var(--ok); }
.messages .error { border-color: var(--danger); }

.board-list { list-style: none; padding: 0; margin: 0 0 2rem; }
.board-list li {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.75rem 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.5rem;
}
.board-list a { font-weight: 500; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }

input[type=text], input[type=email], input[type=password], select {
  width: 100%; max-width: 24rem; padding: 0.5rem; font: inherit;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
button {
  font: inherit; padding: 0.5rem 1rem; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; cursor: pointer;
}
button.link { background: none; color: var(--accent); padding: 0; text-decoration: underline; }
.errorlist { color: var(--danger); padding-left: 1rem; }

/* Board page: header + page bar + full-height canvas */
body.board-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.board-page .site-header { padding: 0.4rem 1rem; }
.board-bar {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.4rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.board-bar .back { text-decoration: none; font-size: 1.2rem; }
.board-bar .board-title { margin-right: 0.5rem; }
.board-bar button { padding: 0.35rem 0.75rem; font-size: 0.9rem; }
.board-bar button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.board-bar button.danger { background: var(--surface); color: var(--danger); border: 1px solid var(--danger); }
.board-bar button:disabled { opacity: 0.4; cursor: default; }
.board-bar select { width: auto; padding: 0.3rem; }
.pager { display: flex; align-items: center; gap: 0.25rem; }
.pager button { padding: 0.35rem 0.6rem; }
.spacer { flex: 1; }
.presence { display: flex; gap: 0.75rem; color: var(--muted); font-size: 0.9rem; }
.presence .peer::before { content: "●"; color: var(--ok); margin-right: 0.25rem; }
.conn-status { font-size: 0.85rem; color: var(--muted); }
.conn-status[data-state="connected"] { color: var(--ok); }
.conn-status[data-state="offline"] { color: var(--danger); }
.board-canvas { flex: 1; min-height: 0; position: relative; }

/* Video call */
.video-join { background: var(--ok); }
.video-join.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgb(30 122 60 / 0.25); } }
@media (prefers-reduced-motion: reduce) { .video-join.pulse { animation: none; outline: 2px solid var(--ok); } }

.video-panel {
  position: fixed; right: 16px; bottom: 72px; z-index: 50;
  width: min(280px, 45vw); background: #1d1d1f; color: #fff;
  border-radius: 10px; overflow: hidden; box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
  touch-action: none;
}
.video-panel.large { width: min(520px, 90vw); }
.video-head {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.5rem;
  font-size: 0.85rem; cursor: move; user-select: none;
}
.video-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-route { color: #a8a8ad; font-size: 0.75rem; }
.video-panel button.icon { background: none; padding: 0 0.25rem; font-size: 1rem; color: #fff; }
.video-stage { position: relative; aspect-ratio: 4 / 3; background: #000; }
.video-stage video { display: block; width: 100%; height: 100%; object-fit: cover; }
.video-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 1rem; text-align: center; font-size: 0.9rem; color: #d0d0d5; background: #2a2a2e;
}
.video-placeholder[hidden] { display: none; }
.local-video {
  position: absolute; right: 6px; bottom: 6px; width: 30% !important; height: auto !important;
  aspect-ratio: 4 / 3; border-radius: 6px; border: 1px solid rgb(255 255 255 / 0.4);
  transform: scaleX(-1); /* mirror the self-view */
}
.local-video[hidden] { display: none !important; }
.remote-muted-badge {
  display: none; position: absolute; left: 6px; top: 6px; padding: 0.1rem 0.4rem;
  font-size: 0.75rem; background: var(--danger); border-radius: 4px;
}
.video-panel.remote-muted .remote-muted-badge { display: block; }
.video-controls { display: flex; gap: 0.35rem; padding: 0.4rem; }
.video-controls button { flex: 1; padding: 0.35rem 0.25rem; font-size: 0.8rem; background: #3a3a3f; }
.video-controls button.off { background: #6b2a26; }
.video-controls button.danger { background: var(--danger); }
.video-controls button:disabled { opacity: 0.4; }
