/* Loaded after feature styles so all workspaces share the same size constraints. */
#app-view main, #app-view .tab-panel, #app-view .card,
#app-view .workspace > *, #app-view .settings-grid > *,
#app-view .pc-heading > div { min-width: 0; }
#app-view form, #app-view fieldset { min-width: 0; }
#app-view input, #app-view select, #app-view textarea { max-width: 100%; }
#app-view pre { white-space: pre-wrap; overflow-wrap: anywhere; }
#app-view canvas, #app-view iframe, #app-view video { max-width: 100%; }
#app-view .card, #app-view .pc-rail { overflow-wrap: anywhere; }
.mobile-menu-toggle { display: none; }
#pcs .pc-device-mark { position: relative; flex: none; }
#pcs .pc-device-mark::after {
  content: ''; position: absolute; width: 10px; height: 10px;
  right: -2px; bottom: -2px; border-radius: 50%;
  background: #89929e; border: 2px solid #20252e;
}
#pcs[data-online=true] .pc-device-mark::after {
  background: #53ed8c; box-shadow: 0 0 9px 3px #53ed8c70;
}
#pcs[data-online=true] #pc-state { color: #a1f5bc; }
#pc-machine-list button[data-online=true] {
  border-color: #53ed8c55; background: linear-gradient(100deg, #53ed8c16, #ffffff05);
}
#pc-machine-list button[data-online=false]::after {
  background: #89929e; box-shadow: none;
}
#pc-machine-list button[data-online=false] small { color: #b9bdc9; }
#pc-machine-list button[aria-pressed=true] { outline: 2px solid #80cfff; outline-offset: -2px; }
@media (min-width: 801px) and (max-width: 1100px) {
  #app-view main { margin-left: 185px; width: calc(100% - 185px); }
  #pcs .pc-deck { grid-template-columns: 180px minmax(0, 1fr); }
  #app-view .workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 800px) {
  html { -webkit-text-size-adjust: 100%; }
  #app-view { display: block; }
  #app-view .sidebar {
    position: relative; width: 100%; height: auto; min-height: 0;
    display: flex; flex-flow: row wrap; align-items: center; justify-content: space-between;
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    gap: 8px; border-bottom: 1px solid var(--line);
  }
  #app-view .sidebar .brand { margin: 0; }
  #app-view .sidebar .side-label, #app-view .sidebar .side-bottom { display: none; }
  #app-view .mobile-menu-toggle {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 8px 14px; border: 1px solid var(--line);
    border-radius: 10px; background: #ffffff0c; color: var(--ink-body);
  }
  #app-view .sidebar nav {
    display: none; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible; gap: 6px; padding: 8px 0 2px;
  }
  #app-view .sidebar[data-menu-open=true] nav { display: grid; }
  #app-view .sidebar .nav {
    width: 100%; min-width: 0; min-height: 48px; padding: 10px;
    margin: 0; white-space: normal; text-align: left; justify-content: flex-start;
    font-size: var(--nav-fs, 13px);
  }
  #app-view .sidebar .nav span { display: inline; font-size: 13px; line-height: 1.3; }
  #app-view main {
    margin: 0; width: 100%; max-width: none;
    padding: 16px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  #app-view main > header { align-items: center; flex-wrap: wrap; gap: 12px; }
  #app-view h1 { font-size: clamp(23px, 6vw, 30px); overflow-wrap: anywhere; }
  #app-view .header-right { margin-left: auto; min-width: 0; flex-wrap: wrap; }
  #sync-status { font-size: 12px; }
  #app-view button, #app-view summary, #app-view .pc-sections button { min-height: 44px; }
  #app-view input:not([type=checkbox]):not([type=radio]):not([type=range]),
  #app-view select, #app-view textarea { font-size: 16px; min-height: 44px; }
  #app-view input[type=checkbox], #app-view input[type=radio] { width: 20px; height: 20px; flex: none; }
  #app-view .workspace, #app-view .settings-grid, #app-view .unified-grid,
  #pcs .pc-deck, #pcs .pc-workgrid { grid-template-columns: minmax(0, 1fr); }
  #app-view .section-intro, #app-view .hub-buttons, #app-view .card-head { flex-wrap: wrap; gap: 10px; }
  #app-view .section-intro > label { flex: 1 1 180px; min-width: 0; }
  #app-view .section-intro select { width: 100%; }
  #pcs .pc-rail { display: flex; flex-direction: column; padding: 12px; }
  #pcs .pc-mobile-picker { order: -2; display: block; }
  #pc-machine-list {
    display: grid; order: -1; gap: 8px; max-height: 210px;
    overflow-y: auto; overscroll-behavior: contain; margin: 8px 0;
  }
  #pc-machine-list button { min-height: 54px; }
  #pcs .pc-rail > h2, #pcs .pc-caption { display: none; }
  #pcs .pc-work { padding: 12px; }
  #pcs .pc-mobile-tools, #pcs .pc-mobile-settings { margin: 8px 0; }
  #pcs .pc-mobile-tools > summary, #pcs .pc-mobile-settings > summary {
    padding: 12px; border: 1px solid var(--line); border-radius: 8px;
    color: var(--ink-body); background: #ffffff08; cursor: pointer;
  }
  #pcs .pc-mobile-tools .pc-sections {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 0; margin: 8px 0; overflow: visible;
  }
  #pcs .pc-mobile-tools .pc-sections button {
    white-space: normal; width: 100%; justify-content: flex-start; text-align: left;
  }
  #pcs .pc-sections { flex-wrap: nowrap; overflow-x: auto; padding: 4px 2px 12px; }
  #pcs .pc-sections button { flex: none; }
  #pcs .pc-bottom { grid-template-columns: minmax(0, 1fr); }
  #pcs .pc-update-badge { margin-left: 0; width: fit-content; }
  #pcs .pc-quickbar, #pcs .pc-terminal-actions, .tv-console-tools { flex-wrap: wrap; }
  #pcs .pc-process-results { width: 100%; }
  #app-view .pc-map-canvas { height: min(55dvh, 440px); min-height: 270px; }
  #app-view .pc-map-shell { padding: 12px; }
  #app-view .pc-map-grid, #app-view .wireless-layout { grid-template-columns: minmax(0, 1fr); }
  #app-view .wireless-layout > div:last-child { max-height: none; }
  #app-view .pc-map-toolbar { align-items: stretch; }
  #app-view .pc-map-toolbar select { width: 100%; flex: 1 1 180px; }
  #app-view .pc-map-toolbar input { min-width: 0; }
  #app-view .home-camera-grid { grid-template-columns: minmax(0, 1fr); }
  #app-view .home-camera-card img { max-width: 100%; }
  dialog { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow: auto; }
  #toast { max-width: calc(100vw - 32px); overflow-wrap: anywhere; }
}
@media (max-width: 480px) {
  #app-view .hub-fields-grid { grid-template-columns: minmax(0, 1fr); }
  #app-view .card { padding: 14px; }
  #app-view .compact-card { padding: 0; }
  #app-view .pc-map-toolbar button { flex: 1 1 130px; }
  #app-view .pc-map-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #pcs .pc-heading { align-items: flex-start; }
  #app-view footer { flex-wrap: wrap; gap: 8px; }
  #app-view footer span { text-align: left; max-width: 100%; }
}
