/* Swytch Camera: cinema-camera layout. Portrait first, landscape below. */
.cam { overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; background: var(--bg); }
.cam::after { content: ""; position: fixed; inset: 0; border: 0 solid var(--red); pointer-events: none; z-index: 60; }
.cam.live::after { border-width: 6px; animation: onair 1.2s ease-out; }
@keyframes onair { 0% { border-width: 22px; background: #ff3b3040; } 100% { border-width: 6px; background: none; } }
@media (prefers-reduced-motion: reduce) { .cam.live::after { animation: none; } }
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-around; padding: 6px 10px max(6px, env(safe-area-inset-bottom)); background: #080d18; }
#tabs button { position: relative; display: grid; justify-items: center; gap: 2px; width: 84px; padding: 8px 0 6px; border-radius: 12px; color: #9fc0f5; font-size: 12px; font-weight: 500; }
#tabs svg { width: 28px; height: 28px; }
#tabs button[aria-current="true"] { background: var(--blue-deep); color: var(--blue); }
#unread { position: absolute; top: 4px; right: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }

#stage { position: fixed; inset: 0 0 calc(64px + env(safe-area-inset-bottom)) 0; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-rows: auto auto auto auto auto auto auto 1fr auto; row-gap: 10px; padding-bottom: 8px; }
body:not([data-tab="camera"]) #stage { visibility: hidden; }
.tc { font-size: 34px; font-weight: 600; letter-spacing: .01em; font-variant-numeric: tabular-nums; text-align: center; }
.tc.recording { color: var(--red); }
.tcP { grid-area: 1 / 1 / 2 / -1; padding-top: max(10px, env(safe-area-inset-top)); }
.tcL { display: none; }
#finder { grid-area: 2 / 1 / 3 / -1; position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; min-width: 0; min-height: 0; }
#view { width: 100%; height: 100%; object-fit: contain; display: block; }
#grid { position: absolute; inset: 0; pointer-events: none; }
.g-thirds #grid { background: linear-gradient(#fff8, #fff8) 33.33% 0 / 1px 100% no-repeat, linear-gradient(#fff8, #fff8) 66.66% 0 / 1px 100% no-repeat, linear-gradient(#fff8, #fff8) 0 33.33% / 100% 1px no-repeat, linear-gradient(#fff8, #fff8) 0 66.66% / 100% 1px no-repeat; }
.g-center #grid { background: linear-gradient(#fffc, #fffc) center / 28px 1px no-repeat, linear-gradient(#fffc, #fffc) center / 1px 28px no-repeat; outline: 1px solid #fff8; outline-offset: -5vmin; }
#badges { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 700; z-index: 3; }
#badges span { padding: 4px 9px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(12px); }
#badges span:empty { display: none; }
#live { background: var(--red) !important; color: #fff; display: inline-flex; align-items: center; gap: 5px; letter-spacing: .04em; }
#live i { width: 7px; height: 7px; border-radius: 50%; background: #fff; }
#busyBadge { background: var(--amber) !important; color: #111; }
#note { position: absolute; left: 50%; bottom: 14px; translate: -50%; max-width: 86%; padding: 9px 14px; border-radius: 14px; background: var(--glass); backdrop-filter: blur(16px); font-size: 13px; text-align: center; z-index: 4; }
#note:empty { display: none; }
/* Director message: a strip along the top for 10 seconds, never over the middle of the picture. */
#banner { position: absolute; top: 8px; left: 8px; right: 96px; padding: 7px 14px; border-radius: 14px; background: #f4f6faf2; color: #0b0f18; z-index: 5; display: flex; gap: 10px; align-items: baseline; pointer-events: none; }
#banner small { color: #5b6677; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; flex: none; }
#banner p { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.2; }

.card { background: var(--glass); backdrop-filter: blur(16px); border-radius: 12px; padding: 7px 10px; }
.cap { display: block; font-size: 11px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#scopes { display: contents; }
#histCard { grid-area: 3 / 1; justify-self: start; margin-left: 8px; width: min(40vw, 190px); }
#hist { width: 100%; height: 44px; display: block; }
.recP { grid-area: 3 / 2; align-self: center; }
#meterCard { grid-area: 3 / 3; justify-self: end; margin-right: 8px; width: min(40vw, 190px); }
#storeCard { grid-area: 9 / 1 / 10 / -1; justify-self: center; display: flex; gap: 10px; align-items: center; min-width: 190px; }
#storeCard svg { width: 30px; height: 30px; }
#storeCard b { font-size: 18px; font-variant-numeric: tabular-nums; }
#storeCard small { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; }
.bar { height: 3px; border-radius: 2px; background: #ffffff30; margin: 3px 0; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--blue); }
.m { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.m em { font-style: normal; font-size: 10px; font-weight: 600; width: 6px; }
.mbar { flex: 1; height: 9px; border-radius: 2px; position: relative; overflow: hidden; background: linear-gradient(90deg, #2fd14a 0 68%, #c9c12f 68% 90%, #e5484d 90%); }
.mbar i { position: absolute; inset: 0 0 0 0; background: #0a1220d9; transition: left .08s linear; }
.scale { display: flex; justify-content: space-between; margin-left: 12px; font-size: 9px; font-weight: 600; color: #cfd6e2; }
.rec { width: 66px; height: 66px; border-radius: 50%; background: #05080e; box-shadow: 0 0 0 2px #fff; display: grid; place-items: center; flex: none; }
.rec i { width: 30px; height: 30px; border-radius: 50%; background: #8f1d16; transition: all .15s; }
.rec[aria-pressed="true"] i { background: var(--red); border-radius: 7px; width: 24px; height: 24px; }
.recL { display: none; }

#params { grid-area: 4 / 1 / 5 / -1; display: flex; justify-content: space-between; padding: 0 8px; }
.cell { display: grid; gap: 1px; text-align: left; padding: 4px 6px; border-radius: 6px; min-width: 0; }
.cell .lbl { font-size: 12px; font-weight: 600; letter-spacing: .02em; display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.cell .val { font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell .a { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 3px; background: var(--blue); color: #fff; font-size: 11px; font-weight: 800; }
.cell.on { background: var(--blue); }
.cell.off { opacity: .4; }
.cell[aria-expanded="true"]:not(.on) { background: var(--card2); }
#tools { grid-area: 5 / 1 / 6 / -1; display: flex; flex-direction: row-reverse; justify-content: space-around; align-items: center; padding: 0 6px; }
.tool { display: grid; justify-items: center; min-width: 48px; min-height: 44px; align-content: center; color: #fff; font-size: 11px; font-weight: 600; position: relative; }
.tool svg { width: 30px; height: 30px; }
.tool.blue { color: var(--blue); }
.tool.off { opacity: .4; }
.tool .a { position: absolute; right: -4px; top: 12px; font-size: 12px; font-weight: 800; }
#zoomer { grid-area: 6 / 1 / 7 / -1; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#lensrow { display: flex; justify-content: space-around; padding: 8px 6px; }
.lens { display: grid; justify-items: center; gap: 1px; min-width: 56px; padding: 6px 4px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.lens svg { width: 24px; height: 24px; }
.lens[aria-pressed="true"] { background: var(--blue); }
#dial { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 2px 12px 8px; border-top: 1px solid var(--line); position: relative; }
#zoomVal { position: absolute; left: 50%; top: -14px; translate: -50%; padding: 2px 14px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); font-size: 19px; font-weight: 600; }
#zoom { appearance: none; -webkit-appearance: none; height: 40px; margin-top: 14px; background: repeating-linear-gradient(90deg, #ffffff66 0 1.5px, transparent 1.5px 14px) left bottom / 100% 14px no-repeat; }
#zoom::-webkit-slider-thumb { -webkit-appearance: none; width: 3px; height: 34px; background: var(--blue); border-radius: 2px; }
#zoom::-moz-range-thumb { width: 3px; height: 34px; background: var(--blue); border: 0; }
#zoom:disabled { opacity: .35; }
#zoomReset { margin-top: 14px; }
.nozoom #dial { display: none; }
.nolens #zoomer { display: none; }
#adjust { grid-area: 7 / 1 / 8 / -1; margin: 0 10px; padding: 12px 14px; border-radius: 16px; background: var(--card); z-index: 6; }
#adjust h3 { margin: 0 0 8px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
#adjust p { margin: 0; color: var(--dim); font-size: 13px; }
#handle { position: absolute; left: 0; bottom: 96px; width: 34px; height: 48px; display: grid; place-items: center; z-index: 7; }
#side { position: absolute; left: 12px; bottom: 60px; display: grid; gap: 10px; z-index: 7; }
#side .icon-btn { width: 72px; height: 60px; border-radius: 16px; gap: 1px; font-size: 10px; font-weight: 600; }
#side:not([hidden]) ~ #handle, #side:not([hidden]) + #handle { opacity: .5; }

/* Swipe up: a clean screen with only the picture, the LIVE icon and the red outline. */
.clean #stage { inset: 0; display: block; padding: 0; }
.clean #stage > :not(#finder), .clean #tabs, .clean #note { display: none; }
.clean #finder { position: absolute; inset: 0; aspect-ratio: auto; border-radius: 0; }
/* Clean feed for an HDMI adapter or wireless transmitter: the mirrored screen carries the picture and nothing else. */
.hdmi.clean::after, .hdmi.clean #badges, .hdmi.clean #banner, .hdmi.clean #grid { display: none !important; }

.page { position: fixed; inset: 0 0 calc(64px + env(safe-area-inset-bottom)) 0; overflow: auto; padding: max(18px, env(safe-area-inset-top)) 16px 24px; display: none; background: #000; }
.page h1 { font-size: 26px; margin: 8px 6px 4px; }
[data-tab="media"] #mediaPage, [data-tab="chat"] #chatPage, [data-tab="settings"] #settingsPage { display: block; }
#chatPage { display: none; flex-direction: column; }
[data-tab="chat"] #chatPage { display: flex; }
#thread { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px 0; }
.bubble { max-width: 78%; padding: 9px 14px; border-radius: 18px; background: var(--card2); align-self: flex-start; }
.bubble.me { background: var(--blue); align-self: flex-end; }
.bubble small { display: block; font-size: 11px; opacity: .7; }
#chatForm { display: flex; gap: 8px; margin-top: 10px; }
#chatForm .field { border-radius: 999px; }
#chatForm .icon-btn { background: var(--blue); border-radius: 50%; }
#player { width: 100%; border-radius: 16px; margin-top: 14px; background: #000; }
#gate { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--bg); padding: 24px; }
#gate .card { display: grid; gap: 12px; padding: 24px; border-radius: 24px; max-width: 400px; text-align: center; background: var(--card); }
#gate h2 { margin: 0; }
#gate p { margin: 0; }

@media (orientation: landscape) {
  #tabs { top: 0; left: auto; width: 96px; flex-direction: column; justify-content: center; gap: 18px; padding: 8px max(6px, env(safe-area-inset-right)) 8px 6px; align-items: center; }
  #stage { inset: 0 calc(96px + env(safe-area-inset-right)) 0 0; grid-template-columns: minmax(0, 1fr) 88px; grid-template-rows: auto minmax(0, 1fr) auto; row-gap: 0; padding: 8px 0 8px max(34px, env(safe-area-inset-left)); }
  .tcP { display: none; }
  .tcL { display: block; flex: 1; font-size: clamp(16px, 2.3vw, 30px); align-self: center; text-shadow: 0 1px 4px #000; }
  #params .cell { padding: 3px 5px; }
  #params .cell .lbl { font-size: clamp(8px, 1.1vw, 12px); }
  #params .cell .val { font-size: clamp(12px, 1.7vw, 19px); }
  #params .cell .a { width: 12px; height: 12px; font-size: 9px; }
  #finder { grid-area: 1 / 1 / -1 / 2; aspect-ratio: auto; height: 100%; border-radius: 14px; }
  #badges { right: 162px; top: 64px; }
  .nolens #badges { right: 12px; }
  #banner { top: 62px; left: 12px; right: 260px; }
  .nolens #params, .nolens #scopes { margin-right: 12px; }
  #params { grid-area: 1 / 1; z-index: 2; margin: 8px 154px 0 8px; padding: 0; gap: 2px; justify-content: flex-start; align-items: flex-start; text-shadow: 0 1px 4px #000; }
  #scopes { display: flex; grid-area: 3 / 1; z-index: 2; margin: 0 160px 10px 12px; justify-content: space-between; align-items: flex-end; gap: 10px; }
  #histCard, #meterCard, #storeCard { width: auto; flex: 1 1 0; min-width: 0; max-width: 210px; margin: 0; }
  .recP { display: none; }
  .recL { display: grid; }
  #tools { grid-area: 1 / 2 / -1 / 3; flex-direction: column; justify-content: space-between; padding: 6px 0; }
  #zoomer { grid-area: 1 / 1 / -1 / 2; justify-self: end; z-index: 2; width: 150px; display: flex; flex-direction: row-reverse; border: 0; border-left: 1px solid #ffffff30; background: linear-gradient(90deg, #0000004d, #00000080); border-radius: 0 14px 14px 0; }
  #lensrow { flex-direction: column-reverse; padding: 10px 4px; width: 84px; }
  #dial { grid-template-columns: 1fr; grid-template-rows: auto 1fr; border: 0; border-right: 1px solid #ffffff30; padding: 8px 6px; width: 66px; justify-items: center; }
  #zoomReset { grid-row: 1; margin: 0; }
  #zoom { writing-mode: vertical-lr; direction: rtl; width: 40px; height: 100%; margin: 0; background: repeating-linear-gradient(0deg, #ffffff66 0 1.5px, transparent 1.5px 14px) right top / 14px 100% no-repeat; }
  #zoom::-webkit-slider-thumb { width: 34px; height: 3px; }
  #zoom::-moz-range-thumb { width: 34px; height: 3px; }
  #zoomVal { left: -96px; top: 50%; translate: 0 -50%; font-size: 22px; padding: 6px 16px; background: #1b1b1bd9; }
  #adjust { grid-area: 2 / 1; align-self: end; justify-self: start; margin: 0 0 96px 12px; width: min(420px, 60%); background: var(--glass); backdrop-filter: blur(18px); }
  #handle { left: 0; top: 50%; bottom: auto; translate: 0 -50%; }
  #side { left: max(44px, calc(env(safe-area-inset-left) + 10px)); top: 50%; bottom: auto; translate: 0 -50%; }
  .page { inset: 0 calc(96px + env(safe-area-inset-right)) 0 0; padding-left: max(24px, env(safe-area-inset-left)); }
  .page > * { max-width: 760px; margin-left: auto; margin-right: auto; }
  .clean #stage { inset: 0; }
}
