:root {
  --bg: #10110e;
  --card: #1c1f17;
  --card-2: #262a1e;
  --ink: #f6f3ea;
  --muted: #a39e8e;
  --line: #3a3f31;
  --accent: #ff5c24;
  --accent-ink: #2a0d05;
  --ok: #d6f06a;
  --photo: #fff;
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  touch-action: manipulation;
}

body {
  min-height: 100dvh;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

button, input, a { font: inherit; color: inherit; }

button { cursor: pointer; }

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px 28px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  padding-bottom: 8px;
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 4px 0 10px;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.brand p, .hint, .meta, .sets, .cue, .more, .weight-meta, .backup p {
  margin: 0;
  color: var(--muted);
}

.chips, .scheme {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chips { margin-bottom: 8px; }

.chips a, .scheme button, .gear button, .backup button, .file {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  border-radius: 999px;
  padding: 10px 14px;
  white-space: nowrap;
  min-height: 44px;
}

.chips a.on, .scheme button.on, .gear button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.dayline {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin: 8px 0;
}

.dayline h2 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}

.scheme { flex: 0 0 auto; }

.scheme button {
  min-width: 52px;
  padding-inline: 16px;
  font-weight: 700;
}

.hint {
  margin-bottom: 12px;
  line-height: 1.35;
}

.ex {
  background: var(--card);
  border-radius: 18px;
  padding: 12px;
  margin-bottom: 12px;
}

.ex-open {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  margin-bottom: 12px;
}

.thumb, .photo img, #zoom img {
  width: 100%;
  display: block;
  background: var(--photo);
  object-fit: contain;
}

.thumb {
  height: 72px;
  border-radius: 12px;
}

.ex h2, .detail h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.more {
  margin-top: 6px;
  color: var(--ok);
  font-size: 0.92rem;
}

.stepper {
  display: grid;
  grid-template-columns: 76px 1fr 76px;
  gap: 8px;
  align-items: stretch;
}

.stepper.text {
  grid-template-columns: 1fr;
}

.step {
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-weight: 800;
}

.step .sign { font-size: 1.4rem; }
.step .delta { font-size: 0.85rem; margin-top: 4px; }

.weight {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-radius: 14px;
  padding: 0 10px;
  min-height: 64px;
}

.weight input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  text-align: center;
  min-width: 0;
  padding: 0;
}

.weight input:focus { outline: none; }
.weight:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }

.unit { color: var(--muted); font-size: 0.95rem; }

.weight-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.85rem;
}

.badge {
  color: var(--ok);
}

.backrow {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.backrow a, .backrow button, .backup button, .file {
  border-radius: 12px;
  min-height: 44px;
}

.backrow a, .backrow button {
  border: 1px solid var(--line);
  background: var(--card);
  text-decoration: none;
  padding: 10px 14px;
}

.photo {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  margin: 8px 0 14px;
  background: var(--photo);
}

.photo img { max-height: 280px; object-fit: contain; }

.detail h3 {
  margin: 16px 0 8px;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail ol, .detail ul {
  margin: 0;
  padding-left: 1.2rem;
  line-height: 1.4;
}

.detail li { margin: 0 0 8px; }

.gear { display: flex; flex-wrap: wrap; gap: 8px; }

.sub {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  background: var(--card-2);
  border-radius: 14px;
  padding: 8px;
  margin-bottom: 8px;
}

.sub img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: var(--photo);
  border-radius: 10px;
}

.sub strong { display: block; }
.sub span { color: var(--muted); font-size: 0.88rem; }

.empty {
  color: var(--muted);
  line-height: 1.4;
}

.home-list { display: grid; gap: 10px; margin-top: 12px; }

.home-list a {
  display: block;
  text-decoration: none;
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  min-height: 72px;
}

.home-list strong { display: block; font-size: 1.25rem; }
.home-list span { color: var(--muted); }

.backup {
  margin-top: 18px;
  color: var(--muted);
}

.backup summary { cursor: pointer; min-height: 44px; }
.backup p { margin: 8px 0; line-height: 1.35; }
.backup .row { display: flex; flex-wrap: wrap; gap: 8px; }
.file { display: inline-flex; align-items: center; }
.file input { display: none; }

#zoom[hidden] { display: none; }

#zoom {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: #fff;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 8px env(safe-area-inset-bottom);
}

#zoom button {
  align-self: flex-end;
  border: 0;
  background: #111;
  color: #fff;
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 16px;
  margin: 8px;
}

#zoom img {
  flex: 1;
  min-height: 0;
  object-fit: contain;
  background: #fff;
}

:focus-visible {
  outline: 2px solid var(--ok);
  outline-offset: 2px;
}
