/* Shared components. Home and Work use these exact rules. */
@layer components {
  .module-shortcut-dots { display: inline-flex; align-items: center; justify-content: center; gap: .125rem; width: 1rem; flex: 0 0 1rem; }
  .module-shortcut-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .module-shortcut[data-unavailable=true] { color: var(--muted); }
  /* Inline setup/review uses the same detail surface as expanded records. */
  .inline-editor { padding: .75rem; margin-bottom: 1rem; background: var(--detail-surface); min-width: 0; }
  .inline-editor > :first-child,.inline-editor form > :first-child { margin-top: 0; }
  /* One filter component for Tasks/Jobs: labels hug their controls. */
  .filter-bar { display: flex; align-items: center; gap: .5rem .75rem; min-width: 0; width: 100%; }
  .filter-panel { display: flex; align-items: center; gap: .75rem; min-width: 0; }
  .filter-panel label { display: flex; align-items: center; gap: .375rem; color: var(--muted); font-size: var(--text-label); white-space: nowrap; min-width: 0; }
  .filter-bar select,.filter-bar input { min-width: 0; max-width: 100%; min-height: 1.875rem; font-size: var(--text-label); padding: .125rem .5rem; }
  .filter-panel select { width: 7.5rem; }
  .filter-panel select[id$="worker"] { width: 11rem; }
  .filter-bar input[type=search] { width: 10rem; flex: 0 1 10rem; }
  .filter-bar .filter-toggle { display: none; }
  .filter-reset,.filter-action { flex-shrink: 0; }
  @container (max-width: 64rem) {
    .filter-bar { display: grid; grid-template-columns: minmax(0,10rem) max-content max-content; align-items: center; }
    .filter-bar input[type=search] { grid-row: 1; grid-column: 1; width: 100%; }
    .filter-bar .filter-toggle { display: block; grid-row: 1; grid-column: 2; }
    .filter-action { grid-row: 1; grid-column: 3; }
    .filter-panel { display: none; grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(auto-fit,minmax(min(100%,9rem),1fr)); gap: .5rem .75rem; align-items: end; }
    .filter-bar[data-expanded=true] .filter-panel { display: grid; }
    .filter-panel label { flex-direction: column; align-items: stretch; gap: .25rem; }
    .filter-panel select,.filter-panel select[id$="worker"] { width: 100%; }
    .filter-panel .filter-reset { justify-self: start; }
  }
  .theme-picker { display: flex; flex: 0 0 auto; align-items: center; gap: .125rem; margin-left: auto; }
  .theme-picker + .view-menu { margin-left: 0; }
  .theme-swatch { display: grid; place-items: center; width: .9375rem; height: .9375rem; min-height: 0; padding: 0; border: 1px solid transparent; border-radius: 0; background: transparent; cursor: pointer; }
  .theme-swatch::before { content: ''; width: .5rem; height: .5rem; background: var(--theme-chip); border: 1px solid var(--theme-chip-border, transparent); }
  .theme-swatch[aria-pressed="true"] { border-color: var(--muted); }
  .theme-swatch:hover { border-color: var(--text); }
  .theme-swatch:focus-visible { outline: 1px solid var(--cyan); outline-offset: 1px; }
  .record-heading {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 0;
    padding: var(--header-padding);
    color: var(--cyan);
    background: var(--surface);
    font: 500 var(--text-section)/1.5 var(--font-mono);
    text-transform: uppercase;
    letter-spacing: .04em;
  }
  .record-heading .tiny { font: 400 var(--text-label)/1.5 var(--font-body); text-transform: none; letter-spacing: 0; }
  .record-heading-label { flex: 0 0 6ch; }
  .recent-group-title { margin-top: var(--work-group-gap); padding: 0; }
  #section-activity-title > .recent-group-title:first-child { margin-top: 0; }
  .record-heading .section-toggle { display: block; width: 100%; padding: var(--header-padding); }
  .record-heading .section-toggle:hover { background: var(--surface-raised); text-decoration: none; }
  .record-list { container-type: inline-size; min-width: 0; width: 100%; overflow: auto; border: 0; border-radius: 0; background: transparent; }
  .record-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; text-align: left; font-size: var(--text-body); }
  .record-table th { background: transparent; color: var(--muted); font: 400 var(--text-label)/1.5 var(--font-mono); text-transform: uppercase; padding: var(--row-padding); border: 0; border-bottom: 1px solid var(--border); }
  .record-table td { height: auto; padding: var(--row-padding); border: 0; border-bottom: 1px solid var(--border); white-space: normal; overflow-wrap: anywhere; vertical-align: middle; }
  .record-table tbody > tr:not(.record-expansion) { cursor: pointer; }
  .record-table tbody > tr:not(.record-expansion):hover,
  .record-table tbody > tr:not(.record-expansion):has(:focus-visible) { background: var(--surface); }
  .record-table tbody > tr:hover .record-link { color: var(--cyan); }
  .record-table .record-link { display: block; width: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--text); font: 500 var(--text-body)/1.6 var(--font-body); text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .record-id { display: block; color: var(--muted); font: .625rem/1.5 var(--font-mono); }
  .record-table .status { max-width: 100%; }
  .record-table td:nth-child(2) { color: var(--muted); }
  .home-tasks th:first-child,.home-jobs th:first-child { width: 34%; }
  .home-tasks th:nth-child(2),.home-jobs th:nth-child(2) { width: 18%; }
  .home-tasks th:nth-child(3),.home-jobs th:nth-child(3) { width: 30%; }
  .home-tasks th:nth-child(4),.home-jobs th:nth-child(4) { width: 18%; }
  .record-expansion > td { padding: .75rem .625rem 1rem; }
  .record-details { min-width: 0; max-width: var(--detail-width); }
  .record-meta { margin-bottom: .5rem; }
  .record-stage { margin: .5rem 0 .75rem; font-size: var(--text-body); }
  .detail-page-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-bottom: 1rem; }
  .detail-page-heading h1 { font: 600 1.25rem/1.3 var(--font-body); margin: 0; overflow-wrap: anywhere; }
  .detail-page-body { width: 100%; max-width: var(--detail-width); min-width: 0; }
  .detail-page-body > p { margin: .75rem 0; }
  .detail-list { display: grid; grid-template-columns: 7rem minmax(0,1fr); gap: .375rem .5rem; margin: .75rem 0; font-size: var(--text-body); }
  .detail-list dt { color: var(--muted); }
  .detail-list dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
  .detail-section { margin-top: .75rem; border-top: 1px solid var(--border); padding-top: .5rem; }
  .detail-section > summary { list-style: none; cursor: pointer; color: var(--green); text-transform: uppercase; font: 400 var(--text-label)/1.5 var(--font-mono); }
  .detail-section > summary::-webkit-details-marker { display: none; }
  .detail-section > summary::after { content: ' +'; }
  .detail-section[open] > summary::after { content: ' −'; }
  .detail-section > div { padding-top: .5rem; font-size: var(--text-body); }
  /* Expandable items are subordinate to section headings, not headings themselves. */
  .disclosure-list { margin-inline-start: .75rem; padding-inline-start: .75rem; border-inline-start: 1px solid var(--border); min-width: 0; }
  .disclosure-row { margin-top: 0; padding-top: 0; border-top: 0; border-bottom: 1px solid var(--border); }
  .disclosure-row > summary { padding: .625rem; color: var(--text); text-transform: none; font: 500 var(--text-body)/1.5 var(--font-body); overflow-wrap: anywhere; }
  .disclosure-row > summary:hover,.disclosure-row > summary:focus-visible { background: var(--surface); }
  .disclosure-row > summary:focus-visible { outline: 1px solid var(--cyan); outline-offset: -1px; }
  .disclosure-row[open] > summary { background: var(--surface); }
  .disclosure-row > div { padding: .5rem .625rem .75rem; background: var(--detail-surface); }
  .detail-section p { white-space: pre-wrap; overflow-wrap: anywhere; }
  .detail-section p + p { margin-top: .375rem; }
  .detail-section pre { margin: 0; color: var(--muted); font: .625rem/1.6 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
  .field { display: flex; flex-direction: column; gap: .25rem; width: 100%; max-width: var(--field-width); margin: .5rem 0; color: var(--muted); font-size: var(--text-label); }
  .field-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
  .field-row > .field { flex: 0 1 12rem; }
  .field input,.field select { min-width: 0; width: 100%; max-width: 100%; font-size: var(--text-body); }
  .field input:disabled { color: var(--muted); cursor: not-allowed; }
  .record-details textarea { display: block; width: 100%; min-height: 3rem; max-height: none; resize: none; overflow: hidden; color: var(--text); background: transparent; border: 0; border-radius: 0; padding: .25rem 0; font: 400 var(--text-body)/1.6 var(--font-body); }
  .detail-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .75rem; padding-top: .375rem; border-top: 1px solid var(--border); }
  .detail-actions .orange { color: var(--orange); }
  @container (max-width: 42rem) {
    .record-table,.record-table tbody { display: block; }
    .record-table thead,.record-table colgroup { display: none; }
    .record-table tbody > tr { display: grid; grid-template-columns: minmax(0,1fr); gap: .25rem; padding: .625rem; border-bottom: 1px solid var(--border); }
    .record-table td { display: block; width: auto; padding: 0; border: 0; min-width: 0; }
    .record-table td[data-label]::before { content: attr(data-label) ' · '; color: var(--muted); }
    .record-table .record-expansion { padding: .75rem .625rem; }
    .detail-list { grid-template-columns: minmax(0,1fr); gap: .125rem; }
    .detail-list dd { margin-bottom: .375rem; }
  }
}

/* Semantic states are shared across Home and Work, for both record types. */
@layer states {
  .module-card[data-expanded=false] .module-summary { min-height: 0; }
  .module-card[data-expanded=false] .module-summary-top { min-height: var(--card-summary-height-collapsed); }
  .record-table tbody > tr[data-expanded=true] { background: var(--surface); }
  .record-table tbody > tr[data-expanded=true] .record-link { color: var(--cyan); }
  .record-table .record-expansion { background: var(--detail-surface); }
}

/* Shared compact toolbars and settings groups, usable in any detail page. */
@layer components {
  .page-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 0 0 .75rem; min-width: 0; }
  .page-toolbar .workspace-title { margin: 0; }
  .page-toolbar > .field { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; width: auto; margin: 0; }
  .page-toolbar > .field select { width: auto; max-width: 100%; }
  .page-toolbar > input { width: 12rem; max-width: 100%; }
  .settings-fields { display: flex; flex-wrap: wrap; gap: .5rem 1rem; border: 0; padding: 0; margin: .75rem 0; }
  .settings-fields legend { padding: 0; margin-bottom: .375rem; }
  .check-field { display: inline-flex; align-items: center; gap: .375rem; font-size: var(--text-body); cursor: pointer; }
  .check-field input { accent-color: var(--green); }
  .record-table td.green { color: var(--green); }
  .record-table td.orange { color: var(--orange); }
}

@layer components { .process-log { max-height: 18rem; overflow: auto; } }

@layer components {
  .operation-feedback { margin-block: 1rem; padding: 1rem; background: var(--detail-surface); border-left: 2px solid var(--cyan); min-width: 0; }
  .operation-feedback h4 { margin: 0 0 .5rem; }
  .operation-feedback p { overflow-wrap: anywhere; }
  .operation-feedback .process-log { white-space: pre-wrap; overflow-wrap: anywhere; }
}

@layer components {
  .log-output { max-height:60vh; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; }
}

@layer components {
  .module-editor { display: block; width: 100%; height: 78vh; min-height: 36rem; border: 1px solid var(--border); background: var(--bg); }
  .module-operation-output { max-height: 14rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
  .module-operation-output:empty { display: none; }
}
