/* Settings sheet — the operator controls (js/settings.js).
 *
 * Leans entirely on base.css for tokens and for .btn / .surface-card /
 * .sheet / .section-label. What is defined here is only what this screen adds:
 * the gear in the Feed header, the status rows, the verdict lines, the commit
 * log and the restart panel.
 *
 * Target is a 390x844 iPhone in standalone mode. Two rules drove the layout:
 * every button is at least 44px and full width (this screen is used one-handed,
 * often in a hurry, and a mis-tap here restarts the server), and every code-ish
 * string scrolls inside its own box rather than widening the sheet — a commit
 * subject or an npm error is arbitrarily long and must never cause a
 * horizontal scroll of the whole page.
 */

/* ---- The gear in the Feed header ---------------------------------------- */

.settings-gear {
  /* 44px of touch target around a small glyph: the visual weight has to stay
   * low (this is not a primary action) without making it hard to hit. */
  min-width: 44px;
  height: 44px;
  margin-right: -8px; /* pulls the optical edge back in line with the title */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 1.25rem;
  line-height: 1;
  transition: transform 0.12s var(--ease-out), color 0.12s ease;
}
.settings-gear:active {
  transform: scale(0.9);
  color: var(--text);
}

/* ---- Sheet body --------------------------------------------------------- */

.settings-body {
  display: flex;
  flex-direction: column;
}

.settings-body > .section-label:first-child { margin-top: 8px; }

.sys-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 56px 0;
}

.sys-error-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 32px 0;
  text-align: center;
  align-items: center;
}
.sys-error-block h2 { font-size: 1.1rem; font-weight: 700; }

/* ---- Status cards ------------------------------------------------------- */

.sys-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sys-headline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sys-version {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sys-commit,
.sys-mono,
.sys-log-sha {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
}

.sys-commit {
  background: var(--surface-3);
  color: var(--text-mid);
  border-radius: 6px;
  padding: 2px 6px;
}

.sys-subject {
  font-size: 0.95rem;
  color: var(--text-mid);
  /* A commit subject can be a paragraph. Two lines, then ellipsis. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sys-when { font-size: 0.8rem; }

.sys-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 26px;
}
.sys-row-label {
  font-size: 0.9rem;
  color: var(--text-dim);
  flex: none;
}
.sys-row-value {
  font-size: 0.9rem;
  text-align: right;
  overflow-wrap: anywhere;
}

/* ---- Verdict lines ------------------------------------------------------ */
/* The one line he reads before deciding whether to tap anything. Colour and
 * glyph both carry the meaning, because colour alone fails in sunlight and
 * fails for anyone colour-blind. */

.sys-verdict {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.88rem;
  line-height: 1.35;
}
.sys-verdict-icon {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 1px;
}
.sys-verdict-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.sys-verdict-detail { font-size: 0.8rem; }

.sys-verdict.sys-ok { border-color: color-mix(in srgb, var(--like) 35%, var(--line)); }
.sys-verdict.sys-ok .sys-verdict-icon { background: var(--like-dim); color: var(--like); }

.sys-verdict.sys-new { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.sys-verdict.sys-new .sys-verdict-icon { background: color-mix(in srgb, var(--accent) 25%, var(--surface-3)); color: var(--accent); }

.sys-verdict.sys-warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.sys-verdict.sys-warn .sys-verdict-icon { background: color-mix(in srgb, var(--warn) 20%, var(--surface-3)); color: var(--warn); }

.sys-verdict.sys-bad { border-color: color-mix(in srgb, var(--reject) 35%, var(--line)); }
.sys-verdict.sys-bad .sys-verdict-icon { background: var(--reject-dim); color: var(--reject); }

/* ---- Commit log and file lists ------------------------------------------ */

.sys-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sys-log-item {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.sys-log-sha { color: var(--accent); flex: none; }
.sys-log-subject {
  font-size: 0.87rem;
  color: var(--text-mid);
  overflow-wrap: anywhere;
}

.sys-files { margin-top: 4px; }
.sys-files > summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
}
.sys-file-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 240px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.sys-file {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: var(--text-mid);
  overflow-wrap: anywhere;
  padding: 2px 0;
}

/* ---- Actions ------------------------------------------------------------ */

.sys-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sys-action {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sys-action .btn { min-height: 50px; }
.sys-action-hint {
  font-size: 0.8rem;
  line-height: 1.35;
}

.sys-foot {
  font-size: 0.78rem;
  line-height: 1.4;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ---- Result panels ------------------------------------------------------ */

.sys-result {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
}
.sys-result-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.sys-result.sys-ok .sys-result-title { color: var(--like); }
.sys-result.sys-bad .sys-result-title { color: var(--reject); }
.sys-result-body {
  font-size: 0.92rem;
  color: var(--text-mid);
  line-height: 1.45;
}
.sys-result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}
.sys-result-actions .btn { min-height: 50px; }

.sys-steps {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sys-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.sys-step-icon {
  flex: none;
  width: 20px;
  text-align: center;
  font-weight: 700;
}
.sys-step.is-ok .sys-step-icon { color: var(--like); }
.sys-step.is-bad { border-color: color-mix(in srgb, var(--reject) 35%, var(--line)); }
.sys-step.is-bad .sys-step-icon { color: var(--reject); }
.sys-step-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 0.88rem;
}
.sys-step-text > .muted { font-size: 0.8rem; }
.sys-step-error { color: var(--reject); font-size: 0.84rem; line-height: 1.4; }

.sys-pre {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--text-mid);
  /* Scrolls itself rather than stretching the sheet. */
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* iOS Safari selects monospace text badly without this when the parent
   * disables callouts app-wide; the journal command exists to be copied. */
  -webkit-user-select: text;
  user-select: text;
}

.sys-journal {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.sys-journal .btn { align-self: flex-start; }

.sys-reload-note {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  margin-top: 8px;
}
.sys-reload-note p { font-size: 0.9rem; }

/* ---- Restarting --------------------------------------------------------- */

.sys-restarting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 64px 8px 40px;
  text-align: center;
}
.sys-restarting h2 { font-size: 1.2rem; font-weight: 700; }
.sys-restarting p { max-width: 32ch; font-size: 0.9rem; }

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

.sys-elapsed {
  font-size: 2.4rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--text-mid);
}

.sys-restart-note { font-size: 0.82rem; line-height: 1.4; }
