:root {
  color-scheme: light;
  --bg: #f4f7f7;
  --surface: #ffffff;
  --surface-2: #eef4f4;
  --text: #172122;
  --muted: #657172;
  --border: #d8e1e1;
  --accent: #256f78;
  --accent-strong: #1d5f68;
  --blue: #2468a8;
  --live: #1d8a5f;
  --danger: #b24135;
  --shadow: 0 18px 55px rgba(31, 49, 51, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(37, 111, 120, 0.12), transparent 38%), var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

input {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.screen {
  display: flex;
  min-height: calc(100vh - 46px);
  flex-direction: column;
  gap: 14px;
}

.is-hidden {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 2px 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
  font-weight: 760;
  letter-spacing: 0;
}

h2 {
  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;
}

.topbar p,
.label,
.small-status,
.link-text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 88px;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a6b1b2;
}

.status-dot.live::before {
  background: var(--live);
  box-shadow: 0 0 0 5px rgba(29, 138, 95, 0.14);
}

.status-dot.warn::before {
  background: var(--danger);
}

.hero-panel,
.panel,
.translation-card,
.empty-state {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.channel-row,
.panel-header,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.token-row {
  display: grid;
  gap: 7px;
}

.token-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.token-input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
}

.config-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.config-pill {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.config-pill.is-ready {
  border-color: rgba(29, 138, 95, 0.28);
  background: rgba(29, 138, 95, 0.09);
  color: #176b4a;
}

.config-pill.is-warn {
  border-color: rgba(178, 65, 53, 0.25);
  background: rgba(178, 65, 53, 0.07);
  color: #8a3028;
}

.phone-readiness {
  display: grid;
  gap: 4px;
  min-height: 68px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.phone-readiness strong {
  font-size: 16px;
  line-height: 1.25;
}

.phone-readiness.is-ready {
  border-color: rgba(29, 138, 95, 0.28);
  background: rgba(29, 138, 95, 0.09);
}

.phone-readiness.is-ready strong {
  color: #176b4a;
}

.phone-readiness.is-warn {
  border-color: rgba(178, 65, 53, 0.25);
  background: rgba(178, 65, 53, 0.07);
}

.phone-readiness.is-warn strong {
  color: #8a3028;
}

.channel-row strong {
  display: block;
  margin-top: 2px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 30px;
  letter-spacing: 0;
}

.mic-area {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 16px;
  min-height: 108px;
}

.mic-ring {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
  border: 1px solid #c9dbdc;
}

.mic-ring.is-live {
  background: rgba(29, 138, 95, 0.12);
  color: var(--live);
  box-shadow: 0 0 0 9px rgba(29, 138, 95, 0.08);
}

.mic-ring svg,
.icon-button svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.mic-area strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
  line-height: 1.1;
}

.mic-level {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.mic-level-bar {
  display: block;
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--live) calc(var(--mic-level, 0) * 100%), #dce6e6 0);
  border: 1px solid #c9dbdc;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 720;
}

.primary-button {
  flex: 1;
  background: var(--accent);
  color: #fff;
}

.primary-button.is-stop {
  background: var(--danger);
}

.secondary-button {
  padding: 0 16px;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.icon-button {
  display: grid;
  width: 38px;
  min-height: 38px;
  place-items: center;
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--accent);
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.split-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.panel {
  padding: 15px;
}

.qr-panel {
  min-height: 300px;
}

.qr-image {
  display: block;
  width: min(100%, 240px);
  aspect-ratio: 1 / 1;
  height: auto;
  margin: 14px auto 10px;
  image-rendering: crisp-edges;
}

.qr-image:not([src]) {
  display: none;
}

.link-text {
  overflow-wrap: anywhere;
  text-align: center;
}

.preview-panel {
  display: grid;
  gap: 12px;
}

.ko-preview {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.zh-preview {
  font-size: 20px;
  line-height: 1.45;
  font-weight: 720;
}

.listener-screen {
  gap: 16px;
}

.listener-host-state {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 720;
  line-height: 1.35;
}

.listener-host-state.is-live {
  border-color: rgba(29, 138, 95, 0.28);
  background: rgba(29, 138, 95, 0.09);
  color: #176b4a;
}

.listener-host-state.is-warn {
  border-color: rgba(178, 65, 53, 0.25);
  background: rgba(178, 65, 53, 0.07);
  color: #8a3028;
}

.translation-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
}

.translation-card {
  padding: 15px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.translation-card.is-new {
  border-color: rgba(29, 138, 95, 0.36);
  box-shadow: 0 0 0 3px rgba(29, 138, 95, 0.13);
}

.translation-card time {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.translation-card .latency {
  display: inline-block;
  margin-left: 8px;
  color: #176b4a;
}

.translation-card p {
  font-size: 20px;
  font-weight: 720;
  line-height: 1.48;
}

.translation-card .source {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-content: center;
  padding: 22px;
  text-align: center;
  box-shadow: none;
}

.empty-state h2 {
  margin-bottom: 8px;
  font-size: 19px;
}

.empty-state p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }

  .status-dot {
    min-width: 0;
  }

  .channel-row,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .channel-row .secondary-button,
  .button-row .primary-button,
  .button-row .secondary-button {
    width: 100%;
    flex: none;
  }

  .token-control,
  .config-strip {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    padding: 16px;
  }
}

@media (min-width: 820px) {
  .app-shell {
    width: min(100%, 980px);
    padding: 30px;
  }

  .screen {
    min-height: calc(100vh - 60px);
  }

  .split-panels {
    grid-template-columns: 0.85fr 1.15fr;
  }

  .listener-screen {
    width: min(100%, 620px);
    margin: 0 auto;
  }
}
