/* RelayCast — shared design system (AMOLED Pure Black) */
:root {
  --bg: #000000;
  --surface: #0A0A0C;
  --surface-2: #121216;
  --surface-3: #19191F;
  --border: #1E1E24;
  --border-strong: #2D2D36;
  --text: #F4F4F6;
  --text-muted: #8E8E9A;
  --text-dim: #5A5A66;
  --accent: #7C9EFF;
  --accent-bg: rgba(124, 158, 255, 0.14);
  --green: #34D399;
  --green-bg: rgba(52, 211, 153, 0.14);
  --red: #F87171;
  --red-bg: rgba(248, 113, 113, 0.14);
  --amber: #FBBF24;
  --amber-bg: rgba(251, 191, 36, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }

::selection { background: var(--accent-bg); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #23232B; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.dot-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex: none;
}
.dot-live.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-live.rec { background: var(--red); box-shadow: 0 0 8px var(--red); }

/* Buttons */
.btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, color 0.15s, filter 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.active {
  background: var(--accent-bg);
  border-color: rgba(124, 158, 255, 0.45);
  color: var(--accent);
}

.btn-stream {
  background: var(--accent);
  border-color: var(--accent);
  color: #04060B;
  font-weight: 600;
  padding: 7px 15px;
}
.btn-stream:hover { filter: brightness(1.07); background: var(--accent); }
.btn-stream.live {
  background: var(--red-bg);
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--red);
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s, color 0.15s;
  flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: rgba(124, 158, 255, 0.35);
}
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.badge-count {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* Chat */
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 100%;
  min-height: 0;
}
.chat-msg {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.chat-msg.me {
  background: var(--accent-bg);
  border-color: rgba(124, 158, 255, 0.28);
}
.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.chat-form { display: flex; gap: 6px; margin-top: auto; }
.chat-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.chat-input:focus { border-color: var(--accent); }

/* Settings primitives */
.field-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.seg-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border);
}
.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 5px 4px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface-3); color: var(--text); }

input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }

.row-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.row-switch input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.pin-input {
  width: 74px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-align: center;
  letter-spacing: 2px;
  outline: none;
}
.pin-input:focus { border-color: var(--accent); }

.btn-danger-outline {
  width: 100%;
  background: var(--red-bg);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--red);
  padding: 7px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}
.btn-danger-outline:hover { background: rgba(248, 113, 113, 0.22); }

/* PIN overlay */
.pin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pin-overlay.open { display: flex; }

.pin-card {
  width: 340px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85);
}

.pin-icon {
  margin: 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.pin-boxes { display: flex; justify-content: center; gap: 8px; }
.pin-digit {
  width: 46px;
  height: 54px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}
.pin-digit:focus { border-color: var(--accent); }
.pin-error { font-size: 11.5px; color: var(--red); min-height: 16px; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.qr-modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 20px;
  width: 300px;
  max-width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85);
}
.qr-canvas { margin: 0 auto; border-radius: 10px; background: #fff; padding: 8px; display: block; }

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 40px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Landing / status screens */
.landing {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 40%, #0B0D14 0%, #000000 70%);
}
.landing-card {
  width: 560px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85);
}
.brand-row { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-bg);
  border: 1px solid rgba(124, 158, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.landing-sub { color: var(--text-muted); font-size: 12.5px; line-height: 1.6; }
.landing-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.landing-actions .btn { padding: 12px; font-size: 13px; }
.landing-join { display: flex; gap: 8px; }
.landing-join .chat-input { padding: 10px 12px; }
.landing-foot {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.landing-brand-sub {
  font-size: 10.5px;
  color: var(--text-dim);
  font-weight: 400;
}
.landing-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.landing-status.on {
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--green);
}
.landing-status.off {
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--red);
}
.landing-status.on .dot-live { background: var(--green); box-shadow: 0 0 8px var(--green); }
.landing-status.off .dot-live { background: var(--red); }

.landing-hero { display: flex; flex-direction: column; gap: 6px; }
.landing-hero h1 {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.landing-hero p { font-size: 12.5px; line-height: 1.6; color: var(--text-muted); }

.landing-join .chat-input { padding: 10px 12px; font-size: 12px; }
.landing-join .btn { padding: 10px 18px; }
.landing-hint {
  margin-top: -12px;
  min-height: 13px;
  font-size: 10.5px;
  color: var(--text-dim);
}
.landing-hint.error { color: var(--red); }

.landing-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.meta-item .mono {
  font-size: 9.5px;
  letter-spacing: 0.4px;
  color: var(--accent);
}
.meta-item span:last-child {
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-muted);
}

@media (max-width: 560px) {
  .landing { align-items: flex-start; padding: 18px; }
  .landing-card { padding: 22px; gap: 16px; }
  .brand-row { flex-wrap: wrap; }
  .landing-status { margin-left: 0; }
  .landing-join { flex-direction: column; }
  .landing-join .btn { width: 100%; }
  .landing-meta { grid-template-columns: 1fr; }
  .landing-foot { flex-direction: column; align-items: flex-start; }
}

.status-screen {
  position: fixed;
  inset: 0;
  background: #000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 500;
}
.status-screen.open { display: flex; }
.status-card {
  width: 380px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  align-items: center;
}
.status-card h2 { font-size: 15px; font-weight: 600; }
.status-card p { font-size: 12.5px; color: var(--text-muted); }

.kbd-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}
