/* The home page: phone-first, one column, 16 px gutters, dark and light. Operate mode: scan, tap, done. */
:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #1d1b16;
  --muted: #6b665c;
  --line: #e2ddd2;
  --accent: #b5471f;
  --accent-ink: #ffffff;
  --good: #2f7a4a;
  --warn: #9a6a00;
  --warn-bg: #fff4d6;
  --code-bg: #f0ece3;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15140f;
    --card: #1f1d17;
    --ink: #f2eee4;
    --muted: #a39d90;
    --line: #2d2a22;
    --accent: #e0693a;
    --accent-ink: #15140f;
    --good: #6fcf8f;
    --warn: #f0c35a;
    --warn-bg: #2d2611;
    --code-bg: #26231b;
  }
}
:root[data-theme="dark"] {
  --bg: #15140f;
  --card: #1f1d17;
  --ink: #f2eee4;
  --muted: #a39d90;
  --line: #2d2a22;
  --accent: #e0693a;
  --accent-ink: #15140f;
  --good: #6fcf8f;
  --warn: #f0c35a;
  --warn-bg: #2d2611;
  --code-bg: #26231b;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}
.top {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 0 10px;
}
.brand-name { font-weight: 800; letter-spacing: 0.08em; }
.brand-sub { color: var(--muted); margin-left: 6px; }
.who { color: var(--muted); font-size: 14px; text-align: right; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stack { display: grid; gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin: 0 0 8px; font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); margin: 4px 0 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.hidden { display: none !important; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 12px 16px; font: inherit; font-weight: 600; min-height: 44px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; min-height: 36px; font-weight: 500; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.wide { width: 100%; }

.code-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.code {
  font: 700 26px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.18em;
  background: var(--code-bg); padding: 12px 14px; border-radius: 10px; user-select: all;
}
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.pet { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; }
.pet-face { width: 56px; height: 56px; border-radius: 14px; background: var(--code-bg); display: grid; place-items: center; font-size: 28px; }
.pet-name { font-weight: 700; }
.bar { height: 8px; background: var(--code-bg); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--code-bg); }

.stat { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stat:last-of-type { border-bottom: 0; }
.stat b { font-size: 20px; }

.chest { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 8px; }
.chest h3 { margin: 0 0 6px; font-size: 15px; }
.chest ul { margin: 6px 0 0; padding-left: 18px; }
.chest .reason { color: var(--warn); }
.check { font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; word-break: break-all; color: var(--muted); margin-top: 8px; }
.good { color: var(--good); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border-radius: 12px; background: var(--code-bg); margin-bottom: 10px; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: 14px;
  min-height: 40px; border-radius: 9px; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.board { list-style: none; margin: 0; padding: 0; }
.board li { display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); }
.board li:last-child { border-bottom: 0; }
.board .rk { font-weight: 800; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.board li:first-child .rk { color: var(--accent); }
.board .nm { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .tm { font-weight: 800; font-variant-numeric: tabular-nums; }
.board .st { grid-column: 2 / 4; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.board li.me { background: var(--code-bg); border-radius: 10px; padding: 9px 8px; border-bottom: 0; }
.board-gap { text-align: center; color: var(--muted); font-size: 13px; padding: 2px 0; }
.small { font-size: 13px; }
.name-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.input { flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink); background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; min-height: 40px; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
