:root {
  --oak-0: #0f0804;
  --oak-1: #140c06;
  --oak-2: #1f140b;
  --oak-3: #2b1c10;
  --oak-4: #3a2716;
  --line: rgba(232, 176, 75, .18);
  --line-strong: rgba(232, 176, 75, .38);
  --cream: #f4e7cf;
  --cream-2: #d9c6a5;
  --muted: #a8916f;
  --amber: #d98a24;
  --amber-2: #f0b04a;
  --gold: #e8b04b;
  --copper: #b8642e;
  --danger: #d0533c;
  --ok: #8fbf6a;
  --radius: 18px;
  --display: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino', Georgia, serif;
  --body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--oak-1); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--cream);
  font: 15px/1.5 var(--body);
  background: var(--oak-1);
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(217, 138, 36, .22), transparent 60%),
    repeating-linear-gradient(92deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, var(--oak-2), var(--oak-1) 40%, var(--oak-0));
  transform: translateZ(0);
}
[hidden] { display: none !important; }
a { color: var(--amber-2); }
img { display: block; max-width: 100%; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: .01em; line-height: 1.08; }
h1, h2, h3, .brand, .age, .stats b, .kpis b, .levelValue b, .lookupItem b, .popList b, .prose.notes { font-variant-numeric: lining-nums; font-feature-settings: 'lnum' 1; }
h1 em, h2 em { font-style: italic; color: var(--gold); font-weight: 600; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .86em; color: var(--amber-2); }
.kicker { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.error { color: #ff9d86; min-height: 1.2em; margin: 8px 0; font-size: 14px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(255, 240, 215, .05);
  color: var(--cream); font: 600 15px var(--body); text-decoration: none; cursor: pointer;
  transition: transform .12s, background .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn.primary { background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: #2a1606; border-color: transparent; box-shadow: 0 8px 24px rgba(217, 138, 36, .3); }
.btn.amber { background: rgba(217, 138, 36, .16); border-color: rgba(240, 176, 74, .5); color: var(--amber-2); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--cream-2); }
.btn.danger { background: rgba(208, 83, 60, .12); border-color: rgba(208, 83, 60, .5); color: #ff9d86; }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn.wide { width: 100%; }
.iconBtn {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(20, 12, 6, .6); color: var(--cream);
  font-size: 28px; line-height: 1; text-decoration: none; cursor: pointer; backdrop-filter: blur(10px);
}

input, select, textarea {
  width: 100%; font: 16px var(--body); color: var(--cream);
  background: rgba(10, 6, 3, .55); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 13px; outline: none; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(217, 138, 36, .18); }
input::placeholder, textarea::placeholder { color: rgba(168, 145, 111, .6); }
textarea { resize: vertical; line-height: 1.5; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type=date] { min-height: 46px; }

input[type=range] { -webkit-appearance: none; appearance: none; height: 30px; padding: 0; background: transparent; border: 0; box-shadow: none; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 8px; background: linear-gradient(90deg, var(--copper), var(--amber-2)); }
input[type=range]::-moz-range-track { height: 8px; border-radius: 8px; background: linear-gradient(90deg, var(--copper), var(--amber-2)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%; background: var(--cream); border: 3px solid var(--amber); box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--cream); border: 3px solid var(--amber); }

.field { display: block; margin: 12px 0 0; }
.field > span { display: block; font-size: 12px; font-weight: 700; color: var(--cream-2); margin: 0 0 5px 2px; letter-spacing: .02em; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row.three { grid-template-columns: repeat(3, 1fr); }
.row.tight { margin-top: 10px; }
@media (max-width: 420px) { .row.three { grid-template-columns: 1fr 1fr; } .row.three > :last-child { grid-column: 1 / -1; } }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 10px 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { flex: none; width: 50px; height: 30px; border-radius: 30px; background: var(--oak-4); border: 1px solid var(--line); position: relative; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--cream-2); transition: transform .2s, background .2s; }
.switch input:checked + span { background: var(--amber); }
.switch input:checked + span::after { transform: translateX(20px); background: #fff7e8; }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(217, 138, 36, .35); }
.switch em { font-style: normal; font-weight: 600; }

/* ---------- Lock screen ---------- */
.lock { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom)); }
.lockCard { width: 100%; max-width: 380px; text-align: center; }
.lockIcon { width: 112px; height: 112px; margin: 0 auto 22px; border-radius: 26px; box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 0 1px var(--line-strong); }
.lockCard h1 { font-size: 44px; margin-bottom: 12px; }
.lockText { color: var(--cream-2); margin: 0 0 22px; }
.lockCard input { text-align: center; margin-bottom: 4px; }
.lockCard details { margin: 12px 0 4px; text-align: left; }
.lockCard summary { color: var(--muted); font-size: 14px; cursor: pointer; text-align: center; list-style: none; }
.lockCard summary::-webkit-details-marker { display: none; }
.lockCard details[open] summary { margin-bottom: 10px; color: var(--gold); }
.lockCard details input { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 500;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(20, 12, 6, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--cream); text-decoration: none; font-family: var(--display); font-size: 22px; font-weight: 700; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand em { color: var(--gold); font-style: italic; font-weight: 600; }
.syncBtn { display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--cream-2); font: 600 12px var(--body); cursor: pointer; }
.syncBtn i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.syncBtn i.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.syncBtn i.wait { background: var(--amber-2); }
.syncBtn i.err { background: var(--danger); }
.syncBtn i.off { background: var(--muted); }
.syncBtn i.busy { background: var(--amber-2); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .25; } }

main { max-width: 920px; margin: 0 auto; padding: 0 16px calc(110px + var(--safe-bottom)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 600;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: rgba(15, 8, 4, .96); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--muted); text-decoration: none; font-size: 10.5px; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--amber-2); }
.tabbar .addTab b {
  display: grid; place-items: center; width: 52px; height: 52px; margin-top: -26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--amber-2), var(--amber) 60%, var(--copper));
  color: #2a1606; font-size: 32px; font-weight: 500; line-height: 1;
  box-shadow: 0 8px 22px rgba(217, 138, 36, .45), 0 0 0 4px var(--oak-1);
}
.tabbar .addTab { color: var(--cream-2); }

/* ---------- Hero / cave ---------- */
.hero { padding: 26px 0 8px; }
.hero h1 { font-size: clamp(36px, 10vw, 54px); }
.stats, .kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0; }
.stats div, .kpis div { padding: 12px 6px; border-radius: 14px; text-align: center; background: rgba(255, 240, 215, .04); border: 1px solid var(--line); }
.stats b, .kpis b { display: block; font-family: var(--display); font-size: 26px; color: var(--amber-2); line-height: 1.1; }
.stats span, .kpis span { font-size: 11px; color: var(--muted); }
.kpis { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }

.search { position: relative; display: block; }
.search svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; }
.search input { padding-left: 42px; border-radius: 999px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 14px -16px 0; padding: 0 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--cream-2); font: 600 13px var(--body); cursor: pointer; }
.chip.on { background: var(--cream); color: var(--oak-1); border-color: var(--cream); }
.sort { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.sort select { width: auto; padding: 7px 32px 7px 12px; font-size: 14px; border-radius: 999px; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--radius); text-decoration: none; color: var(--cream);
  background: linear-gradient(180deg, var(--oak-3), var(--oak-2));
  border: 1px solid var(--line); box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
  transition: transform .15s; contain: layout paint;
}
.card:active { transform: scale(.98); }
.card .photo { aspect-ratio: 3 / 4; }
.badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.age { font-family: var(--display); font-weight: 700; font-size: 22px; line-height: 1; padding: 6px 9px; border-radius: 10px; background: rgba(15, 8, 4, .9); color: var(--gold); border: 1px solid var(--line-strong); }
.age small { font-size: 12px; font-family: var(--body); color: var(--cream-2); }
.state { margin-left: auto; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; padding: 4px 8px; border-radius: 999px; }
.state.open { background: rgba(217, 138, 36, .85); color: #2a1606; }
.state.sealed { background: rgba(15, 8, 4, .9); color: var(--cream-2); border: 1px solid var(--line); }
.cardBody { display: flex; gap: 8px; padding: 10px 10px 12px; flex: 1; }
.cardText { flex: 1; min-width: 0; }
.cardText h3 { font-size: 19px; line-height: 1.1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cardText p { margin: 3px 0 5px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cardMeta { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.miniLevel { flex: none; width: 14px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.miniLevel span { position: relative; width: 8px; flex: 1; min-height: 42px; border-radius: 4px; background: rgba(255, 240, 215, .08); border: 1px solid var(--line); overflow: hidden; }
.miniLevel span::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: var(--l); background: linear-gradient(0deg, var(--copper), var(--amber-2)); }
.miniLevel b { font-size: 9px; color: var(--muted); }

/* Photos & gauge placeholder */
.photo { position: relative; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle at 50% 40%, rgba(217, 138, 36, .18), transparent 65%), var(--oak-1); }
.photo .placeholder { height: 72%; width: auto; }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.photo.has img { opacity: 1; }
.photo.has .placeholder { visibility: hidden; }

.stars { display: inline-flex; gap: 1px; color: rgba(232, 176, 75, .25); font-size: 14px; letter-spacing: 0; }
.stars .on { color: var(--gold); text-shadow: 0 0 8px rgba(232, 176, 75, .4); }
.stars.interactive { gap: 4px; }
.stars.interactive button { border: 0; background: none; padding: 2px; font-size: 34px; line-height: 1; color: rgba(232, 176, 75, .25); cursor: pointer; transition: transform .12s; }
.stars.interactive button.on { color: var(--gold); text-shadow: 0 0 14px rgba(232, 176, 75, .5); }
.stars.interactive button:active { transform: scale(1.25); }

.peatDots { display: inline-flex; gap: 2px; }
.peatDots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(168, 145, 111, .3); }
.peatDots i.on { background: #9aa3a8; box-shadow: 0 0 4px rgba(200, 210, 215, .5); }

.empty { grid-column: 1 / -1; text-align: center; padding: 40px 20px; color: var(--cream-2); }
.empty .emptyBottle { height: 140px; margin: 0 auto 16px; opacity: .8; }
.empty h3 { font-size: 28px; margin-bottom: 8px; }
.empty p { max-width: 420px; margin: 0 auto 20px; color: var(--muted); }
.empty.small { padding: 24px; }

/* ---------- Panels / detail ---------- */
.panel { margin: 14px 0; padding: 16px; border-radius: var(--radius); background: linear-gradient(180deg, rgba(43, 28, 16, .9), rgba(31, 20, 11, .9)); border: 1px solid var(--line); }
.panel h2 { font-size: 24px; margin-bottom: 10px; color: var(--cream); }
.panel h2 small { font-family: var(--body); font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.panel > h2:only-child { margin: 0; }

.detailBar { position: sticky; top: calc(62px + var(--safe-top)); z-index: 450; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; }
.view-b .detailBar { position: relative; top: 0; margin-bottom: -62px; padding: 10px 10px; }
.form .detailBar { position: static; }
.formTitle { font-size: 26px; flex: 1; text-align: center; }
.detailHero { margin: 0 -16px; }
.detailHero .photo { height: min(62vh, 520px); }
.detailHero .photo img { object-fit: contain; background: radial-gradient(circle at 50% 45%, rgba(217, 138, 36, .2), var(--oak-0) 75%); }
.detailHead { padding: 18px 0 2px; }
.detailHead h1 { font-size: clamp(34px, 9vw, 48px); }
.detailHead .sub { margin: 6px 0 8px; color: var(--cream-2); font-size: 15px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid var(--line-strong); color: var(--cream-2); background: rgba(232, 176, 75, .06); }

.levelPanel { display: flex; gap: 18px; align-items: center; }
.bigGauge { flex: none; width: 92px; }
.bigGauge .gauge { width: 100%; height: auto; }
.levelInfo { flex: 1; min-width: 0; }
.levelValue { margin: 0 0 4px; color: var(--muted); }
.levelValue b { font-family: var(--display); font-size: 40px; color: var(--amber-2); line-height: 1; }
.levelInfo .btn { margin-top: 6px; width: 100%; }

.peatMeter { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.peatMeter span { height: 10px; border-radius: 5px; background: rgba(255, 240, 215, .07); }
.peatMeter span.on:nth-child(1) { background: #c9a46a; }
.peatMeter span.on:nth-child(2) { background: #a3946f; }
.peatMeter span.on:nth-child(3) { background: #7f8576; }
.peatMeter span.on:nth-child(4) { background: #626a6b; }
.peatMeter span.on:nth-child(5) { background: #4b5257; }
.peatLabel { margin: 8px 0 0; color: var(--cream-2); font-weight: 600; }

.segmented { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.segmented button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 12px; border: 1px solid var(--line); background: rgba(10, 6, 3, .4); color: var(--muted); font: 600 11px/1.15 var(--body); cursor: pointer; }
.segmented button.on { border-color: var(--amber); background: rgba(217, 138, 36, .15); color: var(--cream); }
.segmented .peatDots i { width: 7px; height: 7px; }

.prose { color: var(--cream-2); font-size: 15.5px; line-height: 1.65; }
.prose p { margin: 0 0 10px; }
.prose.notes { font-family: var(--display); font-style: italic; font-size: 19px; color: var(--cream); }
.source { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted); word-break: break-all; }
.source a { color: var(--muted); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- Maps ---------- */
.map { height: 240px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--oak-1); z-index: 0; }
.map.full { height: calc(100dvh - 250px - var(--safe-top) - var(--safe-bottom)); min-height: 320px; }
.form .map { margin-top: 12px; height: 220px; }
.mapHead { padding: 22px 0 12px; }
.mapHead h1 { font-size: clamp(32px, 9vw, 46px); }
.mapHead p { margin: 6px 0 0; }
.leaflet-container { font-family: var(--body); background: #a3aa98; }
.leaflet-tile-pane { filter: sepia(.45) saturate(.85) brightness(.82) contrast(1.05); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--oak-2); color: var(--cream); border: 1px solid var(--line-strong); box-shadow: 0 10px 30px rgba(0, 0, 0, .6); }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-attribution { background: rgba(20, 12, 6, .7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--cream-2) !important; }
.leaflet-bar a { background: var(--oak-2); color: var(--cream); border-color: var(--line); }
.pin span {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: radial-gradient(circle at 40% 35%, var(--amber-2), var(--amber) 55%, var(--copper));
  border: 2px solid #fff3dc; box-shadow: 0 4px 12px rgba(0, 0, 0, .55);
  font: 700 12px var(--body); color: #2a1606;
}
.pin span:empty::after { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #2a1606; }
.popList { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.popList b { font-family: var(--display); font-size: 18px; color: var(--gold); }
.popList a { color: var(--cream); text-decoration: none; padding: 4px 0; border-top: 1px solid var(--line); }
.popList small { color: var(--muted); }

/* ---------- Form ---------- */
.form { padding-bottom: 20px; }
.photoPanel { display: flex; gap: 16px; align-items: center; }
.photoPick { flex: none; width: 120px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.photoPick .photo { aspect-ratio: 3 / 4; }
.photoActions { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.formActions {
  position: sticky; bottom: calc(76px + var(--safe-bottom)); z-index: 400;
  display: grid; grid-template-columns: 1fr 2fr; gap: 10px; padding: 12px; margin: 0 -4px;
  border-radius: 999px; background: rgba(15, 8, 4, .95); border: 1px solid var(--line);
}

/* ---------- Lookup sheet ---------- */
.sheet {
  width: min(560px, calc(100% - 24px)); max-height: 80dvh; padding: 0; overflow: hidden;
  border-radius: 22px; border: 1px solid var(--line-strong); background: var(--oak-2); color: var(--cream);
}
.sheet::backdrop { background: rgba(5, 3, 1, .7); backdrop-filter: blur(4px); }
.sheetHead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 10px; border-bottom: 1px solid var(--line); }
.sheetHead h2 { font-size: 26px; }
.lookupList { overflow-y: auto; max-height: calc(80dvh - 90px); padding: 8px 10px 14px; }
.lookupItem { display: flex; gap: 12px; width: 100%; padding: 12px 8px; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--cream); font: 14px/1.4 var(--body); cursor: pointer; border-radius: 10px; }
.lookupItem:active { background: rgba(217, 138, 36, .1); }
.lookupItem img, .lookupItem .noThumb { flex: none; width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--oak-3); display: grid; place-items: center; font-size: 26px; }
.lookupItem b { font-family: var(--display); font-size: 19px; }
.lookupItem i { font-style: normal; }
.lookupItem small { display: block; color: var(--muted); margin-top: 3px; }

/* ---------- Stats ---------- */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 28px; gap: 10px; align-items: center; font-size: 14px; }
.bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--cream-2); }
.bar i { height: 10px; border-radius: 5px; background: rgba(255, 240, 215, .06); position: relative; overflow: hidden; }
.bar i::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: 5px; background: linear-gradient(90deg, var(--copper), var(--amber-2)); }
.bar b { text-align: right; color: var(--amber-2); }
.rank { margin: 0; padding-left: 22px; }
.rank li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.rank li:last-child { border: 0; }
.rank li > * { vertical-align: middle; }
.rank a { color: var(--cream); text-decoration: none; font-weight: 600; margin-right: 8px; }

/* ---------- Settings ---------- */
.keyBox { margin: 10px 0; padding: 12px; border-radius: 12px; background: rgba(10, 6, 3, .6); border: 1px dashed var(--line-strong); word-break: break-all; user-select: all; -webkit-user-select: all; }
.dangerZone { border-color: rgba(208, 83, 60, .3); }
.dangerZone .btn { margin-top: 8px; }
.signature { display: flex; justify-content: center; padding: 24px 0 8px; }
.signature img { height: 34px; opacity: .7; filter: invert(1) sepia(1) saturate(.6) hue-rotate(-10deg); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); z-index: 2000;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--cream); color: var(--oak-1); font-weight: 600; font-size: 14px; text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Photo search ---------- */
.imgSearch { display: flex; gap: 8px; padding: 6px 4px 12px; position: sticky; top: 0; z-index: 2; background: var(--oak-2); }
.imgSearch input { flex: 1; border-radius: 999px; }
.imgGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 4px; }
@media (min-width: 520px) { .imgGrid { grid-template-columns: repeat(4, 1fr); } }
.imgStatus { grid-column: 1 / -1; text-align: center; padding: 24px 8px; margin: 0; }
.imgItem { position: relative; aspect-ratio: 3 / 4; padding: 0; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: #f4efe6; cursor: pointer; }
.imgItem img { width: 100%; height: 100%; object-fit: contain; }
.imgItem span { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font: 600 9.5px var(--body); color: var(--cream); background: rgba(15, 8, 4, .82); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imgItem:active { transform: scale(.97); }
.imgGrid.busy .imgItem:not(.loading) { opacity: .4; }
.imgItem.loading::after { content: 'Téléchargement…'; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 8, 4, .7); color: var(--amber-2); font: 700 12px var(--body); }
.lookupList .hint { padding: 0 6px; }
.photoCredit { margin: 6px 16px 0; font-size: 11.5px; color: var(--muted); text-align: right; }
.photoCredit a { color: var(--muted); }
#photoCredit { margin: 0; font-size: 11.5px; word-break: break-word; }
.view-b .detailBar .btn.small { background: rgba(20, 12, 6, .78); border-color: var(--line-strong); }
