/* ==========================================================================
   SETTINGS COMPONENTS — the one visual language for Settings and Profile.
   Uses the app's existing semantic tokens only; no literal colours.
   ========================================================================== */

.s-page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--bg-deep);
  container-type: inline-size;
}

.s-page__header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  padding-top: calc(12px + max(env(safe-area-inset-top, 0px), var(--app-safe-top, 0px)));
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  transition: padding 0.2s ease, border-color 0.2s ease;
}
.s-page.is-scrolled .s-page__header { border-bottom-color: var(--border-medium); }
.s-page__title {
  grid-column: 2;
  min-width: 0;
  max-width: 100%;
  pointer-events: none;
  margin: 0;
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
  transition: font-size 0.2s ease, opacity 0.2s ease;
}
.s-page.is-scrolled .s-page__title { font-size: 1rem; opacity: 0.9; }
.s-page__spacer { grid-column: 3; width: 48px; justify-self: end; }
.s-back {
  grid-column: 1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  min-width: 48px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--color-cyan);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
}
.s-back:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; border-radius: 10px; }

.s-page__body {
  flex: 1;
  /* The panel's .settings-body is the ONE scroller. This element grows with its
     content, so `overflow-y: auto` made it a scroll container with nothing to
     scroll — and `overscroll-behavior: contain` then swallowed every wheel/touch
     gesture instead of chaining it to the host. Every Settings detail page was
     frozen mid-list on a phone. Keep it non-scrolling. */
  padding: 12px 16px calc(32px + var(--safe-bottom));
}
.s-page__intro,
.s-page__footer,
.s-group__footnote {
  margin: 0 8px 12px;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.45;
}
.s-page__footer { margin-top: 16px; }

.s-group { margin: 0 0 18px; }
.s-group__label {
  margin: 0 8px 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.s-group__card {
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  background: var(--bg-card);
}

.s-row {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}
.s-row + .s-row::before {
  content: '';
  position: absolute;
  left: 62px;
  right: 14px;
  top: 0;
  height: 1px;
  background: var(--border-subtle);
}
.s-row--nav { cursor: pointer; }
.s-row--nav:active { background: var(--overlay-sm); }
.s-row--nav:focus-visible,
.s-row--danger:focus-visible { outline: 2px solid var(--color-blue); outline-offset: -2px; border-radius: 14px; }
.s-row.is-disabled { opacity: 0.55; }
.s-row__copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.s-row__label {
  display: block;
  color: var(--text-primary);
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: break-word;
}
.s-row__footnote,
.s-row__reason { color: var(--text-muted); font-size: 0.75rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.s-row__reason { color: var(--color-amber); }
.s-row__value {
  max-width: 40vw;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 650;
  text-align: right;
  overflow-wrap: break-word;
}
.s-row__control { display: flex; align-items: center; justify-content: flex-end; min-width: 0; max-width: 100%; }
.s-row__control > * { max-width: 100%; }
.s-row__chevron { color: var(--text-muted); font-size: 1.25rem; line-height: 1; }
.s-row--danger .s-row__label { color: var(--color-red); }
.s-row--danger .s-row__copy { grid-column: 1 / span 2; }

/* Narrow screens: the responsive rules live at the end of this file, after the
   control-row grid override, so they win the cascade. */

.s-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--overlay-sm);
  color: var(--text-secondary);
}
.s-icon--empty { background: transparent; }
.s-icon--blue { background: color-mix(in srgb, var(--color-blue) 18%, transparent); color: var(--color-blue); }
.s-icon--green { background: color-mix(in srgb, var(--color-green) 18%, transparent); color: var(--color-green); }
.s-icon--orange { background: color-mix(in srgb, var(--color-orange) 18%, transparent); color: var(--color-orange); }
.s-icon--red { background: color-mix(in srgb, var(--color-red) 18%, transparent); color: var(--color-red); }
.s-icon--purple { background: color-mix(in srgb, var(--color-violet) 18%, transparent); color: var(--color-violet); }
.s-icon--pink { background: color-mix(in srgb, var(--color-pink) 18%, transparent); color: var(--color-pink); }
.s-icon--teal { background: color-mix(in srgb, var(--color-cyan) 18%, transparent); color: var(--color-cyan); }
.s-icon--slate { background: var(--overlay-md); color: var(--text-secondary); }

.s-switch {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 48px;
  min-height: 48px;
  cursor: pointer;
}
.s-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.s-switch__track {
  position: relative;
  width: 42px;
  height: 24px;
  border: 1px solid var(--border-medium);
  border-radius: 999px;
  background: var(--overlay-md);
  transition: background 0.16s ease, border-color 0.16s ease;
}
.s-switch__track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform 0.16s ease, background 0.16s ease;
}
.s-switch input:checked + .s-switch__track {
  border-color: var(--color-cyan);
  background: var(--color-cyan);
}
.s-switch input:checked + .s-switch__track::after {
  background: var(--bg-deep);
  transform: translateX(18px);
}
.s-switch input:focus-visible + .s-switch__track {
  outline: 2px solid var(--color-blue);
  outline-offset: 3px;
}
.s-switch.is-disabled { opacity: 0.55; cursor: default; }

.s-segmented { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.s-segmented__chip {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 750;
  cursor: pointer;
}
.s-segmented__chip.is-selected {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-pressed);
}
.s-segmented__chip:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }

.s-stepper { display: flex; align-items: center; gap: 2px; }
.s-stepper__btn {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--color-cyan);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
}
.s-stepper__btn:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.s-stepper__value {
  min-width: 64px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.s-slider { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.s-slider input { width: 120px; accent-color: var(--color-cyan); }
.s-slider__value { min-width: 44px; color: var(--text-primary); font-size: 0.8rem; font-weight: 800; text-align: right; }

.s-time,
.s-input {
  min-height: 48px;
  padding: 0 10px;
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
}
.s-time:focus-visible,
.s-input:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.s-input-wrap { display: inline-flex; align-items: center; gap: 6px; }
.s-input { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
.s-input__unit { color: var(--text-muted); font-size: 0.8125rem; font-weight: 700; }

.s-select-list { display: flex; flex-direction: column; }
.s-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}
.s-select-item:last-child { border-bottom: 0; }
.s-select-item input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.s-select-item__copy { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.s-select-item__label { color: var(--text-primary); font-size: 0.84rem; font-weight: 700; }
.s-select-item__desc { color: var(--text-muted); font-size: 0.68rem; line-height: 1.3; }
.s-select-item__check { color: transparent; font-size: 1rem; font-weight: 900; }
.s-select-item.is-selected .s-select-item__check { color: var(--color-cyan); }
.s-select-item input:focus-visible + .s-select-item__copy { outline: 2px solid var(--color-blue); outline-offset: 3px; border-radius: 8px; }

.s-picker {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: grid;
  align-items: end;
  background: color-mix(in srgb, var(--bg-deep) 72%, transparent);
}
.s-picker[hidden] { display: none; }
.s-picker__panel {
  max-height: 82vh;
  overflow-y: auto;
  padding-bottom: var(--safe-bottom);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border-default);
  background: var(--bg-card);
}
.s-picker__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.s-picker__title { margin: 0; color: var(--text-primary); font-size: 1rem; font-weight: 800; }
.s-picker__close {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}
.s-picker__close:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }

@media (min-width: 700px) {
  .s-page__body { max-width: 680px; margin: 0 auto; width: 100%; }
}

/* Home / search / page extras */
.s-home { display: flex; flex-direction: column; gap: 4px; }
.s-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin: 0 0 14px;
  padding: 0 12px;
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text-muted);
}
.s-search input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.86rem;
}
.s-search input:focus-visible { outline: none; }
.s-search:focus-within { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.s-search__icon { display: inline-flex; }
.s-empty {
  margin: 20px 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}
.s-input--select { width: auto; min-width: 120px; max-width: 190px; }
.s-input--wide { width: min(190px, 100%); }
.s-input--time { width: 82px; }
.s-inline-actions { display: inline-flex; gap: 6px; }
.s-action {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-medium);
  border-radius: 10px;
  background: var(--overlay-sm);
  color: var(--color-cyan);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}
.s-action:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.s-action--danger { color: var(--color-red); }
.s-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.35;
}
.s-status strong { display: block; color: var(--text-primary); font-size: 0.8rem; }
.s-status small { display: block; color: var(--text-muted); font-size: 0.68rem; }
.s-stack-list { padding: 0 14px 10px; }
.s-preset-row { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 14px; }
.s-plate-counts { display: inline-flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.is-pulse { animation: s-pulse 1.1s ease; }
@keyframes s-pulse {
  0%, 100% { background: transparent; }
  20% { background: color-mix(in srgb, var(--color-cyan) 18%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .is-pulse { animation: none; }
}

/* A control row gives the label a readable floor and lets the control wrap. */
.s-row:has(.s-segmented),
.s-row:has(.s-stepper),
.s-row:has(.s-slider),
.s-row:has(.s-time),
.s-row:has(.s-input) {
  grid-template-columns: 36px minmax(72px, 0.8fr) minmax(0, 1.6fr);
}
.s-row:has(.s-segmented) .s-segmented { justify-content: flex-start; }

.s-reset-page {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}
.s-reset-page:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }

.s-undo {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 10px 8px 16px;
  border: 1px solid var(--border-medium);
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: 0 16px 40px color-mix(in srgb, var(--bg-deep) 65%, transparent);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 650;
}
.s-undo__btn {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--color-cyan);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.s-undo__btn:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 2px; }

/* Licences sheet — legal text, read-only. It ships with the app, so it must
   stay readable offline and at 320px; <pre> wraps rather than scrolling wide. */
.licenses-sheet__body { display: grid; gap: 14px; }
.licenses-sheet__section h4 {
  margin: 0 0 6px;
  color: var(--text-2);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.licenses-sheet__body pre {
  margin: 0;
  max-height: 46dvh;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px;
  font: .66rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.licenses-sheet__body pre:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.licenses-sheet__loading,
.licenses-sheet__fallback {
  margin: 0;
  color: var(--text-2);
  font-size: .72rem;
  line-height: 1.5;
}
.licenses-sheet__fallback a { color: var(--accent); }

/* ==========================================================================
   NARROW SCREENS + LARGE TEXT — the text-fit contract.

   Three failures shipped together because a row could clip its own content
   without the document ever overflowing:
     • labels were line-clamped to one line beside a segmented control; and
       values were `white-space: nowrap` + ellipsis, so "Measurement unit" read
       "Measurem…" and "No manual backup yet — export…" lost its meaning;
     • 3–4 option segments shared the label's line and wrapped to a second line
       (Palette/Motion/Text size rows became 112px tall; "Ember" got a third);
     • at 320 — and at 200% text anywhere — the back label overflowed its grid
       column and painted over the page title.

   Below 480px a control row is two lines (label, then the control full width),
   and a row with a summary puts the summary under its label. Nothing is
   clamped or ellipsised; a long label/value grows the row instead.
   ========================================================================== */
@media (max-width: 480px) {
  .s-row:has(.s-row__control) {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: start;
    row-gap: 8px;
  }
  .s-row:has(.s-row__control) .s-icon { grid-column: 1; grid-row: 1; }
  .s-row:has(.s-row__control) .s-row__copy { grid-column: 2; grid-row: 1; }
  .s-row:has(.s-row__control) .s-row__chevron { grid-column: 3; grid-row: 1; }
  .s-row:has(.s-row__control) .s-row__control {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    width: 100%;
    padding-left: 0;
    flex-wrap: wrap;
  }

  /* A page/setting summary used to fight the label for the same line. Put it
     under the label at full copy width; the 64px row still holds both. */
  .s-row:has(.s-row__value):not(:has(.s-row__control)) {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: start;
  }
  .s-row:has(.s-row__value):not(:has(.s-row__control)) .s-icon { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
  .s-row:has(.s-row__value):not(:has(.s-row__control)) .s-row__copy { grid-column: 2; grid-row: 1; }
  .s-row:has(.s-row__value):not(:has(.s-row__control)) .s-row__value {
    grid-column: 2;
    grid-row: 2;
    max-width: none;
    text-align: left;
  }
  .s-row:has(.s-row__value):not(:has(.s-row__control)) .s-row__chevron { grid-column: 3; grid-row: 1 / span 2; align-self: center; }

  /* Four options have to fit one line at 320 without a second row. The
     narrowest real case is Profile → Sex ("Female Male Other Prefer not to
     say"): it is only a few pixels over the control at 390/320 with the old
     8px padding, and a Linux font is wider than the macOS system font. 4px
     padding + a 1px gap keeps ~30px of headroom without shrinking the type. */
  .s-segmented { gap: 1px; }
  .s-segmented__chip { padding: 0 4px; }
}

/* The back label is the first thing to go when the header is narrow relative
   to its own type. `em` in a container query follows the container's font
   size, so 200% text at 390 behaves like a 195px header — the chevron-only
   state — without a separate text-size query. Falls back to the 380px rule
   where container queries are unavailable. */
@container (max-width: 22em) {
  .s-back > span:last-child,
  .settings-back-btn > span:last-child { display: none; }
  .s-back,
  .settings-back-btn { justify-content: center; padding-left: 0; padding-right: 0; }
}
@media (max-width: 380px) {
  .s-back > span:last-child,
  .settings-back-btn > span:last-child { display: none; }
  .s-back,
  .settings-back-btn { justify-content: center; padding-left: 0; padding-right: 0; }
}

/* A grid can let the back control paint over a large title: its 1fr column may
   shrink below the 48px control, which then overflows into the title's track.
   Below 480px (and therefore at 200% text on a phone) lay the header out as a
   flex row, where the title's min-width:0 makes it wrap instead. */
@media (max-width: 480px) {
  .s-page__header {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .s-back { flex: 0 0 auto; }
  .s-page__title { flex: 1 1 auto; min-width: 0; text-align: center; }
  .s-page__spacer { flex: 0 0 48px; width: 48px; }
  .settings-header {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .settings-back-btn { flex: 0 0 auto; }
  .settings-header-title { flex: 1 1 auto; min-width: 0; }
  .settings-header-spacer { flex: 0 0 44px; width: 44px; }
}

/* A toggle is a compact 48px control and has always fitted beside its label
   (measured label width 208px at 390). Moving it to a second line turned every
   switch row into a 93px form field for no readability gain, so it keeps the
   inline layout; every WIDE control (segmented/stepper/slider/time/text/select/
   actions) takes the second line above. */
@media (max-width: 480px) {
  .s-row:has(.s-row__control):has(.s-switch) {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    row-gap: 0;
  }
  .s-row:has(.s-row__control):has(.s-switch) .s-icon { grid-column: 1; grid-row: 1; align-self: center; }
  .s-row:has(.s-row__control):has(.s-switch) .s-row__copy { grid-column: 2; grid-row: 1; }
  .s-row:has(.s-row__control):has(.s-switch) .s-row__control {
    grid-column: 3;
    grid-row: 1;
    width: auto;
    padding-left: 0;
  }
}

/* The one row shape that carries a summary AND a control (a rest override:
   "Back Squat · 3:00 · Custom · Reset") must not let the value auto-place into
   the label's row. Stack it: label, value, control; the chevron (if any) spans
   the block. This is deliberately outside the width query — the base 3-column
   control grid put the control on an implicit second row at every width. */
.s-row:has(.s-row__control):has(.s-row__value) {
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: start;
  row-gap: 6px;
}
.s-row:has(.s-row__control):has(.s-row__value) .s-icon { grid-column: 1; grid-row: 1; align-self: center; }
.s-row:has(.s-row__control):has(.s-row__value) .s-row__copy { grid-column: 2; grid-row: 1; }
.s-row:has(.s-row__control):has(.s-row__value) .s-row__value {
  grid-column: 2;
  grid-row: 2;
  max-width: none;
  text-align: left;
}
.s-row:has(.s-row__control):has(.s-row__value) .s-row__control {
  grid-column: 1 / -1;
  grid-row: 3;
  justify-content: flex-start;
  width: 100%;
  padding-left: 0;
}
.s-row:has(.s-row__control):has(.s-row__value) .s-row__chevron { grid-column: 3; grid-row: 1 / span 3; align-self: center; }

/* At 200% text a long page title no longer fits beside the back control, and
   breaking a word ("Integration/s") is worse than moving the title to its own
   row. This only triggers when the header is narrower than 16em of its own
   type — 320px at default text keeps the one-row chevron + centred title. */
@media (max-width: 480px) {
  @container (max-width: 16em) {
    .s-page__header { flex-wrap: wrap; row-gap: 2px; }
    .s-back { order: 1; }
    .s-page__title { order: 2; flex: 1 1 100%; text-align: left; }
    .s-page__spacer { display: none; }
  }
}

/* =============================================================================
   IMPORT SHEET (js/settings/import-sheet.js)
   One managed modal for the three moments of a restore: preview + Merge/Replace,
   the write itself, and the outcome. Semantic tokens only — the sheet is part of
   Settings and follows the palette.
   ============================================================================= */
.imp {
  position: fixed;
  inset: 0;
  /* Above the Settings overlay (1000) and the onboarding gate (500) because the
     sheet is opened FROM both; below the toast layer so a refusal is still read. */
  z-index: 1050;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: var(--overlay-scrim);
  padding: var(--safe-top) 0 var(--safe-bottom);
}
.imp.active { display: flex; }
@media (min-width: 600px) {
  .imp { align-items: center; }
}
.imp__panel {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-2);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 16px calc(16px + var(--safe-bottom));
  color: var(--text);
  overflow: hidden;
}
@media (min-width: 600px) {
  .imp__panel { padding-bottom: 18px; }
}
.imp__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.imp__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.imp__close {
  min-height: var(--touch-target);
  min-width: var(--touch-target);
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
}
.imp__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.imp__facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}
.imp__fact--file {
  color: var(--text);
  font-weight: 650;
  overflow-wrap: anywhere;
}
.imp__modes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.imp__mode {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: var(--touch-target);
  padding: 12px 14px;
  text-align: left;
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
}
.imp__mode.is-selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
}
.imp__mode-name { font-size: var(--text-sm); font-weight: 700; }
.imp__mode-note { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.4; }
.imp__confirm {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: var(--border-width) solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--danger-subtle);
}
.imp__confirm-label { font-size: var(--text-sm); font-weight: 650; color: var(--danger-text); }
.imp__confirm-input {
  min-height: var(--touch-target);
  padding: 0 12px;
  border: var(--border-width) solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text);
  font: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.imp__foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.imp__btn {
  min-height: var(--touch-target);
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: var(--border-width) solid transparent;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
}
.imp__btn--quiet {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-muted);
}
.imp__btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}
.imp__btn--danger {
  background: var(--danger);
  color: var(--on-accent);
}
.imp__btn[disabled] {
  opacity: 0.45;
}
.imp__status {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}
.imp__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}
.imp__result-headline {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
}
.imp__warn {
  margin: 6px 0 0;
  color: var(--warning-text);
  font-size: var(--text-sm);
}
.imp__actions { display: flex; }
.imp__link {
  min-height: var(--touch-target);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 650;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.imp__note {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--info-subtle);
  color: var(--text-2);
  font-size: var(--text-xs);
  line-height: 1.5;
}
.imp__note strong { color: var(--text); display: block; margin-bottom: 2px; }
