/* Phone/tablet layout and shared accessibility. Native popup keeps its own layout. */
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
[tabindex]:focus-visible { outline: 3px solid var(--brass-hi); outline-offset: 3px; }
button:disabled { opacity: .55; cursor: wait; }
.cam-tile { display: block; padding: 0; text-align: left; color: var(--text); font: inherit; }
.view > *, .brand > div, .cams-head > *, .mic-row > *, .setting > * { min-width: 0; }
.ctl { touch-action: manipulation; }
#pttBtn, #ringTalk, #pipTalk { touch-action: none; -webkit-touch-callout: none; }
.signin, .ring-overlay, .admin-wrap { overflow-y: auto; overscroll-behavior: contain; }
.signin-card, .ring-box, .admin-panel { flex-shrink: 0; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
.people-add input[type=password] { flex: 1; min-width: 140px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 9px; font: inherit; }
.mobile-note { display: none; }
.connection-note { padding: 10px 16px; background: #4b3420; color: #ffe6b6; font-size: 13px; text-align: center; }
.camera-listen { font-family: var(--font); font-size: 14px; font-weight: 600; }
.toast { max-width: calc(100vw - 24px); width: max-content; text-align: center; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 960px) {
  body:not(.popup) button { min-height:44px; }
  body:not(.popup):not(.settings) .view { grid-template-columns: minmax(0, 1fr); flex: none; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .statuszone { grid-column: 2; grid-row: 1; flex-wrap: wrap; }
  .nav { grid-row: 2; }
  .admin-panel { max-width: 100%; }
}
@media (max-width: 600px) {
  body:not(.popup) { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
  body:not(.popup) .topbar { gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; }
  .brand { gap: 7px; }
  .brand-mark { height: 32px; }
  .brand-logo { max-width: 126px; max-height: 30px; padding: 4px 6px; }
  .wordmark { font-size: 16px; }
  .brand .site { font-size: 10px; letter-spacing: 0; max-width: 170px; }
  .statuszone { max-width: 142px; gap: 4px; }
  .chip.status { font-size: 11px; padding: 5px 8px; }
  .chip.user { min-height: 44px; max-width: 142px; }
  #deskName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chip.talker, .chip.doormic { font-size: 10px; padding: 5px 7px; }
  .nav { width: 100%; justify-self: stretch; }
  .nav-btn { flex: 1; min-height: 46px; justify-content: center; font-size: 15px; }
  .deskmenu { position: fixed; top: calc(72px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px; min-width: 0; max-height: calc(100dvh - 96px); overflow-y: auto; }
  .dm-item { min-height: 48px; }
  .dm-row { flex-wrap: wrap; }
  .dm-row select { max-width: 100%; }
  body:not(.popup):not(.settings) .view { padding: 12px; gap: 12px; }
  .card { border-radius: 14px; min-width: 0; }
  body:not(.popup) .cam-frame { aspect-ratio: 4 / 3; }
  .cam-frame canvas, .cam-frame video, .cam-frame img#camMjpeg { object-fit: contain; }
  .cam-badges { top: 8px; left: 8px; right: 8px; gap: 5px; flex-wrap: wrap; }
  .badge { font-size: 10px; padding: 5px 7px; }
  .btn-pip { min-height: 44px; }
  body:not(.popup) .controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 10px; gap: 10px; }
  body:not(.popup) .controls .ctl { min-height: 72px; padding: 13px 7px; }
  body:not(.popup) .controls .buzz, body:not(.popup) .controls #pttBtn { min-height: 92px; }
  .ctl-label { letter-spacing: .9px; }
  .ctl-sub { font-size: 12px; }
  .mobile-note { display: block; padding: 0 14px 14px; color: var(--muted); font-size: 12px; line-height: 1.5; }
  body.popup .mobile-note, body.settings .mobile-note { display: none; }
  .feed-head { padding: 14px 12px 10px; gap: 8px; flex-wrap: wrap; }
  .feed-head h2 { letter-spacing: 1.1px; }
  .feed-card .feed { max-height: 300px; }
  .feed li { grid-template-columns: 30px minmax(0,1fr) auto; gap: 8px; }
  .cams-head { flex-wrap: wrap; padding: 10px; gap: 8px; }
  .cams-head h2 { flex: 1 1 40%; letter-spacing: 1px; }
  #camsGridBtn { min-height: 46px; font-size: 14px; }
  .cams-grid { grid-template-columns: minmax(0,1fr); padding: 10px; }
  .cam-tile { aspect-ratio: 16 / 10; }
  .cam-tile img { object-fit: contain; }
  .cam-tile .tile-label { font-size: 12px; letter-spacing: .5px; }
  .cams-big { margin: 10px; aspect-ratio: auto; padding-bottom: 60px; }
  .cams-big img, .cams-big video { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: contain; }
  .cams-big-label { top: 8px; bottom: auto; left: 8px; right: 8px; width: fit-content; max-width: calc(100% - 16px); font-size: 11px; letter-spacing: .5px; }
  .camera-listen { bottom: 8px; right: 8px; left: 8px; width: calc(100% - 16px); min-height: 44px; }
  .camera-playback-status { font-size: 13px; padding: 10px; text-align: center; }
  .h-pickers { padding: 10px; gap: 10px; }
  .chips button, .linky, .ctl.small, .pf-btn { min-height: 44px; min-width: 44px; }
  .chips { gap: 8px; }
  .h-body { padding: 10px; }
  .h-top, .h-meta { flex-wrap: wrap; gap: 8px; }
  .h-label { overflow-wrap: anywhere; }
  .ring-overlay, .admin-wrap, .signin { padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(10px, env(safe-area-inset-bottom, 0px)); }
  .ring-box, .admin-panel, .signin-card { padding: 18px 14px; border-radius: 16px; max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
  .signin-card { width: 100%; }
  .signin h1 { font-size: 23px; }
  .signin-brand { margin-bottom: 16px; }
  .brand-mark.big { height: 46px; }
  .people button { min-width: 0; flex: 1 1 42%; min-height: 56px; }
  .pin-pad { gap: 8px; max-width: 320px; }
  .pin-pad button { min-height: 48px; aspect-ratio: 1.65; }
  .pin-dots { gap: 8px; flex-wrap: wrap; }
  .ring-title { font-size: 24px; }
  .ring-actions { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .ring-actions .ctl { min-width: 0; min-height: 60px; padding: 12px 8px; }
  .ring-actions .ctl.ghost:last-child { grid-column: 1 / -1; }
  input:not([type=checkbox]):not([type=range]), select, textarea { font-size: 16px !important; min-height: 44px; max-width: 100%; }
  .people-add input { flex: 1 1 100% !important; min-width: 0 !important; }
  .tick { min-height: 44px; padding-right: 12px; }
  .tick input, .setting input[type=checkbox], .people-table input[type=checkbox] { width: 22px; height: 22px; }
  .admin-cards { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .admin-section h3 { letter-spacing: 1px; }
  .admin-head { align-items: center; }
  .setting { flex-wrap: wrap; }
  .setting input.wide { flex-basis: 100%; }
  .mic-row { flex-wrap: wrap; }
  .mic-row select { flex-basis: 100%; min-width: 0; }
  .mic-row .test-btn { flex: 1 1 100%; }
  .inbox-scroll { max-width: 100%; }
  .people-table { min-width: 520px; }
  .foot { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-height: 500px) and (orientation: landscape) {
  .signin, .ring-overlay, .admin-wrap { align-items: flex-start; }
  .signin-card, .ring-box, .admin-panel { margin: auto; }
  .ring-snap { max-height: 150px; }
  body:not(.popup) .cam-frame { max-height: 60vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media (max-width:600px) {
  .tl-hours > :not(:nth-child(4n + 1)) { visibility:hidden; }
  .tl-hours { font-size:11px; }
  .tl-legend { flex-wrap:wrap; line-height:1.5; }
  .tl-hint { flex-basis:100%; }
  .cams-head { scroll-margin-top:12px; }
}

@media (max-width:600px) {
  .people-table { min-width:0; }
  .people-table thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .people-table tbody { display:block; }
  .people-table tr { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); border-bottom:1px solid var(--line-2); }
  .people-table td { display:block; border:0; overflow-wrap:anywhere; }
  .people-table td::before { content:attr(data-label); display:block; font-size:10px; color:var(--muted); margin-bottom:7px; text-transform:uppercase; letter-spacing:1px; }
  .people-table td:first-child, .people-table td:last-child { grid-column:1 / -1; }
  .people-table .row-actions { flex-wrap:wrap; justify-content:flex-start; gap:8px; }
}

.history-search { display:flex; align-items:end; gap:12px; flex-wrap:wrap; padding:12px 0; }
.history-search label { display:grid; gap:6px; color:var(--muted); font-size:13px; }
.history-search input { color-scheme:dark; min-height:44px; min-width:0; background:#211c17; color:#efe7d8; border:1px solid #665335; border-radius:10px; padding:8px 12px; font:inherit; }
.history-search button, #hNextAvailable { min-height:44px; border:1px solid #c9a55c; border-radius:10px; padding:10px 16px; background:#c9a55c; color:#1a1510; font-weight:700; }
.history-zone, #hSearchStatus { color:var(--muted); font-size:13px; line-height:1.5; }
#hSearchStatus { margin-bottom:8px; }
@media(max-width:600px) { .history-search { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); } .history-search button { grid-column:1/-1; } .history-zone { grid-column:1/-1; } .history-search input { width:100%; box-sizing:border-box; } }

.camera-listen { left:auto; right:10px; bottom:10px; width:auto; min-width:80px; max-width:170px; min-height:44px; padding:10px 14px; border-radius:12px; }
