:root {
  --bg: #0f1219;
  --card: #171c26;
  --border: #2a3140;
  --text: #e8ecf3;
  --muted: #8b94a7;
  --accent: #4f8cff;
  --green: #3ecf8e;
  --red: #ff5d5d;
  --amber: #ffb454;
}

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

/* The hidden attribute must always win, even over author display rules
   (display:flex/grid on a class silently overrides it otherwise). */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

h1 { font-size: 20px; }

.header-controls label {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.banner {
  background: #3a2c14;
  color: var(--amber);
  padding: 10px 24px;
  font-size: 14px;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.mode-tab {
  padding: 10px 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #1c2230;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.mode-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mode-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mode-panel[hidden] { display: none; }

.mode-intro {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}
.mode-intro strong { color: var(--text); font-weight: 600; }

.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 860px) {
  .cards-grid { grid-template-columns: 1fr; }
}

.controls-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) {
  .controls-4 { grid-template-columns: 1fr 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h2 { font-size: 17px; }

.status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #232a38;
  color: var(--muted);
}
.status[data-state="live"] { background: #12362a; color: var(--green); }
.status[data-state="connecting"] { background: #3a2c14; color: var(--amber); }
.status[data-state="hearing"],
.status[data-state="translating"] { background: #16294a; color: var(--accent); }

.hint { font-size: 13px; color: var(--muted); line-height: 1.5; }

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

select {
  background: #10141d;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 13px;
  width: 100%;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.checkbox input { accent-color: var(--accent); }

.meter {
  height: 6px;
  background: #10141d;
  border-radius: 3px;
  overflow: hidden;
}
.meter-bar {
  height: 100%;
  width: 0%;
  background: var(--green);
  transition: width 60ms linear;
}

.actions { display: flex; gap: 10px; }

.btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #232a38;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: 0.45; cursor: default; }

.error { color: var(--red); font-size: 13px; min-height: 18px; }

.turns {
  flex: 1;
  min-height: 180px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.turn {
  position: relative;
  background: #10141d;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.turn-original { color: var(--muted); font-size: 13px; }
.turn-translated { font-size: 15px; line-height: 1.45; }

.turn-latency {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 11px;
  color: var(--muted);
  background: #1c2230;
  padding: 1px 7px;
  border-radius: 999px;
}

.ptt-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.ptt {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid #a33;
  background: radial-gradient(circle at 35% 30%, #ff6b6b, #c92a2a);
  font-size: 36px;
  cursor: pointer;
  touch-action: none;               /* no scroll/long-press menu while holding */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.ptt:disabled { opacity: 0.35; cursor: default; }
.ptt.held {
  transform: scale(1.12);
  box-shadow: 0 0 0 10px rgba(255, 93, 93, 0.25), 0 0 30px rgba(255, 93, 93, 0.5);
}
.ptt-label { font-size: 12px; color: var(--muted); }

footer {
  padding: 12px 24px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
