:root {
  color-scheme: dark;
  --ink: #f8f4ef;
  --muted: rgba(248, 244, 239, 0.72);
  --line: rgba(248, 244, 239, 0.12);
  --line-strong: rgba(248, 244, 239, 0.22);
  --accent: #ff8d63;
  --accent-dark: #d8663f;
  --surface: rgba(14, 15, 18, 0.84);
  --surface-strong: rgba(22, 23, 28, 0.94);
  --surface-soft: rgba(255, 255, 255, 0.04);
  --success: #6dd4a2;
  --warning: #ffcf70;
  --danger: #ff8f8f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050608;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

body {
  background:
    radial-gradient(circle at top right, rgba(216, 102, 63, 0.18), transparent 28%),
    radial-gradient(circle at bottom left, rgba(86, 127, 168, 0.18), transparent 32%),
    #050608;
}

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

.hidden {
  display: none !important;
}

.screen-root {
  position: relative;
  width: 100%;
  height: 100%;
}

iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
  opacity: 0;
  transition: opacity 180ms ease;
}

iframe.active {
  opacity: 1;
}

.overlay-toggle-button {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(248, 244, 239, 0.18);
  padding: 0;
  border-radius: 999px;
  background: rgb(255, 255, 255);
  color: var(--ink);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  cursor: pointer;
  line-height: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.screen-root:hover .overlay-toggle-button.is-available,
.overlay-toggle-button.is-available:focus-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.overlay-toggle-button:hover,
.overlay-toggle-button:focus-visible {
  background: rgba(225, 225, 225, 0.96);
  border-color: rgba(248, 244, 239, 0.32);
  outline: none;
}

.overlay-toggle-button svg {
  width: 20px;
  height: 20px;
}

.overlay-toggle-button img {
  width: 20px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
  margin: auto;
  object-fit: contain;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 7, 10, 0.5);
  backdrop-filter: blur(10px);
  transition: opacity 180ms ease;
}

.screen-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-panel {
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px 26px 26px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: 0 38px 110px rgba(0, 0, 0, 0.35);
}

.overlay-shell {
  display: grid;
  gap: 24px;
}

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

.overlay-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 28px;
  align-items: center;
}

.status.is-empty {
  display: none;
}

.overlay-copy {
  display: grid;
  align-content: center;
  gap: 20px;
  min-width: 0;
  padding-top: 0;
}

.overlay-copy-texts {
  display: grid;
  gap: 14px;
}

.overlay-instructions,
.overlay-hint {
  margin: 0;
}

.overlay-instructions {
  max-width: 42ch;
  color: var(--ink);
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  line-height: 1.45;
}

.overlay-hint {
  max-width: 46ch;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.language-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255, 255, 255);
  overflow: hidden;
}

.language-control:focus-within {
  outline: 2px solid rgba(255, 141, 99, 0.18);
  border-color: rgba(255, 141, 99, 0.44);
}

.language-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.language-icon img,
.language-icon svg {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}

.language-icon svg {
  fill: currentColor;
}

.language-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.qr-box {
  display: grid;
  place-items: center;
  width: min(360px, 100%);
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  overflow: hidden;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pair-copy {
  min-width: 0;
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
  width: min(360px, 100%);
}

.overlay-pairing {
  display: grid;
  justify-items: center;
  gap: 18px;
}

.pair-code-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.pair-code {
  min-width: 0;
  font-size: clamp(1.1rem, 2.2vw, 1.45rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pair-refresh {
  flex: 0 0 40px;
  width: 40px;
  min-width: 40px;
  height: 40px;
}

.mini-status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status {
  display: inline-block;
  max-width: 48ch;
  min-height: 1.45em;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status[data-tone="success"] {
  color: var(--success);
}

.status[data-tone="warning"] {
  color: var(--warning);
}

.status[data-tone="danger"] {
  color: var(--danger);
}

.status[data-tone="info"] {
  color: var(--accent);
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

button.primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

button.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.12);
}

button.danger {
  color: white;
  background: linear-gradient(135deg, #ff7d7d, #d84848);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: rgb(255, 255, 255);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-button img {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}

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

@media (max-width: 820px) {
  .screen-overlay {
    padding: 14px;
  }

  .overlay-toggle-button {
    right: 16px;
    bottom: 16px;
  }

  .overlay-panel {
    padding: 18px;
    max-height: calc(100vh - 28px);
  }

  .overlay-content {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .overlay-pairing {
    order: -1;
  }

  .overlay-copy {
    padding-top: 0;
  }

  .qr-box {
    width: min(280px, 100%);
  }

  .overlay-actions {
    justify-content: stretch;
  }

  .overlay-actions button {
    width: 100%;
  }

}

@media (max-width: 560px) {
  .overlay-toolbar {
    gap: 8px;
  }

  .overlay-instructions {
    font-size: 1.08rem;
  }

  .overlay-hint,
  .mini-status,
  .status {
    font-size: 13px;
  }

  .pair-code {
    font-size: 1rem;
  }

  .pair-refresh {
    flex-basis: 38px;
    width: 38px;
    min-width: 38px;
    height: 38px;
  }
}
