:root {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--portal-foreground);
  background: var(--portal-background);
  font-synthesis: none;
  line-height: 1.55;
  --ruby: #9f3444;
  --line: var(--portal-border);
  --muted: color-mix(in srgb, var(--portal-foreground) 60%, var(--portal-muted));
  --page-margin: clamp(16px, 2vw, 40px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, select { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); border-radius: 6px; background: var(--portal-surface); color: var(--portal-foreground); min-height: 42px; padding: 8px 15px; }
button:hover { background: var(--portal-surface-alt); border-color: var(--portal-accent); }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 3px solid var(--portal-accent); outline-offset: 3px; }
.skip-link { position: absolute; top: 8px; left: 12px; padding: 10px; background: var(--portal-surface); color: var(--portal-foreground); transform: translateY(-150%); z-index: 2; }
.skip-link:focus { transform: none; }
.site-header { min-height: 68px; padding: 10px var(--page-margin); background: var(--portal-surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; color: var(--portal-foreground); font-size: 24px; font-weight: 680; text-decoration: none; letter-spacing: -.7px; }
.brand > span:last-child { font-weight: 400; }
.brand-mark { width: 40px; height: 40px; flex: none; margin-right: 10px; fill: none; stroke-width: 2.5; }
.brand-portal-back { stroke: var(--portal-accent); }
.brand-portal-front { stroke: var(--ruby); stroke-width: 4; }
.brand-room { fill: var(--portal-surface); stroke: var(--portal-foreground); stroke-width: 1.4; stroke-linejoin: round; }
.account { display: flex; align-items: center; gap: 18px; font-size: 14px; color: var(--muted); }
.quiet { border-color: var(--line); font-size: 14px; }
.account-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100svh - 32px); overflow: auto; padding: 24px; color: var(--portal-foreground); background: var(--portal-surface); border: 1px solid var(--line); border-radius: 9px; }
.account-dialog::backdrop { background: rgb(0 0 0 / .45); }
.account-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.account-dialog-heading h2 { margin: 0; }
.account-name { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.account-dialog h3 { margin: 22px 0 8px; font-size: 16px; }
.account-facts { margin: 0 0 12px; }
.account-facts > div { display: grid; grid-template-columns: minmax(80px, .65fr) minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--portal-divider); }
.account-facts dd { margin: 0; overflow-wrap: anywhere; }
.account-dialog .detail-note, .account-profile-note { color: var(--muted); font-size: 13px; }
.personal-profile-link { display: inline-block; margin: 18px 0 8px; color: var(--portal-accent); font-weight: 600; }
.account-profile-note { margin: 12px 0 0; }
.development-banner { background: var(--portal-surface-alt); color: var(--muted); padding: 6px var(--page-margin); display: flex; align-items: baseline; gap: 20px; font-size: 12px; border-bottom: 1px solid var(--line); }
.development-banner strong { font-weight: 650; }
main { width: 100%; padding: 20px var(--page-margin) 24px; min-height: calc(100svh - 150px); }
main:focus { outline: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(24px, 2vw, 30px); line-height: 1.2; font-weight: 650; letter-spacing: -.8px; margin-bottom: 0; }
h2 { font-size: 21px; line-height: 1.3; font-weight: 620; letter-spacing: -.35px; }
h3 { font-size: 14px; font-weight: 650; margin-bottom: 7px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px; margin-bottom: 9px; }
.muted, .detail-note, .panel-description { color: var(--muted); font-size: 14px; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.workspace-heading .eyebrow { margin-bottom: 4px; }
.workspace-heading p:last-child { margin-bottom: 0; }
.source-status { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; white-space: nowrap; border: 1px solid var(--line); background: var(--portal-surface); border-radius: 20px; color: var(--muted); font-size: 12px; margin-top: 10px; }
.source-status > span:first-child { width: 7px; height: 7px; background: var(--muted); border-radius: 50%; }
.toolbar { display: flex; gap: 24px; padding: 10px 14px; border: 1px solid var(--line); background: var(--portal-surface); border-radius: 9px; }
.field { flex: 1; max-width: 480px; min-width: 0; display: flex; align-items: center; gap: 12px; }
.field label { font-size: 12px; font-weight: 650; color: var(--muted); }
.field select { min-width: 0; }
select { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 5px; padding: 8px 30px 8px 11px; background: var(--portal-surface); color: var(--portal-foreground); text-overflow: ellipsis; }
.status-message { color: var(--muted); font-size: 12px; margin: 8px 2px; min-height: 19px; }
.workspace-columns { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; height: max(480px, calc(100svh - 365px)); }
.room-sidebar { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.workspace-columns:has(> .floor-map[hidden]) { grid-template-columns: minmax(0, 480px); }
.workspace-columns:has(#ui-core-canvas[hidden]) { height: auto; align-items: start; }
.workspace-columns:has(#ui-core-canvas[hidden]) .room-list { max-height: 360px; }
.room-panel, .detail-panel, .floor-map { background: var(--portal-surface); border: 1px solid var(--line); border-radius: 9px; min-width: 0; }
.room-panel { padding: 12px 0 0; display: flex; flex-direction: column; flex: 1 0 156px; min-height: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 14px 12px; gap: 10px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 17px; }
.count { background: var(--portal-surface-alt); border-radius: 5px; min-width: 27px; padding: 2px 7px; font-size: 12px; color: var(--muted); text-align: center; }
.panel-description { margin: 2px 0 0; font-size: 12px; }
.room-list { padding: 0; margin: 0; list-style: none; min-height: 0; overflow-y: auto; scrollbar-color: var(--portal-border) var(--portal-surface); }
.room-list li + li { border-top: 1px solid var(--portal-divider); }
.room-button { width: 100%; border: 0; background: transparent; border-radius: 0; text-align: left; display: grid; grid-template-columns: minmax(44px, .5fr) minmax(0, 1fr); column-gap: 12px; align-items: center; padding: 8px 12px; min-height: 52px; border-left: 3px solid transparent; }
.room-button:focus-visible { outline-offset: -3px; }
.room-button[aria-current="true"] { background: var(--portal-accent-wash); border-left-color: var(--portal-presence); }
.room-name { grid-row: span 2; font-size: 14px; font-weight: 620; overflow-wrap: anywhere; }
.room-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.room-status-mark { height: 7px; width: 7px; border: 1px solid var(--muted); border-radius: 50%; flex: 0 0 auto; }
.room-status-mark[data-presence="present"] { background: var(--portal-presence); border-color: var(--portal-presence); }
.room-status-mark[data-presence="not_detected"] { border-color: var(--portal-presence); border-radius: 1px; }
.room-presence { grid-column: 2; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.detail-panel { padding: 16px; overflow-wrap: anywhere; flex: 0 1 auto; min-height: 0; overflow-y: auto; }
.detail-panel h2 { font-size: 18px; margin-bottom: 10px; }
.detail-panel > div > p:not(.eyebrow) { color: var(--muted); font-size: 13px; }
.floor-map { padding: 14px; display: flex; flex-direction: column; min-height: 0; }
.floor-map-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.floor-map-heading h2 { margin: 0; font-size: 17px; }
.floor-map-controls { display: flex; gap: 6px; }
.floor-map-controls button { min-width: 42px; min-height: 42px; padding: 6px 12px; }
/* The HTML host allocates the viewport; UI_Core stretches its root inside it. */
.map-viewport { flex: 1; min-height: 0; position: relative; background: var(--portal-surface-alt); border: 1px solid var(--line); border-radius: 7px; }
.map-viewport:has(canvas[hidden]) { flex: none; height: 0; border: 0; }
.map-viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; border-radius: 6px; }
.map-status { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
#map-retry { margin-top: 12px; }
.detail-note { margin-bottom: 0; line-height: 1.65; }
.back-button { margin: -4px 0 12px -4px; padding: 5px 8px; min-height: 42px; border-color: transparent; color: var(--portal-accent); font-size: 13px; }
.room-facts { margin: 14px 0; }
.room-facts > div { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--portal-divider); font-size: 12px; }
dt { color: var(--muted); }
dd { margin: 0; color: var(--portal-foreground); font-weight: 550; }
.explanation { background: var(--portal-surface-alt); border-radius: 6px; padding: 12px; margin-bottom: 14px; color: var(--portal-foreground); }
.explanation p { font-size: 12px; margin-bottom: 0; }
.empty-message { padding: 20px; color: var(--muted); font-size: 14px; }
.error-panel { background: var(--portal-error-wash); border: 1px solid var(--portal-error); border-radius: 7px; padding: 16px 20px; margin: 16px 0 22px; color: var(--portal-foreground); }
.error-panel p { margin-bottom: 10px; }
.session-panel { max-width: 650px; margin: 40px auto; padding: 35px; background: var(--portal-surface); border: 1px solid var(--line); border-radius: 9px; }
.session-panel > p:not(.eyebrow) { color: var(--muted); }
.phone-approval { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.approval-qr { display: block; width: min(224px, 100%); height: auto; border: 1px solid var(--line); background: var(--portal-surface); margin: 0 auto 20px; }
.approval-instruction { font-size: 14px; margin-bottom: 8px; }
.matching-code { display: block; font: 650 30px ui-monospace, monospace; letter-spacing: 3px; color: var(--portal-foreground); margin-bottom: 16px; }
.approval-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.approval-link { display: inline-block; color: var(--portal-accent); font-weight: 600; padding: 9px 0; }
footer { padding: 8px var(--page-margin) 16px; color: var(--muted); font-size: 12px; }
footer span { padding: 0 8px; }
@media (max-width: 850px) {
  .site-header { min-height: 68px; }
  .brand { font-size: 22px; }
  .account { gap: 8px; }
  #account-label { display: none; }
  .development-banner { display: block; }
  .development-banner span { display: block; margin-top: 2px; }
  main { padding-top: 18px; }
  .workspace-heading { display: block; }
  .source-status { margin-top: 14px; }
  .toolbar { padding: 12px; gap: 12px; }
  .field { display: block; }
  .field label { display: block; margin-bottom: 5px; }
  .workspace-columns { grid-template-columns: minmax(0, 1fr); gap: 18px; height: auto; }
  .floor-map { padding: 12px; }
  .floor-map-heading { flex-wrap: wrap; }
  .map-viewport { flex: none; height: clamp(260px, min(80vw, 60svh), 520px); }
  .room-list { max-height: 360px; }
  .session-panel { margin-top: 12px; padding: 25px; }
}
@media (max-width: 380px) {
  .toolbar { display: block; }
  .field + .field { margin-top: 12px; }
  .room-facts > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

.header-actions { display: flex; align-items: center; gap: 18px; }
.theme-picker { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.theme-picker select { width: 130px; min-height: 38px; }
@media (max-width: 700px) {
  .site-header { flex-wrap: wrap; }
  .header-actions { flex-wrap: wrap; gap: 10px; }
  .theme-picker select { width: 120px; }
}

.point-selection { margin-top: 12px; }
.point-selection label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.point-selection select { width: 100%; }
.point-readings { list-style: none; padding: 0; margin: 12px 0; }
.point-readings li { padding: 7px 0; border-bottom: 1px solid var(--portal-divider); font-size: 12px; }
.point-readings strong { display: block; margin-bottom: 3px; }
.point-readings span { color: var(--muted); }
.plan-controls { display: flex; gap: 8px; margin: 12px 0; }
.plan-controls button { min-height: 42px; }
