:root {
  --bg: #0f1115;
  --card: #181b22;
  --fg: #e7e9ee;
  --muted: #9aa0ac;
  --accent: #4f8cff;
  --good: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --line: #262b35;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) 16px 40px;
  min-height: 100%;
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  z-index: 50;
}

.navbar .brand {
  font-weight: 700;
}

.iconbtn {
  background: none;
  border: 0;
  color: var(--fg);
  font-size: 1.3rem;
  line-height: 1;
  padding: 6px;
  border-radius: 8px;
}

.iconbtn:hover {
  background: rgba(255, 255, 255, 0.08);
}

body:has(.navbar) > .card,
body:has(.navbar) > .chat {
  margin-top: 52px;
}

/* Modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

/* The [hidden] attribute must win over the display:flex above. */
.overlay[hidden] {
  display: none;
}

.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 420px;
}

.modalhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modalhead h2 {
  margin: 0;
  font-size: 1.2rem;
}

.danger {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 12px;
  background: var(--bad);
  color: white;
  font-weight: 700;
  margin-top: 14px;
}

.danger:hover {
  filter: brightness(1.08);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
}

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 0.85rem;
}

input[type='password'] {
  width: 100%;
  padding: 14px 16px;
  margin: 16px 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0f131a;
  color: var(--fg);
  font-size: 1rem;
}

button {
  cursor: pointer;
  font-size: 1rem;
}

form button[type='submit'],
.ctrl {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.error {
  color: var(--bad);
  margin: 10px 0 0;
}

.roles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 20px 0 10px;
}

.role {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #0f131a;
  color: var(--fg);
  transition: border-color 0.15s, transform 0.05s;
}

.role:hover {
  border-color: var(--accent);
}

.role:active {
  transform: scale(0.98);
}

.role:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.role .big {
  font-size: 2rem;
}

.role .rname {
  font-weight: 700;
}

.role .rsub {
  color: var(--muted);
  font-size: 0.85rem;
}

.statusrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 18px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 10px currentColor;
}

.dot.good {
  background: var(--good);
}

.dot.bad {
  background: var(--bad);
}

.peers {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.peer {
  background: #0f131a;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.peerlabel {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.meter {
  height: 8px;
  background: #222833;
  border-radius: 6px;
  overflow: hidden;
}

.meter > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--good), var(--accent));
  transition: width 0.06s linear;
}

.controls {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.ctrl.muted-on {
  background: var(--bad);
}

.vol {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.vol input {
  flex: 1;
}

.link {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  padding: 0;
}

.big-center {
  text-align: center;
}

/* Audio-unblock prompt (autoplay blocked) */
.audiogate {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  padding: 14px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--warn);
  color: #1a1205;
  font-weight: 700;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: translateX(-50%) scale(1.05);
  }
}

/* Claude chat panel */
.chat h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.chatlog {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 46vh;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 4px;
}

.bubble {
  padding: 10px 13px;
  border-radius: 14px;
  max-width: 90%;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.bubble.me {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.bubble.bot {
  align-self: flex-start;
  background: #0f131a;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.bubble.bot.pending::after {
  content: '▋';
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.chatform {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chatform textarea {
  width: 100%;
  resize: vertical;
  min-height: 56px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0f131a;
  color: var(--fg);
  font: inherit;
}

.chatform button {
  width: 100%;
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.chatform button:disabled {
  opacity: 0.5;
}

/* Make the chat comfortably tall even when stacked (mobile / narrow). */
.chat .chatlog {
  min-height: 240px;
}

/* Helper layout: voice room on the LEFT, big Claude chat on the RIGHT. */
@media (min-width: 900px) {
  body.helper-layout {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    flex-wrap: nowrap;
  }

  body.helper-layout #live {
    flex: 0 0 360px;
    max-width: 360px;
  }

  body.helper-layout #chatPanel {
    flex: 1 1 560px;
    max-width: 720px;
    height: calc(100vh - 92px);
    display: flex;
    flex-direction: column;
    margin-top: 52px; /* clear the fixed navbar */
  }

  body.helper-layout #chatPanel .chatlog {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
  }

  body.helper-layout #chatPanel .chatlog:empty {
    display: block; /* keep the panel filled even before the first message */
  }
}
