.hidden { display: none !important; }

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

body {
  font-family: Verdana, 'Trebuchet MS', -apple-system, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Header — logo only, no duplicate text */
header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
  width: 100%;
  background: linear-gradient(180deg, #111820 0%, #0d1117 100%);
}

header img.logo-large {
  height: 140px;
  width: auto;
}

header img.logo-small {
  height: 36px;
  width: auto;
}

/* Header variants */
header.landing { padding: 2.5rem 1.5rem 0.5rem; position: relative; }

.back-btn {
  position: absolute;
  top: 1rem;
  left: 1rem;
  color: #ffcc00;
  text-decoration: none;
  font-size: 3.2rem;
  line-height: 1;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  transition: background 0.15s;
}
.back-btn:hover { background: #ffcc0015; }

.header-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
}
header.session {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid #1a1f26;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.container {
  max-width: 960px;
  width: 100%;
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

/* Room code */
.room-code-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.room-code {
  font-size: 1.8rem;
  font-weight: bold;
  letter-spacing: 0.2em;
  color: #ffcc00;
  background: #161b22;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  border: 1px solid #30363d;
  font-family: Verdana, sans-serif;
  user-select: all;
}

.copy-btn {
  background: #1a1f26;
  color: #ffcc00;
  border: 1px solid #ffcc0044;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.copy-btn:hover { background: #ffcc0022; border-color: #ffcc00; }
.copy-btn.copied { color: #3fb950; border-color: #3fb950; }

/* QR code */
.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.qr-canvas {
  border-radius: 6px;
  width: 224px;
  height: 224px;
}
.qr-save {
  font-size: 0.75rem !important;
  padding: 0.3rem 0.7rem !important;
}

/* Status */
.status {
  font-size: 0.9rem;
  color: #8b949e;
  min-height: 1.5em;
}

.status.connected { color: #ffcc00; }
.status.error { color: #f85149; }
.status.working {
  color: #8b949e;
  animation: statusPulse 1.5s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.landing-tagline {
  color: #6e7681;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

/* Landing page footer — social links only on the index page */
.landing-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem 1rem 2rem;
  margin-top: auto;
}
.landing-footer a {
  color: #6e7681;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}
.landing-footer a:hover {
  color: #ffcc00;
  background: #ffcc0015;
}
.landing-footer svg {
  display: block;
}

/* Connection badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  background: #161b22;
  border: 1px solid #30363d;
  color: #8b949e;
}

.badge.mesh { border-color: #ffcc0066; color: #ffcc00; }
.badge.verified { border-color: #3fb95066; color: #3fb950; }
.badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #484f58;
}
.badge.mesh .dot { background: #ffcc00; }
.badge.verified .dot { background: #3fb950; }

/* Identity display */
.identity-area { margin: 0.5rem 0; }
.identity-display {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}
.identity-display .label { color: #8b949e; }
.identity-display .mono { color: #c9d1d9; font-family: monospace; font-size: 0.75rem; }
.wallet-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}
.wallet-status .mono { color: #8b949e; font-family: monospace; font-size: 0.7rem; }

/* Identify form */
.identify-form { margin-top: 0.5rem; }
.identify-form #identifyLinkArea { margin-top: 0.5rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.identify-form #identifyLink { flex: 1; min-width: 200px; }

/* Session timer */
.timer {
  font-size: 0.8rem;
  color: #6e7681;
  font-family: Verdana, monospace;
}

/* Buttons — gold palette */
button {
  background: linear-gradient(180deg, #e6b800 0%, #cc9900 100%);
  color: #0d1117;
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}

button:hover { background: linear-gradient(180deg, #ffcc00 0%, #e6b800 100%); }
button:disabled { background: #21262d; color: #484f58; cursor: not-allowed; }

button.go {
  background: linear-gradient(180deg, #2ea043 0%, #238636 100%);
  color: #fff;
}
button.go:hover { background: linear-gradient(180deg, #3fb950 0%, #2ea043 100%); }

button.stop {
  background: linear-gradient(180deg, #da3633 0%, #b62324 100%);
  color: #fff;
}
button.stop:hover { background: linear-gradient(180deg, #f85149 0%, #da3633 100%); }

button.secondary {
  background: #1a1f26;
  color: #ffcc00;
  border: 1px solid #ffcc0044;
  font-weight: normal;
}
button.secondary:hover { background: #ffcc0015; border-color: #ffcc00; }

button.fullscreen {
  background: #0d1117cc;
  color: #ffcc00;
  border: 1px solid #ffcc0044;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: normal;
}
button.fullscreen:hover { background: #ffcc0022; border-color: #ffcc00; }

/* Inputs */
input {
  background: #161b22;
  color: #e6edf3;
  border: 1px solid #30363d;
  padding: 0.7rem 1rem;
  border-radius: 6px;
  font-size: 1.3rem;
  text-align: center;
  letter-spacing: 0.2em;
  width: 22ch;
  text-transform: uppercase;
  font-family: Verdana, sans-serif;
  font-weight: bold;
}

input:focus { border-color: #ffcc00; outline: none; box-shadow: 0 0 0 2px #ffcc0033; }
input::placeholder { color: #484f58; letter-spacing: 0.05em; font-weight: normal; font-size: 1rem; }

/* Video */
video {
  width: 100%;
  max-width: 960px;
  background: #010409;
  border-radius: 8px;
  border: 1px solid #1a1f26;
}

.preview { max-width: 280px; opacity: 0.6; border-radius: 6px; }

.video-wrap {
  position: relative;
  width: 100%;
  max-width: 960px;
}

/* Annotation canvas overlay */
.annotation-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  cursor: crosshair;
  border-radius: 8px;
}
.annotation-canvas.hidden { display: none; }

/* Camera PiP overlay */
.camera-pip {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  width: 160px;
  height: 120px;
  border-radius: 8px;
  border: 2px solid #ffcc00;
  object-fit: cover;
  z-index: 10;
  background: #000;
}
@media (max-width: 600px) {
  .camera-pip { width: 120px; height: 90px; }
}

.video-controls {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 20;
}
.video-wrap:hover .video-controls { opacity: 1; }
@media (hover: none) {
  .video-controls { opacity: 1; }
}

/* CSS fullscreen fallback (iOS Safari) */
.video-wrap.css-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  z-index: 9999;
  background: #000;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-wrap.css-fullscreen video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  border: none;
}
.video-wrap.css-fullscreen .video-controls {
  opacity: 1;
  z-index: 10000;
}

/* Layout */
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; justify-content: center; align-items: center; }

/* Quality picker */
.quality-select {
  background: #1a1f26;
  color: #ffcc00;
  border: 1px solid #ffcc0044;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: Verdana, sans-serif;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  width: auto;
  text-align: left;
  cursor: pointer;
}
.quality-select:hover { border-color: #ffcc00; }
.quality-select:focus { outline: none; box-shadow: 0 0 0 2px #ffcc0033; }

/* Connection stats indicator */
.conn-stats {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: #8b949e;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  margin-top: 0.5rem;
  display: inline-flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}
.conn-stats .stat-label { color: #6e7681; }
.conn-stats .stat-value { color: #c9d1d9; }
.conn-stats .stat-good { color: #3fb950; }
.conn-stats .stat-warn { color: #d29922; }
.conn-stats .stat-bad { color: #f85149; }
.conn-stats .stat-relay { color: #d29922; font-weight: bold; }
.conn-stats .stat-direct { color: #3fb950; font-weight: bold; }

/* Landing role picker */
.role-picker {
  display: flex;
  gap: 3rem;
  justify-content: center;
  margin-top: 2rem;
  transition: gap 0.4s ease;
}

.role-picker:has(.fade-out) {
  gap: 0;
}


.landing-divider {
  width: 1px;
  align-self: stretch;
  background: #30363d;
}

.role-label {
  color: #c9d1d9;
  font-size: 0.95rem;
}

.role-option button {
  font-size: 1.3rem;
  padding: 1rem 2.5rem;
  min-width: 140px;
}

/* Animated flow transitions */
.role-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  transition: opacity 0.25s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
  max-height: 200px;
  overflow: hidden;
}

.role-option.fade-out,
.fade-out {
  opacity: 0;
  max-height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}

.role-option.chosen button {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
  font-size: 0.9rem;
  padding: 0.5rem 1.2rem;
  min-width: auto;
}

.role-option.chosen .role-label {
  font-size: 0.8rem;
}

.mode-reset {
  display: none;
  font-size: 0.75rem;
  color: #6e7681;
  cursor: pointer;
  margin-top: 0.25rem;
  border: none;
  background: none;
  padding: 0.3rem 0.6rem;
  font-weight: normal;
  letter-spacing: normal;
  min-height: 32px;
}
.mode-reset:hover { color: #c9d1d9; background: none; }
.role-option.chosen .mode-reset { display: none; }

/* Flow panels — expand below the picker */
.flow-panel {
  width: 100%;
  max-width: 560px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.5s ease, opacity 0.4s ease 0.15s;
}

.flow-panel.open {
  max-height: 600px;
  opacity: 1;
}

.flow-panel-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
}

.step-prompt {
  color: #3fb950;
  font-size: 1rem;
  font-weight: bold;
}

/* Page transitions */
body {
  animation: pageEnter 0.25s ease-out;
}

@keyframes pageEnter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

body.exiting {
  animation: pageExit 0.3s ease-in forwards;
}

@keyframes pageExit {
  to { opacity: 0; }
}

/* Separator between flow sections */
.flow-separator {
  width: 60%;
  height: 1px;
  background: #30363d;
  margin: 0.25rem auto;
  opacity: 0;
  transition: opacity 0.4s ease 0.3s;
}

.flow-separator.visible {
  opacity: 1;
}

.join-form { display: flex; gap: 0.5rem; align-items: center; }

/* Host two-column layout */
.host-columns {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  max-width: 720px;
}

.host-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.host-divider {
  width: 1px;
  align-self: stretch;
  background: #30363d;
  min-height: 100px;
}

.col-hint {
  color: #6e7681;
  font-size: 0.8rem;
  text-align: center;
}

.invite-method {
  width: 100%;
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  max-height: 300px;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}
.invite-method.fade-out {
  max-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.invite-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}

.stream-section {
  width: 100%;
  max-width: 720px;
  border-top: 1px solid #1a1f26;
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

@media (max-width: 600px) {
  .host-columns {
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
  }
  .host-divider {
    width: 80%;
    height: 1px;
    min-height: 0;
  }
}

.ring-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}

.ring-input {
  flex: 1;
  font-size: 0.8rem !important;
  letter-spacing: 0.02em !important;
  text-transform: none !important;
  font-weight: normal !important;
  width: 100% !important;
  min-width: 0;
  text-align: left !important;
  padding: 0.6rem 0.75rem !important;
}

.ring-status {
  font-size: 0.85rem;
  color: #8b949e;
  margin-top: 0.5rem;
  min-height: 1.3em;
}

.ring-status.connected { color: #ffcc00; }
.ring-status.error { color: #f85149; }
.ring-status.working { animation: statusPulse 1.5s ease-in-out infinite; }

/* Section label (shared) */
.section-label {
  color: #ffcc00;
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
}

/* Viewer page layout */
.viewer-join, .viewer-inbox {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.viewer-divider {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
  max-height: 50px;
  overflow: hidden;
}
.viewer-divider.fade-out {
  max-height: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.viewer-divider::before, .viewer-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #30363d;
}

.divider-text {
  color: #6e7681;
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 0.1em;
}

/* Contact list */
.contact-list {
  width: 100%;
  max-width: 480px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.contact-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #484f58;
  flex-shrink: 0;
}
.contact-dot.online { background: #3fb950; }

.contact-name {
  flex: 1;
  font-size: 0.85rem;
  color: #c9d1d9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-cast {
  padding: 0.3rem 0.8rem !important;
  font-size: 0.8rem !important;
  min-width: auto !important;
}

.contact-edit, .contact-copy {
  cursor: pointer;
  color: #ffcc00;
  font-size: 0.85rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.contact-edit:hover, .contact-copy:hover { color: #ffcc00; }

.contact-nickname-input {
  flex: 1;
  font-size: 0.85rem !important;
  padding: 0.2rem 0.4rem !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  font-weight: normal !important;
  text-align: left !important;
  width: auto !important;
}

.contact-empty {
  font-style: italic;
}

/* Inbox */

.inbox-empty {
  color: #6e7681;
  font-size: 0.9rem;
  font-style: italic;
}

.invitations {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.invite-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  gap: 1rem;
}

.invite-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: #8b949e;
}

.invite-info .mono {
  font-family: Verdana, monospace;
  color: #c9d1d9;
  font-size: 0.8rem;
}

.invite-card button {
  flex-shrink: 0;
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
}

.invite-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.invite-title {
  font-weight: bold;
  color: #ffcc00;
  font-size: 0.9rem;
}

.invite-card.fade-out {
  opacity: 0;
  max-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Chat panel */
.chat-panel {
  width: 100%;
  max-width: 560px;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #161b22;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: bold;
  color: #ffcc00;
  border-bottom: 1px solid #30363d;
  background: #1a1f26;
}

.chat-messages {
  flex: 1;
  min-height: 120px;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.chat-empty {
  color: #484f58;
  font-size: 0.75rem;
  font-style: italic;
  text-align: center;
  padding: 1rem 0;
}

.chat-msg {
  font-size: 0.8rem;
  line-height: 1.3;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  max-width: 85%;
}

.chat-own {
  align-self: flex-end;
  background: #1a2a1a;
  border: 1px solid #3fb95033;
}

.chat-peer {
  align-self: flex-start;
  background: #1a1f26;
  border: 1px solid #30363d;
}

.chat-sender {
  font-weight: bold;
  margin-right: 0.4rem;
  font-size: 0.75rem;
}

.chat-own .chat-sender { color: #3fb950; }
.chat-peer .chat-sender { color: #ffcc00; }

.chat-body {
  color: #c9d1d9;
}

/* File drop */
.chat-panel.file-dragover {
  border-color: #ffcc00;
  background: #ffcc0010;
}
.file-msg .chat-body { color: #8b949e; font-style: italic; }
.file-sent { color: #3fb950 !important; }
.file-received { color: #3fb950 !important; }
.file-error { color: #f85149 !important; }

.chat-input-row {
  display: flex;
  border-top: 1px solid #30363d;
}

.chat-input {
  flex: 1;
  font-size: 0.8rem !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  font-weight: normal !important;
  text-align: left !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0.5rem 0.75rem !important;
  width: auto !important;
}

.chat-input-row button {
  border-radius: 0;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 600px) {
  header img.logo-large { height: 90px; }
  .room-code { font-size: 1.2rem; padding: 0.5rem 0.8rem; }
  .container { padding: 1rem; }
  input { font-size: 1.1rem; width: 18ch; }
  .invite-card { flex-direction: column; align-items: stretch; }
  .invite-card button { align-self: flex-end; }
  .role-picker { gap: 1.5rem; flex-direction: column; align-items: center; }
  .landing-divider { width: 60%; height: 1px; min-height: 0; }
  .role-option button { font-size: 1.1rem; padding: 0.8rem 1.8rem; min-width: 110px; }
  .join-form { flex-wrap: wrap; justify-content: center; }
  .invite-row { flex-wrap: wrap; }
  .identity-display { flex-wrap: wrap; justify-content: center; }
  .room-code-wrap { flex-wrap: wrap; justify-content: center; }
  .flow-panel { max-width: 100%; }
}

/* Extra bottom padding for mobile browser chrome (address bar overlaps bottom) */
@media (max-width: 600px) {
  .container { padding-bottom: 6rem; }
  body { padding-bottom: env(safe-area-inset-bottom, 0); }
}

@media (max-width: 380px) {
  .role-picker { gap: 0.75rem; }
  .role-option button { font-size: 1rem; padding: 0.7rem 1.2rem; min-width: 90px; }
  .room-code { font-size: 1rem; padding: 0.4rem 0.6rem; letter-spacing: 0.1em; }
  input { font-size: 1rem; width: 16ch; }
  .chat-input-row button { padding: 0.5rem 0.6rem; }
}
