/*
 * Shared PageHeader primitive.
 *
 * Every primary workspace owns its content, but not its title geometry.
 * The one Files exception in doc 05 applies only to focused/full view, where
 * the page heading is hidden; the routed Files page uses this same contract.
 */
.page-header {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 5.25rem;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  margin: 0 0 1.25rem;
}

.page-header-copy {
  display: grid;
  min-width: 0;
  gap: 0.28rem;
}

.page-header-kicker {
  color: var(--ui-accent);
  font: 700 0.625rem/1.2 ui-monospace, Menlo, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.page-header :is(h1, h2) {
  margin: 0;
  color: var(--ui-text);
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.page-header-copy > p {
  max-width: 52rem;
  margin: 0;
  color: var(--ui-text-soft);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.page-header-actions {
  display: flex;
  min-width: 0;
  align-self: center;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}

.apps-empty-state {
  display: grid;
  width: min(38rem, 100%);
  justify-items: center;
  gap: 0.75rem;
  margin: clamp(2rem, 8vh, 5rem) auto 0;
  padding: clamp(2rem, 5vw, 3.5rem);
  border: 1px dashed var(--ui-line-strong);
  border-radius: 0.65rem;
  background: linear-gradient(145deg, var(--ui-panel), var(--ui-panel-soft));
  box-shadow: var(--ui-shadow-sm);
  text-align: center;
}

.apps-empty-state[hidden] {
  display: none;
}

.apps-empty-icon {
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--ui-accent) 42%, var(--ui-line));
  border-radius: 50%;
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}

.apps-empty-icon .ui-icon {
  width: 1.35rem;
  height: 1.35rem;
}

.apps-empty-state h3 {
  margin: 0;
  color: var(--ui-text);
  font-size: 1.05rem;
}

.apps-empty-state p {
  max-width: 30rem;
  margin: 0;
  color: var(--ui-text-soft);
  font-size: 0.78rem;
  line-height: 1.55;
}

@media (max-width: 820px) {
  .page-header {
    min-height: 44px;
    height: 44px;
    align-items: center;
    flex-direction: row;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    overflow: hidden;
  }

  .page-header-copy {
    min-width: 0;
    max-width: 65%;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.45rem;
  }

  /* page-header.js removes these nodes at phone widths. Keep a CSS guard so
     the compact row remains truthful before the first script frame. */
  .page-header-kicker,
  .page-header-copy > p {
    display: none;
  }

  .page-header :is(h1, h2) {
    min-width: 0;
    overflow: hidden;
    font-size: 1.1rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-header-actions {
    width: auto;
    min-height: 44px;
    flex: 1 1 auto;
    align-self: center;
    justify-content: flex-end;
    gap: 0.4rem;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .page-header-actions::-webkit-scrollbar {
    display: none;
  }

  .page-header-actions > * {
    flex: 0 0 auto;
  }

  .page-header-actions :is(button, .button, a) {
    min-height: 44px;
    box-sizing: border-box;
  }

  .page-header-actions :is(.section-meta, #routines-meta),
  .files-index-health {
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--ui-line);
    border-radius: 999px;
    background: var(--ui-panel-soft);
    color: var(--ui-text-soft);
    font: 650 0.67rem/1 system-ui, sans-serif;
  }

  .approvals-count-box {
    min-width: 0;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    text-align: left;
  }

  .approvals-count-box strong,
  .approvals-count-box span {
    font-size: 0.68rem;
    line-height: 1;
  }
}

@media (max-width: 480px) {
  .page-header-actions {
    flex-wrap: nowrap;
  }
}
