/* Quiet system chrome; map coordinates and viewport geometry stay unscaled. */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--ui-text);
  background: #f5f5f7;
  --app-header-height: 76px;
  --ui-text: #1d1d1f;
  --ink: var(--ui-text);
  --text: var(--ui-text);
  --ui-surface: #fff;
  --ui-field: #f5f5f7;
  --ui-hover: #f0f0f3;
  --ui-selected: #eaf3ff;
  --ui-selected-text: #005bb5;
  --ui-focus: #0071e3;
  --blue: #0071e3;
  --muted: #6e6e73;
  --line: #e8e8ed;
  --shadow: 0 4px 20px #0000000a;
}
button, input, select, textarea { font-family: inherit; }
textarea { color: inherit; }
button, a, input, select, textarea, summary { touch-action: manipulation; }
:is(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 3px; }
.primary { border-radius: 11px; font-weight: 600; }
.quiet:hover, .icon-button:hover { color: var(--ui-text); background: var(--ui-hover); }
.surface, .detail-panel, .ws-wizard, .timeline, .place-flow { color: var(--ui-text); background: var(--ui-surface); border-color: var(--line); box-shadow: var(--shadow); }
.segmented { background: var(--ui-field); border-color: var(--line); box-shadow: none; padding: 3px; border-radius: 11px; }
.segmented button { min-height: 44px; color: var(--muted); border-radius: 8px; }
.segmented button[aria-pressed="true"] { color: var(--ui-text); background: var(--ui-surface); box-shadow: 0 1px 4px #00000012; }
.map-toolbar :is(.room-control select, .ws-sort select, .ws-tool, .list-toggle), .map-controls .surface { color: var(--ui-text); background: var(--ui-surface); border-color: var(--line); }
.ws-pane-heading h2, .panel-header h2 { font-weight: 600; letter-spacing: -.02em; }
.ws-pane-heading .icon-button { width: 44px; height: 44px; }
.ws-pane-footer { background: var(--ui-surface); }
.ws-pane-footer :is(.primary, .quiet), .ws-dialog-actions button { min-height: 44px; }
/* Shared forms retain their own widths, validation states and input semantics. */
:is(.ws-dialog, .ws-wizard, .access-dialog, .personal-dialog, .feedback-dialog) :is(input, select, textarea):not(:where([type="checkbox"], [type="radio"], [type="range"])) {
  min-height: 44px;
  border-radius: 10px;
  color: var(--ui-text);
  background: var(--ui-field);
  font-size: 16px;
  line-height: 1.4;
}
:is(.ws-dialog, .ws-wizard, .access-dialog, .personal-dialog, .feedback-dialog) :is(input, select, textarea):not(:where([type="checkbox"], [type="radio"], [type="range"], :focus, :invalid, [aria-invalid="true"])) { border-color: var(--line); }
:is(.ws-dialog, .ws-wizard, .access-dialog, .personal-dialog, .feedback-dialog) :is(input, select, textarea):disabled { color: var(--muted); }
:is(.ws-dialog, .welcome, .feedback-dialog) { color: var(--ui-text); background: var(--ui-surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 70px #0000001f; }
.access-dialog { color: var(--ui-text); background: var(--ui-field); }
.access-plan { background: var(--ui-surface); border-color: var(--line); box-shadow: none; }
.place-selection { background: var(--ui-field); }
:is(.ws-dialog, .access-dialog, .welcome, .feedback-dialog)::backdrop { background: #1d1d1f38; backdrop-filter: blur(6px); }
.topbar.app-topbar {
  height: var(--app-header-height);
  padding: 0 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  gap: 16px;
  color: var(--ui-text);
  background: var(--ui-surface);
  border-color: var(--line);
}
.topbar.app-topbar > .search {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  max-width: 450px;
  height: 44px;
  margin: 0;
  border-radius: 12px;
  background: var(--ui-field);
}
.topbar.app-topbar > .search:focus-within { border-color: var(--ui-focus); background: var(--ui-surface); }
.topbar.app-topbar .search-clear { min-width: 44px; min-height: 44px; margin-right: -13px; color: var(--muted); }
.topbar.app-topbar .search-options { top: calc(100% + 6px); z-index: 4; background: var(--ui-surface); border: 1px solid var(--line); box-shadow: 0 12px 36px #0000001a; }
.topbar.app-topbar .search-option:hover, .topbar.app-topbar .search-option[aria-selected="true"] { background: var(--ui-selected); color: var(--ui-selected-text); }
.topbar.app-topbar > .app-menu { grid-column: 2; grid-row: 1; position: relative; display: flex; align-items: center; gap: 8px; }
.topbar.app-topbar .brand { margin: 0; order: unset; font-size: 1.05rem; gap: 8px; }
.header-access { display: contents; }
.topbar.app-topbar .access-header { min-height: 44px; margin: 0; padding: 9px 14px; font-size: 13px; background: var(--ui-selected); color: var(--ui-selected-text); font-weight: 600; }
.menu-toggle { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border-radius: 10px; color: var(--ui-text); }
.menu-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.menu-toggle:hover, .menu-toggle[aria-expanded="true"] { background: var(--ui-selected); color: var(--ui-selected-text); }
.menu-toggle:focus-visible, .brand:focus-visible, .access-header:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
.app-menu-panel {
  position: absolute;
  z-index: 3;
  top: calc(100% + 8px);
  right: 0;
  width: min(290px, calc(100vw - 24px));
  max-height: calc(100dvh - var(--app-header-height) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--ui-surface);
  box-shadow: 0 12px 36px #0000001a;
}
.topbar #appMenuPanel button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  order: unset;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  margin: 0;
  font-size: .875rem;
  text-align: left;
  color: var(--ui-text);
  border: 0;
  border-radius: 9px;
  white-space: normal;
}
.topbar #appMenuPanel button::after { content: none; }
.topbar #appMenuPanel button:hover { background: var(--ui-hover); }
.topbar #appMenuPanel .ws-navigation { display: grid; gap: 4px; order: unset; }
/* The regular and legacy routes previously duplicated the same action. */
.topbar #appMenuPanel .ws-new-button { display: none; }
.topbar #appMenuPanel .ws-access { border-left: 0; border-top: 1px solid var(--line); padding: 12px; gap: 6px; max-width: none; }
.topbar #appMenuPanel .ws-access > span { font-size: 11px; }
.topbar #appMenuPanel .ws-access select { max-width: none; width: 100%; min-height: 44px; font-size: 14px; color: var(--ui-text); }
/* Keep workspace overlays below the header disclosure, including first visit. */
body #workspace.workspace { height: calc(100dvh - var(--app-header-height)); min-height: 0; isolation: isolate; }
@media (min-width: 761px) and (max-width: 1440px), (min-width: 761px) and (max-height: 820px) {
  :root { --panel-width: 350px; --app-header-height: 60px; }
  .topbar.app-topbar { padding: 0 18px; }
  .topbar.app-topbar > .search { max-width: 390px; }
  .topbar.app-topbar .brand-icon { width: 28px; height: 28px; border-radius: 8px; }
  #workspace .map-toolbar { top: 14px; left: 18px; right: 18px; gap: 7px; }
  #workspace .map-toolbar .segmented button { min-height: 44px; padding: 7px 13px; }
  #workspace .map-toolbar .room-control select { height: 44px; }
  #workspace .map-toolbar .ws-tool, #workspace .map-toolbar .list-toggle { min-height: 44px; height: 44px; padding: 0 12px; }
  #workspace .area-caption { top: 72px; left: 22px; }
  #workspace.ws-has-filters .area-caption { top: 112px; }
  #workspace .ws-chips { top: 66px; left: 18px; right: 18px; }
  #workspace .detail-panel { top: 72px; bottom: 12px; right: 12px; border-radius: 16px; }
  #workspace .panel-header { padding: 10px 8px; }
  #workspace .panel-content { padding: 0 16px 18px; }
  #workspace .listing { padding: 14px 0; }
  #workspace .listing-cover { height: 150px; margin-bottom: 10px; }
  #workspace .detail-cover .listing-cover { height: 180px; }
  #workspace .facts { padding: 16px 0; gap: 14px 12px; }
  #workspace .section-label { margin: 18px 0 10px; }
  #workspace .ws-analytics { max-width: 660px; }
  .ws-dialog .ws-pane-heading { padding: 14px 18px; }
  .ws-dialog .ws-dialog-body { padding: 16px 18px; }
  .ws-dialog .ws-pane-footer { padding: 12px 18px; }
}
@media (max-width: 760px) {
  :root { --app-header-height: 58px; }
  .topbar.app-topbar { padding: 0 12px; gap: 10px; }
  .topbar.app-topbar > .search { max-width: none; }
  .topbar.app-topbar .brand { min-height: 44px; font-size: 1rem; }
  .topbar.app-topbar .brand-icon { width: 30px; height: 30px; }
  .topbar.app-topbar .search input { font-size: 16px; }
  .topbar #appMenuPanel button { font-size: 14px; min-height: 44px; }
  .topbar.app-topbar .search-options { max-height: calc(100dvh - var(--app-header-height) - 12px); overflow-y: auto; overscroll-behavior: contain; }
  #workspace .map-toolbar :is(.segmented button, .ws-tool, .list-toggle), #workspace .map-toolbar select { min-height: 44px; height: 44px; }
  .ws-pane-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  :root { --app-header-height: 96px; }
  .topbar.app-topbar { grid-template-columns: minmax(0, 1fr); grid-template-rows: 44px 44px; padding: 4px 12px; gap: 0; }
  .topbar.app-topbar > .app-menu { grid-column: 1; grid-row: 2; justify-self: end; gap: 6px; }
  .topbar.app-topbar > .search { grid-column: 1; grid-row: 1; position: static; }
  /* Anchor suggestions to the entire header, below the second-row actions. */
  .topbar.app-topbar .search-options { left: 12px; right: 12px; }
  .topbar.app-topbar .access-header { font-size: 12px; padding: 9px 11px; }
  .topbar.app-topbar .brand-name { font-size: 14px; }
  .topbar.app-topbar .app-menu-panel { top: calc(100% + 8px); }
}
@media (max-width: 340px) {
  .topbar.app-topbar .brand-name { display: none; }
  .topbar.app-topbar .brand { gap: 5px; min-width: 44px; }
}

/* A viewport-height sheet must rise above the header's sibling stacking context. */
@media (max-width:760px) {
  body #workspace.workspace:has(#detailPanel.sheet-expanded:not([hidden])) { z-index:31; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    background: #1c1c1e;
    --ui-text: #f5f5f7;
    --ui-surface: #242426;
    --ui-field: #303034;
    --ui-hover: #38383c;
    --ui-selected: #173b63;
    --ui-selected-text: #66adff;
    --ui-focus: #66adff;
    --blue: #66adff;
    --muted: #b0b0b7;
    --line: #424246;
    --shadow: 0 4px 20px #00000024;
  }
  .topbar.app-topbar .search input { color: var(--ui-text); }
  .topbar.app-topbar .brand-icon, .primary { color: #fff; background: #0071e3; }
  .ws-binding, .ws-limit, .ws-wait, .ws-address-target { color: var(--ui-text); background: var(--ui-field); border-color: var(--line); }
}

/* Stable tools row and a single aligned column for map status cards. */
#workspace { --map-overlay-edge:16px; --map-overlay-gap:12px; --map-tools-top:12px; --map-card-width:340px; --map-primary-tools-width:164px; }
#workspace:has(.map-house-filters-toggle) { --map-primary-tools-width:280px; }
#workspace .map-toolbar { top:var(--map-tools-top); left:calc(var(--map-overlay-edge) + var(--map-primary-tools-width)); right:var(--map-overlay-edge); }
#workspace .ws-chips { top:var(--map-chips-top,64px); left:var(--map-overlay-edge); right:var(--map-overlay-edge); }
#workspace .area-caption, #workspace.ws-has-filters .area-caption { top:var(--map-caption-top,72px); left:var(--map-overlay-edge); }
#workspace .ws-progress { top:var(--map-progress-top,112px); left:var(--map-overlay-edge); right:auto; width:min(var(--map-card-width),calc(100% - 2 * var(--map-overlay-edge))); max-height:max(44px,min(36dvh,calc(100% - var(--map-progress-top,112px) - var(--map-bottom-space,0px) - 12px))); overflow:auto; border-radius:16px; }
#workspace:has(.map-layers-panel:not([hidden])) .ws-progress { visibility:hidden; }
#workspace .environment-layer-readout { left:var(--map-overlay-edge); width:min(var(--map-card-width),calc(100% - 2 * var(--map-overlay-edge))); }
#workspace .environment-air-readout { left:var(--map-overlay-edge); width:min(var(--map-card-width),calc(100% - 2 * var(--map-overlay-edge))); }
@media(max-width:1000px) {
 #workspace .map-toolbar { top:68px; left:var(--map-overlay-edge); right:var(--map-overlay-edge); }
 #workspace .ws-progress { max-height:max(44px,min(26dvh,calc(100% - var(--map-progress-top,112px) - var(--map-bottom-space,0px) - 12px))); }
}

@media(max-width:760px) { #workspace { --map-overlay-edge:12px; } }

#workspace .house-layers-readout { left:var(--map-overlay-edge); right:auto; top:var(--map-layers-top,68px); width:min(var(--map-card-width),calc(100% - 2 * var(--map-overlay-edge))); max-height:max(44px,min(560px,calc(100% - var(--map-layers-top,68px) - var(--map-bottom-space,0px) - 12px))); }
@media(max-width:600px) {
 #workspace .house-layers-readout:not(.is-environment-context) { top:auto; bottom:max(var(--map-overlay-gap),env(safe-area-inset-bottom)); left:var(--map-overlay-edge); right:var(--map-overlay-edge); width:auto; max-height:min(58dvh,calc(100% - 80px)); }
 #workspace .house-layers-readout.is-environment-context { top:var(--map-layers-top,68px); bottom:auto; }
}

/* A visible year panel owns the bottom; other cards stay in the column above. */
#workspace:has(.building-age-panel:not([hidden])) .environment-air-readout { bottom:calc(var(--map-bottom-space,0px) + var(--map-overlay-gap)); max-height:max(44px,min(44dvh,calc(100% - var(--map-layers-top,68px) - var(--map-bottom-space,0px) - 12px))); }
@media(max-width:600px) {
 #workspace:has(.building-age-panel:not([hidden])) .house-layers-readout:not(.is-environment-context) { top:var(--map-layers-top,68px); bottom:auto; max-height:max(44px,calc(100% - var(--map-layers-top,68px) - var(--map-bottom-space,0px) - 12px)); }
}
