:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #1b1f24;
  --panel-border: #323942;
  --text: #f2f5f7;
  --muted: #a8b1bb;
  --accent: #2fbf8f;
  --accent-strong: #20a97d;
  --danger: #e16b5f;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  min-height: 100vh;
}

.camera-stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(47, 191, 143, 0.12), transparent 34%),
    radial-gradient(circle at 70% 15%, rgba(239, 201, 93, 0.1), transparent 30%),
    #090a0c;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050607;
}

video.mirrored {
  transform: scaleX(-1);
}

.video-translation-overlay {
  position: absolute;
  left: 50%;
  bottom: clamp(120px, 15vh, 190px);
  z-index: 20;
  width: min(90%, 980px);
  max-height: 30vh;
  overflow: hidden;
  padding: 14px 22px;
  color: #ffffff;
  text-align: center;
  font-size: clamp(22px, 2.6vw, 40px);
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.95),
    0 0 18px rgba(0, 0, 0, 0.9);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  pointer-events: none;
}

.video-translation-overlay.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.remote-videos {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: none;
  grid-template-columns: repeat(2, minmax(140px, 190px));
  gap: 10px;
}

.remote-videos.visible {
  display: grid;
}

.remote-video-tile {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #050607;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.remote-video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remote-video-tile span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  overflow: hidden;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  background: #0c0e11;
}

.empty-state.hidden {
  display: none;
}

.lens-mark {
  width: 92px;
  aspect-ratio: 1;
  border: 3px solid #5d6874;
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 16px #151a20,
    inset 0 0 0 28px #2fbf8f,
    0 20px 60px rgba(0, 0, 0, 0.35);
}

h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 68px);
  line-height: 1;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 22px;
  border-left: 1px solid var(--panel-border);
  background: var(--panel);
  max-height: 100vh;
  overflow-y: auto;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  color: var(--muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6f7782;
}

.status-dot.live {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(47, 191, 143, 0.14);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(225, 107, 95, 0.14);
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.room-panel {
  display: grid;
  gap: 8px;
}

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

.compact-field span {
  font-size: 14px;
}

select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #12161b;
}

input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #12161b;
}

.invite-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.invite-row:has(#phoneLinkInput) {
  grid-template-columns: minmax(0, 1fr) auto;
}

.invite-row button {
  min-height: 36px;
  padding: 0 10px;
  white-space: nowrap;
}

.phone-link-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.link-hint {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.link-hint.warning {
  color: #f4c46b;
}

.share-command-button {
  width: 100%;
  min-height: 34px;
  margin-top: 2px;
  padding: 0 10px;
  font-size: 13px;
}

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

.bottom-controls {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.caption-panel {
  display: grid;
  gap: 8px;
  min-height: 116px;
}

.translation-panel {
  min-height: 116px;
}

.caption-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.caption-header h2 {
  margin: 0;
  font-size: 20px;
}

.caption-header span {
  color: var(--muted);
  font-size: 14px;
}

.caption-output {
  height: 92px;
  min-height: 92px;
  max-height: 92px;
  overflow-y: auto;
  padding: 12px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #12161b;
}

.translation-panel .caption-output {
  height: 92px;
  min-height: 92px;
  max-height: 92px;
}

.caption-output p {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.caption-output p:last-child {
  margin-bottom: 0;
}

.caption-placeholder,
.caption-output .caption-interim {
  color: var(--muted);
}

button {
  min-height: 40px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #242a31;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #4d5865;
  background: #2b323b;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.primary {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #03120d;
  font-weight: 700;
}

.help-text {
  margin-top: auto;
  font-size: 14px;
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 1fr) auto;
  }

  .control-panel {
    gap: 14px;
    padding: 18px;
    border-top: 1px solid var(--panel-border);
    border-left: 0;
  }

  .caption-panel {
    min-height: 108px;
  }

  .translation-panel {
    min-height: 108px;
  }

  .caption-output {
    height: 84px;
    min-height: 84px;
    max-height: 84px;
  }

  .translation-panel .caption-output {
    height: 84px;
    min-height: 84px;
    max-height: 84px;
  }
}
