:root {
  --bg: #121518;
  --bg-accent: #1b2025;
  --panel: rgba(28, 32, 37, 0.92);
  --border: rgba(206, 180, 160, 0.16);
  --text: #f1ece8;
  --muted: #aa9f97;
  --primary: #ceb4a0;
  --primary-dark: #b49580;
  --secondary: #343b44;
  --danger: #b91c1c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(206, 180, 160, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.04), transparent 20%),
    linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 46%, #0f1215 100%);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.host-shell {
  width: min(1380px, calc(100% - 32px));
  padding-top: 24px;
}

.brandline {
  margin: 0 0 10px 32px;
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: clamp(1.45rem, 1.9vw, 1.9rem);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.04;
}

.host-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 34px;
  align-items: start;
}

.host-controls {
  min-height: 560px;
  padding: 18px 18px 22px;
  border-radius: 36px;
  background:
    linear-gradient(180deg, rgba(32, 37, 43, 0.94), rgba(25, 29, 34, 0.94)),
    var(--panel);
}

.compact-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.compact-actions .button {
  min-width: 0;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: clamp(0.9rem, 0.95vw, 1.05rem);
  font-weight: 500;
}

.compact-actions .button:disabled {
  opacity: 0.38;
}

.host-controls .field {
  margin-bottom: 18px;
}

.host-controls .field span {
  margin-bottom: 10px;
  font-size: 0.96rem;
}

.settings-entry {
  margin: -4px 0 18px;
}

.settings-entry--below-status {
  margin-top: 18px;
  margin-bottom: 0;
}

.settings-button {
  padding: 7px 12px;
  font-size: 0.82rem;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 400 !important;
  letter-spacing: 0;
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--text) !important;
}

.settings-summary {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.host-controls input {
  min-height: 84px;
  padding: 0 26px;
  border-radius: 28px;
  font-size: 1rem;
}

.compact-status {
  padding: 6px 6px 0;
  display: grid;
  gap: 8px;
}

.status-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.status-key,
.status-line-value {
  color: var(--muted);
}

.status-line-value.is-active {
  color: var(--text);
}

.host-preview {
  position: relative;
  min-height: 560px;
  height: 560px;
  padding: 0;
  overflow: hidden;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(20, 23, 27, 0.96), rgba(15, 18, 21, 0.98)),
    var(--panel);
}

.host-preview video {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  border: 0;
  border-radius: 28px;
}

.preview-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
  text-align: center;
  pointer-events: none;
}

.viewer-root {
  width: min(100%, calc(100% - 24px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 24px;
}

.viewer-surface {
  display: grid;
  gap: 14px;
  min-height: calc(100vh - 44px);
}

.viewer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.viewer-stage-brand {
  margin: 0;
  padding: 0 4px;
  font-size: clamp(1.2rem, 1.6vw, 1.7rem);
}

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

.hint {
  color: var(--muted);
}

.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(8px);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  background: rgba(14, 17, 20, 0.92);
  color: var(--text);
  appearance: none;
}

select:focus {
  outline: 2px solid rgba(206, 180, 160, 0.2);
  border-color: rgba(206, 180, 160, 0.5);
}

.password-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.password-row input {
  flex: 1 1 auto;
}

.password-row .button {
  flex: 0 0 auto;
  white-space: nowrap;
}

#authorizeButton {
  font-weight: 500;
}

input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  background: rgba(14, 17, 20, 0.92);
  color: var(--text);
}

input::placeholder {
  color: rgba(241, 236, 232, 0.38);
}

input:focus {
  outline: 2px solid rgba(206, 180, 160, 0.2);
  border-color: rgba(206, 180, 160, 0.5);
}

.button {
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 140ms ease,
    opacity 140ms ease,
    background-color 140ms ease;
}

.button:hover:enabled {
  transform: translateY(-1px);
}

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

.button.primary {
  background: var(--primary);
  color: #17120f;
}

.button.secondary {
  background: var(--secondary);
  color: var(--text);
}

.button.tertiary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.host-controls .button,
.host-controls .button.primary,
.host-controls .button.secondary,
.host-controls .button.tertiary,
.modal-panel .button,
.modal-panel .button.primary,
.modal-panel .button.secondary,
.modal-panel .button.tertiary {
  background: var(--primary);
  color: #17120f;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 9, 11, 0.68);
  backdrop-filter: blur(10px);
}

.modal-panel {
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(32, 37, 43, 0.98), rgba(24, 28, 33, 0.98)),
    var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
}

.modal-copy,
.modal-note {
  margin: 6px 0 0;
  line-height: 1.35;
  font-size: 0.88rem;
}

.modal-panel .field span,
.modal-panel .button,
.modal-panel select {
  font-weight: 500;
}

.modal-actions .button {
  width: auto;
  min-width: 120px;
  padding: 10px 18px;
  font-size: 0.92rem;
  font-weight: 500;
}

.modal-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.preview-panel video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  background:
    radial-gradient(circle at center, rgba(206, 180, 160, 0.08), transparent 36%),
    linear-gradient(135deg, #1a1e24, #0b0d10);
  border: 1px solid rgba(255, 255, 255, 0.08);
  object-fit: contain;
}

.viewer-fullscreen-hint {
  display: block;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
  cursor: pointer;
}

.viewer-stage {
  position: relative;
}

.viewer-stage video {
  min-height: min(72vh, 760px);
}

.viewer-stage--full {
  min-height: calc(100vh - 160px);
}

.viewer-stage--full video {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 160px);
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

.fullscreen-exit-overlay {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  background: rgba(12, 14, 17, 0.72);
  backdrop-filter: blur(8px);
}

.viewer-stage:not(:fullscreen) .fullscreen-exit-overlay,
.viewer-stage:not(:-webkit-full-screen) .fullscreen-exit-overlay {
  display: none !important;
}

.viewer-toolbar {
  display: flex;
  gap: 10px;
}

.viewer-toolbar--top {
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.viewer-audio-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.keyboard-button {
  display: block;
  width: fit-content;
  margin: 12px auto 0;
  padding: 9px 14px;
  font-weight: 500;
}

.viewer-keyboard {
  --keyboard-scale: 0.75;
  margin-top: 16px;
  width: 100%;
  margin-inline: auto;
  padding: calc(16px * var(--keyboard-scale)) calc(16px * var(--keyboard-scale)) calc(14px * var(--keyboard-scale));
  border-radius: calc(26px * var(--keyboard-scale));
  background: linear-gradient(180deg, rgba(101, 103, 108, 0.92), rgba(79, 81, 87, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 14px 36px rgba(0, 0, 0, 0.24);
  overflow-x: auto;
  scrollbar-width: none;
}

.viewer-keyboard::-webkit-scrollbar {
  display: none;
}

.viewer-keyboard-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: calc(12px * var(--keyboard-scale));
  width: max-content;
  min-width: 100%;
  margin-top: calc(12px * var(--keyboard-scale));
  margin-inline: auto;
}

.viewer-keyboard-row:first-child {
  margin-top: 0;
}

.viewer-keyboard-row:nth-child(2) {
  padding-inline: clamp(0px, 4vw, calc(54px * var(--keyboard-scale)));
}

.viewer-keyboard-row:nth-child(3) {
  padding-inline: clamp(0px, 1.8vw, calc(20px * var(--keyboard-scale)));
}

.viewer-keyboard-key {
  flex: 0 0 calc(clamp(58px, 5.6vw, 78px) * var(--keyboard-scale));
  height: calc(clamp(58px, 5.6vw, 76px) * var(--keyboard-scale));
  padding: 0 calc(clamp(10px, 1vw, 12px) * var(--keyboard-scale));
  border: 0;
  border-radius: calc(12px * var(--keyboard-scale));
  background: linear-gradient(180deg, rgba(172, 172, 174, 0.98), rgba(142, 142, 146, 0.98));
  color: #fafafa;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: calc(clamp(1rem, 1.8vw, 1.32rem) * var(--keyboard-scale));
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease;
  box-shadow: 0 3px 0 rgba(48, 49, 53, 0.6);
}

.viewer-keyboard-key:hover {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(48, 49, 53, 0.45);
}

.viewer-keyboard-key--utility {
  background: linear-gradient(180deg, rgba(122, 122, 126, 0.98), rgba(96, 97, 101, 0.98));
}

.viewer-keyboard-key--active {
  background: linear-gradient(180deg, rgba(206, 180, 160, 0.96), rgba(172, 144, 124, 0.96));
  color: #17120f;
}

.viewer-keyboard-key--backspace {
  flex-basis: calc(clamp(92px, 8vw, 112px) * var(--keyboard-scale));
  font-size: calc(clamp(0.88rem, 1.2vw, 0.98rem) * var(--keyboard-scale));
}

.viewer-keyboard-key--return {
  flex-basis: calc(clamp(122px, 12vw, 148px) * var(--keyboard-scale));
  font-size: calc(clamp(0.88rem, 1.2vw, 0.98rem) * var(--keyboard-scale));
}

.viewer-keyboard-key--shift {
  flex-basis: calc(clamp(92px, 8vw, 104px) * var(--keyboard-scale));
  font-size: calc(clamp(0.92rem, 1.2vw, 1rem) * var(--keyboard-scale));
}

.viewer-keyboard-key--mode {
  flex-basis: calc(clamp(124px, 13vw, 168px) * var(--keyboard-scale));
  font-size: calc(clamp(0.92rem, 1.2vw, 1rem) * var(--keyboard-scale));
}

.viewer-keyboard-key--space {
  flex: 1 1 calc(clamp(220px, 28vw, 420px) * var(--keyboard-scale));
  max-width: calc(clamp(280px, 34vw, 440px) * var(--keyboard-scale));
  min-width: calc(220px * var(--keyboard-scale));
  font-size: calc(clamp(0.96rem, 1.3vw, 1.08rem) * var(--keyboard-scale));
}

.viewer-keyboard-key--clear {
  flex-basis: calc(clamp(96px, 9vw, 112px) * var(--keyboard-scale));
  font-size: calc(clamp(0.92rem, 1.2vw, 1rem) * var(--keyboard-scale));
}

.viewer-audio-button {
  min-width: 132px;
  padding: 12px 18px;
  font-weight: 600;
}

.viewer-volume-slider {
  width: 110px;
  accent-color: var(--primary);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  background: rgba(206, 180, 160, 0.14);
  border-color: rgba(206, 180, 160, 0.3);
}

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

.viewer-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(10, 12, 14, 0.7), rgba(10, 12, 14, 0.82)),
    rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
}

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

.viewer-overlay.viewer-overlay--minimal {
  padding: 0;
  background: transparent;
  backdrop-filter: none;
}

.viewer-overlay-card {
  width: min(620px, 100%);
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(24, 28, 33, 0.96);
  box-shadow: var(--shadow);
}

.viewer-overlay--password .viewer-overlay-card {
  width: min(1160px, 100%);
}

.viewer-overlay--minimal .viewer-overlay-card {
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.overlay-copy {
  margin: 0 0 18px;
  font-size: 1rem;
}

.viewer-overlay--minimal .overlay-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
  text-align: center;
}

.overlay-status {
  margin-top: 14px;
}

.auth-status {
  min-height: 1.4em;
  margin: 12px 0 0;
}

.viewer-exit-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.viewer-exit-screen[hidden] {
  display: none !important;
}

.viewer-exit-copy {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.3rem, 2vw, 2rem);
  font-weight: 500;
  text-align: center;
}

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

  .host-shell {
    width: min(100%, calc(100% - 24px));
    padding-top: 18px;
  }

  .brandline {
    margin-left: 12px;
    margin-bottom: 12px;
  }

  .host-controls {
    min-height: unset;
    padding: 16px;
    border-radius: 24px;
  }

  .compact-actions {
    flex-direction: column;
    gap: 12px;
  }

  .host-controls input {
    min-height: 64px;
    padding-inline: 18px;
    border-radius: 20px;
  }

  select {
    min-height: 56px;
  }

  .host-preview {
    min-height: 320px;
  }

  .host-preview video {
    min-height: 320px;
    border-radius: 24px;
  }

  .viewer-root {
    width: min(100%, calc(100% - 16px));
    padding-top: 16px;
    padding-bottom: 20px;
  }

  .password-row {
    flex-direction: column;
    align-items: stretch;
  }

  .keyboard-button {
    width: 100%;
  }

  .button {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column;
  }

  .viewer-toolbar {
    width: 100%;
    justify-content: flex-end;
  }

  .viewer-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .viewer-toolbar--top {
    justify-content: center;
  }

  .viewer-audio-group {
    width: 100%;
    justify-content: center;
  }

  .viewer-audio-button {
    width: auto;
  }

  .viewer-stage video {
    min-height: 46vh;
  }

  .viewer-keyboard {
    padding: 12px;
  }

  .viewer-keyboard-row {
    gap: 8px;
    width: max-content;
    min-width: 100%;
  }

  .viewer-keyboard-row:nth-child(2),
  .viewer-keyboard-row:nth-child(3) {
    padding-inline: 0;
  }

  .viewer-keyboard-key {
    flex-basis: 56px;
    height: 56px;
    font-size: 1rem;
  }

  .viewer-keyboard-key--backspace,
  .viewer-keyboard-key--return,
  .viewer-keyboard-key--shift,
  .viewer-keyboard-key--mode,
  .viewer-keyboard-key--clear {
    flex-basis: 96px;
    font-size: 0.9rem;
  }

  .viewer-keyboard-key--space {
    min-width: 180px;
    max-width: none;
  }

  .viewer-stage--full,
  .viewer-stage--full video {
    min-height: calc(100vh - 180px);
  }

  .fullscreen-exit-overlay {
    top: 12px;
    right: 12px;
  }
}
