:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #192124;
  --muted: #647174;
  --line: #d8e0e3;
  --accent: #256a5f;
  --accent-text: #ffffff;
  --danger: #9c2f2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app-shell {
  height: 100vh;
  padding: 28px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: filter 160ms ease, opacity 160ms ease;
}

.app-shell.is-locked {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 48px);
  letter-spacing: 0;
  font-weight: 850;
}

h1 span {
  font-weight: 400;
}

.topbar p,
.hint,
.panel-title span,
.placeholder {
  color: var(--muted);
}

.status-pill {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.status-pill.live {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent), white 55%);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgb(20 35 40 / 0.07);
}

.input-mic-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 120px;
  gap: 14px;
  align-items: center;
  width: min(560px, 100%);
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 8px;
  font-weight: 650;
}

input[type="password"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px 13px;
  background: #fbfcfc;
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcfc;
  margin-bottom: 14px;
  box-shadow: 0 8px 22px rgb(20 35 40 / 0.07);
}

.language-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  background: transparent;
  font-weight: 600;
}

.language-chip:last-child {
  border-right: 0;
}

.language-chip input {
  accent-color: var(--accent);
}

.language-chip:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  min-height: 46px;
}

.primary-button {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
  min-width: 190px;
}

.secondary-button {
  background: #eef3f2;
  color: var(--accent);
  font-weight: 750;
}

.secondary-button:disabled {
  opacity: 0.45;
  cursor: default;
}

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

.hint {
  grid-column: 1 / -1;
  font-size: 13px;
}

.mic-meter {
  height: 10px;
}

.live-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.panel {
  min-height: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
}

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

.display-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toggle-control {
  display: inline-flex !important;
  grid-auto-flow: column;
  align-items: center;
  gap: 7px !important;
  min-height: 34px;
}

.toggle-control input {
  accent-color: var(--accent);
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcfc;
}

.segmented-control button {
  width: 38px;
  height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.is-active {
  background: var(--accent);
  color: var(--accent-text);
}

.segmented-control button:disabled {
  opacity: 0.4;
  cursor: default;
}

.text-size-control button {
  font-weight: 800;
  font-size: 20px;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: #e3ebed;
  overflow: hidden;
}

#meterFill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 80ms linear;
}

.translation-card .caption-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  scroll-behavior: auto;
  min-height: 0;
  padding-right: 4px;
}

.translation-card .caption-stack > :first-child {
  margin-top: auto;
}

.translation-card p {
  font-size: clamp(21px, calc(var(--card-font-scale, 1) * 3vw), 44px);
  line-height: 1.12;
  font-weight: 720;
  hyphens: none;
  overflow-wrap: normal;
  text-wrap: pretty;
  word-break: normal;
}

.translation-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.translation-target-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  min-height: 0;
}

.translation-target-grid.target-count-2,
.translation-target-grid.target-count-3,
.translation-target-grid.target-count-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.translation-target-grid.target-count-3,
.translation-target-grid.target-count-4 {
  grid-auto-rows: minmax(0, 1fr);
}

.translation-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  min-height: 0;
  flex-direction: column;
  background: var(--panel);
}

.source-card {
  background: #f9fbfb;
}

.source-card p {
  font-size: clamp(17px, calc(var(--card-font-scale, 1) * 2vw), 32px);
  color: var(--muted);
}

.translation-grid[data-contrast="warm"] .translation-card {
  background: #fff8ef;
}

.translation-grid[data-contrast="light"] .translation-card {
  background: #fbfcfc;
}

.translation-grid[data-contrast="warm"] .source-card,
.translation-grid[data-contrast="light"] .source-card {
  background: color-mix(in srgb, var(--panel), var(--bg) 55%);
}

.translation-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.translation-card header h3 {
  margin: 0;
}

.pop-button {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  width: 38px;
  height: 38px;
  padding: 0;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.caption-line {
  animation: caption-rise 160ms linear;
}

@keyframes caption-rise {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.display-body {
  --display-bg: #090909;
  --display-text: #fff6df;
  --display-muted: #b5aaa0;
  background: var(--display-bg);
  color: var(--display-text);
  overflow: hidden;
}

.display-body[data-contrast="warm"] {
  --display-bg: #1c1310;
  --display-text: #fff1d6;
  --display-muted: #cbbba4;
}

.display-body[data-contrast="light"] {
  --display-bg: #f8f7f2;
  --display-text: #101414;
  --display-muted: #546061;
}

.projector-root {
  height: 100vh;
  padding: min(5vw, 72px);
}

.projector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: min(3vw, 44px);
}

.projector-with-source {
  grid-template-columns: minmax(240px, 0.42fr) minmax(0, 1fr);
}

.projector-target-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: min(3vw, 44px);
  min-height: 0;
}

.projector-with-source.target-count-2 .projector-target-grid,
.projector-with-source.target-count-3 .projector-target-grid,
.projector-with-source.target-count-4 .projector-target-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.projector-with-source.target-count-3 .projector-target-grid,
.projector-with-source.target-count-4 .projector-target-grid {
  grid-auto-rows: minmax(0, 1fr);
}

.projector-root:not(.projector-grid) .projector-column,
.projector-root > .placeholder {
  height: 100%;
}

.projector-column {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.projector-column h2 {
  margin: 0 0 min(2vw, 24px);
  color: var(--display-muted);
  font-size: clamp(22px, 2.2vw, 42px);
}

.projector-feed {
  flex: 1;
  min-height: 0;
  display: block;
  overflow-y: auto;
  overflow-anchor: none;
  scroll-behavior: auto;
}

.projector-feed p {
  margin: 0 0 min(2.2vw, 22px);
  color: var(--display-text);
  font-size: clamp(34px, calc(var(--font-scale, 1) * 7vw), 118px);
  line-height: 1.06;
  font-weight: 800;
  letter-spacing: 0;
}

.source-column .projector-feed p {
  color: var(--display-muted);
  font-size: clamp(24px, calc(var(--font-scale, 1) * 4.3vw), 72px);
  font-weight: 700;
}

.projector-feed .placeholder {
  color: var(--display-muted);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(245 247 248 / 0.52);
}

.auth-overlay[hidden] {
  display: none;
}

.auth-card {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgb(20 35 40 / 0.18);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand h2 {
  font-size: 34px;
  line-height: 1;
}

.auth-brand h2 span {
  font-weight: 400;
}

.company-logo {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 850;
  letter-spacing: 0;
}

.remember-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 650;
}

.remember-option input {
  accent-color: var(--accent);
}

.auth-status {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
}

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

  .topbar,
  .live-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .input-mic-row {
    grid-template-columns: 1fr;
  }

  .live-grid {
    display: grid;
  }

  .translation-grid,
  .translation-target-grid.target-count-2,
  .translation-target-grid.target-count-3,
  .translation-target-grid.target-count-4 {
    grid-template-columns: 1fr;
  }

  .projector-with-source,
  .projector-with-source.target-count-2 .projector-target-grid,
  .projector-with-source.target-count-3 .projector-target-grid,
  .projector-with-source.target-count-4 .projector-target-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: 330px;
  }

  .primary-button {
    width: 100%;
  }

  .language-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
