:root {
  --bg: #f6f4ee;
  --card: #ffffff;
  --ink: #1f2a22;
  --muted: #5f6b62;
  --line: #ddd8cc;
  --brand: #2f5d3a;
  --brand-ink: #ffffff;
  --accent: #c8792e;
  --warn: #a33a2a;
  --ok: #2f7a45;
  --chip: #e9efe6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141815;
    --card: #1e2420;
    --ink: #eef1ec;
    --muted: #a3ada5;
    --line: #333b35;
    --brand: #5f9c6c;
    --brand-ink: #0d120e;
    --accent: #e09a55;
    --warn: #ef7d6b;
    --ok: #6fc28a;
    --chip: #263029;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand); color: var(--brand-ink);
}
.bar a { color: inherit; text-decoration: none; font-weight: 700; }
#who { font-size: 14px; opacity: .9; }
main { max-width: 560px; margin: 0 auto; padding: 16px; }
h1 { font-size: 24px; margin: 8px 0 4px; }
h2 { font-size: 19px; margin: 24px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 14px; }

.tile {
  display: block; width: 100%; text-align: left; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 16px; margin: 12px 0; font: inherit; cursor: pointer;
}
.tile .t { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 20px; }
.tile .s { color: var(--muted); margin-top: 4px; }
.count {
  min-width: 34px; height: 34px; border-radius: 17px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-size: 17px;
}
.count.zero { background: var(--chip); color: var(--ok); font-size: 14px; }

.row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin: 8px 0; text-decoration: none; color: inherit;
}
.row .l { min-width: 0; }
.row .l b { display: block; overflow-wrap: anywhere; }
.chip { font-size: 13px; padding: 3px 9px; border-radius: 10px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.chip.warn { color: var(--warn); }
.chip.ok { color: var(--ok); }

.btn {
  display: block; width: 100%; padding: 16px; margin: 12px 0; border: 0; border-radius: 12px;
  background: var(--brand); color: var(--brand-ink); font-family: inherit; font-size: 18px; font-weight: 700; line-height: 1.2; text-align: center;
  text-decoration: none; cursor: pointer;
}
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.btn.danger { background: var(--card); color: var(--warn); border: 1px solid var(--warn); font-weight: 600; }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--brand); font: inherit; text-decoration: underline; padding: 8px 0; cursor: pointer; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 12px 0; }
.keys {
  white-space: pre-wrap; font: 700 26px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1px;
  background: var(--chip); border-radius: 10px; padding: 12px; margin: 8px 0; overflow-wrap: anywhere;
}
.code { font: 700 44px/1 ui-monospace, Menlo, monospace; letter-spacing: 6px; text-align: center; padding: 16px 0; }
.step { display: flex; gap: 12px; }
.step .n {
  flex: 0 0 32px; height: 32px; border-radius: 16px; background: var(--brand); color: var(--brand-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.step .b { flex: 1; min-width: 0; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
textarea { min-height: 120px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 22px; height: 22px; flex: 0 0 22px; margin-top: 2px; }
.msg { white-space: pre-wrap; background: var(--chip); border-radius: 10px; padding: 12px; }
.photo { width: 100%; border-radius: 10px; border: 1px solid var(--line); margin: 8px 0; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 528px; margin: 0 auto; padding: 14px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-weight: 600; z-index: 5;
}
.error { color: var(--warn); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
footer.links { margin: 32px 0 16px; text-align: center; font-size: 14px; }
footer.links a { color: var(--muted); margin: 0 8px; }
