@layer stitch-notifications-inbox {
  #main[data-page="notifications"] {
    max-width: 100%;
    overflow-x: clip;
  }
  #main[data-page="notifications"]:has(> .stitch-notifications-inbox) {
    background: #f5f6fc;
    min-height: 100dvh;
  }
  html[data-theme="dark"] #main[data-page="notifications"]:has(> .stitch-notifications-inbox) {
    background: #0b0e1d;
  }

  #main[data-page="notifications"] > .notification-inbox.stitch-notifications-inbox {
    --stitch-inbox-bg: #f5f6fc;
    --stitch-inbox-paper: #fff;
    --stitch-inbox-soft: #eef0fa;
    --stitch-inbox-border: #d5d9ee;
    --stitch-inbox-text: #0f1326;
    --stitch-inbox-muted: #475073;
    --stitch-inbox-accent: #6d28d9;
    box-sizing: border-box;
    width: min(calc(100% - 24px), 48rem) !important;
    max-width: 48rem !important;
    margin-inline: auto !important;
    padding: 12px 0 88px !important;
    color: var(--stitch-inbox-text) !important;
    font-family: "Commissioner", system-ui, sans-serif !important;
  }

  html[data-theme="dark"] #main[data-page="notifications"] > .notification-inbox.stitch-notifications-inbox {
    --stitch-inbox-bg: #0b0e1d;
    --stitch-inbox-paper: #0f1326;
    --stitch-inbox-soft: #141a33;
    --stitch-inbox-border: #2b345e;
    --stitch-inbox-text: #f1f5f9;
    --stitch-inbox-muted: #a5b0d6;
    --stitch-inbox-accent: #c4b5fd;
  }

  #main[data-page="notifications"] .stitch-notifications-inbox > .section-head {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto 44px !important;
    align-items: center !important;
    gap: 8px 12px !important;
    margin: 0 !important;
    padding: 8px 0 14px !important;
    border-bottom: 1px solid var(--stitch-inbox-border) !important;
  }
  .stitch-notifications-inbox > .section-head > :is(.stitch-notifications-back, .stitch-notifications-title, .stitch-notifications-preferences, .np046-inbox-menu) {
    grid-row: 1 !important;
  }
  .stitch-notifications-inbox > .section-head > .stitch-notifications-back { grid-column: 1 !important; }
  .stitch-notifications-inbox > .section-head > .stitch-notifications-title { grid-column: 2 !important; }
  .stitch-notifications-inbox > .section-head > .stitch-notifications-preferences { grid-column: 3 !important; }
  .stitch-notifications-inbox > .section-head > .np046-inbox-menu { grid-column: 4 !important; }

  .stitch-notifications-title { min-width: 0; }
  .stitch-notifications-title h1 {
    margin: 0 !important;
    color: var(--stitch-inbox-text) !important;
    font: 600 22px/28px "Crimson Pro", Georgia, serif !important;
  }

  .stitch-notifications-scope > span,
  .stitch-notifications-inbox :is(time, [data-inbox-status], .notification-clear-scope) {
    color: var(--stitch-inbox-muted) !important;
    font: 400 12px/16px "Spline Sans Mono", ui-monospace, monospace !important;
  }

  .stitch-notifications-back,
  .stitch-notifications-preferences {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 44px !important;
    padding: 7px 12px !important;
    border: 1px solid var(--stitch-inbox-border) !important;
    border-radius: 999px !important;
    background: var(--stitch-inbox-soft) !important;
    color: var(--stitch-inbox-text) !important;
    font: 600 12px/16px "Commissioner", system-ui, sans-serif !important;
    text-decoration: none !important;
    white-space: nowrap;
  }

  .stitch-notifications-back::before { content: "←"; margin-right: 6px; }
  .stitch-notifications-preferences { color: var(--stitch-inbox-accent) !important; }

  .stitch-notifications-scope {
    margin: 8px 0 0;
  }

  .stitch-notifications-read-bar,
  .stitch-notifications-inbox > .notification-inbox-toolbar,
  .stitch-notifications-filter,
  .stitch-notifications-inbox .notification-inbox-tabs {
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    min-width: 0;
  }

  .stitch-notifications-inbox > .notification-inbox-toolbar {
    justify-content: flex-end;
    margin-bottom: 8px;
  }

  .stitch-notifications-read-bar {
    justify-content: space-between;
    margin: 10px 0 4px;
  }

  .stitch-notifications-filter {
    width: max-content;
    max-width: 100%;
    margin: 0 !important;
    padding: 4px;
    border: 1px solid var(--stitch-inbox-border);
    border-radius: 999px;
    background: var(--stitch-inbox-soft);
  }

  .stitch-notifications-filter button,
  .stitch-notifications-inbox :is([data-inbox-tab], [data-inbox-action], [data-inbox-read]) {
    box-sizing: border-box;
    min-height: 40px !important;
    padding: 7px 12px !important;
    border: 1px solid var(--stitch-inbox-border) !important;
    border-radius: 999px !important;
    background: var(--stitch-inbox-paper) !important;
    color: var(--stitch-inbox-text) !important;
    font: 600 12px/16px "Commissioner", system-ui, sans-serif !important;
    white-space: nowrap;
  }

  .stitch-notifications-filter button[aria-pressed="true"] {
    border-color: transparent !important;
    background: linear-gradient(90deg, #5b21b6, #7c3aed) !important;
    color: #fff !important;
  }

  .stitch-notifications-inbox .notification-inbox-tabs {
    max-width: 100%;
    margin: 8px 0 12px !important;
    padding: 0 0 8px !important;
    overflow-x: auto;
    border-bottom: 1px solid var(--stitch-inbox-border) !important;
    scrollbar-width: thin;
  }

  .stitch-notifications-categories { margin-bottom: 8px; }
  .stitch-notifications-categories > summary {
    width: fit-content;
    max-width: 100%;
    min-height: 36px;
    padding: 7px 4px;
    color: var(--stitch-inbox-muted);
    font-size: 13px;
    cursor: pointer;
  }
  .stitch-notifications-categories:not([open]) > .notification-inbox-tabs {
    display: none !important;
  }

  .stitch-notifications-inbox [data-inbox-tab][aria-selected="true"] {
    border-color: var(--stitch-inbox-accent) !important;
    color: var(--stitch-inbox-accent) !important;
    box-shadow: inset 0 -2px var(--stitch-inbox-accent) !important;
  }

  .stitch-notifications-inbox :is(button, a, summary):focus-visible {
    outline: 2px solid var(--stitch-inbox-accent) !important;
    outline-offset: 2px;
  }

  .stitch-notifications-inbox [data-inbox-error]:empty,
  .stitch-notifications-inbox [data-inbox-status]:empty,
  .stitch-notifications-inbox [data-stitch-inbox-empty][hidden],
  .stitch-notifications-inbox [data-inbox-id][data-stitch-inbox-hidden],
  .stitch-notifications-inbox [data-stitch-empty-inbox-group] {
    display: none !important;
  }

  .stitch-notifications-inbox > [data-inbox-list] {
    display: grid !important;
    gap: 6px !important;
    min-width: 0;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }

  .stitch-notifications-inbox :is(.concept-notification-group, .np046-date-heading) {
    min-width: 0;
  }

  .stitch-notifications-inbox .concept-notification-group {
    overflow: hidden;
    border: 1px solid var(--stitch-inbox-border) !important;
    border-radius: 16px !important;
    background: var(--stitch-inbox-paper) !important;
  }

  .stitch-notifications-inbox :is(.concept-notification-group > h2, .np046-date-heading) {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    margin: 4px 0 0 !important;
    padding: 4px 8px !important;
    background: transparent !important;
    color: var(--stitch-inbox-muted) !important;
    font: 500 12px/16px "Spline Sans Mono", ui-monospace, monospace !important;
    text-transform: uppercase;
    letter-spacing: .04em;
  }

  .stitch-notifications-inbox .notification-inbox-row {
    box-sizing: border-box;
    display: grid !important;
    grid-template-columns: 8px 38px minmax(0, 1fr) auto 40px !important;
    align-items: center !important;
    gap: 3px 8px !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 7px 8px !important;
    border: 1px solid var(--stitch-inbox-border) !important;
    border-radius: 12px !important;
    background: var(--stitch-inbox-paper) !important;
    color: var(--stitch-inbox-text) !important;
    box-shadow: none !important;
  }

  .stitch-notifications-inbox .concept-notification-group > .notification-inbox-row {
    border-width: 1px 0 0 !important;
    border-radius: 0 !important;
  }

  .stitch-notifications-inbox .notification-inbox-row[data-unread="true"] {
    background: var(--stitch-inbox-soft) !important;
  }

  .stitch-notifications-inbox .notification-inbox-copy {
    display: contents !important;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .stitch-notifications-inbox .notification-inbox-copy p {
    grid-column: 3 !important;
    grid-row: auto !important;
    min-width: 0;
    margin: 0 !important;
    color: var(--stitch-inbox-text) !important;
    font: 400 14px/20px "Commissioner", system-ui, sans-serif !important;
  }
  .stitch-notifications-inbox .notification-inbox-copy p > a {
    color: var(--stitch-inbox-text) !important;
    text-underline-offset: .15em;
  }

  .stitch-notifications-inbox .notification-inbox-avatar {
    grid-column: 2 !important;
    grid-row: 1 / span 2 !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 999px !important;
    object-fit: cover;
  }
  .stitch-notifications-inbox .notification-inbox-fallback {
    display: grid !important;
    place-items: center;
    background: var(--stitch-inbox-soft) !important;
    border: 1px solid var(--stitch-inbox-border) !important;
    font-weight: 650;
  }

  .stitch-notifications-inbox .notification-inbox-dot {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
    width: 8px !important;
    height: 8px !important;
    background: var(--stitch-inbox-accent) !important;
  }

  .stitch-notifications-inbox .notification-inbox-row :is(.np046-time, .notification-inbox-copy > time) {
    grid-column: 3 !important;
    grid-row: auto !important;
    margin: 0 !important;
    text-align: start !important;
    white-space: normal !important;
  }

  .stitch-notifications-inbox .notification-inbox-row > [data-stitch-inline-read] {
    grid-column: 4 !important;
    grid-row: 1 / span 2 !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding-inline: 8px !important;
    color: var(--stitch-inbox-accent) !important;
  }

  .stitch-notifications-inbox .notification-inbox-copy > :is(.np046-action-menu,.notification-inbox-row-actions) {
    grid-column: 5 !important;
    grid-row: 1 / span 2 !important;
    justify-self: end !important;
  }

  .stitch-notifications-inbox .notification-inbox-copy > .np046-kind-icon { display: none !important; }
  .stitch-notifications-inbox .notification-inbox-copy > .np046-action-menu,
  .stitch-notifications-inbox .notification-inbox-copy > .np046-action-menu > .np046-action-trigger {
    width: 40px !important;
  }

  .stitch-notifications-empty,
  .stitch-notifications-inbox .notification-inbox-empty {
    box-sizing: border-box;
    margin: 12px 0 0;
    padding: 24px !important;
    border: 1px solid var(--stitch-inbox-border) !important;
    border-radius: 16px !important;
    background: var(--stitch-inbox-paper) !important;
    color: var(--stitch-inbox-muted) !important;
    text-align: center;
  }

  @media (max-width: 600px) {
    #main[data-page="notifications"] > .notification-inbox.stitch-notifications-inbox {
      width: min(calc(100% - 16px), 48rem) !important;
      padding-top: 6px !important;
    }

    #main[data-page="notifications"] .stitch-notifications-inbox > .section-head {
      grid-template-columns: 44px minmax(0, 1fr) 44px !important;
    }
    .stitch-notifications-inbox > .section-head > .stitch-notifications-back {
      font-size: 0 !important;
      min-width: 44px;
      padding: 0 !important;
    }
    .stitch-notifications-inbox > .section-head > .stitch-notifications-back::before {
      font-size: 16px;
      margin-right: 0;
    }
    .stitch-notifications-inbox > .section-head > .stitch-notifications-preferences {
      grid-column: 2 / -1 !important;
      grid-row: 2 !important;
      justify-self: start;
    }
    .stitch-notifications-inbox > .section-head > .np046-inbox-menu { grid-column: 3 !important; }

    .stitch-notifications-preferences { display: inline-flex !important; }
    .stitch-notifications-inbox > .notification-inbox-toolbar {
      display: grid !important;
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    .stitch-notifications-inbox > .notification-inbox-toolbar > * { min-width: 0; white-space: normal; }
    .stitch-notifications-inbox > .notification-inbox-toolbar > :last-child { grid-column: 1 / -1; }
    .stitch-notifications-inbox .notification-inbox-row {
      grid-template-columns: 6px 32px minmax(0, 1fr) auto 40px !important;
      column-gap: 6px !important;
      padding: 6px !important;
    }
    .stitch-notifications-inbox .notification-inbox-avatar {
      width: 32px !important;
      height: 32px !important;
    }
  }

  @media (max-width: 360px) {
    .stitch-notifications-inbox .notification-inbox-row {
      grid-template-columns: 6px 32px minmax(0, 1fr) 40px !important;
    }
    .stitch-notifications-inbox .notification-inbox-row .np046-action-menu {
      grid-column: 4 !important;
    }
    .stitch-notifications-inbox .notification-inbox-row > [data-stitch-inline-read] {
      grid-column: 3 !important;
      grid-row: auto !important;
      justify-self: start;
    }
  }
}
