* {
  margin:0;
  padding:0;
  box-sizing:border-box;
}
html, body { height:100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f0f0f;
  color: #fff;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}

/* ──── Layout ──── */
.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px 16px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 4px 0 8px;
  margin-bottom: 12px;
}

.header h1 {
  font-size: 1rem;
  font-weight: 600;
  color: #ccc;
  letter-spacing: 0.02em;
  line-height: 1.25rem;
  min-height: 1.25rem;
}

.header .hint {
  font-size: 0.8rem;
  color: #555;
  margin-top: 8px;
  line-height: 1.2rem;
  min-height: 2.4rem;
}

.footer {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer .ver {
  font-size: 0.7rem;
  color: #444;
  letter-spacing: 0.08em;
}

.lang-dropdown {
  position: relative;
  flex-shrink: 0;
}

#lang-toggle {
  background: transparent;
  border: none;
  border-radius: 0;
  color: #888;
  font-size: 0.65rem;
  width: 64px;
  min-width: 64px;
  height: 28px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 0.2s;
}

#lang-toggle-label {
  flex: 1;
  text-align: center;
}

#lang-toggle:hover,
.lang-dropdown.open #lang-toggle {
  color: #ccc;
}

.lang-chevron {
  width: 6px;
  height: 6px;
  border-right: 1px solid currentcolor;
  border-bottom: 1px solid currentcolor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.lang-dropdown.open .lang-chevron {
  transform: rotate(-135deg) translateY(1px);
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 100%;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  z-index: 10;
}

.footer .lang-dropdown-menu {
  top: auto;
  bottom: calc(100% + 4px);
}

.lang-dropdown-menu[hidden] {
  display: none;
}

.lang-option {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: #888;
  font-size: 0.65rem;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s;
}

.lang-option:hover,
.lang-option.active {
  background: #252525;
  color: #ccc;
}

/* ──── Grid ──── */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* ──── Broadcast card (全部) ──── */
.room-card.broadcast-card {
  grid-column: 1 / -1;
  margin-bottom: 6px;
  padding: 14px clamp(24px, 8vw, 48px);
  align-items: stretch;
}

.broadcast-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.broadcast-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  flex: 0 0 auto;
  margin-left: 12px;
}

.broadcast-label {
  font-size: 30px;
  line-height: 30px;
  font-weight: 600;
  color: #f0a030;
  width: 100%;
}

.broadcast-card .status {
  text-align: left;
  width: 100%;
  margin-top: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.broadcast-card .ptt-wrap {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

.broadcast-card .waves {
  inset: -16px;
}

@media (width <= 420px) {
  .container {
    padding: 16px 14px;
  }

  .room-card.broadcast-card {
    padding: 12px clamp(18px, 6vw, 32px);
  }

  .broadcast-main {
    gap: 8px;
  }

  .broadcast-info {
    margin-left: 6px;
  }

  .broadcast-label {
    font-size: 24px;
    line-height: 24px;
  }

  .broadcast-card .ptt-wrap {
    width: 96px;
    height: 96px;
  }

  .broadcast-card .waves {
    inset: -12px;
  }
}

/* ──── Room card ──── */
.room-card {
  background: #1a1a1a;
  border-radius: 20px;
  padding: 16px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: background .3s, box-shadow .3s;
  border: 1px solid #2a2a2a;
}

.room-card:not(.broadcast-card) {
  padding: 12px 10px 10px;
  gap: 10px;
}

.room-card:not(.broadcast-card) .room-header {
  align-self: stretch;
}

.room-card:not(.broadcast-card) .ptt-wrap {
  width: 92px;
  height: 92px;
}

.room-card:not(.broadcast-card) .waves {
  inset: -12px;
}

/* ──── Room header ──── */
.room-header {
  font-size: 0.9rem;
  font-weight: 500;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.room-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.room-name {
  font-size: 14px;
  line-height: 14px;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  width: 100%;
}

.device-name {
  font-size: 10px;
  line-height: 10px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.room-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
}

.room-header .dot {
  flex-shrink: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #444;
  transition: background .3s;
}

/* Dot state classes — used by pollSpeakerStatus + processAndSend */
.dot-online {
  background: #33d17a !important;
  box-shadow: 0 0 4px #33d17a;
}

.dot-error {
  background: #c0392b !important;
  box-shadow: 0 0 4px #c0392b;
}

/* ──── PTT Button ──── */
.ptt-wrap {
  position: relative;
  width: 120px;
  height: 120px;
}

.ptt-btn {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: none;
  background: #252525;
  box-shadow: 0 6px 16px rgb(0 0 0 / 30%), inset 0 1px 2px rgb(255 255 255 / 6%);
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: transform .15s ease, background .3s, box-shadow .3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ptt-btn:active {
  transform: scale(0.96);
}

/* ──── Ripple waves ──── */
.waves {
  position: absolute;
  inset: -16px;
  z-index: 1;
}

.waves::before,
.waves::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #33d17a;
  opacity: 0;
}

/* ──── PTT icon (9 cells: classic = 4 bars, nothing = 3×3 dots) ──── */
.ptt-icon {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  justify-content: center;
  height: 36px;
  transition: opacity .25s, transform .25s;
}

.ptt-icon span:nth-child(n+5) {
  display: none;
}

.ptt-icon span {
  width: 5px;
  background: #666;
  border-radius: 10px;
  transition: background .3s, height .2s;
}
.ptt-icon span:nth-child(1) { height: 14px; }
.ptt-icon span:nth-child(2) { height: 28px; }
.ptt-icon span:nth-child(3) { height: 20px; }
.ptt-icon span:nth-child(4) { height: 10px; }

/* ──── Big checkmark (sent state) ──── */
.checkmark {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-size: 3.4rem;
  font-weight: 700;
  color: #fff;
  animation: pop-in .4s cubic-bezier(0.34,1.56,0.64,1);
}

.sent .checkmark {
  display: flex;
}

.sent .ptt-icon {
  opacity: 0;
}

@keyframes pop-in {
0% {
  transform: scale(0);
  opacity: 0;
}

60% {
  transform: scale(1.15);
  opacity: 1;
}

100% {
  transform: scale(1);
  opacity: 1;
}
}

/* ──── Status text ──── */
.status {
  font-size: 0.75rem;
  color: #555;
  height: 1.4em;
  line-height: 1.4em;
  text-align: center;
  transition: color .3s;
}

/* ══════════════════════════════════════
   STATES
   ══════════════════════════════════════ */

/* recording */
.room-card.recording {
  border-color: rgb(51 209 122 / 40%);
  box-shadow: 0 0 24px rgb(51 209 122 / 8%);
}

.room-card.recording .ptt-btn {
  background: #2a5038;
  transform: scale(0.95);
  box-shadow: inset 0 4px 14px rgb(0 0 0 / 35%);
}
.room-card.recording .status { color: #33d17a; }

.room-card.recording .ptt-icon span {
  background: #33d17a;
  animation: bounce .6s ease-in-out infinite alternate;
}

/* wave animation */
.room-card.recording .waves::before {
  animation: ripple 2s ease-out infinite;
}

.room-card.recording .waves::after {
  animation: ripple 2s ease-out infinite 1s;
}

@keyframes ripple {
0% {
  transform: scale(1);
  opacity: .5;
}

100% {
  transform: scale(1.4);
  opacity: 0;
}
}

.room-card.recording .ptt-icon span:nth-child(2) { animation-delay: .1s; }
.room-card.recording .ptt-icon span:nth-child(3) { animation-delay: .2s; }
.room-card.recording .ptt-icon span:nth-child(4) { animation-delay: .3s; }

@keyframes bounce {
  from { transform: scaleY(.6); }
  to   { transform: scaleY(1.3); }
}

/* disabled (offline / not ready) */
.room-card.unavailable {
  opacity: .45;
}

.room-card.unavailable .ptt-btn {
  cursor: not-allowed;
  pointer-events: none;
}
.room-card.unavailable .status { color: #c0392b; }

/* sending */
.room-card.sending {
  border-color: rgb(51 209 122 / 35%);
  box-shadow: 0 0 24px rgb(51 209 122 / 8%);
}

.room-card.sending .ptt-btn {
  background: #2a5038;
}
.room-card.sending .ptt-icon { opacity: 0; }
.room-card.sending .checkmark { display: none; }

.room-card.sending .ptt-btn::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 3px solid rgb(51 209 122 / 20%);
  border-top-color: #33d17a;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.room-card.sending .status { color: #f0a030; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* sent */
.room-card.sent {
  border-color: rgb(51 209 122 / 35%);
}

.room-card.sent .ptt-btn {
  background: #2a5038;
}
.room-card.sent .status { color: #33d17a; }

/* broadcast card accent */
.broadcast-card.recording .status { color: #f0a030; }
.broadcast-card.recording .ptt-btn { background: #503a20; }
.broadcast-card.sent .ptt-btn { background: #503a20; }

.broadcast-card .waves::before,
.broadcast-card .waves::after { border-color: #f0a030; }
