/* Screen: settings (overlay) — big on/off switches for the captain; grown-up tools behind
   a 2-second press-and-hold. Two columns on wide screens, one on tablets in portrait and phones. */

.screen--settings {
  gap: var(--sp-4);
}

.screen--settings.is-rerender,
.screen--settings .mate.is-still {
  animation: none;
}

/* ── Header ────────────────────────────────────────────── */
.st-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.st-head__sub {
  margin-top: var(--sp-1);
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--ink-soft);
}

/* ── Layout ────────────────────────────────────────────── */
.st-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--sp-4) var(--sp-5);
  align-items: start;
}

@media (max-width: 53.75em) {
  .st-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.st-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid rgba(13, 48, 71, 0.06);
  box-shadow: var(--shadow-2);
  min-width: 0;
}

.st-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.st-card__title {
  font-size: var(--fs-lg);
}

/* ── Switch rows ───────────────────────────────────────── */
.st-switch {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 64px;
  padding: var(--sp-3) var(--sp-4);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--sea-50);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}

.st-switch:hover {
  border-color: var(--sea-300);
}

.st-switch.is-on {
  background: var(--gain-bg);
  border-color: var(--green-300);
}

.st-switch__emoji {
  flex: none;
  font-size: 1.8rem;
  line-height: 1;
}

.st-switch__text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.st-switch__title {
  font-weight: 900;
  font-size: var(--fs-md);
  line-height: 1.2;
}

.st-switch__sub {
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.st-switch__state {
  flex: none;
  min-width: 2.2em;
  text-align: right;
  font-weight: 900;
  color: var(--ink-faint);
}

.st-switch.is-on .st-switch__state {
  color: var(--gain);
}

.st-switch__track {
  flex: none;
  position: relative;
  width: 60px;
  height: 34px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  transition: background-color var(--dur-2) var(--ease);
}

.st-switch.is-on .st-switch__track {
  background: var(--gain);
}

.st-switch__knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-2) var(--ease);
}

.st-switch.is-on .st-switch__knob {
  transform: translateX(26px);
}

/* ── Press-and-hold buttons (also in dialogs and the safe page) ── */
.hold {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: none;
}

.hold__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--accent-200);
  transform: scaleX(var(--hold, 0));
  transform-origin: left center;
}

.hold.btn--quiet .hold__fill {
  background: var(--sand-200);
}

.hold.is-holding {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--btn-shadow);
}

/* ── Grown-up tools ────────────────────────────────────── */
.st-grown.is-locked {
  background: var(--sea-50);
  box-shadow: var(--shadow-1);
}

.st-tool {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 2px dashed var(--line);
}

.st-tool__title {
  font-size: var(--fs-md);
}

.st-code {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: var(--fs-sm);
  line-height: 1.35;
  word-break: break-all;
}

.st-error {
  margin: 0 !important;
  font-weight: 800;
  color: var(--ink-soft);
}

.st-error:not(:empty) {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  background: var(--sand-100);
  border: 2px solid var(--sand-400);
  color: var(--ink);
}

.st-danger__warn {
  font-weight: 900;
}

.st-tool__actions {
  flex-wrap: wrap;
}

/* Who is sailing + "Switch captain". */
.st-who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 2px dashed var(--line);
}

.st-who__text {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0 !important;
  min-width: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.st-who__emoji {
  font-size: 1.6rem;
  line-height: 1;
}

/* "Switch captain" while her last moves are not saved: the file first, or a grown-up's hold. */
.st-who__unsaved {
  flex: 1 1 100%;
}

.st-who__unsaved > p {
  margin: 0;
}

/* "Load a backup" (Settings and the title screen). */
.bk-load {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.bk-load__actions {
  flex-wrap: wrap;
}

/* "Load this backup?" */
.bk-confirm__ship {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-2);
}

.bk-confirm__ship .ship-art {
  width: min(300px, 100%);
  height: auto;
}

.bk-confirm__who {
  font-size: var(--fs-md);
  font-weight: 900;
}

.bk-confirm__replace {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 2px dashed var(--line);
}

/* ── Footer ────────────────────────────────────────────── */
.st-foot {
  display: flex;
  justify-content: center;
}

@media (max-width: 37.5em) {
  .st-card {
    padding: var(--sp-4);
    border-radius: var(--r-md);
  }

  .st-switch {
    padding: var(--sp-3);
    gap: var(--sp-2);
  }

  .st-switch__state {
    display: none;
  }

  .screen--settings .hold,
  .bk-confirm .hold {
    width: 100%;
  }

  .bk-load__actions .btn,
  .st-tool__actions .btn,
  .st-who .btn {
    flex: 1 1 auto;
  }
}
