:root {
  --ink: #1d1d1b;
  --paper: #f4f1ea;
  --card: #fbf9f4;
  --line: #d8d3c8;
  --muted: #6b675f;
  --ok: #2f6b3a;
  --bad: #9b2c2c;
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.45 Georgia, "Iowan Old Style", serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
main { max-width: 32rem; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
svg { fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.mark { width: 44px; height: 44px; flex: none; }
h1 { font-size: 1.6rem; margin: 0; line-height: 1.1; }
.steps { padding: 0; margin: 0 0 1.25rem; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0.35rem 0 0.35rem 2.4rem; color: var(--muted); }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0.3rem;
  width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid var(--ink);
  font: 700 0.85rem/1.45rem system-ui, sans-serif; text-align: center; color: var(--ink);
}
.steps b { color: var(--ink); }
form { display: flex; gap: 0.5rem; }
input#code {
  flex: 1; min-width: 0;
  font: 700 1.7rem/1 ui-monospace, Menlo, monospace; letter-spacing: 0.35em; text-align: center;
  padding: 0.6rem 0 0.6rem 0.35em; border: 2px solid var(--ink); border-radius: 10px; background: #fff; color: var(--ink);
}
input#code::placeholder { color: #c9c3b6; }
button {
  font: 600 1rem/1 -apple-system, system-ui, sans-serif;
  padding: 0 1.3rem; border: 2px solid var(--ink); border-radius: 10px;
  background: var(--ink); color: var(--paper); cursor: pointer;
}
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem; text-align: center;
  margin: 1rem 0 0.5rem; padding: 2rem 1.25rem; cursor: pointer;
  border: 2px dashed var(--ink); border-radius: 14px; background: var(--card);
}
.pick svg { width: 48px; height: 48px; }
.pick-title { font: 700 1.2rem/1.2 -apple-system, system-ui, sans-serif; }
.pick-sub { color: var(--muted); font-size: 0.92rem; }
.pick input { display: none; }
.error { color: var(--bad); }
.status { display: flex; align-items: center; gap: 0.5rem; font-family: system-ui, sans-serif; margin: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.status.off .dot { background: var(--bad); }
ul { list-style: none; padding: 0; margin: 1rem 0 0; }
li.file { border-top: 1px solid var(--line); padding: 0.75rem 0; }
li .name { word-break: break-word; font-weight: 700; font-family: system-ui, sans-serif; }
li .meta { font: 0.85rem/1.3 system-ui, sans-serif; color: var(--muted); margin-top: 0.25rem; }
li.ok .meta { color: var(--ok); }
li.bad .meta { color: var(--bad); }
progress { width: 100%; height: 6px; margin-top: 0.4rem; accent-color: var(--ink); }
li.ok progress, li.bad progress { display: none; }
header .status { margin-top: 0.3rem; font-size: 0.9rem; color: var(--muted); }
nav#tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0 0 1rem;
  border: 2px solid var(--ink); border-radius: 10px; overflow: hidden;
}
nav#tabs button {
  border: 0; border-radius: 0; background: var(--card); color: var(--ink);
  padding: 0.75rem 0.2rem; font-size: 0.88rem;
}
nav#tabs button + button { border-left: 2px solid var(--ink); }
nav#tabs button.on { background: var(--ink); color: var(--paper); }
.meter { margin: 0.25rem 0 1rem; font-family: system-ui, sans-serif; }
.meter-head { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 0.35rem; }
.meter-label { font-weight: 700; }
.meter-free { color: var(--muted); }
.meter-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; background: var(--ink); }
ul.rows li { display: flex; align-items: center; gap: 0.75rem; border-top: 1px solid var(--line); padding: 0.75rem 0; }
.row-text { flex: 1; min-width: 0; }
.row-title { font: 700 1rem/1.3 system-ui, sans-serif; word-break: break-word; }
.row-meta { font: 0.82rem/1.35 system-ui, sans-serif; color: var(--muted); margin-top: 0.15rem; }
li.empty { color: var(--muted); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); padding: 0.55rem 0.8rem; font-size: 0.85rem; flex: none; }
button.danger.armed { background: var(--bad); color: #fff; }
button:disabled { opacity: 0.4; }
.builtin { font: 0.8rem system-ui, sans-serif; color: var(--muted); flex: none; }
.settings .field { border-top: 1px solid var(--line); padding: 0.9rem 0; }
.field-label { display: block; font: 700 1rem system-ui, sans-serif; margin-bottom: 0.5rem; }
.field-help { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.88rem; }
.settings input { width: 100%; font: 1rem system-ui, sans-serif; padding: 0.65rem; border: 2px solid var(--ink); border-radius: 10px; background: #fff; }
.choice { display: flex; gap: 0.5rem; }
.choice button { flex: 1; background: var(--card); color: var(--ink); padding: 0.7rem; }
.choice button.on { background: var(--ink); color: var(--paper); }
.stepper { display: flex; align-items: center; gap: 0.75rem; }
.stepper button { width: 3rem; height: 3rem; padding: 0; font-size: 1.4rem; }
.stepper output { min-width: 2.5rem; text-align: center; font: 700 1.3rem system-ui, sans-serif; }
.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 0.7rem 1.1rem; border-radius: 10px;
  font: 0.92rem system-ui, sans-serif; max-width: 90vw; margin: 0;
}
.toast.bad { background: var(--bad); }
[hidden] { display: none !important; }
form.settings { display: block; }
.field-help { font-family: system-ui, sans-serif; }
h2.section { font: 700 1.1rem system-ui, sans-serif; margin: 1.6rem 0 0.4rem; }
form.wifi-add { display: grid; gap: 0.5rem; margin-top: 0.75rem; }
form.wifi-add input { font: 1rem system-ui, sans-serif; padding: 0.65rem; border: 2px solid var(--ink); border-radius: 10px; background: #fff; }
form.wifi-add button { padding: 0.8rem; font-size: 1rem; }
