/* Mobile-first. System fonts only, no external resources. */
:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --fg: #1a1918;
  --muted: #6b6963;
  --rule: #1a1918;
  --line: #dcd8d0;
  --badge: #ebe7de;
  --btn: #1f1d1c;
  --btn-fg: #ffffff;
  --error: #b42318;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151413;
    --surface: #1e1c1b;
    --fg: #f4f2ee;
    --muted: #a19d94;
    --rule: #f4f2ee;
    --line: #3a3733;
    --badge: #2c2927;
    --btn: #f4f2ee;
    --btn-fg: #1a1918;
    --error: #f97066;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

.bar {
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  text-align: center;
  font: 26px/1 var(--serif);
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 28px 20px calc(env(safe-area-inset-bottom) + 32px);
}

section + section { margin-top: 44px; }

h1 {
  margin: 0 0 4px;
  font: 700 32px/1.15 var(--serif);
  letter-spacing: -0.01em;
}
.sub { margin: 0 0 18px; color: var(--muted); }
.rule { border: 0; border-top: 2px solid var(--rule); margin: 0; }

/* A row: badge, text, optional action. Dotted divider between rows. */
.row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 18px 0;
  border-bottom: 1px dotted var(--line);
}
.row.plain { grid-template-columns: 1fr auto; }
.row:last-child { border-bottom: 0; }
.badge {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--badge);
  font: 600 22px/1 var(--serif);
}
.title { font-weight: 600; overflow-wrap: anywhere; }
.detail { color: var(--muted); overflow-wrap: anywhere; }

label.field { display: block; padding: 14px 0 0; }
label.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="email"], input[type="tel"], input:not([type]) {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  font: inherit;
  font-size: 17px; /* 16px+ stops iOS zooming on focus */
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  font-family: inherit;
  font-weight: 600;
  font-size: 17px;
  line-height: 1;
  color: var(--btn-fg);
  background: var(--btn);
  border: 1px solid var(--btn);
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
}
button.secondary { color: var(--fg); background: transparent; border-color: var(--line); }
button.small { min-height: 40px; padding: 0 16px; font-size: 16px; }
button:disabled { opacity: 0.45; cursor: default; }

.actions { display: grid; gap: 12px; margin-top: 28px; }
.actions button { width: 100%; }

/* iOS-style switch on a native checkbox, so it stays accessible and clickable. */
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 51px; height: 31px; margin: 0;
  border-radius: 31px;
  background: var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
  transition: transform 0.15s;
}
input[type="checkbox"]:checked { background: #34c759; }
input[type="checkbox"]:checked::after { transform: translateX(20px); }

.note { color: var(--muted); font-size: 15px; }
.error { color: var(--error); font-weight: 600; }
a { color: inherit; }
:focus-visible { outline: 3px solid #3b82f6; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

select {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  font: inherit;
  font-size: 17px;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.tag {
  font-size: 14px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
a.button.secondary { color: var(--fg); background: transparent; border-color: var(--line); }

.hero { padding: 12px 0 8px; }
.hero h1 { font-size: 38px; line-height: 1.1; margin-bottom: 16px; }
.lead { font-size: 19px; color: var(--muted); margin: 0 0 8px; }
h2 { margin: 0 0 4px; font: 700 26px/1.2 var(--serif); }

/* Console forms: multi-line field list, grouped switches, compact row actions. */
textarea {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 15px;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  resize: vertical;
}
fieldset { border: 0; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: center; }
legend { padding: 0; margin-bottom: 12px; font-weight: 600; }
label.inline { font-size: 17px; }
.actions.inline { display: flex; margin-top: 0; gap: 8px; }
.actions.inline button { width: auto; }
#key-value { font-family: ui-monospace, Menlo, monospace; font-size: 15px; }
#new-key { margin-bottom: 28px; }
