:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --text: #16181d;
  --muted: #5f6672;
  --border: #dcdfe5;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --done: #1f9d55;
  --done-soft: #e3f5ea;
  --tip-bg: #e8f0ff;
  --tip-ink: #1d4fb8;
  --warn-bg: #fff4dc;
  --warn-ink: #8a5a00;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2026;
    --surface-2: #272b33;
    --text: #eef0f3;
    --muted: #9aa1ad;
    --border: #2f343d;
    --accent: #5b8cff;
    --accent-ink: #0b0d10;
    --done: #3ccf7a;
    --done-soft: #17301f;
    --tip-bg: #1a2640;
    --tip-ink: #9dbaff;
    --warn-bg: #33270f;
    --warn-ink: #f2c66b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; font-weight: 650; font-size: 17px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: 0; background: transparent; font-size: 22px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); }
.topbar .icon-btn[hidden] + .topbar-title { margin-left: 48px; }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 120px; }

/* ---------- Home ---------- */
.hero h1 { font-size: 26px; margin: 8px 0 4px; }
.hero p { margin: 0 0 20px; color: var(--muted); }
.guide-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.guide-card.soon { opacity: .55; }
.guide-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.guide-icon { font-size: 30px; width: 48px; height: 48px; display: grid; place-items: center; background: var(--surface-2); border-radius: 12px; }
.guide-head h2 { margin: 0; font-size: 19px; }
.guide-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.routine-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.routine-btn {
  text-align: left; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.routine-btn strong { display: block; font-size: 16px; }
.routine-btn span { font-size: 13px; color: var(--muted); }
.mini-bar { height: 5px; border-radius: 9px; background: var(--border); margin-top: 8px; overflow: hidden; }
.mini-bar > i { display: block; height: 100%; background: var(--accent); }
.mini-bar.full > i { background: var(--done); }

/* ---------- Progress header ---------- */
.progress-wrap { margin-bottom: 14px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.progress { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }
.progress.full > i { background: var(--done); }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- Step card (step-by-step view) ---------- */
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.step-card.is-done { border-color: var(--done); }
.step-body { padding: 16px; }
.step-section { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.step-title { font-size: 22px; margin: 4px 0 12px; line-height: 1.25; }
.step-title .num { color: var(--muted); font-weight: 500; }

.photo { position: relative; aspect-ratio: 4 / 3; max-width: 100%; background: var(--surface-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo-ph {
  position: absolute; inset: 12px; border: 2px dashed var(--border); border-radius: 10px;
  display: grid; place-content: center; text-align: center; color: var(--muted); gap: 4px;
}
.photo-ph b { font-size: 36px; }
.photo-ph small { font-size: 12px; opacity: .8; }
.photo-caption { font-size: 13px; color: var(--muted); padding: 8px 16px 0; }
.photo-credit { display: block; font-size: 11px; opacity: .75; }
.photo-badge {
  position: absolute; top: 10px; left: 10px; pointer-events: none;
  background: rgba(0,0,0,.65); color: #fff; font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 99px;
}

.instructions { margin: 0 0 12px; padding-left: 22px; }
.instructions li { margin-bottom: 8px; }
.note-box { border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 15px; }
.note-box.tip { background: var(--tip-bg); color: var(--tip-ink); }
.note-box.warn { background: var(--warn-bg); color: var(--warn-ink); }

.user-note summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-top: 8px; }
.user-note textarea {
  width: 100%; min-height: 70px; margin-top: 8px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; resize: vertical;
}
.done-stamp { font-size: 13px; color: var(--done); font-weight: 600; margin-top: 8px; }

/* Bottom action bar */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 10px);
}
.action-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; }
.btn {
  border: 1px solid var(--border); background: var(--surface-2);
  padding: 14px 16px; border-radius: 12px; font-weight: 650; font-size: 16px;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { flex: 1; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.done { flex: 1; background: var(--done-soft); border-color: var(--done); color: var(--done); }
.btn.block { width: 100%; }

/* ---------- List view ---------- */
.list-section { margin-bottom: 18px; }
.list-section h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; display: flex; justify-content: space-between; }
.list-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; margin-bottom: 8px; text-align: left;
}
.check {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--border); display: grid; place-items: center;
  background: transparent; font-size: 16px; color: transparent;
}
.list-item.is-done .check, .check.on { background: var(--done); border-color: var(--done); color: #fff; }
.list-item.is-done .li-title { color: var(--muted); text-decoration: line-through; }
.li-text { flex: 1; min-width: 0; }
.li-title { font-weight: 600; }
.li-sub { font-size: 13px; color: var(--muted); }
.li-go { color: var(--muted); font-size: 20px; }

/* ---------- Complete ---------- */
.complete { text-align: center; padding: 30px 10px; }
.complete .big { font-size: 64px; }
.complete h2 { margin: 8px 0; }
.complete p { color: var(--muted); }
.summary-notes { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 20px 0; }
.summary-notes h3 { margin: 0 0 8px; font-size: 15px; }
.summary-notes li { margin-bottom: 6px; }

.log-status { font-size: 14px; }
.log-status.sent { color: var(--done); }
.log-status.pending, .log-status.off { color: var(--warn-ink); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; }

/* ---------- Start screen ---------- */
.start-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 16px; margin-top: 8px;
}
.start-card .guide-icon { margin-bottom: 10px; }
.start-card h2 { margin: 0 0 4px; }
.start-sub { margin: 0 0 18px; color: var(--muted); }
.field-error { color: #d33; margin: -4px 0 12px; font-size: 14px; }

/* ---------- Lightbox & sheet ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 8px; }
.lightbox-close { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 12px; color: #fff; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 520px; background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
}
.sheet h3 { margin: 0 0 12px; }
.sheet .btn { width: 100%; margin-bottom: 10px; text-align: left; }
.sheet .btn.danger { color: #d33; }
.field label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; margin-bottom: 12px;
}

@media (min-width: 700px) {
  .step-title { font-size: 26px; }
}
