:root {
  --bg: #eef1f4;
  --card: #ffffff;
  --card-2: #f6f8fa;
  --line: #d3dae1;
  --line-strong: #b9c2cc;
  --text: #1b2430;
  --muted: #56616f;
  --accent: #e3a815;
  --on-accent: #1b2430;
  --primary: #1b2430;
  --on-primary: #ffffff;
  --error: #c2412d;
  --c0: #2f6fd6; --c1: #c2412d; --c2: #3e8a5a; --c3: #8a57c7;
  --c4: #d08a12; --c5: #1f8a94; --c6: #b5487e; --c7: #6b7684;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c; --card: #1a2129; --card-2: #1d252e; --line: #2e3843; --line-strong: #4a5663;
    --text: #e8edf2; --muted: #9aa6b3; --accent: #f0b92e; --on-accent: #11161c;
    --primary: #e8edf2; --on-primary: #11161c; --error: #ef6b55;
    --c0: #6fa0f0; --c1: #ef7b66; --c2: #6cc08a; --c3: #b38bea;
    --c4: #f0b24a; --c5: #4fc0c9; --c6: #e27dae; --c7: #9aa6b3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11161c; --card: #1a2129; --card-2: #1d252e; --line: #2e3843; --line-strong: #4a5663;
  --text: #e8edf2; --muted: #9aa6b3; --accent: #f0b92e; --on-accent: #11161c;
  --primary: #e8edf2; --on-primary: #11161c; --error: #ef6b55;
  --c0: #6fa0f0; --c1: #ef7b66; --c2: #6cc08a; --c3: #b38bea;
  --c4: #f0b24a; --c5: #4fc0c9; --c6: #e27dae; --c7: #9aa6b3;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 760px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bar { display: flex; align-items: center; gap: 8px; min-height: 64px; padding-top: env(safe-area-inset-top); }
.bar h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand::before { content: ""; width: 8px; height: 24px; border-radius: 3px; background: var(--accent); }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%; background: transparent;
}
.icon-btn:hover { background: var(--card-2); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid var(--line-strong);
  background: var(--card); font-weight: 600;
}
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.btn.danger { color: var(--error); border-color: var(--error); }
.btn.text { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.wide { width: 100%; }

.fab {
  position: fixed; right: max(16px, calc(50vw - 364px)); bottom: calc(20px + env(safe-area-inset-bottom));
  height: 56px; padding: 0 22px; border: 0; border-radius: 18px;
  background: var(--accent); color: var(--on-accent); font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 4px 14px rgb(0 0 0 / .18);
}
.fab svg { width: 22px; height: 22px; fill: currentColor; }

.search {
  width: 100%; height: 48px; padding: 0 16px; border-radius: 24px;
  border: 1px solid var(--line); background: var(--card);
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: 17px; border: 1px solid var(--line); background: var(--card); font-size: 14px; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip .n { opacity: .7; font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.month { margin: 20px 4px 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card {
  display: flex; width: 100%; text-align: left; gap: 12px; padding: 0; margin-bottom: 8px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
.card:hover { border-color: var(--line-strong); }
.card .stripe { width: 5px; flex: none; }
.card .body { flex: 1; min-width: 0; padding: 12px 14px 12px 0; }
.card .title { font-weight: 700; overflow-wrap: anywhere; }
.card .meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.card .snip { font-size: 14px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

.panel { border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 16px; margin-bottom: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--error); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

.detail-cat { font-weight: 700; }
.detail-title { font-size: 26px; font-weight: 800; margin: 4px 0; overflow-wrap: anywhere; }
.detail-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 16px; }

form.edit { display: grid; gap: 14px; }
label.field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card); color: var(--text);
}
.field textarea { min-height: 180px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

.cat-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: 0; }
.cat-row input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card-2); }
.swatch { width: 26px; height: 26px; border-radius: 7px; border: 2px solid transparent; flex: none; }
.swatch[aria-pressed="true"] { border-color: var(--text); }
.palette { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0 10px 36px; }

.status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.status.ok .pip { background: var(--c2); }
.status.warn .pip { background: var(--accent); }
.status.err .pip { background: var(--error); }
@media (max-width: 520px) {
  .bar .status .label { display: none; }
  .bar .status .pip { width: 12px; height: 12px; }
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--primary); color: var(--on-primary); font-size: 14px; box-shadow: 0 4px 14px rgb(0 0 0 / .2);
}
.welcome { min-height: 80vh; display: grid; align-content: center; gap: 16px; }
.welcome h1 { font-size: 38px; margin: 0; }

/* obrázky */
.img-count { display: inline-flex; align-items: center; gap: 3px; }
.img-count svg { width: 14px; height: 14px; fill: currentColor; }
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 16px; }
.field .gallery { margin: 0 0 4px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--card-2); border: 1px solid var(--line); }
.thumb-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.missing .thumb-open::after {
  content: "Stahuje se…"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; color: var(--muted);
}
.thumb-remove {
  position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgb(0 0 0 / .6); color: #fff;
}
.thumb-remove svg { width: 18px; height: 18px; fill: currentColor; }

.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #000; color: #fff; overflow: hidden;
}
.viewer::backdrop { background: rgb(0 0 0 / .9); }
.viewer[open] { display: grid; place-items: center; }
.viewer img { max-width: 100%; max-height: 100dvh; object-fit: contain; }
.viewer-missing { color: #ccc; }
.viewer-bar {
  position: fixed; top: env(safe-area-inset-top); right: 0; display: flex; align-items: center; gap: 8px; padding: 8px;
}
.viewer-count { font-size: 14px; }
.viewer .icon-btn { color: #fff; background: rgb(0 0 0 / .45); }
.viewer .icon-btn:hover { background: rgb(255 255 255 / .15); }
.viewer-nav {
  position: fixed; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  display: flex; justify-content: space-between; padding: 0 8px; pointer-events: none;
}
.viewer-nav .icon-btn { pointer-events: auto; width: 48px; height: 48px; }

/* přílohy */
.files { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; }
.field .files { margin: 0 0 4px; }
.files li { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.file-open {
  flex: 1; min-width: 0; display: grid; grid-template-columns: 24px 1fr; column-gap: 10px; align-items: center;
  padding: 8px 12px; border: 0; background: none; text-align: left;
}
.file-open svg { width: 22px; height: 22px; fill: var(--muted); grid-row: span 2; }
.file-name { overflow-wrap: anywhere; color: var(--text); }
