@media (max-width: 1300px) and (min-width: 841px) {
  :root {
    --rail-width: 220px;
  }

  .operations-shell {
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
  }

  body:not(.client-mode) .guest-panel-host {
    position: fixed;
    z-index: 1760;
    inset: 0;
    display: block;
    width: auto;
    height: auto;
    overflow: visible;
    pointer-events: none;
  }

  body:not(.client-mode) .guest-panel-placeholder {
    display: none;
  }

  body:not(.client-mode) .guest-panel {
    position: absolute;
    inset: 0;
    height: auto;
    pointer-events: auto;
  }

  body:not(.client-mode) .guest-panel > .modal-backdrop {
    display: block;
  }

  body:not(.client-mode) .guest-panel-card {
    position: absolute;
    top: 0;
    right: 0;
    width: 400px;
    height: 100%;
    border-radius: 0;
    box-shadow: -24px 0 70px rgba(0, 0, 0, .22);
  }
}

@media (max-width: 840px) {
  :root {
    --mobile-gutter: 10px;
  }

  .app-view {
    background:
      radial-gradient(ellipse 24rem 20rem at -8% 9%, var(--canvas-role-glow), transparent 72%),
      radial-gradient(ellipse 22rem 26rem at 108% 54%, var(--canvas-role-wash), transparent 74%),
      linear-gradient(180deg, #f8f5ee 0%, #f2eee6 52%, #ece7dd 100%);
  }

  .app-view::before {
    background-size: 48px 48px;
    opacity: .72;
  }

  .app-view::after {
    background:
      radial-gradient(circle at 112% 17%, transparent 0 8.2rem, var(--canvas-role-line) 8.25rem 8.31rem, transparent 8.37rem),
      radial-gradient(circle at -18% 76%, transparent 0 10rem, rgba(97, 92, 84, .045) 10.05rem 10.11rem, transparent 10.17rem);
    opacity: .68;
  }

  .login-view {
    min-height: 100dvh;
    overflow-y: auto;
    padding: max(14px, env(safe-area-inset-top, 0px)) 14px max(14px, env(safe-area-inset-bottom, 0px));
    place-items: start center;
  }

  .login-shell {
    width: min(100%, 580px);
    min-height: 0;
    grid-template-columns: 1fr;
    border-top-width: 5px;
    border-radius: 24px;
  }

  .login-brand {
    min-height: 230px;
    padding: 30px 28px;
    justify-content: flex-start;
    gap: 22px;
  }

  .login-brand::before {
    top: auto;
    bottom: 0;
    width: 100%;
    height: 4px;
  }

  .login-brand::after {
    right: -145px;
    bottom: -190px;
  }

  .login-logo {
    width: 230px;
  }

  .brand-copy h1 {
    margin-bottom: 9px;
    font-size: 30px;
  }

  .brand-copy p:last-child {
    max-width: 440px;
    font-size: 12px;
    line-height: 1.5;
  }

  .login-panel {
    padding: 30px 24px 26px;
  }

  .login-panel h2 {
    font-size: clamp(28px, 8vw, 36px);
  }

  .login-panel .muted {
    margin-bottom: 22px;
    font-size: 13px;
  }

  .app-header {
    position: relative;
  }

  .header-row {
    display: grid;
    min-height: auto;
    padding: calc(11px + env(safe-area-inset-top, 0px)) 12px 13px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-2);
  }

  .event-lockup {
    min-width: 0;
    gap: 10px;
  }

  .header-logo {
    width: 44px;
    height: 44px;
    padding: 7px;
    border-radius: 12px;
  }

  .event-copy h1 {
    display: -webkit-box;
    max-width: none;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.15;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .event-copy p {
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .event-kicker {
    font-size: 8.5px;
    line-height: 1.25;
    white-space: normal;
  }

  .event-kicker i {
    width: 10px;
  }

  .header-controls {
    display: contents;
  }

  .header-controls > .environment-badge,
  .header-controls > .sync-status {
    display: none;
  }

  .operator-menu-wrap {
    position: static;
    justify-self: end;
  }

  .operator-button {
    max-width: 180px;
  }

  .operator-text strong,
  .operator-text small {
    max-width: 105px;
  }

  .operator-menu {
    position: fixed;
    z-index: 2100;
    top: calc(env(safe-area-inset-top, 0px) + 72px);
    right: 10px;
    width: min(250px, calc(100vw - 20px));
    max-height: calc(100dvh - 92px);
    overflow-y: auto;
  }

  .operator-menu .menu-item {
    min-height: 44px;
    font-size: 13px;
  }

  .app-main {
    width: 100%;
    padding: 12px var(--mobile-gutter) calc(34px + env(safe-area-inset-bottom, 0px));
  }

  .operations-shell,
  body.client-mode .operations-shell {
    display: block;
    height: auto;
    min-height: 0;
  }

  .left-rail {
    position: static;
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    margin-bottom: var(--space-2);
  }

  .left-rail > .rail-card:not(.rail-summary) {
    display: none;
  }

  .rail-card {
    padding: 13px;
    border-radius: 18px;
  }

  .rail-heading {
    display: none;
  }

  .rail-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
  }

  .rail-stat {
    min-height: 102px;
    padding: 13px;
  }

  .rail-extra {
    display: none;
  }

  .workspace-card,
  body.client-mode .workspace-card {
    height: auto;
    min-height: 0;
    overflow: visible;
    grid-template-rows: auto auto auto;
    border-radius: 19px;
  }

  .workspace-toolbar,
  body.client-mode .workspace-toolbar {
    position: static;
    display: block;
    padding: 12px 12px 0;
  }

  .search-row {
    align-items: stretch;
    flex-direction: column;
  }

  .search-row > .button,
  .search-box {
    width: 100%;
  }

  .search-box input,
  body.desk-mode .search-box input {
    height: 50px;
    padding-right: 52px;
    font-size: 15px;
  }

  .search-box input:focus-visible {
    outline: none;
  }

  .walkin-button {
    color: var(--walkin);
    border-color: rgba(148, 82, 58, .4);
    background: var(--walkin-soft);
    box-shadow: none;
  }

  .search-box kbd {
    display: none;
  }

  .clear-search {
    right: 5px;
    width: 44px;
    height: 44px;
  }

  .filter-command-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .filter-bar {
    padding: 9px 0 var(--space-2);
  }

  .filter-chip {
    min-height: 44px;
    flex: 1;
    justify-content: center;
  }

  .filter-toggle {
    min-height: 44px;
    margin-bottom: var(--space-2);
  }

  .advanced-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-reset {
    min-height: 44px;
    margin-top: 0;
    grid-column: 1 / -1;
  }

  .operator-actions .button {
    min-height: 44px;
  }

  .compact-field select {
    min-height: 44px;
  }

  .list-heading {
    padding: 16px 14px 10px;
  }

  .list-heading .eyebrow {
    display: none;
  }

  .list-heading h2 {
    font-size: 16px;
  }

  .guest-list {
    overflow: visible;
    padding: 0 10px 12px;
  }

  .guest-card {
    min-height: 92px;
    border-radius: 13px;
  }

  .guest-row__open {
    min-height: 86px;
    padding: 10px 11px 10px 15px;
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .guest-name {
    font-size: 16px;
  }

  .guest-institution {
    font-size: 12px;
  }

  .guest-meta {
    flex-wrap: wrap;
    gap: 3px var(--space-2);
    white-space: normal;
  }

  .badge-row {
    justify-content: flex-start;
  }

  .guest-panel-host,
  body.client-mode .guest-panel-host,
  body:not(.client-mode) .guest-panel-host {
    position: fixed;
    z-index: 1760;
    inset: 0;
    display: block;
    width: auto;
    height: auto;
    overflow: visible;
    pointer-events: none;
  }

  .guest-panel-placeholder {
    display: none;
  }

  .guest-panel,
  body.client-mode .guest-panel,
  body:not(.client-mode) .guest-panel {
    position: absolute;
    inset: 0;
    height: auto;
    padding-top: max(56px, env(safe-area-inset-top, 0px));
    pointer-events: auto;
  }

  .guest-panel > .modal-backdrop {
    display: block;
  }

  .guest-panel-card,
  body.client-mode .guest-panel-card,
  body:not(.client-mode) .guest-panel-card {
    position: absolute;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 88dvh;
    padding: 22px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    border-top-width: 6px;
    border-radius: 26px 26px 0 0;
    background:
      linear-gradient(180deg, var(--role-soft), rgba(255, 254, 250, 0) 150px),
      var(--surface-raised);
    box-shadow: 0 -28px 80px rgba(20, 16, 12, .34);
    animation: sheet-in var(--motion-standard) ease-out;
  }

  .guest-panel-card::before {
    display: block;
    width: 42px;
    height: 4px;
    margin: -10px auto 14px;
    border-radius: 99px;
    background: var(--role-accent);
    content: "";
  }

  .guest-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 0;
    align-items: end;
  }

  .modal-card {
    width: 100%;
    max-height: min(92dvh, 860px);
    padding: 22px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    border-radius: 24px 24px 0 0;
    animation: sheet-in var(--motion-standard) ease-out;
  }

  .operator-modal-header {
    flex-direction: column;
  }

  .operator-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .operator-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .viewer-tabs {
    position: sticky;
    z-index: 150;
    top: 0;
    width: 100%;
    margin-bottom: 13px;
    border-radius: 14px;
  }

  .viewer-hero {
    min-height: 208px;
    padding: 20px 18px 16px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 1fr auto auto;
    gap: 10px 12px;
    border-top-width: 5px;
    border-left-width: 4px;
    border-radius: 20px;
  }

  .viewer-kicker {
    font-size: 9px;
  }

  .viewer-hero-count {
    font-size: clamp(31px, 8.4vw, 40px);
  }

  .viewer-rate {
    position: relative;
    right: auto;
    bottom: auto;
    min-width: 0;
    padding: 10px 11px;
    border-radius: 12px;
    align-self: center;
  }

  .viewer-rate strong {
    font-size: 25px;
  }

  .viewer-rate span {
    font-size: 9px;
  }

  .viewer-progress {
    right: auto;
    bottom: auto;
    left: auto;
  }

  .viewer-hero-footer {
    gap: var(--space-2);
  }

  .viewer-credit {
    overflow: hidden;
    max-width: 52%;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .viewer-source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .viewer-dashboard-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }

  .viewer-pre-event {
    min-height: 0;
    padding: 15px;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
  }

  .viewer-pre-event-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    align-self: start;
  }

  .viewer-pre-event-copy h2 {
    font-size: 16px;
  }

  .viewer-readiness {
    display: flex;
    min-width: 0;
    grid-column: 1 / -1;
    flex-wrap: wrap;
    gap: 8px 14px;
  }

  .viewer-card {
    min-height: 0;
    padding: 18px;
    border-radius: 17px;
  }

  .viewer-card-heading {
    min-height: 44px;
    margin-bottom: 12px;
  }

  .live-badge {
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .attention-card { order: 1; }
  .priority-card { order: 2; }
  .equipment-card { order: 3; }
  .arrivals-card { order: 4; }

  .viewer-sort {
    justify-content: stretch;
  }

  .viewer-sort select {
    min-width: 0;
    min-height: 44px;
    flex: 1;
  }

  .viewer-arrivals .side-empty {
    min-height: 142px;
  }

  .viewer-arrival {
    min-height: 60px;
  }

  .viewer-all-link {
    min-height: 44px;
  }

  .more-actions summary {
    min-height: 48px;
  }

  .drawer-panel {
    top: auto;
    bottom: 0;
    width: 100%;
    height: min(84dvh, 760px);
    padding: 26px 18px calc(20px + env(safe-area-inset-bottom, 0px));
    border-top: 6px solid var(--brand);
    border-radius: 26px 26px 0 0;
    background: var(--surface-raised);
    animation: sheet-in var(--motion-standard) ease-out;
  }

  .action-flash {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
  }

  .toast-container {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 841px) and (max-height: 820px) {
  .guest-list {
    padding-bottom: var(--space-2);
  }

  .guest-card {
    min-height: 52px;
  }

  .guest-row__open {
    min-height: 50px;
    padding-block: 2px;
  }

  .guest-institution {
    margin-bottom: 2px;
  }

  .guest-card .tag {
    padding-block: 3px;
  }
}

@media (max-width: 520px) {
  .login-brand {
    min-height: 205px;
    padding: 26px 22px;
  }

  .login-logo {
    width: 205px;
  }

  .brand-copy h1 {
    font-size: 27px;
  }

  .brand-copy p:last-child {
    display: none;
  }

  .login-panel {
    padding: 27px 20px 24px;
  }

  .header-row {
    grid-template-columns: minmax(0, 1fr) 52px;
  }

  .operator-text {
    display: none;
  }

  .operator-button {
    width: 52px;
    padding: 5px;
    justify-content: center;
    gap: 2px;
  }

  .chevron {
    display: inline;
    color: rgba(255, 255, 255, .72);
    font-size: 11px;
  }

  .viewer-metric {
    min-width: 0;
    min-height: 116px;
    padding: 14px;
  }

  .viewer-metric span {
    font-size: 9px;
  }

  .viewer-metric::after {
    right: 14px;
    bottom: 14px;
  }

  .priority-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .priority-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .priority-actions button {
    width: 100%;
  }

  .equipment-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .equipment-grid button {
    min-height: 98px;
  }

  .operator-row {
    grid-template-columns: 1fr;
  }

  .operator-actions {
    grid-column: auto;
  }
}

@media (max-width: 380px) {
  .filter-command-row {
    grid-template-columns: 1fr;
  }

  .filter-toggle {
    width: 100%;
    margin-top: -4px;
  }

  .filter-chip {
    padding-inline: 7px;
    font-size: 10px;
  }

  .filter-count {
    min-width: 20px;
  }

  .guest-detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-item.wide {
    grid-column: auto;
  }

  .viewer-hero-label {
    font-size: .46em;
  }

  .viewer-live-status {
    font-size: 8px;
  }

  .viewer-credit {
    display: none;
  }
}

@media print {
  .app-view {
    background: var(--white);
  }

  .app-view::before,
  .app-view::after {
    display: none;
  }

  .app-header,
  .workspace-toolbar,
  .viewer-drawer,
  .guest-panel-host,
  .operator-menu-wrap,
  .header-controls {
    display: none;
  }

  .operations-shell,
  body.client-mode .operations-shell {
    display: block;
  }

  .workspace-card {
    height: auto;
    border: 0;
    box-shadow: none;
  }

  .guest-list {
    overflow: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
