:root {
  --bg: #0d120c;
  --bg-2: #141b13;
  --card: #18211700;
  --card: #1a2418;
  --card-2: #212d1f;
  --line: #2c3a29;
  --text: #eef3ea;
  --muted: #9aab93;
  --accent: #e0b04f;
  --accent-ink: #1d1708;
  --green: #86b86a;
  --bar: #79ad5c;
  --grid: #2a3627;
  --danger: #e06c5d;
  --radius: 18px;
  --tap: 52px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; color: var(--text); font-size: 17px; line-height: 1.4;
  background: radial-gradient(120% 60% at 50% -10%, #1f2e1b 0%, var(--bg) 60%) fixed;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .92rem; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
.notice { background: #2b2412; border: 1px solid #5a4a1d; color: var(--accent); padding: .7rem .9rem; border-radius: 12px; }
h2 { font-size: 1.25rem; margin: .4rem 0 .7rem; letter-spacing: -.01em; }
h2.section { margin-top: 1.8rem; }
h3 { font-size: 1.05rem; margin: 0 0 .2rem; }

/* ---------- formuláře a tlačítka ---------- */
input, select, button { font: inherit; color: var(--text); }
input, select {
  width: 100%; min-height: var(--tap); padding: .75rem 1rem; border-radius: 14px;
  background: var(--bg-2); border: 1px solid var(--line); outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #e0b04f33; }
select { appearance: none; -webkit-appearance: none; padding-right: 2.4rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
button {
  min-height: 44px; padding: .6rem 1.1rem; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card-2); cursor: pointer; font-weight: 600; transition: transform .08s, background .15s;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .55; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.ghost { background: transparent; }
button.danger { background: #3a1c18; border-color: #6b2c25; color: #ffb4a8; }
button.big { min-height: var(--tap); font-size: 1.02rem; }
button.wide { width: 100%; }
.stack { display: grid; gap: .7rem; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.btn-row > * { flex: 1 1 auto; }
.two { display: grid; grid-template-columns: 7rem 1fr; gap: .6rem; }

.switch { display: flex; align-items: center; gap: .6rem; cursor: pointer; font-size: .95rem; user-select: none; }
.switch input { appearance: none; -webkit-appearance: none; width: 46px; min-height: 0; height: 28px; padding: 0; flex: none;
  border-radius: 99px; background: var(--line); border: none; position: relative; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: transform .2s; }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------- přihlášení ---------- */
#login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-box { width: min(380px, 100%); text-align: center; }
.login-logo { width: 96px; height: 96px; border-radius: 26px; box-shadow: 0 10px 40px #0008; }
.login-box h1 { margin: .8rem 0 .1rem; font-size: 2rem; }
.login-box form { margin-top: 1.4rem; text-align: left; }
.login-box .install-btn { margin-top: 1.2rem; }

/* ---------- horní lišta a dlaždicové menu ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + .6rem) 1rem .3rem; max-width: 1100px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; }
.brand img { width: 38px; height: 38px; border-radius: 11px; }
.top-actions { display: flex; gap: .5rem; }
.icon-btn { width: 48px; height: 48px; padding: 0; border-radius: 14px; font-size: 1.35rem; background: var(--card); }
#refresh.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tiles {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem;
  padding: .6rem 1rem .8rem; max-width: 1100px; margin: 0 auto;
  background: linear-gradient(var(--bg) 75%, transparent);
}
.tiles button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem;
  min-height: 78px; padding: .5rem .2rem; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.tiles .ic { line-height: 0; }
.tiles .ic svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tiles button:not(.active) .ic { color: var(--text); opacity: .85; }
.tiles .lb { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tiles button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px #e0b04f33; }

main { padding: .2rem 1rem calc(2rem + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }

/* ---------- snímky ---------- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1rem; align-items: center; }
.filters .switch { padding-left: .2rem; }
.feed { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 6px 24px #0005; }
.card .photo { position: relative; }
.card img { width: 100%; aspect-ratio: 16/11; object-fit: cover; display: block; background: #060906; cursor: zoom-in; }
.card .conf { position: absolute; top: .6rem; right: .6rem; background: #000a; backdrop-filter: blur(6px);
  padding: .2rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 600; }
.card .body { padding: .8rem 1rem 1rem; }
.card .species { display: flex; align-items: center; gap: .55rem; font-size: 1.3rem; font-weight: 800; letter-spacing: -.01em; }
.card .species .em { font-size: 2rem; line-height: 1; }
.card .cnt { background: var(--card-2); border-radius: 99px; padding: .05rem .55rem; font-size: .95rem; }
.card .meta { color: var(--muted); font-size: .95rem; margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .2rem .9rem; }
.card .desc { font-size: .9rem; margin-top: .5rem; color: #cfd8ca; }
.card .desc.err { color: #ffb4a8; font-size: .8rem; word-break: break-word; }
.card-acts { display: flex; gap: .5rem; margin-top: .8rem; }
.card-acts select { flex: 1; min-width: 0; min-height: 46px; font-size: .92rem; }
.card-acts button { width: 46px; min-height: 46px; padding: 0; flex: none; }
.card.empty-shot { opacity: .65; }

/* výběr více snímků */
.card .pick { display: none; position: absolute; inset: 0; z-index: 2; background: transparent; border: none; border-radius: 0; padding: 0; }
.selecting .card .pick { display: block; }
.card .pick::after { content: ""; position: absolute; top: .7rem; left: .7rem; width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid #fff; background: #0006; }
.card.picked { outline: 3px solid var(--accent); outline-offset: -3px; }
.card.picked .pick::after { background: var(--accent); content: "✓"; color: var(--accent-ink); font-weight: 900; display: grid; place-items: center; }
.bulk {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem .6rem 1.1rem; border-radius: 99px;
  background: #222d20f2; border: 1px solid var(--line); box-shadow: 0 10px 40px #000a; backdrop-filter: blur(10px);
  width: max-content; max-width: calc(100% - 2rem);
}
.bulk span { font-weight: 700; margin-right: .3rem; white-space: nowrap; }
.bulk button { border-radius: 99px; }

/* ---------- přehled ---------- */
.stats { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stat { display: grid; grid-template-columns: 3.2rem 1fr auto; gap: .8rem; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; cursor: pointer; }
.stat .em { font-size: 2.4rem; text-align: center; }
.stat .name { font-weight: 700; font-size: 1.05rem; }
.stat .num { font-size: 1.7rem; font-weight: 800; color: var(--accent); }
.bar { height: 7px; background: var(--line); border-radius: 4px; margin: .35rem 0 .2rem; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 4px; }

/* ---------- místa ---------- */
.cams { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cam { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: grid; gap: .7rem; }
.cam .head { display: flex; align-items: center; gap: .7rem; }
.cam .head .ic { font-size: 2rem; }
.cam .head b { display: block; font-size: 1.05rem; }
.cam .save-row { display: flex; gap: .5rem; }
.cam .save-row input { flex: 1; }

/* ---------- upozornění, účet ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; }
.panel h2 { margin-top: 0; }
.status { font-weight: 600; margin: 0 0 .9rem; }
.toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .5rem; }
.toggles label { display: flex; align-items: center; gap: .55rem; min-height: var(--tap); padding: .4rem .8rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; font-size: .95rem; }
.toggles label:has(input:not(:checked)) { opacity: .5; }
.toggles input { width: 22px; height: 22px; min-height: 0; accent-color: var(--green); flex: none; }
.toggles .em { font-size: 1.5rem; }
.result.ok { color: var(--green); }
.result.err { color: var(--danger); }
.user { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.user:last-child { border-bottom: none; }
.user .acts { display: flex; gap: .4rem; flex-wrap: wrap; }
.user .acts button { min-height: 40px; padding: .4rem .8rem; font-size: .88rem; }
.badge { font-size: .72rem; background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 2px 7px; margin-left: .35rem; vertical-align: middle; }

/* ---------- prohlížeč fotky ---------- */
dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem; width: min(96vw, 1100px); max-height: 96vh; }
dialog::backdrop { background: #000c; }
#viewer-img { width: 100%; border-radius: 12px; display: block; }
#viewer-info { margin: .8rem .2rem; font-size: 1.05rem; }

.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 1rem); transform: translateX(-50%);
  background: var(--green); color: #0f1a0b; padding: .75rem 1.2rem; border-radius: 14px; font-weight: 700; z-index: 50;
  box-shadow: 0 10px 30px #0008; max-width: calc(100% - 2rem); text-align: left; white-space: pre-line; cursor: pointer; }

/* ---------- mobil ---------- */
@media (max-width: 600px) {
  main { padding-left: .75rem; padding-right: .75rem; }
  .tiles { gap: .4rem; padding: .5rem .75rem .7rem; }
  .tiles button { min-height: 70px; border-radius: 16px; }
  .tiles .ic { font-size: 1.7rem; }
  .tiles .lb { font-size: .72rem; }
  .feed, .cams, .stats { grid-template-columns: 1fr; }
  .card { border-radius: 16px; }
  .card img { aspect-ratio: 4/3; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters select { font-size: .88rem; padding-left: .65rem; padding-right: 1.6rem; background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%; }
  .filters .switch, .filters #select-toggle { grid-column: span 1; }
}
@media (min-width: 900px) {
  .tiles { grid-template-columns: repeat(5, minmax(0, 170px)); justify-content: start; }
  .filters { justify-content: start; }
}
.two.wide-first { grid-template-columns: 1fr auto; }

/* ---------- hlavička: název a odkaz na stažení ---------- */
.brand em { font-style: normal; color: var(--accent); font-weight: 700; }
.icon-btn svg, .install-link svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { display: grid; place-items: center; }
.install-link {
  display: inline-flex; align-items: center; gap: .45rem; height: 48px; padding: 0 1rem; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; font-size: .95rem; white-space: nowrap;
}
.login-install { display: block; height: auto; padding: .9rem; margin-top: 1.4rem; text-align: center; background: transparent; color: var(--accent); border: 1px solid #5a4a1d; }
h3.group { margin: 1.1rem 0 .5rem; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- statistiky ---------- */
.stats-filters { grid-template-columns: repeat(3, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; margin-bottom: 1rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .v { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.charts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1rem; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1rem .8rem; min-width: 0; margin-bottom: 1rem; }
.charts .chart-card { margin-bottom: 0; }
.chart-card h3 { margin: 0; }
.chart-card .sub { margin: .1rem 0 .6rem; font-size: .85rem; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart { min-height: 180px; }
.chart .ax { fill: var(--muted); font-size: 12px; font-family: inherit; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .bar { fill: var(--bar); pointer-events: none; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .bar.hl { fill: #9bcf7d; }
.chart .peak { fill: var(--text); font-size: 12px; font-weight: 700; }
.hbars { display: grid; gap: .55rem; }
.hbar { display: grid; grid-template-columns: minmax(0, 9rem) 1fr 2.5rem; gap: .6rem; align-items: center; font-size: .92rem; }
.hbar .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .tr { height: 12px; }
.hbar .tr i { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 3px; }
.hbar b { text-align: right; }
.tooltip { position: fixed; z-index: 40; pointer-events: none; background: #0b0f0aee; border: 1px solid var(--line);
  padding: .45rem .7rem; border-radius: 10px; font-size: .85rem; box-shadow: 0 6px 20px #0008; transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; }
.stat.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

@media (max-width: 760px) {
  .charts { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .brand { font-size: 1.1rem; gap: .5rem; }
  .brand img { width: 34px; height: 34px; }
  .install-link { padding: 0 .75rem; font-size: .82rem; height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .stats-filters { grid-template-columns: 1fr 1fr; }
  .stats-filters #s-days { grid-column: 1 / -1; }
  .filters #f-sort { grid-column: 1 / -1; }
  .kpi .v { font-size: 1.6rem; }
}
@media (max-width: 380px) { .install-link span { display: none; } }
@media (min-width: 900px) {
  .filters { grid-template-columns: 220px 220px 210px auto auto; }
  .stats-filters { grid-template-columns: 220px 220px 220px; }
}

/* ---------- prohlížeč: listování ---------- */
.viewer-stage { position: relative; touch-action: pan-y; user-select: none; }
#viewer-img { transition: transform .18s ease, opacity .18s ease; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; padding: 0; border-radius: 50%;
  background: #000a; border: 1px solid #ffffff33; color: #fff; font-size: 2rem; line-height: 1; backdrop-filter: blur(6px); }
.v-nav.prev { left: .6rem; } .v-nav.next { right: .6rem; }
.v-nav:disabled { opacity: .25; }
.v-count { position: absolute; top: .6rem; left: 50%; transform: translateX(-50%); background: #000a; padding: .15rem .6rem;
  border-radius: 99px; font-size: .82rem; font-weight: 600; }
@media (hover: none) { .v-nav { width: 44px; height: 44px; font-size: 1.7rem; background: #0007; } }

.two.half { grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .two.half { grid-template-columns: 1fr; } }

/* ---------- obrysové ikony na tlačítkách (stejný styl jako menu) ---------- */
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
button:has(> svg.i) { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.card-acts button svg.i { width: 22px; height: 22px; }
.card-acts .redo { color: var(--text); }
.card-acts .del, button.danger { color: #ff9d8f; }
button.spin svg.i { animation: spin 1s linear infinite; }
h3.ih { display: flex; align-items: center; gap: .5rem; }
h3.ih svg.i { color: var(--accent); }

/* přepínače upozornění: text se zalomí, nepřeteče */
.toggles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
.toggles label { min-width: 0; gap: .5rem; padding: .45rem .7rem; line-height: 1.2; }
.toggles .em { font-size: 1.3rem; flex: none; }
.toggles .t { min-width: 0; overflow-wrap: normal; word-break: keep-all; hyphens: manual; }
/* stav je vidět na dlaždici: zapnuto = zelený okraj a fajfka, vypnuto = ztlumené */
.toggles input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.toggles label { position: relative; padding-right: 2rem; }
.toggles label:has(input:checked) { border-color: var(--green); background: #1f2c1c; }
.toggles label:has(input:checked)::after { content: ""; position: absolute; right: .75rem; top: 50%; width: 7px; height: 12px;
  border: solid var(--green); border-width: 0 2.5px 2.5px 0; transform: translateY(-65%) rotate(45deg); }
.toggles label:has(input:focus-visible) { box-shadow: 0 0 0 3px #e0b04f55; }
@media (max-width: 370px) {
  .filters select { font-size: .84rem; padding-left: .55rem; padding-right: 1.4rem; }
  .filters { gap: .5rem; }
}

@media (max-width: 420px) {
  .toggles { gap: .4rem; }
  .toggles label { font-size: .9rem; gap: .4rem; padding: .4rem 1.75rem .4rem .6rem; }
  .toggles .em { font-size: 1.15rem; }
  .toggles label:has(input:checked)::after { right: .65rem; }
}
@media (max-width: 340px) { .toggles { grid-template-columns: 1fr; } }
@media (max-width: 380px) and (min-width: 341px) {
  .toggles label { font-size: .84rem; gap: .35rem; padding-left: .5rem; padding-right: 1.6rem; }
  .toggles .em { font-size: 1.05rem; }
  .toggles label:has(input:checked)::after { right: .6rem; }
}

/* ---------- ikony zvěře (stejný obrysový styl jako menu) ---------- */
svg.si { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.card .species, #viewer-info .species { gap: .6rem; font-size: 1.12rem; font-weight: 800; }
.card .species svg.em, #viewer-info .species svg.em { width: 38px; height: 38px; color: var(--accent); }
/* název zvířete, místo a čas stejně velkým písmem */
.card .meta, #viewer-info .meta { font-size: 1.12rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-top: .35rem; }
.card .meta span, #viewer-info .meta span { display: inline-flex; align-items: center; gap: .35rem; }
.card .meta svg.i, #viewer-info .meta svg.i { width: 19px; height: 19px; color: var(--muted); }
.stat .em svg.si { width: 44px; height: 44px; color: var(--accent); }
.toggles svg.si.em { width: 24px; height: 24px; }
.toggles label:has(input:checked) svg.si { color: var(--accent); }
.cam .head .ic svg.i { width: 30px; height: 30px; color: var(--accent); }
.status { display: flex; align-items: center; gap: .5rem; }
.status svg.i { color: var(--muted); }
.status.on svg.i { color: var(--green); }
@media (max-width: 600px) {
  .card .species, #viewer-info .species, .card .meta, #viewer-info .meta { font-size: 1.05rem; }
}

/* ztlumené ikony pomocných kategorií */
.card .species svg.si.dim, #viewer-info .species svg.si.dim, .stat .em svg.si.dim,
.toggles label:has(input:checked) svg.si.dim { color: var(--muted); }
svg.si.dim { stroke-width: 1.5; }

/* hesla v administraci: zobrazená jako tečky, ale ne jako type=password (aby je prohlížeč neukládal k účtu) */
input.secret { -webkit-text-security: disc; text-security: disc; }

/* ---------- náhled fotky: Zavřít hned pod fotkou, vše se vejde na obrazovku ---------- */
#viewer { padding: .7rem; }
#viewer-img { max-height: calc(100dvh - 210px); object-fit: contain; background: #000; }
.viewer-bottom { display: flex; align-items: flex-end; gap: .6rem; margin-top: .6rem; }
#viewer-info { flex: 1; min-width: 0; margin: 0 .2rem; }
#viewer-info .species { display: flex; align-items: center; gap: .55rem; }
#viewer-info .species svg.em { width: 30px; height: 30px; }
#viewer-info .meta { margin-top: .2rem; }
.v-close-form { margin: 0; flex: none; }
.v-close { min-height: 36px; padding: .35rem .8rem; font-size: .88rem; gap: .35rem; border-radius: 10px; }
.v-close svg.i { width: 16px; height: 16px; }
.v-count { left: 1rem; transform: none; top: .6rem; }
@media (max-width: 600px) {
  #viewer { width: 100vw; max-width: 100vw; max-height: 100dvh; margin: auto 0; border-radius: 0; border-left: none; border-right: none;
    padding: .5rem .5rem calc(env(safe-area-inset-bottom) + .5rem); }
  #viewer-img { max-height: calc(100dvh - 230px); border-radius: 10px; }
  #viewer-info .species, #viewer-info .meta { font-size: .95rem; }
  #viewer-info .species svg.em { width: 26px; height: 26px; }
  #viewer-info .meta { gap: .15rem .7rem; }
  #viewer-info .meta svg.i { width: 16px; height: 16px; }
}

/* náhled: místo a čas na jednom řádku vedle tlačítka Zavřít */
#viewer-info .meta { flex-wrap: nowrap; white-space: nowrap; }
#viewer-info .meta span:first-child { min-width: 0; overflow: hidden; }
#viewer-info .meta span:first-child { display: inline-flex; }
#viewer-info .meta .txt { overflow: hidden; text-overflow: ellipsis; }
#viewer-info .meta span:last-child { flex: none; }
@media (max-width: 600px) {
  #viewer-info .species { font-size: .95rem; }
  #viewer-info .meta { font-size: .84rem; gap: .6rem; }
  #viewer-info .meta svg.i { width: 15px; height: 15px; }
  .v-close { padding: .3rem .6rem; font-size: .82rem; min-height: 32px; }
  .v-close svg.i { width: 14px; height: 14px; }
}

/* text karty a náhledu: název zvířete méně tučně, místo a čas výrazněji */
.card .species, #viewer-info .species { font-weight: 500; letter-spacing: 0; }
.card .meta, #viewer-info .meta { font-weight: 650; color: #d6dfd1; }
.card .meta svg.i, #viewer-info .meta svg.i { color: var(--accent); stroke-width: 2.1; }

/* ---------- náhled na telefonu na šířku: fotka přes celou obrazovku, popis přes spodek fotky ---------- */
@media (orientation: landscape) and (max-height: 600px) {
  #viewer {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0;
    padding: 0; border: none; border-radius: 0; background: #000; overflow: hidden;
  }
  #viewer .viewer-stage { width: 100%; height: 100dvh; }
  #viewer-img { width: 100%; height: 100dvh; max-height: none; object-fit: contain; border-radius: 0; background: #000; }
  .viewer-bottom {
    position: absolute; left: 0; right: 0; bottom: 0; margin: 0; z-index: 2;
    padding: 1.6rem max(1rem, env(safe-area-inset-right)) calc(.6rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    background: linear-gradient(transparent, #000c 55%);
    align-items: flex-end;
  }
  #viewer-info .species { font-size: .95rem; }
  #viewer-info .species svg.em { width: 24px; height: 24px; }
  #viewer-info .meta { font-size: .9rem; margin-top: .1rem; }
  .v-close { background: #000a; border-color: #ffffff40; }
  .v-count { top: max(.6rem, env(safe-area-inset-top)); left: max(1rem, env(safe-area-inset-left)); }
  .v-nav { width: 46px; height: 46px; background: #0007; }
  .v-nav.prev { left: max(.6rem, env(safe-area-inset-left)); }
  .v-nav.next { right: max(.6rem, env(safe-area-inset-right)); }
}

/* ---------- přibližování fotky ---------- */
.viewer-stage { touch-action: none; overflow: hidden; border-radius: 12px; }
#viewer-img { transform-origin: center center; will-change: transform; cursor: zoom-in; user-select: none; -webkit-user-drag: none; }
#viewer.zoomed #viewer-img { cursor: grab; }
#viewer.zoomed .v-nav, #viewer.zoomed .v-count { opacity: 0; pointer-events: none; }
.v-nav, .v-count, .viewer-bottom { transition: opacity .2s; }
@media (orientation: landscape) and (max-height: 600px) {
  .viewer-stage { border-radius: 0; }
  #viewer.zoomed .viewer-bottom { opacity: 0; pointer-events: none; }
}

/* ---------- náhled: oprava druhu ---------- */
.viewer-bottom { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: .6rem; }
.v-fix { width: auto; min-width: 11rem; min-height: 38px; padding: .35rem 2rem .35rem .8rem; font-size: .9rem; border-radius: 10px; }
@media (max-width: 600px) {
  /* na výšku: popis + Zavřít v prvním řádku, oprava druhu přes celou šířku pod tím */
  .viewer-bottom { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "info close" "fix fix"; }
  #viewer-info { grid-area: info; }
  .v-close-form { grid-area: close; }
  .v-fix { grid-area: fix; width: 100%; min-width: 0; }
}
@media (orientation: landscape) and (max-height: 600px) {
  /* na šířku: vše v jednom řádku přes spodek fotky */
  .viewer-bottom { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: none; }
  #viewer-info, .v-close-form, .v-fix { grid-area: auto; }
  .v-fix { width: auto; min-width: 10rem; background-color: #000a; border-color: #ffffff40; }
}
