/* Application frame and page contract (docs/plans/screen-concept.html).
   Top bar: project, breadcrumb path, search field, edit history, files, settings, user.
   Page: one heading with the actions on the right, tabs below it, then one panel whose
   toolbar holds filters on the left and the search on the right. Loaded last. */

/* Top bar */
html:root #app .topbar {
  height: 52px;
  min-height: 52px;
  padding: 0 12px 0 24px;
  gap: 16px;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
}

/* Project name and path on the first line, the save state quietly below. */
html:root .topbar .project-heading {
  display: grid;
  flex: 1 1 0;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 2px;
  min-width: 0;
}

html:root .topbar .project-heading #project-name {
  grid-area: 1 / 1;
}

html:root .topbar .project-heading .eyebrow {
  grid-area: 1 / 2;
}

html:root .topbar .project-heading #save-status {
  grid-area: 2 / 1 / 3 / 3;
}

html:root .topbar.crumbs-global .project-heading .eyebrow,
html:root #app.settings-mode .topbar .project-heading .eyebrow {
  grid-area: 1 / 1 / 2 / 3;
  padding-left: 6px;
}

html:root .topbar #project-name {
  width: auto;
  min-width: 60px;
  max-width: 220px;
  field-sizing: content;
  height: 26px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--scs-radius-s);
  background: transparent;
  color: var(--scs-ink);
  font-size: var(--scs-text-m);
  font-weight: 600;
  text-overflow: ellipsis;
}

html:root .topbar #project-name:hover:not(:disabled),
html:root .topbar #project-name:focus {
  border-color: var(--scs-line);
  background: var(--scs-surface);
}

html:root .topbar .eyebrow.is-crumbs {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--scs-ink-3);
  font-size: var(--scs-text-m);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

/* Parent steps give way first; the current page keeps a readable part, separators and the ID stay whole. */
html:root .topbar .eyebrow.is-crumbs > * {
  flex: 0 1 auto;
  min-width: 2.5em;
  overflow: hidden;
  text-overflow: ellipsis;
}

html:root .topbar .eyebrow.is-crumbs > :is(.crumb-sep, .id-chip) {
  flex-shrink: 0;
  min-width: 0;
}

html:root .topbar .eyebrow.is-crumbs .crumb-current {
  flex-shrink: 0.2;
  min-width: 8em;
  color: var(--scs-ink);
  font-weight: 600;
}

/* Outside a project (start page) the path starts without the project name. */
html:root .topbar.crumbs-global #project-name,
html:root #app.settings-mode .topbar #project-name {
  display: none;
}

html:root .topbar #save-status {
  margin: 0;
  padding-left: 7px;
  overflow: hidden;
  color: var(--scs-ink-3);
  font-size: var(--scs-text-xs);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html:root .topbar #save-status.error {
  color: var(--scs-danger);
}

html:root #top-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  min-width: 0;
}

/* The search looks like the field it opens. */
html:root .topbar .search-field {
  justify-content: flex-start;
  gap: 8px;
  width: 220px;
  height: 32px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--scs-line);
  background: var(--scs-surface-2);
  color: var(--scs-ink-3);
  font-weight: 400;
  box-shadow: none;
}

html:root .topbar .search-field:hover {
  border-color: var(--scs-line-strong);
  background: var(--scs-surface);
}

.topbar .search-field span {
  flex: 1;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .search-field kbd {
  padding: 1px 5px;
  border: 1px solid var(--scs-line);
  border-radius: var(--scs-radius-s);
  background: var(--scs-surface);
  color: var(--scs-ink-3);
  font-family: inherit;
  font-size: var(--scs-text-xs);
  white-space: nowrap;
}

/* Folding the top bar gives tables and diagrams the full height. */
html:root .topbar-fold {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--scs-ink-3);
  box-shadow: none;
}

html:root .topbar-fold:hover {
  border-color: var(--scs-line);
  color: var(--scs-ink);
}

.topbar-fold svg,
.topbar-unfold svg {
  width: 16px;
  height: 16px;
}

html:root .workspace {
  position: relative;
}

html:root .topbar-unfold {
  display: none;
}

html:root #app.topbar-collapsed .topbar {
  display: none;
}

html:root #app.topbar-collapsed .topbar-unfold {
  position: absolute;
  top: 0;
  right: 24px;
  z-index: 30;
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 0;
  height: 18px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--scs-line);
  border-top: 0;
  border-radius: 0 0 var(--scs-radius-m) var(--scs-radius-m);
  background: var(--scs-surface);
  color: var(--scs-ink-3);
  box-shadow: var(--scs-shadow-1);
}

html:root #app.topbar-collapsed .topbar-unfold:hover {
  color: var(--scs-accent);
}

/* Page heading: title and description left, page actions right. */
html:root .content-heading > div:first-child {
  display: block;
}

html:root .content-heading > div:first-child:has(> #view-title-id) {
  display: grid;
  grid-template-columns: minmax(0, max-content) auto;
  justify-content: start;
  align-items: center;
  column-gap: 10px;
}

html:root .content-heading > div:first-child:has(> #view-title-id) > #view-description {
  grid-column: 1 / -1;
}

html:root #view-title-id {
  justify-self: start;
}

html:root #heading-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

html:root .content-heading,
html:root #app.project-dashboard-mode .content-heading {
  padding: 20px 28px 14px;
}

html:root #heading-actions .page-action {
  margin: 0;
}

/* Every heading action has the same size, whichever page rendered it. */
html:root #heading-actions > button,
html:root #heading-actions > details > summary {
  min-height: var(--scs-control-h);
  padding: 0 14px;
  border-radius: var(--scs-radius-s);
  font-size: var(--scs-text-m);
  line-height: 1.2;
}

html:root #heading-actions > details > summary {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--scs-line-strong);
  background: var(--scs-surface);
  color: var(--scs-ink);
  font-weight: 400;
}

html:root #heading-actions > details > summary::after {
  margin-left: 6px;
  content: '▾';
}

html:root #heading-actions > .dashboard-project-tools {
  margin: 0;
  padding: 0;
  border: 0;
}

/* Diagram editor: title, description and actions share one compact row, so the
   table, the preview and the Pro editor keep the height. */
html:root #app[data-view='chain'] .content-heading {
  align-items: center;
  min-height: 0;
  padding: 8px 22px 8px 28px;
}

html:root #app[data-view='chain'] .content-heading > div:first-child:has(> #view-title-id) {
  grid-template-columns: minmax(0, max-content) auto minmax(0, 1fr);
}

html:root #app[data-view='chain'] #view-title {
  overflow: hidden;
  margin: 0;
  padding-right: 0;
  font-size: var(--scs-text-xl);
  line-height: 28px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

html:root #app[data-view='chain'] #view-description.is-cramped {
  visibility: hidden;
}

/* Room for the rename pencil, which sits at the end of the title. */
html:root #app[data-view='chain'] #view-title.diagram-title-target {
  padding-right: 34px;
}

html:root #app[data-view='chain'] .content-heading > div:first-child:has(> #view-title-id) > #view-description {
  grid-column: auto;
  overflow: hidden;
  margin: 0;
  color: var(--scs-ink-3);
  white-space: nowrap;
  text-overflow: ellipsis;
}

html:root #app[data-view='chain'] #heading-actions {
  flex-wrap: nowrap;
  gap: 6px;
}

html:root #app[data-view='chain'] #heading-actions > button,
html:root #app[data-view='chain'] #heading-actions > details > summary {
  min-height: var(--scs-control-h-s);
  padding: 0 10px;
  white-space: nowrap;
}

/* Diagram preview: one heading row with zoom, export and view actions in both
   layouts; the viewer's own toolbar stays hidden. A narrow pane drops the label
   first, then wraps the actions into a second row. */
html:root #app[data-view='chain'] .preview-pane {
  container-type: inline-size;
}

html:root #app[data-view='chain'] .preview-heading {
  flex-wrap: wrap;
  height: auto;
  min-height: 40px;
  overflow: visible;
  gap: 6px 10px;
}

html:root #app[data-view='chain'] .preview-actions {
  margin-left: auto;
}

@container (max-width: 860px) {
  html:root #app[data-view='chain'] .preview-title strong {
    display: none;
  }
}

@container (max-width: 730px) {
  html:root #app[data-view='chain'] .preview-layout-mode {
    overflow: hidden;
    max-width: 96px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

/* With the top bar folded, its tab sits at the end of the diagram heading row. */
html:root #app.topbar-collapsed[data-view='chain'] .content-heading {
  padding-right: 62px;
}

html:root #app.topbar-collapsed[data-view='chain'] .topbar-unfold {
  top: 8px;
  right: 22px;
  width: 32px;
  height: var(--scs-control-h-s);
  border-top: 1px solid var(--scs-line);
  border-radius: var(--scs-radius-s);
  box-shadow: none;
}

/* Toolbar of the page panel: filters left, search right. */
html:root .table-toolbar {
  align-items: center;
}

html:root .table-toolbar > .table-tools {
  margin-left: auto;
}

/* Catalog pages: selection actions and filters wrap on the left, the search stays top right. */
html:root
  #app:is(
    [data-view='systems'],
    [data-view='interfaces'],
    [data-view='domains'],
    [data-view='terminology'],
    [data-view='icons'],
    [data-view='functions'],
    [data-view='templates'],
    [data-view='project-notes'],
    [data-view='diagrams']
  )
  .table-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px 16px;
}

html:root #app.catalog-mode .table-toolbar > #table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

html:root #app.catalog-mode .table-toolbar > .table-tools {
  min-height: var(--scs-control-h);
}

html:root #app.catalog-mode .table-toolbar :is(.catalog-filter, .section-project-filter, .sort-control) {
  padding: 0 4px;
  color: var(--scs-ink-3);
  font-size: var(--scs-text-s);
}

html:root #app.catalog-mode .table-toolbar :is(.catalog-filter, .section-project-filter, .sort-control) select {
  max-width: 190px;
}

html:root #app.catalog-mode .table-toolbar #search {
  width: 13rem;
}

/* Pickers on model pages look like the filters of every other page: a quiet label and a plain field. */
html:root .chip-select select {
  min-height: var(--scs-control-h);
  height: var(--scs-control-h);
  padding: 0 28px 0 10px;
  border: 1px solid var(--scs-line-strong);
  border-radius: var(--scs-radius-s);
  background-color: var(--scs-surface);
  font-weight: 400;
}

html:root .chip-toggle,
html:root .chip-toggle:has(input:checked) {
  min-height: var(--scs-control-h);
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--scs-ink-2);
  font-weight: 400;
}

/* Counts, quiet filters and the hints of a catalog sit in one line above its entries. */
html:root .catalog-summary {
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  color: var(--scs-ink-3);
  font-size: var(--scs-text-m);
}

html:root .catalog-summary > span:first-child strong {
  color: var(--scs-ink);
  font-weight: 600;
}

html:root .catalog-summary > .catalog-filter {
  margin-right: auto;
  padding: 0;
}

html:root .catalog-help summary {
  color: var(--scs-accent);
  font-size: var(--scs-text-m);
}

html:root .catalog-help[open] {
  flex-basis: 100%;
  order: 9;
  max-width: none;
}

html:root .catalog-help[open] summary {
  text-align: left;
}

html:root .catalog-help p {
  max-width: 78ch;
  color: var(--scs-ink-2);
}

/* Project overview: its areas are tabs like on object pages. */
html:root .project-dashboard-toolbar {
  padding-bottom: 0;
  border-bottom: 1px solid var(--scs-line);
}

html:root .project-dashboard-toolbar .dashboard-tabs {
  display: flex;
  gap: 20px;
  align-self: flex-end;
}

html:root .project-dashboard-toolbar .dashboard-tabs button {
  min-height: 40px;
  padding: 0 0 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--scs-ink-2);
  font-size: var(--scs-text-m);
  font-weight: 400;
  box-shadow: none;
}

html:root .project-dashboard-toolbar .dashboard-tabs button:hover {
  color: var(--scs-ink);
}

html:root .project-dashboard-toolbar .dashboard-tabs button.primary {
  border-bottom-color: var(--scs-accent);
  background: transparent;
  color: var(--scs-ink);
  font-weight: 600;
}

/* Every tab of the project overview uses the full width with the same inset. */
html:root
  #app.project-dashboard-mode
  #editor-content
  > :is(.project-overview, .method-guide, .home-content, .model-mapping, .diagram-relations) {
  max-width: none;
  margin: 0;
  padding: 16px 24px 24px;
}

/* Tab panels of the project overview start with their purpose, not a second title. */
html:root :is(.method-heading, .mapping-heading, .sketch-list-heading) h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

html:root :is(.method-heading, .mapping-heading, .sketch-list-heading) p {
  margin: 0;
  color: var(--scs-ink-2);
  font-size: var(--scs-text-m);
}

/* The two icon areas are tabs, like the areas of the project overview. */
html:root .icon-library-areas {
  gap: 20px;
  margin: 0 18px;
  padding: 0;
  border-bottom: 1px solid var(--scs-line);
}

html:root .icon-library-areas button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 40px;
  padding: 0 0 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--scs-ink-2);
  font-size: var(--scs-text-m);
  font-weight: 400;
  box-shadow: none;
}

html:root .icon-library-areas button:hover {
  color: var(--scs-ink);
}

html:root .icon-library-areas button.primary {
  border-bottom-color: var(--scs-accent);
  background: transparent;
  color: var(--scs-ink);
  font-weight: 600;
}

html:root .icon-library-areas button strong {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--scs-surface-3);
  color: var(--scs-ink-2);
  font-size: var(--scs-text-xs);
  font-weight: 600;
  line-height: 18px;
}

html:root .icon-usage-description {
  margin: 12px 0 0;
  color: var(--scs-ink-3);
  font-size: var(--scs-text-m);
}

html:root .icon-category-toolbar label {
  color: var(--scs-ink-3);
  font-size: var(--scs-text-s);
}

html:root .icon-category-toolbar select {
  min-height: var(--scs-control-h);
  font-size: var(--scs-text-m);
}

/* Empty states: one quiet, centred block wherever a list has nothing to show. */
html:root :is(.empty-table, .req-empty) {
  max-width: none;
  margin: 0;
  padding: 56px 24px;
  color: var(--scs-ink-3);
  text-align: center;
}

html:root :is(.empty-table, .req-empty) :is(h2, h3) {
  margin: 0 0 6px;
  color: var(--scs-ink);
  font-size: var(--scs-text-l);
  font-weight: 600;
}

html:root :is(.empty-table, .req-empty) p {
  max-width: 62ch;
  margin: 0 auto;
  font-size: var(--scs-text-m);
  line-height: 1.6;
}

/* 6.5.1: the unified empty state (symbol, one sentence, the next step) uses a smaller symbol than
   the diagram preview, and the error notice keeps a close button at its end. */
html:root .empty-unified .empty-symbol {
  font-size: 30px;
  line-height: 1;
  margin-bottom: 10px;
  color: var(--scs-ink-disabled);
}
html:root .empty-unified > button {
  margin-top: 14px;
}
/* 6.9 audit: the action of an empty state sets icon and label like every other button. */
html:root :is(.empty-table, .req-empty) button.has-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
html:root .quality-also {
  margin: 2px 0 5px;
  font-size: 12px;
  color: var(--scs-ink-3);
}
html:root .history-row.history-mark {
  background: var(--scs-warn-soft);
}

/* The next step of an empty list (4.9.0): its buttons in one row under the text. The inner row
   carries .empty-table too (icons), but none of the block's own padding. */
html:root :is(.empty-table, .req-empty) .empty-actions,
html:root .empty-table:is(.empty-actions, .empty-inline) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 0;
  margin-top: 14px;
}
html:root .empty-table.empty-inline {
  margin: 0;
}
html:root :is(.empty-actions, .empty-inline) button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 0;
}

html:root :is(.domain-cards > p.muted:only-child, .terminology-catalog > p.muted[role='status']) {
  grid-column: 1 / -1;
  margin: 0;
  padding: 56px 24px;
  color: var(--scs-ink-3);
  font-size: var(--scs-text-m);
  text-align: center;
}

/* Numbers and IDs line up in columns. */
html:root :is(table, .id-chip, [data-menu-count], .object-count) {
  font-variant-numeric: tabular-nums;
}

/* The user menu shows only its symbol until there is room for the name. */
@media (max-width: 1599px) {
  html:root #user-menu span {
    display: none;
  }

  html:root .topbar #project-name {
    max-width: 170px;
  }

  html:root .topbar .search-field {
    width: 190px;
  }

  html:root .topbar .search-field kbd {
    display: none;
  }
}

/* With less room the search takes the first line and the filters use the full width below it. */
@media (max-width: 1180px) {
  html:root #app.catalog-mode .table-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  html:root #app.catalog-mode .table-toolbar > .table-tools {
    order: -1;
    justify-self: end;
  }
}

@media (max-width: 1050px) {
  html:root .topbar .search-field {
    width: 160px;
  }

  html:root #app[data-view='chain'] .content-heading > div:first-child > #view-description {
    display: none;
  }

  html:root #app[data-view='chain'] #heading-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  html:root #app .topbar {
    padding: 0 8px 0 12px;
    gap: 8px;
  }

  html:root .topbar .search-field {
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  html:root .topbar .search-field span {
    display: none;
  }
}

/* Links over navigation entries (page_history.js, 4.13.1): the browser treats the entry as a link
   (context menu, middle click, address at the bottom); the entry keeps its look and own click. */
.page-link-host {
  position: relative;
}
.page-link {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: transparent;
  color: transparent;
  text-decoration: none;
  -webkit-user-drag: none;
}
.page-link:focus {
  outline: none;
}
.page-link-above {
  position: relative;
  z-index: 1;
}

/* 6.0: below 1200 px the toolbar gives up its labels before the breadcrumb
   disappears; search, Versionen and Dateien stay reachable as icons with tooltip. */
@media (max-width: 1200px) {
  html:root .topbar .project-heading {
    min-width: 160px;
  }
  html:root #command-palette-open > :is(span, kbd),
  html:root #export > span {
    display: none;
  }
  html:root #command-palette-open {
    width: auto;
    min-width: 0;
  }
  html:root body #top-actions #history {
    gap: 0;
    font-size: 0;
  }
  html:root .topbar .project-heading {
    min-width: 230px;
  }
  html:root .topbar #project-name:not(:focus) {
    max-width: 110px;
    text-overflow: ellipsis;
  }
}

/* 6.9 audit: dashboard tabs carry a symbol each; same icon gap as all buttons. */
html:root .dashboard-tabs button.has-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 6.12: one inner inset for every page below the toolbar. Lists, catalogs, matrices and
   overviews used 0 to 24 px, so tables of Änderungen, Anforderungen or Schnittstellen touched
   the card edge while Domänen sat 24 px inside. The full-width grid of the system catalog and
   the dashboard tabs keep their own frame. */
html:root
  #app:not(.project-dashboard-mode, .settings-mode)
  #editor-content
  > :is(
    .model-list,
    .function-catalog,
    .domain-catalog,
    .variant-page,
    .trace-matrix-page,
    .quality-content,
    .notes-content,
    .compact-catalog,
    .template-catalog
  ) {
  padding: var(--scs-space-4) 20px 20px;
}

@media (max-width: 750px) {
  html:root
    #app:not(.project-dashboard-mode, .settings-mode)
    #editor-content
    > :is(
      .model-list,
      .function-catalog,
      .domain-catalog,
      .variant-page,
      .trace-matrix-page,
      .quality-content,
      .notes-content,
      .compact-catalog,
      .template-catalog
    ) {
    padding: var(--scs-space-3);
  }
}

/* The count under a list lines up with the first table column inside the inset. */
html:root #editor-content > .model-list > .model-list-footer {
  padding: 10px 12px 0;
}
