:root {
  --color-bg: #f7f9fc;
  --color-surface: #ffffff;
  --color-surface-alt: #f2f5f9;
  --color-border: #e4e9f1;
  --color-text: #162033;
  --color-muted: #66748a;
  --color-primary: #65cbb6;
  --color-secondary: #6e9ce0;
  --color-shadow: rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 20px 50px var(--color-shadow);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --container-width: 1480px;
  --header-height: 104px;
  --footer-height: 72px;
  --transition-base: 180ms ease;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: var(--color-text);
  background:
    radial-gradient(circle at top left, rgba(101, 203, 182, 0.08), transparent 24%),
    radial-gradient(circle at top right, rgba(110, 156, 224, 0.08), transparent 26%),
    var(--color-bg);
}

img,
video,
iframe {
  display: block;
  max-width: 100%;
}

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

code {
  padding: 0.16rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface-alt);
  font-size: 0.9em;
}

.site-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: min(94%, var(--container-width));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--header-height);
  border-bottom: 1px solid rgba(228, 233, 241, 0.95);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.header-layout {
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand__logo {
  width: clamp(220px, 26vw, 360px);
  height: auto;
}

.header-actions {
  min-width: 180px;
  min-height: 48px;
  border: 1px dashed transparent;
  border-radius: var(--radius-sm);
}

.site-main {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 28px 0 36px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr);
  gap: 24px;
  align-items: stretch;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(228, 233, 241, 0.92);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel__tag {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-secondary);
}

.panel__header h2 {
  margin: 0;
  font-size: clamp(1.4rem, 1.8vw, 1.9rem);
  line-height: 1.1;
}

.panel__hint {
  max-width: 320px;
  margin: 0;
  color: var(--color-muted);
  font-size: 0.96rem;
  line-height: 1.45;
  text-align: right;
}

.panel__body {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: linear-gradient(180deg, #f9fbfd 0%, #f2f5f9 100%);
}

.panel__body--embed,
.panel__body--camera {
  min-height: clamp(420px, 64vh, 760px);
}

.panel__body--embed iframe,
.panel__body--camera video {
  width: 100%;
  height: 100%;
  border: 0;
}

#avatarFrame {
  aspect-ratio: 16 / 9;
  background: #edf3f9;
}

#webcamVideo {
  object-fit: cover;
  background: #edf3f9;
}

#webcamVideo.is-mirrored {
  transform: scaleX(-1);
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.9) 100%);
  backdrop-filter: blur(6px);
  transition:
    opacity var(--transition-base),
    visibility var(--transition-base);
}

.camera-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.camera-overlay__content {
  max-width: 320px;
  padding: 24px;
  text-align: center;
  border: 1px solid rgba(228, 233, 241, 0.92);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.camera-overlay__title {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 700;
}

.camera-overlay__message {
  margin: 0;
  color: var(--color-muted);
  line-height: 1.5;
}

.panel__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(228, 233, 241, 0.92);
}

.camera-status {
  flex: 1;
  margin: 0;
  color: var(--color-muted);
  line-height: 1.5;
}

.panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform var(--transition-base),
    box-shadow var(--transition-base),
    opacity var(--transition-base),
    background var(--transition-base);
}

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

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

.button--primary {
  color: #0f172a;
  background: linear-gradient(135deg, var(--color-primary) 0%, #a8f0df 100%);
  box-shadow: 0 10px 22px rgba(101, 203, 182, 0.25);
}

.button--secondary {
  color: var(--color-text);
  background: #eef3f8;
  border: 1px solid var(--color-border);
}

.site-footer {
  min-height: var(--footer-height);
  border-top: 1px solid rgba(228, 233, 241, 0.95);
  background: rgba(255, 255, 255, 0.88);
}

.site-footer__layout {
  min-height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--color-muted);
  font-size: 0.92rem;
}

.site-footer__layout p {
  margin: 0;
}

.site-footer__placeholder {
  text-align: right;
}

.panel--camera[data-camera-state="active"] {
  border-color: rgba(101, 203, 182, 0.35);
}

.panel--camera[data-camera-state="error"] {
  border-color: rgba(244, 63, 94, 0.2);
}

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

  .panel__body--embed,
  .panel__body--camera {
    min-height: clamp(360px, 52vh, 680px);
  }
}

@media (max-width: 820px) {
  :root {
    --header-height: 88px;
  }

  .site-main {
    align-items: flex-start;
  }

  .header-layout,
  .panel__header,
  .panel__footer,
  .site-footer__layout {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel__hint,
  .site-footer__placeholder {
    text-align: left;
  }

  .brand__logo {
    width: min(100%, 280px);
  }

  .header-actions {
    width: 100%;
    min-width: 0;
  }

  .panel__actions {
    width: 100%;
  }

  .button {
    flex: 1;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
