@import url("v10-shell.css");
@import url("workspace-hand.css?v=1.0.1");
@import url("workspace-board.css?v=1.2.1");

/* Shared application rhythm; domain canvases keep their local geometry. */
:root {
  --ui-space-1: var(--s-1, 4px);
  --ui-space-2: var(--s-2, 8px);
  --ui-space-3: var(--s-3, 12px);
  --ui-radius: var(--r-sm, 4px);
  --ui-control: 32px;
  --ui-motion: var(--m-normal, 160ms);
}

.ui-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:where(button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
:is(.detail-panel, .modal, .modal-content, .navigator-layout-menu) :is(.btn-primary, .btn-secondary) {
  min-height: var(--ui-control);
  border-radius: var(--ui-radius);
  transition: background-color var(--ui-motion), color var(--ui-motion), border-color var(--ui-motion);
}
#data-sync-modal .btn-primary { background: var(--accent) !important; }
.tasks-hub button.hub-disc-info {
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}
.detail-panel > h3, .detail-section-heading > h3 { color: var(--text); line-height: 1.4; }
.detail-section-heading {
  flex-wrap: wrap;
  align-items: flex-start !important;
  row-gap: var(--ui-space-3) !important;
}
.detail-section-heading > h3 { flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.detail-actions { flex: 0 1 auto; max-width: 100%; gap: var(--ui-space-2) !important; }
.detail-actions > button { white-space: nowrap; }
.detail-panel .detail-row {
  grid-template-columns: 110px minmax(0, 1fr);
  gap: var(--ui-space-2);
  padding-block: var(--ui-space-1);
}
.detail-panel .detail-value { min-width: 0; }
.detail-identity-panel .detail-value :is(input:not([type="checkbox"]):not([type="radio"]), select) {
  box-sizing: border-box;
  min-height: var(--ui-control);
  max-width: 100%;
  font: inherit;
  border-radius: var(--ui-radius);
}
.room-detail-notes textarea { box-sizing: border-box; max-width: 100%; line-height: 1.5; }
.fa-rooms-panel :is(input[type="text"], input[type="number"], select) {
  box-sizing: border-box;
  min-height: var(--ui-control);
  font-variant-numeric: tabular-nums;
}
.fa-room-grid-controls { gap: var(--ui-space-2) !important; }
.room-row-action { min-height: var(--ui-control); border-radius: var(--ui-radius); }
.room-row-action--danger {
  background: var(--overlay-subtle) !important;
  color: var(--muted) !important;
  border-color: var(--border) !important;
}
.room-row-action--danger:is(:hover, :focus-visible) {
  color: var(--error) !important;
  background: var(--error-faint, var(--overlay-hover)) !important;
}
.room-list-add-btn { border-width: 1px; color: var(--text); }
.room-list-add-btn:hover { transform: none; }
.fa-room-grid-controls { flex-wrap: wrap; }
.room-grid-scroll-hint { display: none; }

#equipment-detail-content .equipment-detail-section { min-width: 0; }
#equipment-detail-content .equipment-detail-section h3 { color: var(--text); }
#equipment-detail-content :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  box-sizing: border-box;
  max-width: 100%;
  min-height: var(--ui-control);
}

/* Existing state classes drive compact marks instead of colored edge rails. */
.app-window.win-focused { box-shadow: 0 2px 12px var(--card-shadow); }
.window-titlebar[style*="--win-accent"] .window-title,
.win-focused .window-titlebar[style*="--win-accent"] .window-title { color: var(--text); }
.win-focused .window-icon { filter: none; }
.taskbar-btn.taskbar-active, .taskbar-btn.taskbar-focused {
  border: 1px solid transparent;
  background: var(--overlay-hover);
}
.taskbar-btn::after {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0;
}
.taskbar-btn.taskbar-active::after { opacity: .6; }
.taskbar-btn.taskbar-focused::after { background: currentColor; opacity: 1; }
.taskbar-btn.taskbar-minimized::after { background: transparent; opacity: .6; }
.taskbar-start-btn, .taskbar-start-btn:hover {
  background: var(--overlay-hover);
  box-shadow: none;
  color: var(--text);
}
.wm-start-item { min-height: var(--ui-control); }
.wm-start-item:focus-visible { outline-offset: -2px; background: var(--overlay-hover); }
.context-menu-item {
  display: flex;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
}
.context-menu-item:focus-visible { outline-offset: -2px; background: var(--overlay-hover); }

/* Preserve onboarding and dismissal with a compact, finite arrival. */
.taskbar-attention-hint { width: 64px; height: 56px; opacity: .7; animation: none; }
.taskbar-hint-dismissed { animation: taskbarHintExit 160ms ease-in forwards; }
.taskbar-spiral-line { animation-duration: 380ms; animation-delay: 0ms; }
.taskbar-arrow-head { animation-duration: 160ms; animation-delay: 260ms; }

@media (max-width: 768px), (max-width: 1024px) and (pointer: coarse) {
  :root { --ui-control: 44px; }
  /* Home's percentage height needs a sized body in the mobile card stack. */
  body.windowed-layout [data-win-id="detail"] > .window-body:has(.hs-fit) {
    flex: 0 0 auto;
    height: min(75dvh, calc(var(--arrange-visual-height, 100dvh) - 152px));
  }
  .detail-section-heading > h3 { flex-basis: 100%; }
  .room-detail-notes { min-width: 0 !important; }
  .detail-panel .detail-row { grid-template-columns: 100px minmax(0, 1fr); }
  .detail-panel .detail-label { min-width: 0; }
  .context-menu-item { min-height: 44px; }
  .tasks-hub button.hub-disc-info { min-height: 44px; }
  .fb-header { flex-wrap: wrap; padding: 12px; }
  .fb-header-title { min-width: 0; }
  .fb-header-actions { max-width: 100%; flex-wrap: wrap; gap: 8px; }
  .fb-view-toggle { max-width: 100%; flex-wrap: wrap; }
  .fb-toggle-btn, .fb-add-btn { min-height: var(--ui-control); }
  .navigator-layout-actions button { min-height: 44px; min-width: 44px; }
  /* The narrow onboarding cue stays inside the Start control's taskbar area. */
  .taskbar-attention-hint {
    left: 43px;
    z-index: 10003;
    bottom: calc(35px + env(safe-area-inset-bottom, 0px));
    width: 6px;
    height: 6px;
    transform: none;
    border-radius: 50%;
    background: var(--accent);
  }
  .taskbar-attention-hint .taskbar-spiral-arrow { display: none; }
  .tree-item:has(> .nav-project-strip) {
    display: grid !important;
    grid-template-columns: 64px minmax(0, 1fr);
  }
  .tree-item:has(> .nav-project-strip) > div:first-of-type { grid-column: 2; }
  .tree-item:has(> .nav-project-strip) > div:first-of-type > div {
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  .tree-item:has(> .nav-project-strip) > div:last-child {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
  .room-grid-scroll-hint { display: block; margin: 8px 0 4px; color: var(--muted); font-size: .75rem; }
  #equipment-list-catalog > div { min-width: 0; overflow-wrap: anywhere; }
  #equipment-list-project > div > div > div:first-child { overflow-wrap: anywhere; }
  #data-sync-modal li, #sync-status { overflow-wrap: anywhere; }
  :is(#equipment-detail-content, .reference-equipment-detail-content).eq-compact {
    grid-template-columns: minmax(0, 1fr);
    padding: 8px;
    gap: 16px;
  }
  #equipment-detail-content .equipment-detail-grid { grid-template-columns: minmax(0, 1fr) !important; }
  #equipment-detail-content .equipment-detail-row { min-width: 0; }
  #equipment-detail-content .equipment-detail-value { min-width: 0; flex: 1; }
  #equipment-detail-content .equipment-detail-value:has(> input) { display: flex; align-items: center; gap: 4px; }
  #equipment-detail-content .equipment-detail-value > :is(input, .project-history-field) { flex: 1 1 0; min-width: 0; }
  #equipment-detail-content .equipment-vendor-card { min-width: 0; flex-basis: 100%; }
  #equipment-detail-content .eq-full-span { flex-wrap: wrap; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --ui-motion: 0ms; }
  .app-window,
  .app-window:is(.win-opening, .win-closing, .win-minimize-anim),
  .wm-start-menu, .wm-workspace-menu,
  .fb-modal-overlay, .fb-modal-panel,
  .project-save-dot,
  .taskbar-attention-hint, .taskbar-hint-dismissed, .taskbar-spiral-arrow,
  .taskbar-spiral-line, .taskbar-arrow-head {
    animation: none !important;
    transition: none !important;
  }
  .taskbar-spiral-line { stroke-dashoffset: 0; }
  .taskbar-arrow-head { opacity: 1; transform: none; }
  .taskbar-hint-dismissed { opacity: 0; }
}
/* Let the narrow reference picker grow its two sections without overlapping. */
@media (max-width: 720px) {
  #replace-room-modal .reference-workflow-body {
    grid-template-rows: max-content max-content;
    align-content: start;
  }

  #replace-room-list {
    min-height: 0;
    max-height: 34dvh;
    overflow: auto;
  }
}

/* Matrix modes remain fully operable in a narrow applet. The table keeps its
   independent horizontal scrolling and column resize gestures. */
@media (max-width: 768px), (max-width: 1024px) and (pointer: coarse) {
  .rm-view-toggle {
    max-width: 100%;
    flex-wrap: wrap;
    overflow: visible;
    gap: var(--s-1, 4px);
    padding: var(--s-1, 4px);
    border: 0;
    background: transparent;
  }
  .rm-view-toggle .rm-toggle-btn {
    flex: 1 1 auto;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm, 4px);
  }
}


/* The reference browsers use the same compact field composition as project details. */
/* Compact secondary Navigator actions before their toolbar can wrap. */
@container navhead (max-width:420px) {
 .nav-actions { flex-wrap:nowrap; }
 .nav-actions > .nav-view-toolbar .nav-action { width:34px; min-width:34px; padding:0; }
 .nav-view-toolbar .nav-action span,
 .nav-view-toolbar #tree-sort-toggle::after { display:none; }
}
.reference-readonly-status { margin:4px 0 8px; color:var(--muted); font-size:.75rem; line-height:1.4; }
.reference-panel-heading { display:flex; align-items:center; width:100%; padding:0; margin:0 0 8px; min-height:36px; border:0; background:transparent; color:var(--text); text-align:left; cursor:pointer; }
.reference-panel-heading:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.reference-attribute-note { margin-top:3px; color:var(--muted); font-size:.72rem; line-height:1.3; }
.reference-equipment-item { width:100%; border:0; background:transparent; color:var(--text); font:inherit; text-align:left; cursor:pointer; }
.reference-equipment-item:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.reference-room-attribute-row .detail-value { overflow-wrap:anywhere; line-height:1.4; }
.room-detail-identity, .reference-room-identity { container:room-identity / inline-size; }
.room-detail-identity-fields > .detail-row { min-width:0; }
.room-detail-notes textarea[aria-label="Room notes"] { flex:0 0 auto !important; height:84px; }
.detail-identity-panel > .detail-section-heading { flex-wrap:wrap; margin-bottom:8px !important; }
.detail-identity-panel > .detail-section-heading h3 { min-width:0; overflow-wrap:anywhere; flex:1 1 180px; }
.room-detail-overview { align-items:flex-start !important; }
.room-detail-overview .room-detail-notes { align-self:flex-start; }
/* Keep the inline model and its narrative useful without two oversized cards. */
.room-story-inline { container:room-story-inline / inline-size; }
.room-story-inline .room-story-grid-inline { grid-template-columns:minmax(0,1fr); gap:12px; }
.room-story-inline .room-story-canvas-wrap { height:clamp(200px,45cqw,280px); min-height:200px; }
.room-story-inline .room-story-narrative-panel { min-height:0; }
.room-story-inline .room-story-textarea { flex:0 0 auto; height:144px; min-height:120px; margin:10px; }
.room-story-inline .room-story-panel-head { padding:8px 10px; }
@container room-story-inline (min-width:600px) {
 .room-story-inline .room-story-grid-inline { grid-template-columns:repeat(2,minmax(0,1fr)); align-items:stretch; }
 .room-story-inline .room-story-textarea { flex:1 1 auto; }
}
@media (pointer:coarse) {
 .room-story-inline button { min-height:44px; }
 .detail-identity-panel .detail-actions button { min-height:44px; }
}
.reference-equipment-detail-panel { container:equipment-dialog / inline-size; }
.reference-equipment-detail-panel .detail-header { padding:0 0 8px; }
.reference-equipment-detail-panel .detail-header h2 { margin:0; font-size:.95rem; line-height:1.4; overflow-wrap:anywhere; }
@container room-identity (min-width:400px) {
 .room-detail-identity-fields { display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 12px; }
 .room-detail-identity-fields > .detail-row { grid-column:1 / -1; }
 .room-detail-identity-fields > .detail-row:has(input[aria-label="Room code"], input[aria-label="Room number"], input[aria-label="NSF"]),
 .reference-room-metadata > .detail-row:nth-last-child(-n+2) { grid-column:auto; }
 .room-detail-identity-fields > .detail-row:has(input[aria-label="Room code"], input[aria-label="Room number"], input[aria-label="NSF"]) .detail-label { flex-basis:84px; }
}

/* Bound each reference window and give the actual detail pane its scroll space. */
:is([data-win-id="reference-db"], [data-win-id="jsn-lookup-app"]) .window-body { display:flex; flex-direction:column; flex:1 1 0; min-height:0; height:auto; max-height:none; overflow:hidden; }
:is([data-win-id="reference-db"], [data-win-id="jsn-lookup-app"]) .dynamic-window-content { display:flex; flex:1 1 0; min-height:0; min-width:0; overflow:hidden !important; padding:0; container:reference-browser / inline-size; }
.ref-window-container, .jsn-app-container { flex:1 1 0; min-height:0; min-width:0; }
.ref-window-tree, .jsn-app-nav { min-height:0; }
.ref-window-resizer, .jsn-window-resizer { position:relative; width:8px; flex-shrink:0; touch-action:none; user-select:none; }
.ref-window-resizer::before, .jsn-window-resizer::before { content:""; position:absolute; inset:0 -8px; }
.ref-window-resizer:focus-visible, .jsn-window-resizer:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.ref-window-detail, .jsn-app-detail { min-height:0 !important; min-width:0 !important; padding:12px !important; overscroll-behavior:contain; }
.ref-window-detail { --text:var(--v10-ink); --muted:var(--v10-muted); --accent:var(--v10-ink); color:var(--v10-ink); }
.jsn-app-nav #jsn-window-list { min-height:0; }
.jsn-list-item { width:100%; border:0; background:transparent; color:var(--text); text-align:left; font:inherit; }
.jsn-list-item:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.ref-window-tree { display:flex; flex-direction:column; overflow:hidden !important; }
#ref-window-tree-view { flex:1 1 0; min-height:0; overflow:auto; overscroll-behavior:contain; }
/* TIL equipment belongs to its room, using disclosure within the same sheet. */
#ref-window-detail .equipment-list { max-height:none; overflow:visible; }
.reference-room-equipment-item { border:0; border-bottom:1px solid var(--border); background:transparent; box-shadow:none; }
.reference-room-equipment-item > summary, .reference-room-equipment-item.is-unresolved { display:grid; grid-template-columns:12px minmax(0,1fr) max-content; gap:10px; align-items:baseline; min-height:44px; padding:10px 0; box-sizing:border-box; font-size:12px; }
.reference-room-equipment-item > summary { cursor:pointer; list-style:none; }
.reference-room-equipment-item > summary::before { content:'›'; }
.reference-room-equipment-item[open] > summary::before { transform:rotate(90deg); }
.reference-room-equipment-item > summary::-webkit-details-marker { display:none; }
.reference-room-equipment-item > summary:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.reference-room-equipment-item.is-unresolved > span:first-child { grid-column:2; }
.reference-room-equipment-item b { margin-right:6px; }
.reference-room-equipment-sheet { padding:0 0 10px 22px; }
.reference-equipment-provenance { font-size:12px; color:var(--muted); }
/* Resize borders sit inside the clipped window, where they can be hit reliably. */
:is([data-win-id="reference-db"],[data-win-id="jsn-lookup-app"]) .resize-e { right:0; width:8px; }
:is([data-win-id="reference-db"],[data-win-id="jsn-lookup-app"]) .resize-w { left:0; width:8px; }
:is([data-win-id="reference-db"],[data-win-id="jsn-lookup-app"]) .resize-n { top:0; height:8px; }
:is([data-win-id="reference-db"],[data-win-id="jsn-lookup-app"]) .resize-s { bottom:0; height:8px; }
:is([data-win-id="reference-db"],[data-win-id="jsn-lookup-app"]) .resize-ne { top:0; right:0; }
:is([data-win-id="reference-db"],[data-win-id="jsn-lookup-app"]) .resize-nw { top:0; left:0; }
:is([data-win-id="reference-db"],[data-win-id="jsn-lookup-app"]) .resize-se { bottom:0; right:0; }
:is([data-win-id="reference-db"],[data-win-id="jsn-lookup-app"]) .resize-sw { bottom:0; left:0; }
@container reference-browser (max-width:640px) {
 .ref-window-container, .jsn-app-container { flex-direction:column; }
 .ref-window-tree, .jsn-app-nav { width:100% !important; min-width:0 !important; max-width:none !important; flex:0 0 38%; max-height:220px; border-bottom:1px solid var(--border); }
 .ref-window-resizer, .jsn-window-resizer { display:none; }
 .ref-window-detail, .jsn-app-detail { flex:1 1 0; }
}
@media (max-width:768px) {
 .ref-window-tree, .jsn-app-nav { width:100% !important; min-width:0 !important; max-width:none !important; }
 .ref-window-detail, .jsn-app-detail { min-height:0 !important; }
 .ref-window-resizer, .jsn-window-resizer { display:none; }
 #ref-window-search, #jsn-window-search, .jsn-list-item, #jsn-window-pagination button, .reference-panel-heading { min-height:44px; }
}
