@font-face {
  font-family: Geist;
  src: url('/geist.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f3f7f4;
  --surface: #fff;
  --ink: #17231e;
  --muted: #4e5c54;
  --line: #c9d8ce;
  --green: #176448;
  --green-dark: #0e5037;
  --green-soft: #e4f1e6;
  --neutral: #edf1ee;
  --stage: #1b302d;
  --warning: #faf1d9;
  --danger: #fbe8e3;
  --radius: 0;
  --header-height: 56px;
  font: 16px/1.45 Geist, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--page); }
h1, h2, p, dl, dd { margin: 0; }
button, input, select, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #399779;
  outline-offset: 3px;
}

.shell { width: min(100% - 48px, 1920px); margin-inline: auto; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-content { min-height: var(--header-height); display: flex; align-items: center; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 1.25rem; font-weight: 700; letter-spacing: -.045em; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 9px; color: white; background: var(--green); --icon-background: var(--green); }
.camera-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 0;
  font-weight: 650;
  line-height: 1.24;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}
.button.primary { background: var(--green); color: white; }
.button.primary:hover:not(:disabled) { background: var(--green-dark); }
.button.outline { border-color: var(--green); color: var(--green); background: transparent; }
.button.outline:hover:not(:disabled) { background: #eff7f1; }
.button.quiet { color: var(--muted); background: transparent; }
.button.quiet:hover:not(:disabled) { background: var(--neutral); }
.button:disabled { opacity: .54; cursor: default; }
.camera-actions .primary { min-width: 182px; min-height: 52px; font-size: 1.06rem; }
.full-width { width: 100%; }
.notice { margin: -16px 0 18px; padding: 9px 13px; border-radius: 0; color: #70471a; background: var(--warning); }

.dashboard { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 22px; align-items: start; }
.card { min-width: 0; padding: 19px; border: 1px solid var(--line); border-radius: 0; background: var(--surface); }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 33px; margin-bottom: 16px; }
.card-heading h2 { display: flex; align-items: center; gap: 12px; font-size: clamp(1.23rem, 1.9vw, 1.62rem); letter-spacing: -.045em; line-height: 1.2; }
.card-heading i { flex: 0 0 auto; color: #25473c; }
.chip { flex: 0 0 auto; padding: 4px 10px; border-radius: 0; font-size: .8rem; font-weight: 650; }
.chip[data-tone='neutral'] { color: #3d4d43; background: var(--neutral); }
.chip[data-tone='steady'] { color: var(--green-dark); background: var(--green-soft); }
.chip[data-tone='warning'] { color: #704710; background: var(--warning); }

.stage {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 210px;
  overflow: hidden;
  background: var(--stage);
  border-radius: 0;
  color: #f7faf8;
  --icon-background: var(--stage);
}
.stage img, .stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage-message { max-width: 85%; display: grid; justify-items: center; text-align: center; gap: 8px; padding-block: 14px; }
.stage-message .camera-icon { font-size: clamp(2.65rem, 5vw, 4.3rem); margin-bottom: 12px; }
.stage-message strong { font-size: clamp(1.27rem, 2.3vw, 1.8rem); letter-spacing: -.035em; }
.stage-message > span { color: #d1ddd7; font-size: clamp(.87rem, 1.35vw, 1.04rem); }
.frame-guides { position: absolute; inset: clamp(12px, 4.5%, 36px); pointer-events: none; }
.frame-guides i { position: absolute; width: clamp(16px, 6%, 38px); aspect-ratio: 1; border: 2px solid #91aa9f; border-width: 0; }
.frame-guides i:nth-child(1) { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.frame-guides i:nth-child(2) { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; }
.frame-guides i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; }
.frame-guides i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }
.stage[data-playing='true'] .frame-guides { display: none; }
.camera-status { display: grid; grid-template-columns: 1fr; margin: 20px 4px 4px; }
.camera-status > div + div { padding-left: 25px; border-left: 1px solid var(--line); }
dt { color: var(--muted); font-size: .92rem; }
dd { font-weight: 650; }
.camera-status dd { margin-top: 1px; font-size: 1.05rem; }
.demo-button { margin-top: 16px; }

.rail { display: flex; flex-direction: column; gap: 20px; }
.dashboard[data-urgent='true'] .incident-card { order: -1; }
.incident-panel { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 14px; padding: 18px; border-radius: 0; background: var(--green-soft); }
.incident-panel[data-tone='warning'] { background: var(--warning); }
.incident-panel[data-tone='danger'] { background: var(--danger); }
.incident-panel strong { display: block; font-size: 1.21rem; letter-spacing: -.035em; line-height: 1.25; }
.incident-panel p { margin-top: 5px; color: var(--muted); font-size: .94rem; line-height: 1.45; }
.incident-status { margin-top: 16px; }
.incident-status > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.incident-status > div:last-child { padding-bottom: 0; }
.incident-status dd { font-size: .9rem; text-align: end; }
.countdown { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 5px 8px; margin: 14px 0; color: #71500c; }
.countdown #time-remaining { font-size: 2.75rem; font-weight: 700; line-height: .97; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.countdown progress { grid-column: 1 / -1; width: 100%; height: 7px; appearance: none; border: 0; border-radius: 0; background: #f2e5c6; }
.countdown progress::-webkit-progress-bar { background: #f2e5c6; border-radius: 0; }
.countdown progress::-webkit-progress-value { background: #be881d; border-radius: 0; }
.countdown progress::-moz-progress-bar { background: #be881d; border-radius: 0; }
#rearm { margin-top: 14px; }
.telegram-card p { color: var(--muted); font-size: .96rem; }
.telegram-card .card-heading { margin-bottom: 12px; }
#open-link, .telegram-actions { margin-top: 18px; }
.telegram-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.telegram-actions .outline { flex: 1 0 auto; }
.inline-result { margin-top: 12px; font-size: .92rem; color: var(--muted); }
.inline-result[data-tone='error'] { color: #9d3829; }
.privacy { display: flex; flex: none; align-items: flex-start; gap: 10px; color: var(--muted); font-size: .86rem; }
.lock-icon { position: relative; flex: none; width: 16px; height: 12px; margin-top: 9px; border: 2px solid #315547; border-radius: 3px; }
.lock-icon::before { content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); width: 9px; height: 8px; border: 2px solid #315547; border-bottom: 0; border-radius: 8px 8px 0 0; }

dialog { width: min(100% - 32px, 465px); max-height: 90vh; padding: 23px; border: 1px solid var(--line); border-radius: 0; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgb(17 35 28 / 50%); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dialog-heading h2 { font-size: 1.55rem; letter-spacing: -.045em; }
.icon-button { flex: 0 0 auto; min-width: 36px; min-height: 36px; border: 0; border-radius: 0; background: var(--neutral); color: var(--ink); cursor: pointer; font-size: 1.25rem; }
dialog p { color: var(--muted); }
dialog label { display: block; margin-top: 16px; font-weight: 650; }
dialog input { width: 100%; min-height: 44px; padding: 8px 11px; margin: 4px 0 14px; border: 1px solid #a9bdb0; border-radius: 0; color: var(--ink); background: var(--surface); }
.pair-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 17px; }
.pair-actions > * { flex: 1 0 auto; }
details { margin: 13px 0 5px; color: var(--muted); font-size: .87rem; }
summary { cursor: pointer; }
details code { display: block; margin-top: 6px; padding: 7px 9px; overflow-wrap: anywhere; border-radius: 0; background: var(--neutral); }
#change-token { padding-left: 0; min-height: 35px; font-size: .86rem; }

.camera-icon { position: relative; display: inline-block; width: 1.08em; height: .81em; margin-top: .13em; border: .077em solid currentColor; border-radius: 0; }
.camera-icon::before { content: ''; position: absolute; width: .44em; height: .18em; left: 50%; top: -.16em; transform: translateX(-50%); border: .077em solid currentColor; border-bottom: 0; border-radius: 0; background: var(--icon-background, white); }
.camera-icon::after { content: ''; position: absolute; inset: 50% auto auto 50%; width: .48em; aspect-ratio: 1; border: .077em solid currentColor; border-radius: 50%; transform: translate(-50%, -50%); }
.brand-mark .camera-icon { font-size: 20px; border-radius: .15em; }
.brand-mark .camera-icon::before { border-radius: .1em .1em 0 0; }
.plane-icon { display: inline-block; width: 1.18em; height: 1.18em; background: currentColor; clip-path: polygon(0 35%, 100% 0, 74% 96%, 48% 69%, 29% 86%, 30% 54%, 0 35%, 11% 38%, 35% 48%, 81% 18%, 44% 60%, 70% 82%, 90% 10%, 11% 38%); }
.play-icon { display: inline-block; width: 14px; height: 16px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.play-icon.paused-shape { clip-path: polygon(0 0, 37% 0, 37% 100%, 0 100%, 0 0, 63% 0, 100% 0, 100% 100%, 63% 100%, 63% 0); }
.incident-icon { display: grid; place-items: center; width: 43px; height: 43px; border: 2px solid currentColor; color: var(--green); border-radius: 50%; }
.incident-icon i { width: 27px; height: 20px; background: currentColor; clip-path: polygon(0 46%, 23% 46%, 36% 2%, 57% 75%, 68% 44%, 100% 44%, 100% 56%, 76% 56%, 56% 100%, 36% 29%, 29% 57%, 0 57%); }
[data-tone='warning'] .incident-icon { color: #8a6419; }
[data-tone='danger'] .incident-icon { color: #9d3829; }

@media (max-width: 980px) {
  .shell { width: calc(100% - 36px); }
  .card { padding: 15px; }
  .dashboard { gap: 16px; }
  .rail { gap: 16px; }
}

@media (max-width: 740px) {
  .shell { width: calc(100% - 32px); }
  .camera-actions { flex-wrap: wrap; }
  .camera-actions .button { min-height: 45px; }
  .dashboard { display: flex; flex-direction: column; }
  .card { width: 100%; }
  .rail { display: contents; }
  .dashboard[data-urgent='true'] .incident-card { order: -1; }
  .stage { min-height: 190px; }
  .camera-status { margin-top: 14px; }
}

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

/* Live, display-only activity evidence. Alerts keep priority during a check-in. */
.activity-current { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.activity-current > span { color: var(--muted); font-size: .88rem; }
.activity-current > strong { font-size: 1.25rem; letter-spacing: -.035em; }
.activity-detail { color: var(--muted); font-size: .8rem; margin-top: 5px; min-height: 1.45em; }
.activity-fall { margin-top: 16px; padding: 13px 14px; background: var(--neutral); border-radius: 0; }
.activity-fall[data-tone='warning'] { background: var(--danger); color: #97382c; }
.activity-score-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .9rem; }
.activity-score-heading strong { font-size: .83rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.activity-score-heading small { margin-left: 6px; color: var(--muted); font-size: .58rem; letter-spacing: .07em; }
.activity-fall .activity-score-heading { font-weight: 650; }
.activity-card progress { width: 100%; height: 5px; display: block; margin-top: 7px; border: 0; appearance: none; border-radius: 0; overflow: hidden; background: var(--neutral); }
.activity-card progress::-webkit-progress-bar { background: #e7eeE8; border-radius: 0; }
.activity-card progress::-webkit-progress-value { background: #9ab2a3; border-radius: 0; transition: width 180ms ease; }
.activity-card progress::-moz-progress-bar { background: #9ab2a3; border-radius: 0; }
.fall-track { position: relative; }
.fall-track i { position: absolute; top: -2px; bottom: -2px; left: 90%; border-left: 1px solid #91725b; }
.activity-fall[data-tone='warning'] progress::-webkit-progress-value { background: #b34835; }
.activity-fall[data-tone='warning'] progress::-moz-progress-bar { background: #b34835; }
.activity-scores { list-style: none; margin: 10px 0 0; padding: 0; }
.activity-scores li { display: flex; align-items: center; gap: 13px; padding: 10px 0; border-bottom: 1px solid #edf1ee; }
.activity-rank { color: #84948a; font-size: .7rem; font-variant-numeric: tabular-nums; }
.activity-row-content { flex: 1; min-width: 0; }
.activity-scores li[data-leading='true'] .activity-score-heading { color: var(--green); font-weight: 650; }
.activity-scores li[data-leading='true'] progress::-webkit-progress-value { background: var(--green); }
.activity-scores li[data-leading='true'] progress::-moz-progress-bar { background: var(--green); }
.activity-scores li[data-unknown='true'] strong { color: #829087; }

/* Ranked rows move as a stack; the leading row passes above its neighbors. */
.activity-scores li { position: relative; background: var(--surface); }
.activity-scores li[data-leading='true'] { z-index: 2; }
@media (prefers-reduced-motion: reduce) {
  .activity-card progress::-webkit-progress-value { transition: none; }
}

/* Desktop workspace: all four panels fit the viewport at normal zoom. */
@media (min-width: 881px) {
  .shell { width: min(100% - 28px, 1920px); }
  .monitor-shell { height: calc(100dvh - var(--header-height) - 1px); padding-block: 14px; display: flex; flex-direction: column; gap: 10px; }
  .notice { flex: 0 0 auto; margin: 0; }
  .dashboard { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(360px, 520px); grid-template-rows: minmax(0, 1fr); grid-template-areas: 'camera rail'; gap: 12px; align-items: stretch; }
  .rail { grid-area: rail; display: flex; flex-direction: column; align-self: start; max-height: 100%; min-height: 0; overflow-y: auto; gap: 10px; }
  .card { padding: 12px; border-radius: 0; }
  .card-heading { min-height: 26px; margin-bottom: 9px; }
  .card-heading h2 { font-size: 1.2rem; }
  .camera-card { grid-area: camera; display: flex; flex-direction: column; align-self: start; min-height: 0; }
  .camera-heading { flex: 0 0 auto; flex-wrap: wrap; gap: 8px; }
  .camera-toolbar { display: flex; align-items: center; gap: 12px; margin-left: auto; }
  .camera-actions { gap: 7px; }
  .camera-actions .button { min-height: 35px; padding: 7px 11px; font-size: .86rem; }
  .camera-actions .primary { min-width: 0; }
  .video-space { flex: none; min-height: 0; aspect-ratio: auto; }
  .stage { flex: none; min-height: 0; aspect-ratio: auto; }
  .camera-status { flex: 0 0 auto; margin: 8px 2px 0; }
  .camera-status > div { display: flex; align-items: baseline; gap: 9px; }
  .camera-status dt, .camera-status dd { font-size: .8rem; margin: 0; }
  .activity-card { display: flex; flex-direction: column; align-self: stretch; }
  .activity-current > span { font-size: .8rem; }
  .activity-current > strong { font-size: 1.07rem; }
  .activity-detail { font-size: .72rem; margin-top: 3px; }
  .activity-fall { margin-top: 9px; padding: 9px 11px; }
  .activity-scores { flex: none; margin-top: 7px; }
  .activity-scores li { padding: 6px 0; }
  .activity-score-heading { font-size: .82rem; }
  .activity-score-heading strong { font-size: .77rem; }
  .activity-card progress { height: 4px; margin-top: 5px; }
  .incident-card { display: block; }
  .incident-panel { gap: 9px; padding: 9px; }
  .incident-panel strong { font-size: .95rem; }
  .incident-panel p { font-size: .75rem; margin-top: 3px; }
  .incident-icon { width: 30px; height: 30px; }
  .incident-icon i { width: 20px; height: 15px; }
  .incident-status { margin-top: 8px; }
  .incident-status > div { padding: 5px 0; gap: 8px; }
  .incident-status dt, .incident-status dd { font-size: .73rem; }
  .incident-status dd { overflow-wrap: anywhere; }
  .countdown { margin: 8px 0; gap: 3px 7px; }
  .countdown #time-remaining { font-size: 2rem; }
  .countdown > span:last-of-type { font-size: .8rem; }
  #cancel, #rearm { min-height: 33px; margin: 6px 0 0; font-size: .8rem; padding: 6px 9px; }
  .telegram-card { align-self: stretch; }
  .telegram-card .card-heading { margin-bottom: 7px; }
  .telegram-card p { font-size: .78rem; }
  #open-link, .telegram-actions { margin-top: 9px; }
  .telegram-card .button { min-height: 33px; padding: 6px 10px; font-size: .8rem; }
  .telegram-card .inline-result { margin-top: 6px; }
}
/* Smaller screens retain readable controls and natural scrolling. */
@media (max-width: 880px) {
  .shell { width: calc(100% - 24px); }
  .monitor-shell { padding-block: 12px; }
  .dashboard { display: flex; flex-direction: column; gap: 12px; }
  .rail { display: contents; }
  .card { width: 100%; }
  .camera-heading { flex-wrap: wrap; }
  .camera-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
  .incident-card { order: 1; }
  .telegram-card { order: 2; }
  .camera-actions { flex-wrap: wrap; }
  .camera-actions .button { min-height: 36px; padding: 7px 10px; font-size: .84rem; }
  .camera-actions .primary { min-width: 0; }
  .notice { margin: 0 0 10px; }
  .privacy { margin-block: 16px 8px; }
}
.camera-toolbar .play-icon { color: inherit; }

.video-space { display: grid; place-items: center; min-width: 0; width: 100%; }
.stage[data-playing='true'] { background: transparent; min-height: 0; }
@media (max-width: 880px) {
  .video-space { aspect-ratio: 4 / 3; }
}
@media (min-width: 881px) and (max-height: 820px) {
  .rail { gap: 8px; }
  .rail .card { padding: 9px; }
  .rail .card-heading { min-height: 22px; margin-bottom: 5px; }
  .rail .card-heading h2 { font-size: 1.08rem; }
  .activity-fall { margin-top: 6px; padding: 7px 9px; }
  .activity-scores { margin-top: 5px; }
  .activity-scores li { padding: 3px 0; }
  .activity-score-heading { font-size: .77rem; }
  .activity-score-heading strong { font-size: .73rem; }
  .activity-card progress { height: 3px; margin-top: 3px; }
  .incident-panel { padding: 7px; }
  .incident-status { margin-top: 5px; }
  .incident-status > div { padding: 3px 0; }
  .telegram-card p { font-size: .74rem; }
  #open-link, .telegram-actions { margin-top: 6px; }
}
@media (min-width: 881px) {
  .rail > .card { flex: none; }
}

@media (min-width: 881px) {
  .incident-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 9px; row-gap: 6px; }
  .incident-card > .card-heading { grid-column: 1 / -1; grid-row: 1; margin: 0; }
  .incident-panel { grid-column: 1 / -1; grid-row: 2; }
  .countdown { grid-column: 1; grid-row: 3; margin: 0; }
  #cancel { grid-column: 2; grid-row: 3; margin: 0; }
  #rearm { grid-column: 1 / -1; grid-row: 3; margin: 0; }
  .incident-status { grid-column: 1 / -1; grid-row: 4; margin-top: 2px; }
  .incident-status dt { flex-shrink: 0; }
}
@media (min-width: 881px) and (max-height: 740px) {
  .rail { gap: 6px; }
  .activity-scores li { padding: 1px 0; }
}

@media (min-width: 881px) {
  .rail .card-heading h2 { font-size: 1.25rem; }
  .activity-current > strong { font-size: 1.15rem; }
  .activity-score-heading { font-size: .9rem; }
  .activity-score-heading strong { font-size: .83rem; }
  .telegram-card p { font-size: .85rem; }
}

@media (min-width: 881px) and (min-height: 821px) {
  .rail .card-heading h2 { font-size: 1.4rem; }
  .activity-current > span { font-size: .95rem; }
  .activity-current > strong { font-size: 1.35rem; }
  .activity-detail { font-size: .82rem; }
  .activity-score-heading { font-size: 1rem; }
  .activity-score-heading strong { font-size: .95rem; }
  .activity-rank { font-size: .8rem; }
  .activity-scores li { padding: 8px 0; }
  .activity-card progress { height: 5px; }
}

/* Shared desktop/PWA controls retain the compact, square monitor layout. */
.camera-start { position: absolute; inset: 0; width: 100%; max-width: none; place-content: center; padding: 12px; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; }
.camera-start:focus-visible { outline-offset: -4px; }
.camera-start:disabled { cursor: default; }
.camera-options { display: grid; gap: 10px; }
.camera-options .button { justify-content: flex-start; text-align: left; }
