:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #172e46;
  background: #fff;
  --ink: #142b45;
  --muted: #53677d;
  --accent: #225ecd;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
:focus-visible { outline: 3px solid #72a7f9; outline-offset: 4px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.sr-only:focus-visible {
  position: static; clip-path: none; width: auto; height: auto; margin: .5rem auto; padding: .35rem .6rem;
}
body[data-role="sender"] {
  display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; background: #fff;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right))
           max(1.25rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
  -webkit-text-size-adjust: 100%;
}
.cast-shell { width: min(100%, 23rem); min-width: 0; text-align: center; padding-block: .65rem; }
.sender-header { position: relative; margin-bottom: clamp(2.1rem, 7vh, 3.75rem); }
.sender-header h1 { margin: 0; font-size: clamp(1.65rem, 4.5vw, 2.1rem); }
#wordmark { font-weight: 740; letter-spacing: -.045em; }
#desktopNotice { padding-inline: .5rem; }
#desktopNotice .guidance { overflow-wrap: anywhere; }
.identity {
  max-width: 100%; padding: .25rem; border: 0; background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; min-height: 44px; border-radius: .5rem;
  font-weight: 550; letter-spacing: -.045em; line-height: 1.25;
}
.identity .brand { font-weight: 740; }
.identity-dash { margin-inline: .03em; font-weight: 400; color: #8391a2; }
.marquee { display: block; min-width: 0; overflow: hidden; direction: ltr; }
.marquee.inline-marquee { display: inline-block; max-width: 100%; vertical-align: bottom; }
.marquee-text { display: inline-block; max-width: none; white-space: nowrap; vertical-align: top; }
.marquee[data-overflow] { text-align: start; }
.pencil {
  flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; margin-left: .42rem;
  border: 1px solid #b4c9e3; border-radius: .55rem; background: #f1f6ff; color: #23569b;
}
.identity:hover .pencil, .identity:focus-visible .pencil { color: #13499b; border-color: #6790c8; background: #e7f0ff; }
.identity:hover #userName { color: var(--accent); }
.stage-window { display: grid; overflow: hidden; padding: .35rem .4rem; }
.stage {
  grid-area: 1 / 1; min-width: 0; align-self: center; padding: .3rem .35rem;
  transition: transform .32s cubic-bezier(.22,.76,.26,1), opacity .23s, visibility 0s .32s;
}
.first-stage { transform: translateX(-105%); visibility: hidden; opacity: 0; pointer-events: none; }
.next-stage { transform: translateX(105%); }
[data-step="entry"] .next-stage { visibility: hidden; opacity: 0; pointer-events: none; }
[data-step="entry"] .first-stage, [data-step="session"] .next-stage {
  transform: translateX(0); visibility: visible; opacity: 1; pointer-events: auto; transition-delay: 0s;
}
.stage form { display: grid; justify-items: center; }
.prompt { display: block; font-size: clamp(1.25rem, 3.5vw, 1.48rem); font-weight: 450; line-height: 1.4; margin: 0; }
.code-field {
  width: 100%; min-width: 0; min-height: 3.45rem; padding: .35rem .6rem .15rem .85rem; text-align: center;
  font: 550 1.65rem/1.25 "Segoe UI", sans-serif; letter-spacing: .24em;
  border: 0; border-bottom: 2px solid #69809b; border-radius: 0;
  background: transparent; color: var(--ink); caret-color: var(--accent);
  transition: border-color .15s;
}
.code-field:hover, .code-field:focus { border-bottom-color: var(--accent); }
.code-field:focus-visible { outline: none; box-shadow: inset 0 -1px var(--accent); }
.code-field[aria-invalid="true"] { border-bottom-color: #b13f34; }
.target { margin: 0 0 .6rem; font-size: .95rem; line-height: 1.4; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
.target:focus-visible, .marquee.inline-marquee:focus-visible { outline: 2px solid #72a7f9; outline-offset: 1px; }
.pin-field { width: min(100%, 13.5rem); }
.guidance { margin: .85rem 0 0; line-height: 1.5; font-size: .96rem; color: var(--muted); }
.sender-status { position: relative; margin: .45rem 0 0; line-height: 1.5; font-size: .95rem; color: var(--muted); overflow-wrap: anywhere; }
.sender-status:not([data-visible]) { margin: 0; }
#statusText, #statusFade { display: block; }
#statusFade { pointer-events: none; }
.sender-status[data-tone="error"] { color: #a6372f; }
.primary-action {
  min-height: 44px; padding: .65rem 1.3rem; border: 1px solid var(--accent); border-radius: .65rem;
  font-size: 1rem; font-weight: 600; color: #fff; background: var(--accent);
}
.primary-action:hover { background: #184caa; }
#share { margin-top: 1.1rem; }
.text-action { min-height: 44px; padding: .4rem .6rem; border: 0; border-radius: .5rem; color: var(--muted); background: transparent; }
.text-action:hover { color: var(--accent); background: #f1f5fa; }
.session-stop { margin-top: .35rem; }
.sender-footer {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .3rem 1rem;
  margin-top: clamp(1.1rem, 5vh, 2.4rem);
}
.downloads { position: relative; max-width: 100%; }
.download-app {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: 0 .55rem;
  color: var(--accent); font-size: .9rem; font-weight: 600; border: 0; border-radius: .65rem; background: transparent;
}
.download-app:hover, .download-app[aria-expanded="true"] { background: #edf4ff; }
.download-choices {
  position: absolute; z-index: 5; bottom: calc(100% + .4rem); left: 0; width: min(15rem, calc(100vw - 1.5rem));
  padding: .35rem; color: var(--ink); background: white; border: 1px solid #d9e3ef; border-radius: .9rem;
  box-shadow: 0 10px 32px #18395622, 0 2px 6px #18395610;
}
.download-choices a {
  display: grid; grid-template-columns: 1.4rem 1fr auto; align-items: center; column-gap: .6rem; min-height: 46px;
  padding: .45rem .6rem; border-radius: .6rem; color: inherit; text-align: start; text-decoration: none;
}
.download-choices a:hover, .download-choices a:focus-visible { background: #edf4ff; }
.download-choices a svg { width: 1.35rem; height: 1.35rem; color: #345d91; }
.download-choices strong { font-size: .9rem; font-weight: 630; }
.download-choices small, .download-choices bdi { color: var(--muted); font-weight: 500; font-size: .77rem; }
.download-choices bdi { font-variant-numeric: tabular-nums; }
.language-bar {
  position: relative; width: fit-content; max-width: 100%; display: flex; align-items: center; justify-content: center;
  gap: .4rem; margin: 0; color: var(--muted);
}
.language-bar select {
  appearance: none; -webkit-appearance: none; max-width: 100%; padding: .5rem 1.05rem .5rem 1.5rem;
  min-height: 44px; font-size: .9rem; background: transparent; border: 0; border-radius: .35rem;
}
.language-bar:hover { color: var(--accent); }
.language-globe, .chevron { pointer-events: none; position: absolute; }
.language-globe { left: .1rem; width: .94rem; height: .94rem; border: 1.3px solid currentColor; border-radius: 50%; }
.language-globe::before {
  position: absolute; content: ""; inset: -1px 22%; border: 1px solid currentColor; border-radius: 50%;
}
.language-globe::after { position: absolute; content: ""; left: 0; right: 0; top: 46%; border-top: 1px solid currentColor; }
.chevron { right: .16rem; width: .38rem; height: .38rem; transform: translateY(-1px) rotate(45deg); border: solid currentColor; border-width: 0 1px 1px 0; }
#nameForm { width: min(100%, 18rem); margin: 0 auto; }
#nameForm label { font-size: .94rem; color: var(--muted); }
.name-field {
  display: flex; align-items: baseline; gap: .1rem; margin: .4rem 0; padding: .25rem .5rem;
  border-bottom: 2px solid var(--accent); text-align: left; font-size: 1.3rem;
}
.name-field span { font-weight: 680; }
.name-field input { min-width: 0; width: 100%; padding: .35rem 0; border: 0; outline: none; background: transparent; }
.rename-actions { display: flex; justify-content: flex-end; gap: .45rem; margin-top: .75rem; }
@media (max-height: 470px) {
  .sender-header { margin-bottom: 1rem; }
  .language-bar { margin-top: .75rem; }
}
@media (prefers-reduced-motion: reduce) { .stage, .code-field { transition: none; } }
@media (prefers-reduced-motion: reduce) {
  .marquee[data-overflow] .marquee-text, .marquee-text {
    animation: none; white-space: normal; overflow-wrap: anywhere; max-width: 100%;
  }
}
.code-field, .prompt, .primary-action, .text-action { overflow-wrap: anywhere; }
#share span, #retry span { display: inline-block; }

body[data-role="receiver"] {
  display: grid; place-items: center; padding: clamp(12px,4vw,60px);
  background: radial-gradient(ellipse at top right,#dae9f7,transparent 62%),#f0f5f8;
}
[data-role="receiver"] main {
  width: min(100%,560px); padding: clamp(20px,4vw,42px); border-radius: 24px; background: white;
  border: 1px solid #cfdfed; box-shadow: 0 16px 54px #18355212;
}
[data-role="receiver"] header { display: flex; align-items: center; gap: 12px; color: #1d4b71; }
[data-role="receiver"] header strong { font-size: 22px; letter-spacing: -.045em; }
[data-role="receiver"] header span { border-left: 1px solid #b9cbdb; padding-left: 12px; font-size: 14px; }
.device-id { font-size: clamp(18px,3.5vw,26px); color: #172f4b; }
.device-id output { display: inline; font-size: inherit; }
[data-role="receiver"] h1 { font-size: clamp(27px,4.5vw,40px); letter-spacing: -.04em; margin: 32px 0 18px; }
[data-role="receiver"] h2 { font-size: 23px; margin: 0 0 8px; }
[data-role="receiver"] p, [data-role="receiver"] label { line-height: 1.65; color: #476078; font-size: 1rem; }
[data-role="receiver"] button { border: 1px solid #2059b8; border-radius: 12px; background: #235dc6; color: white; font-weight: 650; font-size: 1rem; min-height: 45px; padding: 10px 20px; }
[data-role="receiver"] .secondary { background: #eef4f9; border-color: #c6d8e7; color: #153857; }
[data-role="receiver"] output { display: block; font: 650 clamp(30px,7vw,52px)/1.25 ui-monospace,monospace; letter-spacing: .15em; color: #164d86; }
[data-role="receiver"] .device-id output { display: inline; font-size: inherit; }
[data-role="receiver"] #status:empty { display: none; }
[data-role="receiver"] video { width: 100%; max-height: 65dvh; object-fit: contain; margin: 10px 0; background: #10233b; border-radius: 12px; }
body[data-role="receiver"].showing { background: #071421; }
body.showing main { max-width: 100%; width: 100%; background: #101f30; color: white; border-color: #25415d; }
body.showing p, body.showing header { color: #c5d9ec; }
body[data-role="receiver"].pending { padding: 0; background: transparent; }
body.pending main { background: transparent; padding: 0; border: 0; box-shadow: none; }
body.pending main > header { display: none; }
#approval {
  --action-height: clamp(46px,6vh,60px);
  position: fixed; z-index: 1; inset: 0; display: grid; justify-items: center;
  grid-template-rows: minmax(0,2fr) auto minmax(0,1fr); align-items: end;
  margin: 0; padding: 8px 12px; background: rgb(15 35 55 / .35);
}
#approval .approval-body, #approval .actions { width: min(100%,clamp(242px,32vh,344px)); background: white; border: 1px solid #c1d5e7; box-shadow: 0 18px 50px #102a4322; }
#approval .approval-body {
  height: clamp(205px,34vh,355px); max-height: 100%; overflow: auto; border-radius: 22px 22px 0 0;
  border-bottom: 0; padding: clamp(12px,2.8vh,28px) clamp(16px,4vw,28px) 12px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
}
#approval .signal { color: #2863bb; background: #e6f0fe; border: 1px solid #cbdef6; border-radius: 12px; width: 42px; height: 42px; display: grid; place-items: center; font-size: 24px; margin: 0 0 10px; }
#approval h2 { font-size: clamp(20px,3.8vh,30px); margin: 0; color: #112e48; }
#approval p { margin: 3px 0 12px; overflow-wrap: anywhere; }
.pin-block { border-radius: 12px; background: #eef5fe; width: 100%; padding: 8px; color: #36546d; }
#approval output { font: 700 clamp(29px,5vh,48px)/1.12 ui-monospace,monospace; letter-spacing: .18em; padding-left: .18em; color: #1b538b; }
#approval .actions { grid-row: 2; align-self: start; display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; margin: 0; padding: 0 16px 16px; border-top: 0; border-radius: 0 0 22px 22px; }
#approval .actions button { min-height: var(--action-height); }
@media (max-height:450px) {
  #approval .signal { display: none; }
  #approval .approval-body { padding: 9px 16px; }
  #approval p { margin: 0 0 3px; }
  .pin-block { padding: 2px 4px; }
}
