:root {
  color: #111;
  background: #f7f7f5;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: #111;
  --muted: #6d6d69;
  --line: #d9d9d4;
  --paper: #fff;
  --soft: #efefec;
  --danger: #b42318;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    linear-gradient(90deg, transparent calc(50% - .5px), rgba(17, 17, 17, .035) 50%, transparent calc(50% + .5px)),
    #f7f7f5;
}

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

.topbar {
  height: 74px;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(247, 247, 245, .92);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 650;
  font-size: 20px;
  letter-spacing: -.04em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--ink);
  border-radius: 7px;
  font-size: 13px;
  letter-spacing: -.06em;
}

.topbar-meta,
.connection-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.privacy-dot,
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #171717;
  box-shadow: 0 0 0 4px rgba(17, 17, 17, .08);
}

main { min-height: calc(100vh - 74px); }
.view { width: min(1440px, 100%); margin: 0 auto; }
.is-hidden { display: none !important; }

.landing {
  min-height: calc(100vh - 74px);
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
}

.landing-copy {
  padding: clamp(72px, 10vw, 150px) clamp(32px, 8vw, 120px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  margin: 0 0 22px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .14em;
  font-weight: 700;
}

.landing h1,
.lobby h1 {
  margin: 0;
  font-weight: 520;
  font-size: clamp(52px, 7vw, 104px);
  line-height: .96;
  letter-spacing: -.065em;
}

.lede {
  max-width: 620px;
  margin: 32px 0 0;
  color: #4e4e4a;
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.45;
  letter-spacing: -.02em;
}

.landing-actions { display: flex; gap: 10px; margin-top: 44px; flex-wrap: wrap; }

.button,
.device-button,
.control-button,
.text-button {
  border: 0;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, color .16s ease, border-color .16s ease;
}

.button:active,
.device-button:active,
.control-button:active { transform: translateY(1px); }

.button:focus-visible,
.device-button:focus-visible,
.control-button:focus-visible,
.text-button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid #111;
  outline-offset: 3px;
}

.button {
  min-height: 48px;
  border-radius: 999px;
  padding: 0 22px;
  font-size: 14px;
  font-weight: 650;
}

.button-primary { background: var(--ink); color: #fff; }
.button-primary:hover { background: #333; }
.button-secondary { background: transparent; border: 1px solid #bdbdb7; }
.button-secondary:hover { border-color: var(--ink); background: var(--paper); }
.button-wide { width: 100%; }
.button-small { min-height: 38px; padding: 0 16px; font-size: 13px; }

.landing-proof {
  border-left: 1px solid var(--line);
  padding: clamp(54px, 7vw, 108px) clamp(28px, 5vw, 64px);
  background: rgba(255, 255, 255, .48);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.proof-index { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.landing-proof h2 { margin: 12px 0 8px; font-size: 20px; letter-spacing: -.03em; font-weight: 600; }
.landing-proof p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 14px; }
.landing-proof code { color: var(--ink); background: var(--soft); padding: 2px 5px; border-radius: 4px; }
.proof-rule { height: 1px; background: var(--line); margin: 32px 0; }

.link-form { margin-top: 34px; max-width: 680px; }
label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 650; }
.inline-field { display: flex; gap: 8px; }
input, textarea {
  width: 100%;
  border: 1px solid #c8c8c2;
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 13px 14px;
}
input::placeholder, textarea::placeholder { color: #999993; }

.field-error { min-height: 18px; color: var(--danger); font-size: 13px; margin: 9px 0 0; }

.lobby {
  min-height: calc(100vh - 74px);
  display: grid;
  place-items: center;
  padding: 44px 20px;
}

.lobby-card { width: min(760px, 100%); }
.lobby-heading { text-align: center; margin-bottom: 28px; }
.lobby-heading .eyebrow { margin-bottom: 14px; }
.lobby h1 { font-size: clamp(42px, 7vw, 70px); }
.lobby-heading > p:last-child { color: var(--muted); margin: 16px auto 0; }

.preview-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #161616;
  border-radius: 24px;
  overflow: hidden;
}

.preview-frame video,
.video-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-frame video { transform: scaleX(-1); }
.preview-badge { position: absolute; bottom: 16px; left: 16px; color: #fff; background: rgba(0,0,0,.62); padding: 8px 11px; border-radius: 999px; font-size: 12px; backdrop-filter: blur(8px); }

.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #a9a9a4;
  text-align: center;
  padding: 24px;
  font-size: 14px;
  background: #e9e9e5;
}
.video-placeholder.large { font-size: 18px; }

.lobby-fields { margin-top: 22px; }
.device-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.device-button {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 15px;
  font-size: 13px;
  font-weight: 600;
}
.device-button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.device-icon { width: 28px; height: 28px; border: 1px solid currentColor; border-radius: 50%; display: grid; place-items: center; font-size: 11px; }

.invite-box {
  margin: 20px 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.62);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.invite-box span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.invite-box strong { font-size: 13px; }
.text-button { background: transparent; padding: 4px; font-size: 13px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.call { padding: 28px clamp(18px, 3vw, 46px) 34px; }
.call-header { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 22px; }
.call-header .eyebrow { margin-bottom: 7px; }
.call-header h1 { margin: 0; font-size: 28px; letter-spacing: -.045em; font-weight: 580; }

.status-banner {
  margin: 20px 0 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 13px;
}
.status-banner span:last-child { color: var(--muted); text-align: right; }

.call-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; }
.stage-column { min-width: 0; }
.video-stage { min-height: 520px; height: calc(100vh - 260px); position: relative; }
.video-tile { position: relative; overflow: hidden; background: #e9e9e5; border: 1px solid #d2d2cd; }
.remote-tile { height: 100%; border-radius: 22px; }
.local-tile { position: absolute; width: min(28%, 260px); aspect-ratio: 4 / 3; right: 18px; bottom: 18px; border-radius: 16px; box-shadow: 0 14px 40px rgba(0,0,0,.18); background: #202020; }
.local-tile video { transform: scaleX(-1); }
.tile-label { position: absolute; left: 13px; right: 13px; bottom: 12px; display: flex; justify-content: space-between; gap: 8px; color: #fff; font-size: 11px; text-shadow: 0 1px 5px rgba(0,0,0,.7); }

.call-controls { display: flex; justify-content: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.control-button { min-width: 100px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); padding: 10px 13px; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; }
.control-button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.control-symbol { width: 25px; height: 25px; border: 1px solid currentColor; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.control-danger { color: var(--danger); }
.control-danger:hover { background: #fff1ef; border-color: #f0b7b0; }

.chat-panel { height: calc(100vh - 246px); min-height: 520px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); display: grid; grid-template-rows: auto 1fr auto auto; overflow: hidden; }
.chat-heading { padding: 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; }
.chat-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.03em; }
.chat-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.lock-label { border: 1px solid var(--ink); border-radius: 999px; padding: 4px 7px; font: 10px ui-monospace, monospace; }
.message-list { min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 11px; }
.system-message { align-self: center; color: var(--muted); font-size: 11px; text-align: center; max-width: 250px; line-height: 1.45; margin: 8px 0; }
.message { max-width: 84%; border-radius: 14px; padding: 10px 12px; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.message.mine { align-self: flex-end; color: #fff; background: var(--ink); border-bottom-right-radius: 4px; }
.message.theirs { align-self: flex-start; background: var(--soft); border-bottom-left-radius: 4px; }
.message.file-message { display: block; color: inherit; text-decoration: none; }
.message small { display: block; margin-top: 5px; opacity: .62; font-size: 9px; }
.transfer-status { border-top: 1px solid var(--line); padding: 9px 14px; color: var(--muted); font-size: 11px; }
.chat-form { border-top: 1px solid var(--line); padding: 12px; }
.chat-form textarea { resize: none; min-height: 58px; max-height: 130px; }
.chat-actions { margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
button:disabled, textarea:disabled { cursor: not-allowed; opacity: .42; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); background: #111; color: #fff; border-radius: 999px; padding: 10px 15px; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; z-index: 40; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.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; }

@media (max-width: 980px) {
  .landing { grid-template-columns: 1fr; }
  .landing-proof { border-left: 0; border-top: 1px solid var(--line); }
  .call-layout { grid-template-columns: 1fr; }
  .chat-panel { height: 430px; min-height: 0; }
  .video-stage { height: min(66vh, 620px); min-height: 420px; }
}

@media (max-width: 640px) {
  .topbar { height: 62px; padding: 0 16px; }
  main { min-height: calc(100vh - 62px); }
  .landing { min-height: calc(100vh - 62px); }
  .landing-copy { padding: 70px 20px 56px; }
  .landing h1 { font-size: 50px; }
  .landing-proof { padding: 44px 20px; }
  .inline-field { flex-direction: column; }
  .lobby { padding: 26px 14px; }
  .device-actions { grid-template-columns: 1fr; }
  .call { padding: 18px 10px 24px; }
  .call-header { grid-template-columns: 1fr auto; gap: 10px; }
  .connection-summary { grid-column: 1 / -1; grid-row: 2; }
  .status-banner { align-items: flex-start; flex-direction: column; gap: 4px; }
  .status-banner span:last-child { text-align: left; }
  .video-stage { height: 57vh; min-height: 360px; }
  .remote-tile { border-radius: 16px; }
  .local-tile { width: 36%; right: 10px; bottom: 10px; border-radius: 12px; }
  .control-button { min-width: 72px; flex: 1; }
  .chat-panel { border-radius: 16px; }
}

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