:root {
  --ink: #17231f;
  --muted: #5d6b66;
  --bg: #f6f3ec;
  --card: #ffffff;
  --line: #e3ddd0;
  --emerald: #123d33;
  --emerald-2: #1d5a4b;
  --gold: #b8924a;
  --gold-soft: #f3ead8;
  --danger: #a33a2c;
  --ok: #2f7a4f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 35, 31, .06), 0 6px 20px rgba(23, 35, 31, .06);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece7dc;
    --muted: #a7b1ac;
    --bg: #0f1614;
    --card: #17211e;
    --line: #2a3632;
    --emerald: #0c2a23;
    --emerald-2: #2a7a64;
    --gold: #d4b06a;
    --gold-soft: #2b2619;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; margin: 0 0 .25rem; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1rem; font-family: inherit; }
.muted { color: var(--muted); }
p { margin: .25rem 0; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--emerald); color: #f4ecdc;
}
.brand { all: unset; cursor: pointer; display: flex; gap: 10px; align-items: center; font-family: Georgia, serif; font-size: 1.15rem; letter-spacing: .02em; }
.brand em { color: var(--gold); font-style: normal; }
.mark { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--gold); display: grid; place-items: center; color: var(--gold); font-size: 1rem; }
.bar .ghost { color: #f4ecdc; border-color: rgba(244, 236, 220, .35); }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px); }
.view { display: grid; gap: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.narrow { max-width: 380px; width: 100%; margin: 8vh auto 0; }
.center { text-align: center; justify-items: center; }

label { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; }
label .muted { font-weight: 400; }
input, textarea, select {
  font: inherit; font-weight: 400; width: 100%;
  padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--emerald-2); outline-offset: 1px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.primary, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  min-height: 46px; padding: 10px 16px; border-radius: 12px;
}
.primary { background: var(--emerald-2); color: #fff; border: 0; }
.primary:active { transform: translateY(1px); }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.block { width: 100%; }
button:disabled { opacity: .55; cursor: default; }

.snap {
  display: grid; justify-items: center; gap: 6px; cursor: pointer;
  padding: 34px 16px; border-radius: 20px; text-align: center;
  background: linear-gradient(160deg, var(--emerald) 0%, var(--emerald-2) 100%); color: #f4ecdc;
  box-shadow: var(--shadow);
}
.snap:active { transform: scale(.99); }
.snap-icon { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--gold); color: var(--gold); margin-bottom: 6px; }
.snap-title { font-family: Georgia, serif; font-size: 1.5rem; }
.snap-sub { opacity: .8; font-size: .92rem; }

.search { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 6px; }
.status { font-size: .85rem; color: var(--muted); text-align: center; display: grid; gap: 6px; justify-items: center; }
.status .warn { color: var(--danger); }

.shot { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; }
.shot img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }

.list { display: grid; gap: 10px; }
.match { display: grid; grid-template-columns: 92px 1fr; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.match.best { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), var(--shadow); }
.thumb { width: 92px; height: 92px; object-fit: cover; border-radius: 10px; background: var(--bg); }
.info { min-width: 0; display: grid; gap: 4px; align-content: start; }
.title { font-size: .98rem; overflow-wrap: anywhere; }
.meta { font-size: .84rem; }
.tagline { display: flex; gap: 6px; flex-wrap: wrap; }
.badge, .pstatus { font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: var(--gold-soft); color: var(--gold); }
.badge.strong { background: #dff0e5; color: var(--ok); }
.badge.weak { background: var(--bg); color: var(--muted); }
.pstatus:empty { display: none; }
.pstatus.draft { background: var(--bg); color: var(--muted); }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.confirm.done, .confirm.done:disabled { border-color: var(--ok); color: var(--ok); opacity: 1; }

.stockpanel { margin-top: 6px; border-top: 1px dashed var(--line); padding-top: 8px; display: grid; gap: 8px; font-size: .9rem; }
.stockrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.stepper { display: inline-grid; grid-template-columns: 38px 48px 38px auto; gap: 4px; align-items: center; }
.stepper button { min-height: 38px; padding: 0; font-size: 1.2rem; }
.stepper output { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper output.changed { color: var(--emerald-2); }

.actions { display: grid; gap: 8px; margin-top: 4px; }
.note { background: var(--gold-soft); border-radius: 10px; padding: 10px 12px; font-size: .88rem; }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; }
.tick { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: #dff0e5; color: var(--ok); font-size: 2rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 18px); transform: translate(-50%, 140%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .92rem;
  transition: transform .25s ease; max-width: calc(100vw - 32px); z-index: 20;
}
.toast.show { transform: translate(-50%, 0); }
.busy { position: fixed; inset: 0; z-index: 15; background: rgba(15, 22, 20, .55); display: grid; place-content: center; justify-items: center; gap: 12px; color: #fff; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .3); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .toast { transition: none; } }
