:root {
  --bg: #0b1220;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.08);
  --text: rgba(255, 255, 255, 0.9);
  --muted: rgba(255, 255, 255, 0.65);
  --border: rgba(255, 255, 255, 0.14);
  --primary: #7c3aed;
  --primary2: #8b5cf6;
  --danger: #ef4444;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, Noto Sans,
    "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 800px at 20% 10%, rgba(124, 58, 237, 0.35), transparent 60%),
    radial-gradient(900px 700px at 80% 20%, rgba(59, 130, 246, 0.22), transparent 60%),
    radial-gradient(700px 600px at 50% 90%, rgba(16, 185, 129, 0.18), transparent 60%), var(--bg);
  color: var(--text);
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 36px 18px 56px;
}

.header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.card {
  background: linear-gradient(180deg, var(--card), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.spacer {
  flex: 1 1 auto;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
}

.btn:active {
  transform: translateY(0px);
}

.btn-primary {
  border-color: rgba(124, 58, 237, 0.6);
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.75), rgba(124, 58, 237, 0.45));
}

.btn-primary:hover {
  border-color: rgba(139, 92, 246, 0.9);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.82), rgba(124, 58, 237, 0.5));
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.6);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.75), rgba(239, 68, 68, 0.45));
}

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

select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 12px;
  outline: none;
}

.dual-status {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.dual-status.active {
  border-color: rgba(124, 58, 237, 0.5);
  background: rgba(124, 58, 237, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.0);
  transition: background 120ms ease;
}

.dot.live {
  background: var(--primary2);
  box-shadow: 0 0 0 6px rgba(124, 58, 237, 0.18);
}

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

.panel {
  margin-top: 12px;
}

.panel h2 {
  margin: 0 0 8px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.panel-head h2 {
  margin: 0;
}

.translation-status {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.translation-status.loading {
  color: rgba(139, 92, 246, 0.95);
}

.translation-status.error {
  color: #fca5a5;
}

.conversation {
  min-height: 320px;
  max-height: 420px;
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px;
  background: rgba(3, 7, 18, 0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.conversation-empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.msg {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.msg-speaker {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}

.msg-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.55), rgba(124, 58, 237, 0.35));
  border: 1px solid rgba(139, 92, 246, 0.35);
  line-height: 1.45;
  word-break: break-word;
}

.msg-translation {
  max-width: 85%;
  margin-top: 4px;
  padding: 8px 12px;
  border-radius: 12px 12px 4px 12px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-translation span {
  flex: 1;
}

.btn-speak {
  border: 1px solid rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.2);
  color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.btn-speak:hover {
  background: rgba(16, 185, 129, 0.32);
}

.msg-translation.loading {
  color: var(--muted);
  border-style: dashed;
  background: rgba(255, 255, 255, 0.04);
}

.msg-translation.error {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
}

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

h2 {
  margin: 0 0 8px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 12px 12px;
  background: rgba(3, 7, 18, 0.35);
  color: var(--text);
  line-height: 1.4;
  outline: none;
}

.hint {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--muted);
  line-height: 1.35;
  min-height: 20px;
}

.hint.error {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
  color: rgba(255, 255, 255, 0.85);
}

.hint[hidden] {
  display: none;
  margin: 0;
  padding: 0;
  min-height: 0;
  border: 0;
}

.select.invalid select {
  border-color: rgba(239, 68, 68, 0.65);
}

/* Mobile app layout */
body {
  min-height: 100dvh;
  background:
    radial-gradient(520px 420px at 20% 0%, rgba(124, 58, 237, 0.32), transparent 60%),
    radial-gradient(520px 420px at 90% 18%, rgba(14, 165, 233, 0.22), transparent 60%),
    #07111f;
  overflow: hidden;
}

.wrap {
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  margin: 0 auto;
  padding: 0;
}

.app-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border: 0;
  padding: 14px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(3, 7, 18, 0.98));
  box-shadow: none;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 10px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.language-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.055);
}

.language-bar .select {
  min-width: 0;
  display: grid;
  gap: 5px;
  font-size: 11px;
}

.language-bar .select span {
  padding-left: 3px;
}

.language-bar select {
  width: 100%;
  min-width: 0;
  padding: 10px 9px;
  border-radius: 13px;
  font-size: 13px;
  background: rgba(15, 23, 42, 0.9);
}

.swap-mark {
  align-self: center;
  color: var(--muted);
  font-weight: 700;
  padding-bottom: 4px;
}

.dual-status {
  grid-column: 1 / -1;
  width: 100%;
  text-align: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.busy-room-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  color: var(--text);
}

.busy-room-toggle input {
  accent-color: var(--primary);
}

.busy-room-toggle:has(input:checked) {
  border-color: rgba(124, 58, 237, 0.55);
  background: rgba(124, 58, 237, 0.12);
}

.audio-options {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.mic-select {
  width: 100%;
  padding: 10px 11px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font-size: 13px;
}

.mic-meter {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
}

.mic-meter-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.mic-meter-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #84cc16);
  transition: width 80ms linear;
}

.mic-meter-fill.loud {
  background: linear-gradient(90deg, #84cc16, #7c3aed);
}

.mic-meter-threshold {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.75);
  pointer-events: none;
}

.status {
  margin: 0;
  justify-content: flex-end;
  font-size: 13px;
  white-space: nowrap;
}

.conversation {
  flex: 1;
  min-height: 0;
  max-height: none;
  margin-top: 12px;
  padding: 14px 10px;
  border-radius: 22px;
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(2, 6, 23, 0.52);
  gap: 16px;
  scroll-behavior: smooth;
}

.conversation-empty {
  max-width: 220px;
  line-height: 1.45;
}

.msg {
  align-items: stretch;
  gap: 6px;
}

.msg-row {
  display: flex;
}

.msg-stack {
  max-width: 84%;
}

.msg-label {
  display: block;
  margin: 0 4px 3px;
  color: rgba(255, 255, 255, 0.38);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.msg-row.source .msg-label {
  text-align: right;
}

.msg-row.source {
  justify-content: flex-end;
}

.msg-row.translated {
  justify-content: flex-start;
}

.msg-bubble,
.msg-translation {
  border-radius: 20px;
  padding: 11px 14px;
  font-size: 15px;
  line-height: 1.38;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.msg-bubble {
  border-bottom-right-radius: 6px;
  background: linear-gradient(180deg, #7c3aed, #5b21b6);
}

.msg-translation {
  margin: 0;
  border-bottom-left-radius: 6px;
  background: rgba(16, 185, 129, 0.18);
}

.msg-time {
  display: block;
  padding: 0 4px;
  text-align: right;
  color: rgba(255, 255, 255, 0.38);
  font-size: 10px;
}

.live-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.live-strip textarea {
  min-height: 54px;
  max-height: 72px;
  resize: none;
  border-radius: 16px;
  padding: 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.045);
}

.hint {
  min-height: 0;
  margin-top: 8px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.48);
  font-size: 12px;
}

.bottom-bar {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
}

.btn {
  min-height: 44px;
  border-radius: 16px;
  font-weight: 700;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
}

.mic-button {
  min-height: 58px;
  border-radius: 999px;
  font-size: 17px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.mic-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.mic-button.talking {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.85), rgba(5, 150, 105, 0.62));
  border-color: rgba(16, 185, 129, 0.8);
  box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.12);
}

.session-button {
  padding-inline: 10px;
  font-size: 13px;
}

.translation-status {
  text-align: right;
  font-size: 11px;
  white-space: normal;
}

@media (min-width: 700px) {
  body {
    overflow: auto;
  }

  .wrap {
    padding: 20px 0;
  }

  .app-shell {
    border-radius: 32px;
    min-height: calc(100dvh - 40px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding: 10px;
  }

  .app-header h1 {
    font-size: 21px;
  }

  .language-bar {
    gap: 6px;
    padding: 8px;
  }

  .msg-bubble,
  .msg-translation,
  .msg-stack {
    max-width: 90%;
  }
}

