@font-face {
  font-family: "DM Sans";
  src: url("fonts/DMSans-Variable.ttf?v=20260805") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "DM Serif Display";
  src: url("fonts/DMSerifDisplay-Regular.ttf?v=20260805") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --cream: #F0F4F8;
  --navy: #0D1B2A;
  --blue: #2563EB;
  --blue-dark: #1D4ED8;
  --blue-pale: #EFF6FF;
  --blue-light: #BFDBFE;
  --muted: #4A5A6B;
  --ink-light: #8A9BAD;
  --white: #FFFFFF;
  --danger: #DC2626;
  --success: #16803A;
  --border: rgba(13, 27, 42, 0.11);
  --serif: "DM Serif Display", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--cream);
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 80px 80px;
  color: var(--navy);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

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

.site-header {
  min-height: 68px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(240, 244, 248, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
}

.brand span { color: var(--blue); }

.product-name {
  color: var(--muted);
  font-size: 13px;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.secure-label {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.secure-label i,
.stage-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(22, 128, 58, 0.12);
}

main {
  width: min(1120px, 90vw);
  margin: 0 auto;
  flex: 1;
}

.join-layout {
  min-height: calc(100vh - 138px);
  padding: 76px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  align-items: center;
  gap: clamp(48px, 8vw, 104px);
}

.eyebrow,
.card-label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--blue);
}

.intro h1 {
  margin: 24px 0 0;
  font-family: var(--serif);
  font-size: clamp(52px, 6.5vw, 82px);
  font-weight: 400;
  line-height: 1.01;
  letter-spacing: -0.025em;
}

.intro h1 em {
  color: var(--blue);
  font-weight: 400;
}

.intro-copy {
  max-width: 560px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 18px;
  font-weight: 350;
  line-height: 1.7;
}

.steps {
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.steps li {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.steps span {
  color: var(--blue);
  font-family: var(--serif);
  font-size: 14px;
}

.access-card {
  padding: clamp(28px, 4vw, 44px);
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 3px solid var(--blue);
  border-radius: 4px;
  box-shadow: 0 22px 55px rgba(13, 27, 42, 0.10);
}

.access-card h2,
.session-heading h2 {
  margin: 14px 0 0;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.15;
}

.card-copy {
  margin: 10px 0 30px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.access-card label,
.color-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#code-input {
  width: 100%;
  margin-top: 9px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 3px;
  outline: none;
  background: var(--cream);
  color: var(--navy);
  font-family: var(--sans);
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#code-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button {
  min-height: 48px;
  padding: 0 19px;
  border: 0;
  border-radius: 3px;
  background: var(--blue);
  color: var(--white);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s, transform 0.2s, opacity 0.2s;
}

button:hover:not(:disabled) {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 3px solid var(--blue-light);
  outline-offset: 2px;
}

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

#connect-btn {
  width: 100%;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.status.error { color: var(--danger); }
.status.ok { color: var(--success); }

.privacy-note {
  margin-top: 26px;
  padding: 14px 0 0;
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.privacy-note span { color: var(--success); font-weight: 700; }
.hidden { display: none !important; }

.session-panel { padding: 48px 0 72px; }

.session-heading {
  margin-bottom: 22px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.session-heading h2 { font-size: 38px; }
.session-heading .status { max-width: 480px; margin: 0; text-align: right; }

#stage {
  position: relative;
  width: min(100%, 760px);
  max-height: 68vh;
  margin: 0 auto;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: var(--navy);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 4px;
  box-shadow: 0 20px 50px rgba(13, 27, 42, 0.18);
}

#remote-video,
#draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#remote-video { object-fit: contain; }

#draw-canvas {
  cursor: crosshair;
  touch-action: none;
}

.stage-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  background: rgba(13, 27, 42, 0.82);
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}

#toolbar {
  margin-top: 16px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
}

#toolbar .spacer { flex: 1; }

.color-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

#pen-color {
  width: 40px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--white);
  cursor: pointer;
}

button.secondary {
  background: var(--blue-pale);
  color: var(--blue-dark);
  border: 1px solid var(--blue-light);
}

button.secondary:hover:not(:disabled) { background: #DBEAFE; }
button.danger { background: var(--danger); }
button.danger:hover:not(:disabled) { background: #B91C1C; }

footer {
  min-height: 70px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--border);
  color: var(--ink-light);
  font-size: 12px;
}

footer a { text-decoration: none; }
footer a:hover { color: var(--blue); }

@media (max-width: 820px) {
  .site-header { padding: 15px 22px; flex-wrap: wrap; }
  .product-name { order: 3; width: 100%; padding: 10px 0 0; border: 0; border-top: 1px solid var(--border); }
  .secure-label { font-size: 10px; }
  main { width: min(100% - 36px, 620px); }
  .join-layout { padding: 52px 0; grid-template-columns: 1fr; gap: 44px; }
  .intro h1 { font-size: clamp(48px, 15vw, 70px); }
  .session-heading { align-items: start; flex-direction: column; }
  .session-heading .status { text-align: left; }
}

@media (max-width: 520px) {
  .join-layout { padding-top: 38px; }
  .access-card { padding: 28px 22px; }
  #toolbar .spacer { display: none; }
  #toolbar button { flex: 1; min-width: calc(50% - 8px); }
  .color-label { width: 100%; justify-content: space-between; padding-bottom: 8px; }
}

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