:root {
  color-scheme: light;
  --ink: #14201d;
  --muted: #66736f;
  --paper: #f7f7f3;
  --panel: #ffffff;
  --line: #d9dfdc;
  --green: #146b54;
  --green-strong: #0e4d3d;
  --blue: #315f9a;
  --coral: #c75f4d;
  --gold: #b98222;
  --shadow: 0 18px 50px rgba(20, 32, 29, 0.11);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(20, 107, 84, 0.07), transparent 34%),
    linear-gradient(180deg, #eef3f1 0%, var(--paper) 42%, #f2f0eb 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 2px 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.35rem, 3vw, 2.25rem);
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
  line-height: 1.15;
}

.status-pill,
.room-code,
.lang-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  padding: 0 12px;
  color: var(--green-strong);
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr 310px;
  gap: 16px;
  align-items: start;
}

.panel,
.stage {
  border: 1px solid rgba(217, 223, 220, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.stage {
  grid-column: 2;
  grid-row: 1 / span 3;
  padding: 18px;
  min-height: 720px;
}

.pair-panel {
  grid-column: 1;
  grid-row: 1 / span 3;
}

.settings-panel {
  grid-column: 3;
  grid-row: 1;
}

.engine-panel {
  grid-column: 3;
  grid-row: 2;
}

.section-head,
.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.qr-shell {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  min-height: 248px;
  padding: 14px;
}

.qr-code {
  display: grid;
  place-items: center;
  width: 218px;
  aspect-ratio: 1;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.qr-code svg {
  display: block;
  width: 100%;
  height: auto;
}

.button-grid,
.nfc-row,
.join-row,
.manual-row,
.field-grid {
  display: grid;
  gap: 10px;
}

.button-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
}

.nfc-row {
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.join-row {
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-top: 12px;
}

.manual-row {
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-top: 14px;
}

.field-grid {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.field-grid.single {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.field.compact {
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 64px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 107, 84, 0.14);
}

.btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  font-weight: 850;
  cursor: pointer;
}

.btn:hover {
  border-color: rgba(20, 107, 84, 0.45);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.btn.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.btn.primary:hover {
  background: var(--green-strong);
}

.microcopy {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  background: #f2f5f3;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  cursor: pointer;
  user-select: none;
}

.segmented input:checked + span {
  background: #fff;
  color: var(--green-strong);
  box-shadow: 0 6px 14px rgba(20, 32, 29, 0.09);
}

.peer-strip {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.peer-strip div {
  display: grid;
  gap: 4px;
}

.muted {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.engine-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(185, 130, 34, 0.16);
}

.engine-dot.proxy {
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(49, 95, 154, 0.16);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.toggle input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.meter {
  display: inline-grid;
  grid-template-columns: repeat(5, 6px);
  align-items: end;
  gap: 5px;
  height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.meter span {
  display: block;
  width: 6px;
  height: 7px;
  border-radius: 4px;
  background: var(--green);
  opacity: 0.38;
  transition: height 120ms ease, opacity 120ms ease;
}

.meter.live span:nth-child(1) {
  height: 13px;
  opacity: 0.7;
}

.meter.live span:nth-child(2) {
  height: 22px;
  opacity: 0.9;
}

.meter.live span:nth-child(3) {
  height: 29px;
  opacity: 1;
}

.meter.live span:nth-child(4) {
  height: 18px;
  opacity: 0.8;
}

.meter.live span:nth-child(5) {
  height: 11px;
  opacity: 0.65;
}

.mic-button {
  display: grid;
  place-items: center;
  gap: 7px;
  width: min(340px, 88vw);
  aspect-ratio: 1;
  margin: 26px auto 20px;
  border: 0;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.22), transparent 32%),
    linear-gradient(145deg, var(--green), #173d6a);
  color: #fff;
  box-shadow:
    0 24px 58px rgba(20, 107, 84, 0.28),
    inset 0 -16px 36px rgba(0, 0, 0, 0.16);
  cursor: pointer;
}

.mic-button span {
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 900;
}

.mic-button small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.86rem;
  font-weight: 800;
}

.mic-button.live {
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.2), transparent 32%),
    linear-gradient(145deg, var(--coral), #7f3654);
}

.live-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  padding: 12px;
  min-height: 82px;
}

.live-box p {
  margin: 6px 0 0;
  font-size: 1rem;
  line-height: 1.45;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.turn {
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.turn.remote {
  border-left-color: var(--blue);
}

.turn.system {
  border-left-color: var(--gold);
}

.turn.error {
  border-left-color: var(--coral);
}

.turn-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.turn p {
  margin: 8px 0 0;
  line-height: 1.42;
}

.turn .translated {
  color: var(--green-strong);
  font-weight: 850;
}

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

  .pair-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .settings-panel,
  .engine-panel {
    grid-column: 2;
    grid-row: auto;
  }

  .stage {
    grid-column: 1 / -1;
    grid-row: auto;
    min-height: auto;
  }
}

@media (max-width: 680px) {
  .app {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .appbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout,
  .field-grid,
  .manual-row {
    grid-template-columns: 1fr;
  }

  .pair-panel,
  .settings-panel,
  .engine-panel,
  .stage {
    grid-column: 1;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }

  .qr-shell {
    min-height: 226px;
  }

  .qr-code {
    width: 198px;
  }

  .mic-button {
    width: min(276px, 82vw);
  }
}
