@layer components {
  .alert-sheet__body {
    padding-inline: var(--space-md);
    gap: var(--space-sm);
  }

  .alert-sheet__title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    line-height: var(--leading-tight);
  }

  .alert-sheet__subtitle {
    font-size: var(--text-xs);
    margin-block-start: var(--space-3xs);
  }

  .alert-sheet__preview {
    padding: var(--space-sm) var(--space-md);
    background: var(--surface-sunken);
    border: var(--border-width) dashed var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: none;
    opacity: 0.68;
    pointer-events: none;
    user-select: none;
  }

  .alert-sheet__preview-label {
    margin: 0 0 var(--space-xs);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  .alert-sheet__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  .alert-sheet__chip {
    display: inline-flex;
    align-items: center;
    min-block-size: calc(var(--touch-target) * 0.75);
    padding-inline: var(--space-md);
    border-radius: var(--radius-pill);
    border: var(--border-width) solid var(--color-border);
    background: var(--surface);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    white-space: nowrap;
    cursor: default;
  }

  .alert-sheet__chip--active {
    background: var(--accent);
    border-color: transparent;
    color: var(--accent-contrast);
    font-weight: var(--weight-semibold);
  }

  .alert-sheet__chips + .alert-sheet__chips {
    margin-top: var(--space-xs);
  }

  .alert-sheet__callout {
    margin-block: 0;
    font-size: var(--text-xs);
    line-height: var(--leading-normal);
  }

  .alert-sheet__section-title {
    margin-block: var(--space-xs) var(--space-xs);
  }

  .alert-sheet__slots {
    gap: var(--space-sm);
  }

  .alert-sheet__warnings:not(:empty) {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
  }

  .alert-sheet .alert-slot {
    padding: var(--space-sm) var(--space-md);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .alert-sheet .alert-slot--off {
    opacity: 0.62;
  }

  .alert-sheet .alert-slot--off .alert-slot__body {
    pointer-events: none;
    user-select: none;
  }

  .alert-sheet .alert-slot__head {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
  }

  .alert-sheet .alert-slot__title {
    flex: 1 1 auto;
    font-weight: var(--weight-bold);
    font-size: var(--text-sm);
  }

  .alert-sheet .alert-slot__toggle {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex: 0 0 auto;
  }

  .alert-sheet .alert-slot__toggle .badge {
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    padding-block: var(--space-3xs);
    padding-inline: var(--space-sm);
  }

  /* Checkbox-driven switch (prototype .switch.sm) scoped to alert slots */
  .alert-sheet .switch--sm {
    position: relative;
    display: inline-flex;
    align-items: center;
    inline-size: 2.375rem;
    block-size: 1.4375rem;
    flex: 0 0 auto;
    cursor: pointer;
  }

  .alert-sheet .switch--sm .switch__input {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
  }

  .alert-sheet .switch--sm .switch__track {
    display: block;
    inline-size: 100%;
    block-size: 100%;
    border-radius: var(--radius-pill);
    background: var(--color-border-strong);
    transition: background var(--dur-fast) var(--ease);
  }

  .alert-sheet .switch--sm .switch__knob {
    position: absolute;
    top: 0.1875rem;
    left: 0.1875rem;
    inline-size: 1.0625rem;
    block-size: 1.0625rem;
    border-radius: var(--radius-pill);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: translate var(--dur-fast) var(--ease);
  }

  .alert-sheet .switch--sm:has(.switch__input:checked) .switch__track {
    background: var(--accent);
  }

  .alert-sheet .switch--sm:has(.switch__input:checked) .switch__knob {
    translate: 0.9375rem 0;
  }

  .alert-sheet .switch--sm:has(.switch__input:focus-visible) .switch__track {
    box-shadow: var(--focus-ring);
  }

  .alert-sheet .desig-seg {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--space-3xs);
    padding: var(--space-3xs);
    margin-bottom: var(--space-sm);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-pill);
    background: var(--surface-sunken);
  }

  .alert-sheet .desig-seg__option {
    position: relative;
    flex: 1 1 0;
    min-inline-size: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-block-size: var(--touch-target);
    padding-inline: var(--space-xs);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-text-muted);
    cursor: pointer;
    white-space: nowrap;
  }

  .alert-sheet .desig-seg__option input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
  }

  .alert-sheet .desig-seg__option:has(input:focus-visible) {
    box-shadow: var(--focus-ring);
  }

  .alert-sheet .desig-seg__option--reminder:has(input:checked) {
    background: var(--status-info-fg);
    color: var(--accent-contrast);
    box-shadow: var(--shadow-sm);
  }

  .alert-sheet .desig-seg__option--first-reminder:has(input:checked) {
    background: var(--status-info-fg);
    color: var(--accent-contrast);
    box-shadow: var(--shadow-sm);
  }

  .alert-sheet .desig-seg__option--second-reminder:has(input:checked) {
    background: var(--status-warning-fg);
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
  }

  .alert-sheet .desig-seg__option--missed-event:has(input:checked) {
    background: var(--status-danger-fg);
    color: var(--accent-contrast);
    box-shadow: var(--shadow-sm);
  }

  .alert-sheet .alert-slot__stepper {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-2xs);
  }

  .alert-sheet .alert-slot__time-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-2xs);
    flex-wrap: wrap;
  }

  .alert-sheet .alert-slot__time-box {
    position: relative;
    flex: 1 1 12rem;
    min-inline-size: 0;
    max-inline-size: 100%;
  }

  .alert-sheet .alert-slot__time-hit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    inline-size: 100%;
    min-block-size: var(--touch-target);
    padding: var(--space-sm) var(--space-md);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--surface-raised);
    color: var(--color-text);
    text-align: start;
    cursor: pointer;
  }

  .alert-sheet .alert-slot__time-hit:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
  }

  .alert-sheet .alert-slot__time-hit:disabled {
    cursor: not-allowed;
    opacity: 0.7;
  }

  .alert-sheet .alert-slot__time-display {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    letter-spacing: -0.01em;
    line-height: 1;
    color: var(--color-text);
    user-select: none;
  }

  .alert-sheet .alert-slot__time-icon {
    display: inline-flex;
    color: var(--color-text-muted);
    flex: 0 0 auto;
  }

  /* Hidden native picker — the pill button opens it via showPicker(). */
  .alert-sheet .alert-slot__time-native {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    min-block-size: 0;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
  }

  .alert-sheet .alert-slot__step {
    inline-size: 2rem;
    block-size: 2rem;
    border-radius: var(--radius-pill);
    border: var(--border-width) solid var(--color-border);
    background: var(--surface);
    color: var(--color-text);
    font-size: var(--text-lg);
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
  }

  .alert-sheet .alert-slot__step:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
  }

  .alert-sheet .alert-slot__time-edit {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
  }

  .alert-sheet .alert-slot__offset {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-inline-start: var(--space-2xs);
  }

  .alert-sheet .alert-slot__channel {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin: var(--space-sm) 0 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }

  .alert-sheet__sent {
    margin-block-start: var(--space-sm);
  }

  .alert-sheet__sent-body .msg-preview {
    padding: var(--space-sm);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--surface-raised);
  }

  .alert-sheet__sent-body .msg-preview__head {
    display: flex;
    justify-content: space-between;
    gap: var(--space-sm);
    margin: 0 0 var(--space-xs);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .alert-sheet__sent-body .msg-preview__count {
    color: var(--status-warning-fg);
  }

  .alert-sheet__sent-body .msg-preview__bubble {
    margin: 0;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    background: var(--status-info-fg);
    color: var(--accent-contrast);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
  }

  .alert-sheet__sent-body .msg-preview__voice {
    margin: 0;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
  }

  .alert-sheet__sent-body .voice-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--surface);
  }

  .alert-sheet__sent-body .voice-card__icon {
    display: grid;
    place-items: center;
    inline-size: 1.75rem;
    block-size: 1.75rem;
    border-radius: var(--radius-sm);
    background: var(--status-warning-fg);
    color: var(--color-text);
    flex: 0 0 auto;
    font-size: var(--text-sm);
  }

  .alert-sheet__sent-body .voice-card__text {
    margin: 0;
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--color-text);
  }

  .alert-sheet__actions {
    margin-top: var(--space-md);
  }

  .alert-sheet__actions .btn {
    inline-size: 100%;
    justify-content: center;
  }

  /* Autosave in flight: cover the sheet with a spinner (same language as
     the global loading overlay) and keep Close locked as "Saving…". */
  .alert-sheet__body { position: relative; }
  .alert-sheet__saving {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    background: color-mix(in oklab, var(--surface-raised) 78%, transparent);
    border-radius: inherit;
  }
  .alert-sheet__saving[hidden] { display: none; }
  .alert-sheet__saving-spinner {
    inline-size: 2.25rem;
    block-size: 2.25rem;
    border: 0.1875rem solid var(--color-border);
    border-block-start-color: var(--accent);
    border-radius: var(--radius-pill);
    animation: loading-spin calc(var(--dur-base) * 4) linear infinite;
  }
  .alert-sheet__saving-status {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
  }
  .alert-sheet.is-saving .alert-sheet__form,
  .alert-sheet.is-saving .alert-sheet__title { pointer-events: none; }
  .alert-sheet.is-saving .alert-sheet__actions .btn[disabled] { opacity: 1; }

  @media (prefers-reduced-motion: reduce) {
    .alert-sheet__saving-spinner {
      animation: none;
      border-block-start-color: var(--accent);
      opacity: 0.85;
    }
  }

  .shift-strip-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .shift-strip {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--accent-tint);
    border-color: transparent;
  }

  .shift-strip__head {
    align-items: flex-start;
    gap: var(--space-sm);
    margin-bottom: 0;
  }

  .shift-strip__title {
    margin: 0;
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    text-transform: none;
    letter-spacing: normal;
  }

  .shift-strip__status {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .shift-strip form {
    inline-size: 100%;
  }

  .shift-strip__action {
    inline-size: 100%;
    justify-content: center;
  }

  .shift-strip__armed {
    margin: 0;
    inline-size: 100%;
  }

  .timeline-row__critical {
    margin-inline-start: var(--space-2xs);
  }

  .plan-item__sub .badge,
  .schedule-card__title-row .badge,
  .together-item__sub .badge {
    margin-inline-start: var(--space-2xs);
    vertical-align: middle;
  }

  .consent-delivery .designation-card {
    padding: var(--space-md);
  }

  .consent-delivery .designation-card__head {
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .consent-delivery .designation-card__title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
  }

  .consent-delivery .designation-card__channel {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }

  .consent-delivery .msg-preview {
    padding: var(--space-sm);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
  }

  .consent-delivery .msg-preview__head {
    margin: 0;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .consent-delivery .msg-preview__bubble {
    margin: 0;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    border-end-start-radius: var(--radius-sm);
    background: var(--status-info-fg);
    color: var(--accent-contrast);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    word-break: break-word;
  }

  .consent-delivery .voice-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--surface);
  }

  .consent-delivery .voice-card__icon {
    display: grid;
    place-items: center;
    inline-size: 1.75rem;
    block-size: 1.75rem;
    border-radius: var(--radius-sm);
    background: var(--status-warning-fg);
    color: var(--color-text);
    flex: 0 0 auto;
  }

  .consent-delivery .voice-card__text {
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--color-text);
  }

  .consent-delivery .phone-input {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: var(--space-sm);
    inline-size: 100%;
  }

  .consent-delivery .phone-input__code {
    flex: 0 0 auto;
    inline-size: 5.5rem;
    min-inline-size: 4.75rem;
    max-inline-size: 6.5rem;
    padding-inline: var(--space-xs);
  }

  .consent-delivery .phone-input__number {
    flex: 1 1 auto;
    min-inline-size: 0;
    inline-size: auto;
  }

  @media (max-width: 22rem) {
    .consent-delivery .phone-input__code {
      inline-size: 4.75rem;
      min-inline-size: 4.25rem;
      font-size: var(--text-sm);
    }
  }
}
