/* #1133: local Signal finish, preserving the existing cockpit compartments and jobs. */
@media (min-width: 901px) {
  .personal-schedule .narrative-summary {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-4);
    border-left: 4px solid var(--color-brand);
    background: var(--color-surface);
  }

  .narrative-summary .narrative-summary-headline {
    font-size: var(--typography-size-section);
  }

  .narrative-summary .narrative-summary-duration {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1);
    color: var(--color-ink);
    font-size: var(--typography-size-meta);
  }

  .narrative-summary-duration .narrative-icon {
    align-self: center;
    width: 16px;
    height: 16px;
    color: var(--color-brand-strong);
  }

  .narrative-summary-duration strong {
    font-size: var(--typography-size-section);
    font-variant-numeric: tabular-nums;
  }

  .narrative-summary-next strong {
    line-height: 1.4;
  }

  .narrative-reference-navigation {
    width: 100%;
  }

  .narrative-reference-step + .narrative-reference-trigger {
    width: auto;
    flex: 1 1 15rem;
  }

  .narrative-controls--unified .narrative-filter-grid > .narrative-filter-group {
    border-color: transparent;
    background: var(--color-canvas);
  }

  .narrative-controls--unified .narrative-filter-group--content,
  .narrative-controls--unified .narrative-filter-group--space {
    background: transparent;
  }

  .narrative-scope button[aria-pressed="true"] {
    border-color: var(--color-brand);
    background: var(--color-brand-soft);
    color: var(--color-brand-strong);
  }

  .narrative-time-strip {
    background: var(--color-surface);
    margin-block: var(--space-3);
  }

  .narrative-time-strip-heading > strong {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
  }

  .narrative-time-strip-heading .narrative-icon {
    width: 18px;
    height: 18px;
    color: var(--color-brand-strong);
  }

  /* No Workspace color model: these are graph tones, never workspace identities.
     Calendar colors supplied inline by the projection retain precedence. */
  .narrative-time-segment,
  .narrative-time-dot {
    background: var(--color-brand);
  }

  .narrative-time-segment:nth-child(3n + 2),
  .narrative-time-legend > span:nth-child(3n + 2) .narrative-time-dot {
    background: color-mix(in srgb, var(--color-brand) 58%, var(--color-surface));
  }

  .narrative-time-segment:nth-child(3n + 3),
  .narrative-time-legend > span:nth-child(3n + 3) .narrative-time-dot {
    background: var(--color-brand-strong);
  }

  .narrative-time-legend > span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .narrative-repartition-row {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }

  .narrative-side-empty h3 {
    font-size: var(--typography-size-body);
    line-height: 1.4;
  }

  .narrative-side-empty p {
    margin-bottom: 0;
    font-size: var(--typography-size-meta);
  }

  .narrative-event-card,
  .narrative-allday-card,
  .narrative-event-card.is-selected,
  .narrative-allday-card.is-selected {
    border-color: color-mix(in srgb, var(--calendar-color, var(--color-brand)) 24%, var(--color-line));
    border-left: 5px solid var(--calendar-color, var(--color-brand));
    background: color-mix(in srgb, var(--calendar-color, var(--color-brand)) 10%, var(--color-surface));
    color: var(--color-ink);
  }

  .narrative-event-card.has-calendar-collision,
  .narrative-allday-card.has-calendar-collision {
    border-color: color-mix(in srgb, var(--calendar-effective-color) 36%, var(--color-line));
    border-left-color: var(--calendar-effective-color);
    background: color-mix(in srgb, var(--calendar-effective-color) 11%, var(--color-surface));
  }

  /* #1158 — semantic event pictograms reuse existing clock/calendar data.
     No new workspace color, card link, line of metadata, or absolute position. */
  .narrative-event-card .narrative-event-title,
  .narrative-allday-card .narrative-event-title {
    display: block;
    line-height: 1.35;
  }

  /* Inline icon takes space only on the first line, not every wrapped line. */
  .narrative-event-title > .narrative-icon {
    display: inline;
    width: 0.875rem;
    height: 0.875rem;
    vertical-align: -0.125em;
    margin-inline-end: 0.2rem;
    color: var(--color-brand-strong);
  }

  .narrative-event-title > span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .narrative-event-card .narrative-event-provenance,
  .narrative-allday-card .narrative-event-provenance,
  .narrative-detail--event .narrative-event-detail-grid dt {
    color: var(--color-ink);
  }

  .narrative-event-card.is-selected,
  .narrative-allday-card.is-selected {
    box-shadow: inset 0 0 0 2px var(--color-brand), var(--shadow-surface);
  }

  .narrative-event-detail-scroll > h3 {
    margin-block: var(--space-2);
    font-size: var(--typography-size-body);
    line-height: 1.4;
  }

  .narrative-event-detail-grid > div {
    border-top: 0;
    padding-block: var(--space-2);
  }

  .narrative-event-detail-grid > div + div {
    border-top: 1px solid color-mix(in srgb, var(--color-line) 60%, transparent);
  }

  .narrative-detail--event .personal-event-detail-actions {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
  }
}

@media (min-width: 1180px) {
  .narrative-side--detail {
    height: clamp(24rem, 45vh, 34rem);
  }
}

@media (min-width: 901px) and (hover: hover) and (pointer: fine) {
  .narrative-event-card:hover,
  .narrative-allday-card:hover {
    border-block-color: var(--color-brand-strong);
    border-inline-end-color: var(--color-brand-strong);
    border-left-color: var(--calendar-color, var(--color-brand));
  }

  .narrative-event-card.has-calendar-collision:hover,
  .narrative-allday-card.has-calendar-collision:hover {
    border-left-color: var(--calendar-effective-color);
  }

  .narrative-event-card.is-selected:hover,
  .narrative-allday-card.is-selected:hover {
    box-shadow: inset 0 0 0 2px var(--color-brand), var(--shadow-surface);
  }
}

@media (min-width: 901px) and (forced-colors: active) {
  .narrative-event-card,
  .narrative-allday-card {
    border-color: ButtonText;
    background: Canvas;
    color: CanvasText;
  }

  .narrative-event-card.is-selected,
  .narrative-allday-card.is-selected,
  .narrative-scope button[aria-pressed="true"] {
    border-color: Highlight;
    box-shadow: none;
  }
}


/* #1150 — first owner-guided aesthetic convergence: scope and factual time strip.
   Neutral brand treatments are UI states, never invented Workspace identities. */
@media (min-width: 901px) {
  .personal-schedule .narrative-controls--unified .narrative-scope button {
    border-radius: var(--radius-surface);
    background: color-mix(in srgb, var(--color-brand) 3%, var(--color-surface));
    box-shadow: 0 1px 2px rgb(19 29 58 / 6%);
  }

  .personal-schedule .narrative-controls--unified
    .narrative-scope button[aria-pressed="true"] {
    border-color: var(--color-brand);
    background: var(--color-brand-soft);
    box-shadow: inset 0 0 0 1px var(--color-brand);
    color: var(--color-brand-strong);
  }

  .personal-schedule .narrative-controls--unified
    .narrative-scope button:not([aria-pressed="true"]):hover {
    border-color: var(--color-brand);
    background: color-mix(in srgb, var(--color-brand) 9%, var(--color-surface));
  }

  .personal-schedule .narrative-time-strip {
    border-color: color-mix(in srgb, var(--color-brand) 12%, var(--color-line));
    box-shadow: var(--shadow-surface);
  }

  .personal-schedule .narrative-time-track {
    height: 14px;
    border-radius: 999px;
    box-shadow: inset 0 1px 2px rgb(19 29 58 / 8%);
  }

  .personal-schedule .narrative-time-legend {
    column-gap: var(--space-2);
  }

  .personal-schedule .narrative-time-legend > span {
    max-width: 100%;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-control);
    background: color-mix(in srgb, var(--color-canvas) 30%, var(--color-surface));
    font-size: var(--typography-size-meta);
    line-height: 1.4;
  }

  .personal-schedule .narrative-time-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
  }
}

/* At 1024px, keep secondary filters in two compact rows rather than three.
   The scope chips retain their separate, keyboard-scrollable strip. */
@media (min-width: 901px) and (max-width: 1039px) {
  .personal-schedule .narrative-controls--unified .narrative-filter-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr);
  }
}

/* High contrast mode must not depend on color-mix, subtle shadows or tints. */
@media (min-width: 901px) and (forced-colors: active) {
  .personal-schedule .narrative-controls--unified .narrative-scope button {
    border-color: ButtonText;
    background: ButtonFace;
    box-shadow: none;
    color: ButtonText;
  }

  .personal-schedule .narrative-controls--unified
    .narrative-scope button[aria-pressed="true"] {
    border-color: Highlight;
    background: Highlight;
    box-shadow: none;
    color: HighlightText;
    forced-color-adjust: none;
  }

  .personal-schedule .narrative-time-strip,
  .personal-schedule .narrative-time-legend > span {
    border-color: ButtonText;
    background: Canvas;
    box-shadow: none;
  }
}


/* #1150 owner feedback: methodology is contextual, not a permanent text row.
   Native details preserves click, keyboard and touch; title supports hover. */
@media (min-width: 901px) {
  .personal-schedule .narrative-time-help {
    flex: 0 0 auto;
    position: relative;
    align-self: center;
  }

  .personal-schedule .narrative-time-help > summary {
    list-style: none;
    width: 24px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--color-line);
    border-radius: 999px;
    background: var(--color-canvas);
    color: var(--color-ink);
    font-size: var(--typography-size-meta);
    font-weight: var(--typography-weight-semibold);
  }

  .personal-schedule .narrative-time-help > summary::-webkit-details-marker {
    display: none;
  }

  .personal-schedule .narrative-time-help > summary:hover {
    border-color: var(--color-brand);
  }

  .personal-schedule .narrative-time-help > summary:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
  }

  .personal-schedule .narrative-time-help-content {
    position: absolute;
    top: calc(100% + var(--space-2));
    left: 0;
    width: min(22rem, calc(100vw - 3rem));
    padding: var(--space-3);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-surface);
    background: var(--color-surface);
    color: var(--color-ink);
    box-shadow: var(--shadow-surface);
    line-height: 1.5;
    font-size: var(--typography-size-meta);
    z-index: 10;
  }
}

@media (min-width: 901px) and (forced-colors: active) {
  .personal-schedule .narrative-time-help > summary,
  .personal-schedule .narrative-time-help-content {
    border-color: ButtonText;
    background: Canvas;
    color: CanvasText;
    box-shadow: none;
  }
}


/* #1272 — at the intermediate B rail width, keep the whole reference date
   readable instead of painting an ellipsis. The canonical date, arrows,
   five filter compartments, A fallback and mobile remain unchanged. */
@media (min-width: 1400px) and (max-width: 1599px) {
  body.authenticated-shell[data-shell-mode="b"]
    .personal-schedule .narrative-reference-navigation
    .narrative-reference-trigger > span {
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: normal;
    line-height: 1.25;
    text-align: center;
  }
}


/* #1280 — the effective A layout at 1040–1399px is independent of the
   saved A/B preference (B may persist when its rail is hidden). Reallocate
   only the existing five filter compartments to keep the complete date. */
@media (min-width: 1040px) and (max-width: 1399px) {
  body.authenticated-shell .personal-schedule .narrative-filter-grid {
    grid-template-columns:
      minmax(14.5rem, 1.25fr)
      minmax(12rem, 1.25fr)
      minmax(13.5rem, 1.2fr)
      minmax(10.5rem, .8fr)
      minmax(8.5rem, .7fr);
  }

  /* #1280 UX v2: keep the four horizon buttons on one line at A1180.
     The date stays complete on two lines without increasing toolbar height. */
  body.authenticated-shell .personal-schedule
    .narrative-controls--unified .narrative-horizons a {
    padding-inline: 2px;
  }

  body.authenticated-shell .personal-schedule
    .narrative-reference-navigation .narrative-reference-trigger {
    padding-inline: var(--space-1);
  }

  body.authenticated-shell
    .personal-schedule .narrative-reference-navigation
    .narrative-reference-trigger > span {
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: normal;
    line-height: 1.25;
    text-align: center;
  }
}
