/* ============================================================
   settings-shell.css — "Settings Shell" for pages/settings.html
   (see settings-layout-suggestion.md)

   Loaded AFTER css/series-shell.css (for the neutral --ss-* token
   scale) and AFTER css/main.css, so it supersedes the old
   .settings-layout / .settings-nav / .settings-section rules on
   this page only. No other page references .st-shell, so nothing
   else in the project moves.

   Zones: st-identity -> st-controlzone (sticky tabs) ->
          st-panelhead -> st-panel (one at a time) -> st-savebar.

   One row component (.st-row), one group label (.st-group),
   three neutral buttons. No cards, no gradients, no icon chips,
   no purple, no radius above 8px.

   Spacing scale: 4 / 8 / 12 / 16 / 24 / 32 / 48px only.
   ============================================================ */

/* ---------- Shell frame (copied from .gs-shell) ---------- */
.st-shell {
  max-width: var(--ss-max, 1120px);
  margin: 0 auto;
  padding: 0 16px 48px;
  color: var(--ss-text);
}
.st-shell *,
.st-shell *::before,
.st-shell *::after { box-sizing: border-box; }

.st-shell a { color: inherit; }

.st-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- 1. Identity strip (mirrors .gs-identity) ---------- */
.st-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 24px 0 12px;
}
.st-h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--ss-text);
}
.st-identity-meta {
  font-size: 13px;
  color: var(--ss-text-muted);
  word-break: break-all;
}

/* ---------- 2. Sticky control zone (mirrors .gs-searchzone) ---------- */
.st-controlzone {
  position: sticky;
  /* The site header is sticky at the top, so the control zone docks
     directly beneath it — same position it holds on Global Search. */
  top: var(--header-height, 64px);
  z-index: 20;
  background: var(--ss-bg);
  border-bottom: 1px solid var(--ss-border);
}

/* Plain text tabs with a 2px underline — no pills, no icons. */
.st-tabs {
  display: flex;
  align-items: stretch;
  gap: 24px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.st-tabs::-webkit-scrollbar { display: none; }

.st-tab {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 12px 0;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--ss-text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.st-tab:hover { color: var(--ss-text); }
.st-tab[aria-selected="true"] {
  color: var(--ss-text);
  border-bottom-color: var(--ss-text);
}
.st-tab:focus-visible {
  outline: 2px solid var(--ss-border-strong);
  outline-offset: 2px;
}

/* ---------- 3. Panel head ---------- */
.st-panelhead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 24px 0 12px;
}
.st-panelhead-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ss-text);
}
.st-panelhead-count {
  margin-left: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ss-text-muted);
}
.st-panelhead-context {
  font-size: 13px;
  color: var(--ss-text-muted);
}

/* ---------- 4. Panels: flat bordered ledgers ---------- */
.st-panel {
  border: 1px solid var(--ss-border);
  border-radius: 8px;
  background: var(--ss-bg);
}
.st-panel[hidden] { display: none !important; }

/* Group label: uppercase 12px, muted, no icon */
.st-group {
  padding: 16px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ss-text-muted);
  border-top: 1px solid var(--ss-border);
}
.st-group:first-child { border-top: 0; }
.st-group-note {
  padding: 0 16px 8px;
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ss-text-muted);
}

/* The one row component */
.st-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 12px 16px;
  border-top: 1px solid var(--ss-border);
}
.st-row:first-child { border-top: 0; }
.st-group + .st-row { border-top: 0; }
.st-group-note + .st-row { border-top: 0; }

.st-row-main { min-width: 0; flex: 1 1 auto; }
.st-row-label {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ss-text);
}
.st-row-hint {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ss-text-muted);
}
.st-row-control {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Stacked variant for full-width inputs and rich content */
.st-row-stack {
  display: block;
}
.st-row-stack .st-row-control {
  display: block;
  margin-top: 8px;
}

/* Child rows under a master switch — indented once */
.st-row-child { padding-left: 32px; }

/* Fields inside rows */
.st-input,
.st-shell textarea.st-input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 12px;
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: 8px;
  color: var(--ss-text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
}
.st-shell textarea.st-input { resize: vertical; }
.st-input::placeholder { color: var(--ss-text-muted); }
.st-input:focus { outline: 0; border-color: var(--ss-border-strong); }
.st-input:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Buttons: same three variants as .gs-btn ---------- */
.st-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.st-btn i { font-size: 16px; }
.st-btn:disabled { opacity: .55; cursor: not-allowed; }
.st-btn:focus-visible {
  outline: 2px solid var(--ss-border-strong);
  outline-offset: 2px;
}
.st-btn-primary {
  background: var(--ss-primary-bg);
  color: var(--ss-primary-fg);
}
.st-btn-primary:hover:not(:disabled) { background: var(--ss-primary-bg-hover); }
.st-btn-secondary {
  background: var(--ss-secondary-bg);
  color: var(--ss-secondary-fg);
  border-color: var(--ss-secondary-border);
}
.st-btn-secondary:hover:not(:disabled) { background: var(--ss-secondary-bg-hover); }
.st-btn-ghost {
  background: transparent;
  color: var(--ss-ghost-fg);
}
.st-btn-ghost:hover:not(:disabled) { background: var(--ss-ghost-bg-hover); }

/* --error is the only colour on the page, reserved for Account/Danger */
.st-btn-danger {
  background: transparent;
  color: var(--error, #f87171);
  border-color: var(--error, #f87171);
}
.st-btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, .12); }

.st-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--ss-border);
}
.st-actions:first-child { border-top: 0; }

/* ---------- Switches inside the shell ---------- */
/* The switch keeps its id / data-pref / role / onclick from main.css;
   only its parent changed. These rules just normalise its metrics. */
.st-shell .toggle-switch {
  flex-shrink: 0;
  margin: 0;
}
.st-shell [data-pref][aria-busy="true"],
.st-shell .toggle-switch[aria-busy="true"] { opacity: .55; pointer-events: none; }

/* ---------- Status / notices ---------- */
.st-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--ss-border);
  background: var(--ss-surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--ss-text-muted);
}
.st-status.is-yes { color: #22c55e; border-color: rgba(34, 197, 94, .35); }
.st-status.is-no  { color: #f59e0b; border-color: rgba(245, 158, 11, .35); }

.st-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--ss-border);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ss-text-muted);
}
.st-notice:first-child { border-top: 0; }
.st-notice a { text-decoration: underline; }

.st-feedback {
  padding: 0 16px 12px;
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ss-text-muted);
}
.st-feedback:empty { display: none; }
.st-feedback.is-error { color: #f87171; }
.st-feedback.is-ok { color: #22c55e; }

.st-list {
  margin: 0;
  padding: 0 16px 12px 32px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ss-text-muted);
}

/* Cover preview / position pad live inside a stacked row */
.st-cover-pad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 4px;
  margin-top: 12px;
}
.st-cover-pad .st-btn { padding: 0; min-height: 44px; }

/* ---------- Per-surface visibility, re-skinned onto the ledger ---------- */
.st-shell .perctx-wrap { display: block; gap: 0; margin-top: 0; }
.st-shell .perctx-card {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--ss-border);
  border-radius: 0;
  padding: 12px 16px;
}
.st-shell .perctx-card:first-child { border-top: 0; }
.st-shell .perctx-card-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ss-text-muted);
  margin-bottom: 4px;
}
.st-shell .perctx-row {
  min-height: 44px;
  padding: 8px 0;
  border-top: 0;
}
.st-shell .perctx-row-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--ss-text);
}
.st-shell .perctx-btn {
  min-height: 36px;
  border-radius: 8px;
  font-size: 13px;
}

/* ---------- 5. Sticky save bar (only while dirty) ---------- */
.st-savebar {
  position: sticky;
  bottom: 0;
  z-index: 25;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding: 12px 16px;
  background: var(--ss-bg);
  border: 1px solid var(--ss-border);
  border-radius: 8px;
  box-shadow: var(--ss-shadow);
}
.st-savebar.is-dirty { display: flex; }
.st-savebar-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--ss-text-muted);
}
.st-savebar-actions { display: flex; gap: 8px; }

/* ---------- Responsive: same single column, only the tabs change ---------- */
@media (max-width: 720px) {
  .st-tabs {
    gap: 16px;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to right, #000 88%, transparent 100%);
    mask-image: linear-gradient(to right, #000 88%, transparent 100%);
  }
  .st-tab { scroll-snap-align: start; }
  .st-identity { padding: 16px 0 12px; }
  .st-row { flex-wrap: wrap; }
  .st-row-control { width: auto; }
  .st-row-child { padding-left: 24px; }
}
