:root {
  --bg: #f7f2ec; --card: #fff; --text: #2a1d15; --muted: #8a7869; --line: #e8ddd2;
  --accent: #8a4b2a; --accent-ink: #fff; --chip: #f1e6da; --danger: #b3261e; --star: #d38b2c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17110d; --card: #221a14; --text: #f3e9df; --muted: #a8978a; --line: #3a2d24;
    --accent: #d9915e; --accent-ink: #1b120c; --chip: #33261d; --danger: #f2756a; --star: #e9a94f;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-size: 26px; margin: 0; line-height: 1.2; }
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 8px; }
.muted { color: var(--muted); font-size: 14px; }
.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

header.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { flex: 1; font-weight: 700; }
.icon-btn { font-size: 24px; text-decoration: none; color: var(--accent); padding: 0 8px; line-height: 1; }
#back { font-size: 34px; margin-top: -4px; }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs a { flex: 1; text-align: center; padding: 8px 0 6px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
nav.tabs .ic { display: block; font-size: 22px; opacity: .45; filter: grayscale(1); }
nav.tabs a.active { color: var(--accent); }
nav.tabs a.active .ic { opacity: 1; filter: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.page-head + .muted { margin-top: -6px; }

.card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 10px; color: inherit; text-decoration: none;
}
.card:active { transform: scale(.99); }
.card.dim { opacity: .55; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.stars { color: var(--star); letter-spacing: 1px; white-space: nowrap; }
.stars.big { font-size: 26px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line);
  background: transparent; color: var(--text);
}
.chip.on { background: var(--chip); border-color: transparent; }
.tags .chip.on { background: var(--accent); color: var(--accent-ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  padding: 11px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 8px; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* Forms */
.form { display: flex; flex-wrap: wrap; column-gap: 12px; }
.form > .section { width: 100%; }
.field { width: 100%; margin-bottom: 14px; }
.field.half { width: calc(50% - 6px); }
.field label, .field .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: 13px; }
.field output { color: var(--accent); }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; }
.field.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.field.check input { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); }
input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--accent); min-height: 32px; }
.range-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.stars-input button { font-size: 34px; background: none; border: 0; padding: 0 4px; color: var(--line); cursor: pointer; }
.stars-input button.on { color: var(--star); }
.tag-add { margin-top: 10px; }

/* Detail */
.meta { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 12px 0; }
.meta dt { color: var(--muted); font-size: 14px; }
.meta dd { margin: 0; }
.notes { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 96px 1fr; align-items: center; font-size: 14px; }
meter { width: 100%; height: 10px; }
meter::-webkit-meter-bar { background: var(--chip); border: 0; border-radius: 6px; height: 10px; }
meter::-webkit-meter-optimum-value { background: var(--accent); border-radius: 6px; }
meter::-moz-meter-bar { background: var(--accent); }

.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; gap: 14px; padding: 10px 12px; border-radius: 10px; }
.steps .t { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 40px; }
.steps li.past { opacity: .45; }
.steps li.current { background: var(--chip); font-weight: 600; }
.steps li.current .t { color: var(--accent); }

/* Timer */
.timer { text-align: center; padding: 20px 0 12px; }
.clock { font-size: 76px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.now { font-size: 20px; font-weight: 600; min-height: 28px; margin-top: 12px; color: var(--accent); }

/* Bag scan */
.scan { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 18px; }
.scan .muted { flex: 1; min-width: 180px; }
.scan details { width: 100%; font-size: 14px; }
.scan summary { color: var(--accent); cursor: pointer; }
.scan pre { white-space: pre-wrap; font: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0 0; }
.field.filled :is(input, select) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
