:root,
:root[data-theme="shop"] {
  color-scheme: light;
  --bg: #f3f0e7;
  --bg-outside: #e4dfd2;
  --ink: #1c1915;
  --muted: #4e4940;
  --card: #fffdf8;
  --line: #ddd4c4;
  --accent: #f0b400;
  --accent-press: #d9a200;
  --on-accent: #1c1915;
  --accept: #0f6b32;
  --reject: #a11d16;
  --hold: #8a5d00;
  --on-accept: #fff;
  --on-reject: #fff;
  --on-hold: #1c1915;
  --banner: #fff6d8;
  --banner-line: #e6d48a;
  --app-width: 480px;
  --shadow: 0 1px 0 rgba(28, 25, 21, 0.04);
}

:root[data-theme="night"] {
  color-scheme: dark;
  --bg: #14130f;
  --bg-outside: #0d0c0a;
  --ink: #f4f0e6;
  --muted: #b7b0a2;
  --card: #1e1c17;
  --line: #3a362e;
  --accent: #f0b400;
  --accent-press: #d9a200;
  --on-accent: #1c1915;
  --accept: #7dcea0;
  --reject: #f0a8a2;
  --hold: #f0b400;
  --on-accept: #14130f;
  --on-reject: #14130f;
  --on-hold: #1c1915;
  --banner: #2a2412;
  --banner-line: #6a5a20;
}

:root[data-theme="acco"] {
  color-scheme: light;
  --bg: #f3f6f9;
  --bg-outside: #e3ebf2;
  --ink: #2c333a;
  --muted: #5a636c;
  --card: #ffffff;
  --line: #d5dee6;
  --accent: #005996;
  --accent-press: #00497f;
  --on-accent: #ffffff;
  --accept: #0f6b32;
  --reject: #a11d16;
  --hold: #8a5a00;
  --on-accept: #fff;
  --on-reject: #fff;
  --on-hold: #1c1915;
  --banner: #e6f1f8;
  --banner-line: #b9d3e6;
  --shadow: 0 1px 0 rgba(0, 73, 127, 0.06);
}

:root[data-theme="field"] {
  color-scheme: light;
  --bg: #f7f4ea;
  --bg-outside: #111111;
  --ink: #111111;
  --muted: #3a3a3a;
  --card: #ffffff;
  --line: #111111;
  --accent: #f0b400;
  --accent-press: #d9a200;
  --on-accent: #111111;
  --accept: #0c5c2b;
  --reject: #9b1b14;
  --hold: #8a5a00;
  --on-accept: #fff;
  --on-reject: #fff;
  --on-hold: #111111;
  --banner: #fff3c4;
  --banner-line: #111111;
  --shadow: none;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg-outside);
  color: var(--ink);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior-y: none;
  touch-action: manipulation;
}

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

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: min(100%, var(--app-width));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
}

.sheet {
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  display: grid;
  gap: 14px;
  align-content: start;
}

.pad-tabs { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.pad-save { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }

h1, h2, p { margin: 0; }

h1 {
  font-size: clamp(1.7rem, 7vw, 2.05rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.lede { font-size: 1.05rem; }

.muted { color: var(--muted); }

.head { display: grid; gap: 6px; }

a { color: inherit; }

.banner {
  background: var(--banner);
  border: 1px solid var(--banner-line);
  border-radius: 12px;
  padding: 10px 12px;
}

.banner a { font-weight: 700; }

.meter {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.tally-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 16px;
}

.tally-row + .tally-row { border-top: 1px solid var(--line); }

.tally-row .label {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper .minus,
.stepper .plus,
.stepper .count {
  min-width: 56px;
  min-height: 56px;
  border-radius: 14px;
  font-size: 1.6rem;
  font-weight: 700;
  background: var(--card);
  border: 1.5px solid var(--line);
}

.stepper .plus {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.stepper .plus:active { background: var(--accent-press); }

.stepper .minus:disabled { opacity: 0.35; }

.stepper .count {
  min-width: 4.2ch;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  font-size: 2.1rem;
  font-variant-numeric: tabular-nums;
}

.stepper input {
  width: 5.4rem;
  min-height: 56px;
  padding: 8px;
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.logged { color: var(--muted); font-weight: 650; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1.5px solid transparent;
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  text-align: center;
}

.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:active { background: var(--accent-press); }
.btn.secondary { border-color: var(--line); background: var(--card); }
.btn.danger { background: transparent; color: var(--reject); min-height: 48px; }
.btn:disabled { opacity: 0.55; }

.row-btns { display: flex; gap: 8px; }
.row-btns .btn { flex: 1; }

input[type="text"],
input[type="search"],
input[type="date"],
textarea,
.field input,
.field textarea {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 16px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.35;
}

.welder-input {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  min-height: 64px;
}

.field { display: grid; gap: 6px; font-weight: 700; }
.field > span { font-size: 0.95rem; }

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

.chip {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 0.95rem;
  font-weight: 650;
  text-align: left;
  max-width: 100%;
}

.results {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.result-btn {
  min-height: 52px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-weight: 700;
}

.result-btn[data-result="accept"][aria-pressed="true"] {
  background: var(--accept);
  border-color: var(--accept);
  color: var(--on-accept);
}

.result-btn[data-result="reject"][aria-pressed="true"] {
  background: var(--reject);
  border-color: var(--reject);
  color: var(--on-reject);
}

.result-btn[data-result="hold"][aria-pressed="true"] {
  background: var(--hold);
  border-color: var(--hold);
  color: var(--on-hold);
}

.search-wrap input { width: 100%; }

#list, #day-results, .stack { display: grid; gap: 10px; }

.card {
  display: block;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--line);
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  overflow-wrap: anywhere;
}

.card.result-accept { border-left-color: var(--accept); }
.card.result-reject { border-left-color: var(--reject); }
.card.result-hold { border-left-color: var(--hold); }

.card-top, .day-card {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.day-card { display: grid; gap: 4px; }
.day-card span, .time, .where, .meta, .empty { color: var(--muted); }

.welder { font-size: 1.25rem; font-weight: 750; margin-top: 2px; }

.finding {
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-word {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card.result-accept .result-word,
.result-word.result-accept { color: var(--accept); }
.card.result-reject .result-word,
.result-word.result-reject { color: var(--reject); }
.card.result-hold .result-word,
.result-word.result-hold { color: var(--hold); }

.pin-block { display: grid; }
.pin-actions { display: flex; gap: 18px; align-items: center; }

.facts { display: grid; gap: 12px; margin: 0; }
.facts div { display: grid; gap: 2px; }
.facts dt { color: var(--muted); font-size: 0.85rem; font-weight: 700; }
.facts dd { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }

.text-btn {
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
}

.note { white-space: pre-wrap; overflow-wrap: anywhere; }

.gps-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  overflow-wrap: anywhere;
}

.photo-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.photo-strip figure {
  position: relative;
  width: 96px;
  flex: none;
  margin: 0;
}

.photo-strip .shot {
  position: relative;
  z-index: 1;
  width: 96px;
  padding: 0;
  border: 0;
  background: none;
  line-height: 0;
}

.photo-strip img,
.photo-grid img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
  background: var(--line);
}

.photo-strip .remove {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 0 12px 0 12px;
  background: rgba(28, 25, 21, 0.78);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.shot {
  padding: 0;
  border: 0;
  background: none;
  border-radius: 12px;
}

.photo-grid img { height: 160px; }
.photo-grid .shot:only-child { grid-column: 1 / -1; }
.photo-grid .shot:only-child img { height: 220px; object-fit: contain; background: #1c1915; }

.missed, .section { display: grid; gap: 8px; padding-top: 8px; }

.savebar, .tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, var(--app-width));
  z-index: 20;
  background: var(--card);
  border-top: 1px solid var(--line);
}

.savebar {
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}

.tabbar {
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
}

.tabbar a {
  min-height: 48px;
  display: grid;
  place-items: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 650;
  border-radius: 10px;
}

.tabbar a[aria-current="page"] {
  color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--accent);
  font-weight: 800;
}

.themes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-pick {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-weight: 700;
  text-align: left;
}

.theme-pick[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--line);
  flex: none;
}

.file-input,
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(28, 25, 21, 0.48);
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.dialog, .lightbox {
  width: min(100%, var(--app-width));
  background: var(--card);
  color: var(--ink);
  border-radius: 20px;
  padding: 20px 16px 16px;
  display: grid;
  gap: 10px;
}

.dialog h2 { font-size: 1.35rem; letter-spacing: -0.02em; text-transform: none; color: var(--ink); }
.dialog ol { margin: 0; padding-left: 1.2rem; display: grid; gap: 6px; }

.lightbox { margin: 0; }
.lightbox img {
  width: 100%;
  max-height: 70vh;
  height: auto;
  object-fit: contain;
  background: #111;
  border-radius: 12px;
}

#toast {
  position: fixed;
  left: 50%;
  top: calc(10px + env(safe-area-inset-top));
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 448px);
  background: #1c1915;
  color: #f3f0e7;
  padding: 12px 14px;
  border-radius: 12px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
}

#toast.show { opacity: 1; }

:root[data-theme="night"] #toast {
  background: #f3f0e7;
  color: #1c1915;
}

#update-bar {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: min(calc(100% - 24px), 448px);
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
}

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

:root[data-theme="night"] :focus-visible { outline-color: var(--accent); }

@media (hover: hover) {
  .card:hover { border-color: #c9bfae; }
}
