/*
 * Settings modal (ISH-552) — the shared overlay + grouped sidebar + form/table primitives every
 * Unified Settings tab builds its real content on top of. The sidebar was a horizontal tab strip
 * until ISH-586 rebuilt it into a grouped vertical list per an approved mockup; the class names
 * below reflect that (`.settings-sidebar-nav`, `.settings-sidebar-heading`, …).
 *
 * Fully self-contained, modeled on css/portal-rail.css rather than css/docusign-proposal-modal.css:
 * the docusign sheet only defines 3 classes and leans on its two host pages already declaring
 * `.modal-overlay`/`.modal-card` themselves, which not every `has-portal-rail` page does. This file
 * assumes nothing from its host page's inline <style> — every rule here resolves against the host
 * page's own :root tokens where those exist (--red, --border, --card-bg, …, all declared per-page
 * per this app's existing convention — see js/shared.js's SALES_PIPELINE_PAGES comment and
 * sales-pipeline-settings.html's own inline <style> header), falling back to the same literal
 * defaults that page uses when a token is missing.
 *
 * Rules are namespaced under `.settings-` throughout, deliberately not reusing `.tabs-nav`/
 * `.tab-btn`/`.tab-pane`/`.form-group`/`.form-control`/`.settings-table` etc. verbatim — this modal
 * opens from sales-pipeline-settings.html, sales-pipeline-approvals.html and
 * sales-pipeline-detail.html, all three of which already define that exact contract for their own
 * in-page tab strips, and reusing it here would collide.
 *
 * Ships the complete primitive set later Unified Settings issues need (sidebar, toggle switch,
 * form field rows, cards, link-out cards, table styles) so none of them has to touch this file —
 * content only, inside the panes `js/settings-modal.js` builds.
 */

.settings-modal-overlay {
  --settings-red: var(--red, #a62626);
  --settings-red-hover: var(--red-hover, #8f2121);
  --settings-page-bg: var(--page-bg, #f8f9fa);
  --settings-card-bg: var(--card-bg, #ffffff);
  --settings-info-bg: var(--info-bg, #f4f4f4);
  --settings-border: var(--border, #e0e0e0);
  --settings-border-light: var(--border-light, #ebebeb);
  --settings-text: var(--text, #1a1a1a);
  /* ISH-520: was #55606e — an eighth opinion, in the shared layer, that nothing else in the
     repo used. Fallbacks now match css/tokens.css so one can never reintroduce the drift. */
  --settings-text-secondary: var(--text-secondary, #4b5563);
  --settings-text-label: var(--text-label, #94a3b8);
  --settings-green: var(--green, #28a745);
  --settings-amber: var(--amber, #b26a00);
  --settings-radius: var(--radius, 6px);
  --settings-radius-lg: var(--radius-lg, 8px);
  /* Sidebar chrome (ISH-586): the sidebar reads slightly grayer than the content-pane cards it
   * sits beside, and both stay distinct from the pane's own white background — reusing this app's
   * existing page-bg/info-bg tokens rather than inventing new hex values for what is really just a
   * two-step tint scale (white -> settings-page-bg -> settings-info-bg). */
  --settings-sidebar-bg: var(--settings-info-bg);
  --settings-card-tint-bg: var(--settings-page-bg);

  position: fixed;
  inset: 0;
  /* ISH-622. The ladder this sits in is `page chrome < this modal < toasts`, and both ends are
   * real constraints:
   *
   *   - **Above every host page's own chrome.** ISH-552 shipped `300`, which was never checked
   *     against what the 22 `has-portal-rail` pages actually declare and lost on most of them —
   *     analytics.html and map.html put `.top-nav` at 1500 (raised deliberately to clear their own
   *     1010 dropdown widgets), four pages put `.export-sidebar` at 4001, and about a dozen carry
   *     `.modal-overlay`/sidebar/autocomplete layers in the 1000-1080 band. Only the five pages
   *     that top out at 100 rendered this modal correctly, which is why it looked fine when it
   *     shipped. Raising this is the fix; lowering a page's nav is not, since those values are
   *     load-bearing against that page's own widgets.
   *   - **Below the toast layer.** `js/shared.js`'s injected `#brokerapp-toast-container` is 9999,
   *     and a toast fired from inside this modal (a save confirmation) has to be visible over it.
   *
   * `js/settings-modal-z-index.test.js` recomputes both bounds from disk on every run rather than
   * pinning today's numbers, so a page that later raises its nav past this fails CI instead of
   * quietly reintroducing the bug. */
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
  font-family: inherit;
}

.settings-modal-overlay[hidden] {
  display: none;
}

.settings-modal-overlay.is-visible {
  opacity: 1;
}

.settings-modal {
  position: relative;
  width: 100%;
  max-width: 760px;
  max-height: min(88vh, 820px);
  display: flex;
  flex-direction: column;
  background: var(--settings-card-bg);
  border-radius: var(--settings-radius-lg);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  color: var(--settings-text);
  transform: translateY(10px) scale(0.98);
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
  opacity: 0;
  overflow: hidden;
}

/* Additive width modifier (ISH-586's sidebar addendum) — a grouped sidebar plus real tab content
 * (the PNC recipient table, the Stage Goals grid) does not fit the 760px cap above, but a future
 * narrow settings dialog reusing this shell should still get that cap by default, so this widens
 * rather than replacing the base rule. `js/settings-modal.js` applies this class unconditionally
 * today, since every shipped tab now needs the room. */
.settings-modal.is-wide {
  max-width: min(1480px, 96vw);
  width: 96vw;
  height: min(93vh, 980px);
  max-height: min(93vh, 980px);
}

.settings-modal-overlay.is-visible .settings-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--settings-border-light);
  flex-shrink: 0;
}

.settings-modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.settings-modal-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--settings-text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.settings-modal-close-btn:hover {
  background: var(--settings-page-bg);
  color: var(--settings-text);
}

.settings-modal-close-btn:focus-visible {
  outline: 2px solid var(--settings-red);
  outline-offset: 2px;
}

/* Body layout — sidebar + content pane side by side (ISH-586, replacing the horizontal tab strip
 * ISH-552 shipped). Namespaced under `.settings-` throughout, same reasoning as this file's header
 * comment. */
.settings-modal-main {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar — namespaced equivalent of this app's existing .tabs-nav/.tab-btn[data-tab] contract
 * (sales-pipeline-settings.html, sales-pipeline-approvals.html, sales-pipeline-detail.html), now a
 * grouped vertical list rather than a horizontal strip. */
.settings-sidebar-nav {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.6rem;
  background: var(--settings-sidebar-bg);
  border-right: 1px solid var(--settings-border-light);
  overflow-y: auto;
  min-height: 0;
}

.settings-sidebar-divider {
  height: 1px;
  margin: 0.5rem 0.4rem;
  background: var(--settings-border-light);
  flex-shrink: 0;
}

.settings-sidebar-heading {
  padding: 0.9rem 0.6rem 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--settings-text-label);
}

/* Sidebar item. The left-border-plus-red-text active convention mirrors this app's existing
 * active-nav idiom (css/portal-rail.css's `.rail-item.is-current`, css/broker-flags-rail.css's
 * `.sidebar-flag-card.is-critical` left accent) rather than inventing new visual language. */
.settings-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 0 var(--settings-radius) var(--settings-radius) 0;
  padding: 0.55rem 0.6rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--settings-text);
  text-align: left;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.settings-tab-btn:hover {
  background: rgba(15, 23, 42, 0.04);
}

.settings-tab-btn.is-active {
  background: rgba(166, 38, 38, 0.08);
  border-left-color: var(--settings-red);
  color: var(--settings-red);
}

.settings-tab-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.settings-tab-label {
  flex: 1;
  min-width: 0;
}

/* ISH-588. The amber dot marking a section with unsaved edits. Emitted `hidden` on every sidebar
 * row by js/settings-modal.js's renderSidebarItem() and simply un-hidden by paintDirtyChrome(), so
 * flagging a section never rebuilds markup — re-rendering a pane would restore it from its stored
 * values and discard the very edit that marked it dirty. */
.settings-dirty-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--settings-amber);
}

.settings-dirty-dot[hidden] {
  display: none;
}

/* Text present for a screen reader but not on screen — the dot's own label. Namespaced like every
 * other rule in this file rather than reusing a host page's `.sr-only`, which not every
 * has-portal-rail page declares. */
.settings-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip-path: inset(50%);
}

/* Content pane — heading + one-line description above the active tab's actual content
 * (ISH-586), then the tab panes themselves. */
.settings-modal-body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.settings-content-header {
  margin-bottom: 0.9rem;
}

.settings-content-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.settings-content-desc {
  font-size: 0.825rem;
  color: var(--settings-text-secondary);
  margin: 0.25rem 0 0;
}

.settings-content-divider {
  border: none;
  border-top: 1px solid var(--settings-border-light);
  margin: 0 0 1.25rem;
}

.settings-tab-pane {
  display: none;
}

.settings-tab-pane.is-active {
  display: block;
}

/* Section cards — namespaced equivalent of sales-pipeline-settings.html's .settings-section /
 * .section-header / .section-body, for a tab that groups its content into cards. */
.settings-section {
  background: var(--settings-card-bg);
  border: 1px solid var(--settings-border);
  border-radius: var(--settings-radius-lg);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-header {
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--settings-border-light);
  background: var(--settings-info-bg);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.settings-section-header > div {
  flex: 1;
  min-width: 0;
}

.settings-section-header h3 {
  font-size: 0.975rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.settings-section-header p {
  color: var(--settings-text-secondary);
  font-size: 0.8rem;
  margin: 0.2rem 0 0;
}

.settings-section-body {
  padding: 1.1rem;
}

.settings-section-body.is-flush {
  padding: 0;
}

/* Form field rows — namespaced equivalent of .form-group/.form-control. */
.settings-form-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.settings-form-row:last-child {
  margin-bottom: 0;
}

.settings-form-row label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--settings-text-label);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--settings-border);
  border-radius: var(--settings-radius);
  font: inherit;
  font-size: 0.9rem;
  color: var(--settings-text);
  background: #fff;
  outline: none;
}

.settings-form-control:focus {
  border-color: var(--settings-red);
  box-shadow: 0 0 0 2px rgba(166, 38, 38, 0.12);
}

textarea.settings-form-control {
  min-height: 140px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.825rem;
  line-height: 1.6;
}

.settings-form-help {
  font-size: 0.78rem;
  color: var(--settings-text-label);
  margin: 0;
  max-width: 70ch;
}

/* Toggle switch — no prior art elsewhere in this app to port; a later tab (e.g. Preferences) is
 * the first real caller. */
.settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--settings-text);
}

.settings-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-toggle-track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--settings-border);
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.settings-toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.settings-toggle input:checked + .settings-toggle-track {
  background: var(--settings-red);
}

.settings-toggle input:checked + .settings-toggle-track::after {
  transform: translateX(16px);
}

.settings-toggle input:focus-visible + .settings-toggle-track {
  outline: 2px solid var(--settings-red);
  outline-offset: 2px;
}

.settings-toggle input:disabled + .settings-toggle-track {
  opacity: 0.5;
  cursor: default;
}

/* Shared content-pane card look (ISH-586's mockup): light-gray fill, rounded corners, comfortable
 * padding, stacked with a gap when there's more than one. Reused as-is by the Fun Mode toggle
 * (`.settings-card` — see js/shared.js's renderPreferencesTab()) and extended by the 6 link-out
 * cards below (`.settings-linkout-card`), rather than each keeping its own one-off card styling. */
.settings-card {
  background: var(--settings-card-tint-bg);
  border-radius: var(--settings-radius-lg);
  padding: 1rem 1.1rem;
}

.settings-card + .settings-card {
  margin-top: 0.75rem;
}

/* Row pairing a card's bold title with a right-anchored control (e.g. Fun Mode's toggle),
 * vertically centered against the title specifically — any description text is a sibling below
 * this row, not inside it, so it does not affect that centering. */
.settings-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.settings-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.settings-card-desc {
  color: var(--settings-text-secondary);
  font-size: 0.8rem;
  margin: 0.3rem 0 0;
}

/* Landing-page rows (ISH-587) — one per portal inside the Preferences tab's second card: the
 * portal's own rail icon, its name, and a <select> of that portal's pages, plus a "Sign in to"
 * row whose icon cell is empty (it picks a portal, not a page). Built on `.settings-form-control`
 * for the select rather than a new control primitive. */
.settings-portal-rows {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-portal-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.settings-portal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--settings-text-secondary);
}

.settings-portal-icon svg {
  width: 100%;
  height: 100%;
}

.settings-portal-name {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--settings-text);
}

/* The select and the "nothing to choose" note share a width so the rows line up as a column
 * regardless of which of the two a portal renders. */
.settings-portal-select,
.settings-portal-empty {
  width: 260px;
  flex-shrink: 0;
}

.settings-portal-empty {
  font-size: 0.8rem;
  color: var(--settings-text-label);
}

@media (max-width: 560px) {
  .settings-portal-select,
  .settings-portal-empty {
    width: 150px;
  }
}

/* Link-out cards — for a tab whose "setting" is really a pointer to another page (e.g. the
 * Operations Hub/Admin tabs linking out to manage-templates.html/manage-flags.html rather than
 * duplicating them). Built on `.settings-card` above, with its own icon/body/arrow row layout and
 * a hover state (a plain, non-interactive `.settings-card` has none) signaling it's clickable. */
.settings-linkout-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
  margin-bottom: 0.75rem;
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.settings-linkout-card:last-child {
  margin-bottom: 0;
}

.settings-linkout-card:hover {
  background: var(--settings-card-bg);
  box-shadow: inset 0 0 0 1px var(--settings-red);
}

.settings-linkout-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--settings-radius);
  background: var(--settings-info-bg);
  color: var(--settings-red);
  flex-shrink: 0;
}

.settings-linkout-body {
  flex: 1;
  min-width: 0;
}

.settings-linkout-title {
  /* Fixed alongside this issue's other link-out card work: both spans had no `display` rule, so
   * title and description rendered on one line and `-desc`'s `margin-top` below was inert — a
   * pre-existing bug on the live Admin Tools tab, worth fixing now that this issue adds 6 more
   * cards on the same primitive rather than filing it separately. */
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--settings-text);
}

.settings-linkout-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--settings-text-secondary);
  margin-top: 0.15rem;
}

.settings-linkout-arrow {
  color: var(--settings-text-label);
  flex-shrink: 0;
}

/* Table styles — namespaced equivalent of .settings-table (sales-pipeline-settings.html's
 * recipient table), renamed to avoid colliding with that page's own global class of the same
 * name once both are on screen at once (the modal opens from that very page). */
.settings-modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.settings-modal-table th,
.settings-modal-table td {
  text-align: left;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--settings-border-light);
  vertical-align: middle;
}

.settings-modal-table th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--settings-text-label);
  font-weight: 600;
  background: var(--settings-info-bg);
}

.settings-modal-table tbody tr:last-child td {
  border-bottom: none;
}

.settings-modal-table tbody tr:hover td {
  background: var(--settings-page-bg);
}

.settings-modal-table tbody tr.is-inactive td {
  opacity: 0.5;
}

.settings-status-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(40, 167, 69, 0.12);
  color: var(--settings-green);
}

.settings-status-pill.is-inactive {
  background: rgba(148, 163, 184, 0.18);
  color: var(--settings-text-label);
}

/* Buttons — namespaced equivalents of .btn-primary/.btn-secondary, for a tab's own Save/Cancel. */
.settings-btn-primary,
.settings-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--settings-radius);
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.15s ease,
    transform 0.1s ease;
}

.settings-btn-primary {
  background: var(--settings-red);
  color: #fff;
  border: none;
}

.settings-btn-primary:hover:not(:disabled) {
  background: var(--settings-red-hover);
}

.settings-btn-secondary {
  background: #fff;
  color: var(--settings-text);
  border: 1px solid var(--settings-border);
}

.settings-btn-secondary:hover:not(:disabled) {
  background: var(--settings-page-bg);
}

.settings-btn-primary:active:not(:disabled),
.settings-btn-secondary:active:not(:disabled) {
  transform: scale(0.98);
}

.settings-btn-primary:disabled,
.settings-btn-secondary:disabled {
  opacity: 0.55;
  cursor: default;
}

.settings-save-note {
  font-size: 0.8rem;
  color: var(--settings-text-label);
}

.settings-save-note.is-error {
  color: var(--settings-red);
}

.settings-save-note.is-success {
  color: var(--settings-green);
}

.settings-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--settings-text-secondary);
  font-size: 0.875rem;
}

/* Unsaved-changes dialog (ISH-588). Absolutely positioned inside `.settings-modal` — which is why
 * that element carries `position: relative` — rather than being a second body-level overlay: inside
 * the card it inherits the `--settings-*` token block declared on `.settings-modal-overlay` above,
 * and it cannot end up stacked behind the modal it is asking about. */
.settings-guard {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.4);
}

.settings-guard[hidden] {
  display: none;
}

.settings-guard-card {
  width: 100%;
  max-width: 440px;
  padding: 1.25rem 1.4rem;
  background: var(--settings-card-bg);
  border-radius: var(--settings-radius-lg);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
}

.settings-guard-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--settings-text);
}

.settings-guard-body {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--settings-text-secondary);
}

.settings-guard-note {
  margin: 0.6rem 0 0;
  font-size: 0.8rem;
  color: var(--settings-red);
}

.settings-guard-note[hidden] {
  display: none;
}

/* "Keep editing" sits leftmost and "Save changes" rightmost, so the least destructive answer is
 * furthest from the button the user was already reaching for when the dialog appeared. */
.settings-guard-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.settings-guard-actions button[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .settings-modal-overlay,
  .settings-modal,
  .settings-tab-btn,
  .settings-toggle-track,
  .settings-toggle-track::after,
  .settings-linkout-card,
  .settings-btn-primary,
  .settings-btn-secondary {
    transition: none;
  }
}

/* Below ~860px there isn't room for a 250px sidebar next to real content, so the sidebar becomes
 * a horizontal scroller above the content pane instead: section grouping (headers + dividers)
 * drops — there's no room to show it and no room lost by dropping it, since the group a narrow
 * screen cares about is "which item is active" — and the active-item accent moves from a left
 * border to a bottom border to match the now-horizontal row. Known gap: this strip does not
 * scroll the active item into view on activation, so on a very long list the current item can
 * still sit offscreen after a click elsewhere scrolls the strip. */
@media (max-width: 860px) {
  .settings-modal-main {
    flex-direction: column;
  }

  .settings-sidebar-nav {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.6rem;
    overflow-x: auto;
    overflow-y: visible;
    border-right: none;
    border-bottom: 1px solid var(--settings-border-light);
  }

  .settings-sidebar-heading,
  .settings-sidebar-divider {
    display: none;
  }

  .settings-tab-btn {
    width: auto;
    flex-shrink: 0;
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
    border-radius: var(--settings-radius) var(--settings-radius) 0 0;
  }

  .settings-tab-btn.is-active {
    border-left-color: transparent;
    border-bottom-color: var(--settings-red);
  }
}

@media (max-width: 560px) {
  .settings-modal-overlay {
    padding: 0;
    align-items: stretch;
  }

  /* Matches `.is-wide`'s specificity (two classes) so this full-bleed override wins the cascade
   * at this width regardless of `.is-wide` being present — a plain `.settings-modal` selector here
   * would lose to `.settings-modal.is-wide`'s higher specificity and never take effect. */
  .settings-modal,
  .settings-modal.is-wide {
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 0;
  }
}
