/* =========================================================
   Seznam zážitků – dark, rychlý, bez masonry (modernized)
   - Vylepšená responzivita (lepší breakpoints, fluidní grid)
   - Lepší focus stavy (a11y), safe-areas, drobné ladění kontrastu
   - Plynulejší interakce a hezčí dropzona / thumbnails / lightbox
   ========================================================= */

/* ============ Design Tokens ============ */
:root{
  --bg:#0b0e14;
  --bg-2:#0e131b;
  --fg:#e9eef5;
  --muted:#a3adba;

  --card:rgba(255,255,255,.055);
  --card-2:rgba(255,255,255,.08);
  --border:rgba(255,255,255,.10);

  --accent:#25d366;
  --danger:#ff5b6e;

  --shadow-1:0 1px 2px rgba(0,0,0,.25);
  --shadow-2:0 6px 18px rgba(0,0,0,.22);

  --r:14px;
  --r-sm:10px;
  --gap:14px;

  --font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans";
  --fs-body:15.5px;
  --fs-h1:clamp(1.6rem,1.15rem + 1.7vw,2.25rem);

  --t-fast:.12s;
  --t-med:.18s;

  /* kontejnery / safe area */
  --container: 1200px;
  --gutter: max(14px, env(safe-area-inset-left, 0px));
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce){
  *{animation-duration:0.001ms !important;animation-iteration-count:1 !important;transition-duration:0.001ms !important;scroll-behavior:auto !important}
}

/* ============ Reset / Base ============ */
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  font-family:var(--font);
  font-size:var(--fs-body);
  color:var(--fg);
  background:
    radial-gradient(1100px 820px at -12% -8%, #162031 0%, #0e141c 65%) fixed,
    radial-gradient(1100px 820px at 112% -10%, #141f2e 0%, #0d1219 70%) fixed,
    linear-gradient(180deg, var(--bg), var(--bg-2)) fixed;
  background-attachment:fixed,fixed,fixed;
  background-repeat:no-repeat;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a{color:inherit;text-decoration:none}
img{display:block;max-width:100%;height:auto}
button{font:inherit;color:inherit;background:transparent;border:0;cursor:pointer}
input,select,textarea{font:inherit;color:inherit}
.hidden{display:none !important}

h1{
  text-align:center;margin:26px auto 10px;
  font-size:var(--fs-h1);letter-spacing:.2px;font-weight:700;line-height:1.15;
  color:#f3f7fc;text-shadow:0 1px 0 rgba(0,0,0,.35);
}

/* Focus states (a11y) */
:focus-visible{outline:3px solid color-mix(in oklab, var(--accent) 50%, transparent); outline-offset:2px; border-radius:10px}
.btn:focus-visible,.btn-outline:focus-visible,.action-btn:focus-visible,
.form input:focus-visible,.form select:focus-visible,.form textarea:focus-visible{outline:none; box-shadow:0 0 0 3px rgba(37,211,102,.28)}

/* ============ Horní lišta (auth) ============ */
.auth-bar{
  position:sticky;top:0;z-index:40;
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:10px 14px;border-bottom:1px solid var(--border);
  background:rgba(14,19,27,.9);
  backdrop-filter:saturate(120%) blur(6px);
}
.auth-bar .brand{font-weight:700;letter-spacing:.2px}
.auth-bar .auth-side{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}
.auth-bar .login-inline{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}
.auth-bar .login-inline input[type="text"],
.auth-bar .login-inline input[type="password"]{
  min-width:160px;padding:.55rem .75rem;border:1px solid var(--border);
  background:rgba(255,255,255,.06);border-radius:var(--r-sm);
  transition:border-color var(--t-med) ease, background var(--t-med) ease, box-shadow var(--t-med) ease;
  box-shadow:var(--shadow-1);
}
.auth-bar .login-inline input[type="text"]:focus,
.auth-bar .login-inline input[type="password"]:focus{
  border-color:var(--accent);background:rgba(255,255,255,.1);
  outline:none;box-shadow:0 0 0 3px rgba(37,211,102,.18);
}

/* ============ Buttons ============ */
.btn{
  background:var(--accent);color:#0b281a;
  padding:.55rem .88rem;border-radius:var(--r-sm);
  border:1px solid transparent;transition:transform var(--t-fast) ease, filter var(--t-med) ease, border-color var(--t-med) ease, box-shadow var(--t-med) ease;
  box-shadow:0 0 0 0 rgba(37,211,102,.0);
}
.btn.small{padding:.42rem .65rem;font-size:.94rem}
.btn:hover{transform:translateY(-1px);filter:saturate(1.02)}
.btn:active{transform:none}
.btn:focus-visible{outline:none;box-shadow:0 0 0 3px rgba(37,211,102,.28)}
.btn:disabled{opacity:.6;cursor:not-allowed}

.btn-outline{
  background:transparent;border:1px solid var(--border);color:var(--fg);
  border-radius:var(--r-sm);
  transition:border-color var(--t-med) ease, background var(--t-med) ease, box-shadow var(--t-med) ease, transform var(--t-fast) ease;
}
.btn-outline:hover{border-color:var(--accent);background:rgba(255,255,255,.06);transform:translateY(-1px)}
.btn-outline:focus-visible{outline:none;box-shadow:0 0 0 3px rgba(37,211,102,.18)}

/* Ikonová tlačítka */
.action-btn{
  width:34px;height:34px;border:1px solid var(--border);
  border-radius:var(--r-sm);background:rgba(255,255,255,.04);
  display:inline-flex;align-items:center;justify-content:center;
  transition:border-color var(--t-med) ease, background var(--t-med) ease, transform var(--t-fast) ease, box-shadow var(--t-med) ease;
  box-shadow:var(--shadow-1);
}
.action-btn:hover{border-color:var(--accent);background:rgba(255,255,255,.07);transform:translateY(-1px)}
.action-btn:active{transform:none}
.action-btn:focus-visible{outline:none;box-shadow:0 0 0 3px rgba(37,211,102,.18)}
.action-btn .ico{width:18px;height:18px;display:block;background:currentColor;mask-size:18px 18px;mask-position:center;mask-repeat:no-repeat}

/* SVG masky ikon (edit, koš) */
.ico-edit{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zm18-11.5a1.25 1.25 0 0 0 0-1.77l-1.98-1.98a1.25 1.25 0 0 0-1.77 0l-1.83 1.83l3.75 3.75L21 5.75z'/%3E%3C/svg%3E")}
.ico-trash{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M6 7h12v13a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V7zm3-4h6l1 1h4v2H2V4h4l1-1z'/%3E%3C/svg%3E")}

/* ============ Kontejnery ============ */
.top-forms,#list{max-width:var(--container);margin-inline:auto}
.top-forms{display:grid;grid-template-columns: repeat(12,minmax(0,1fr));gap:var(--gap);padding:12px var(--gutter) 0}
.form-card{grid-column:1 / -1;background:var(--card);border:1px solid var(--border);border-radius:var(--r);padding:12px;box-shadow:var(--shadow-1)}
.form-card h2{font-size:1.02rem;font-weight:700;margin-bottom:8px;letter-spacing:.2px}
.form-card.locked{color:var(--muted)}
@media (min-width: 980px){
  #addForm{grid-column:1 / span 7}
  #filters{grid-column:8 / span 5}
}
@media (max-width: 640px){
  .top-forms{grid-template-columns: 1fr; gap:12px; padding-inline: var(--gutter)}
}

/* ============ Form ============ */
.form{display:block}
.grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:10px}
.field{grid-column:span 6;display:flex;flex-direction:column;gap:6px}
.field.full{grid-column:1 / -1}
.field label{font-size:.92rem;color:var(--muted);font-weight:600}
.field .help{color:var(--muted);font-size:.85rem}
.input{position:relative}
.input.with-icon .icon{position:absolute;left:10px;top:50%;transform:translateY(-50%);width:18px;height:18px;color:var(--muted);pointer-events:none}
.input.with-icon input{padding-left:34px}

/* Inputs */
.form input[type="text"],
.form input[type="password"],
.form textarea,
.form select{
  width:100%;background:rgba(255,255,255,.06);border:1px solid var(--border);
  color:var(--fg);border-radius:12px;padding:.62rem .8rem;
  transition:border-color var(--t-med) ease, background var(--t-med) ease, box-shadow var(--t-med) ease;
  box-shadow:var(--shadow-1);
}
.form textarea{resize:vertical;min-height:42px;max-height:320px;line-height:1.45}
.form input::placeholder,.form textarea::placeholder{color:var(--muted)}
.form input:focus,.form textarea:focus,.form select:focus{
  border-color:var(--accent);background:rgba(255,255,255,.1);outline:none;box-shadow:0 0 0 3px rgba(37,211,102,.18);
}

/* Select */
.form select{
  appearance:none;-webkit-appearance:none;-moz-appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cpath fill='%23a8afba' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 10px center;padding-right:38px;
}
.form select option{background:#0f141b;color:var(--fg)}

/* Switch */
.switch{display:inline-flex;gap:.55rem;align-items:center;color:var(--muted)}
.switch input[type="checkbox"]{
  appearance:none;-webkit-appearance:none;-moz-appearance:none;
  width:44px;height:24px;border-radius:999px;background:rgba(255,255,255,.08);
  border:1px solid var(--border);position:relative;transition:background var(--t-med),border-color var(--t-med), box-shadow var(--t-med);
  box-shadow:var(--shadow-1) inset;
}
.switch input[type="checkbox"]::after{
  content:"";position:absolute;top:2px;left:2px;width:20px;height:20px;border-radius:50%;background:#cbd5e1;
  transition:transform var(--t-med), background var(--t-med);box-shadow:0 1px 2px rgba(0,0,0,.35);
}
.switch input[type="checkbox"]:checked{background:var(--accent);border-color:transparent}
.switch input[type="checkbox"]:checked::after{transform:translateX(20px);background:#0d1c15}

/* ============ Dropzone & Previews ============ */
.dropzone{border:1px dashed var(--border);background:rgba(255,255,255,.05);padding:12px;border-radius:12px;text-align:center;transition:border-color var(--t-med) ease, background var(--t-med) ease, box-shadow var(--t-med) ease}
.dropzone.is-clickable{cursor:pointer}
.dropzone .dropzone-text{color:var(--muted);display:flex;flex-direction:column;gap:8px;align-items:center;justify-content:center}
.dropzone .dropzone-text .help{font-size:.85rem}
.dropzone.drag{border-color:var(--accent);background:rgba(37,211,102,.12);box-shadow:0 0 0 3px rgba(37,211,102,.18) inset}

#addPreviews,.edit-new-previews{display:flex;flex-wrap:wrap;gap:.55rem;margin-top:6px}
.img-chip{
  display:grid;grid-template-columns:36px 1fr auto;align-items:center;gap:.45rem;
  padding:.32rem .55rem;border-radius:10px;background:rgba(255,255,255,.06);
  border:1px solid var(--border);box-shadow:var(--shadow-1)
}
.img-chip .thumb{width:36px;height:36px;overflow:hidden;border-radius:8px;background:#0002;display:grid;place-items:center}
.img-chip .thumb img{width:100%;height:100%;object-fit:cover}
.img-chip .name{font-size:.86rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.img-chip .remove{width:26px;height:26px;border-radius:999px;background:transparent;color:#fff;opacity:.85}
.img-chip .remove:hover{opacity:1}

/* Progress */
.upload-progress{display:none;height:4px;background:#0003;border-radius:999px;overflow:hidden;margin-top:6px}
.upload-progress.active{display:block}
.upload-progress .bar{height:100%;width:0%;background:var(--accent);transition:width .2s ease}
.saving-indicator.add-saving{display:none;font-size:.9rem;color:var(--muted);margin-top:4px}
.saving-indicator.add-saving.show{display:inline-block}

/* ============ LIST ============ */
#list{
  padding:14px var(--gutter) 34px;
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(280px, 48vw, 360px), 1fr));
  gap: var(--gap);
}
@media (max-width: 420px){ #list{ grid-template-columns: 1fr; } }

/* Karta položky */
.item{
  position:relative;background:var(--card);border:2px solid var(--border);
  border-radius:var(--r);padding:12px;
  transition:border-color var(--t-med) ease, background var(--t-med) ease, transform var(--t-fast) ease, box-shadow var(--t-med) ease;
  box-shadow:var(--shadow-1);will-change:transform;
}
.item:hover{border-color:rgba(255,255,255,.16);background:var(--card-2);transform:translateY(-1px);box-shadow:var(--shadow-2)}
.item .title-label{display:flex;align-items:center;gap:.6rem;font-size:1.04rem;font-weight:700;line-height:1.25}
.item .title{overflow-wrap:anywhere}

/* Barevné orámování podle tagů (podpora gradientu + border-radius) */
.item {
  position: relative;
  border-radius: var(--r);
  overflow: hidden; /* aby obsah respektoval radius */
}
.item::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 2px; /* tloušťka rámečku */
  border-radius: var(--r);
  background: var(--cat-border, #03dac6);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
/* Hover: jemný glow */
.item:hover::before {
  box-shadow: 0 0 6px rgba(255,255,255,.25);
}
/* Pokud je položka splněná, nech jen gradientový border (bez zeleného override) */
.item:has(.toggle-complete:checked)::before,
.item.is-complete::before {
  background: var(--cat-border, #03dac6);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* Splněno *//* Splněno *//* Splněno */
.item:has(.toggle-complete:checked),
.item.is-complete{
  border-color:rgba(57,217,138,.38);
  background:linear-gradient(180deg, rgba(37,211,102,.08), rgba(255,255,255,.03));
  box-shadow:0 0 0 1px rgba(37,211,102,.18) inset, var(--shadow-1);
}
.item:has(.toggle-complete:checked) .title-label{color:#eafdf3}

/* Checkbox vpravo nahoře */
.item .toggle-complete{
  appearance:none;-webkit-appearance:none;
  position:absolute;top:10px;right:10px;width:36px;height:36px;margin:0;
  border:1px solid var(--border);border-radius:var(--r-sm);
  background:rgba(255,255,255,.045);display:grid;place-items:center;
  transition:border-color var(--t-med), background var(--t-med), box-shadow var(--t-med), transform var(--t-fast);
  color:#c5ccd6;box-shadow:var(--shadow-1);
}
.item .toggle-complete::before{
  content:"";width:18px;height:18px;background:currentColor;
  mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='m9 16.2l-3.5-3.5l-1.4 1.4L9 19l11-11l-1.4-1.4z'/%3E%3C/svg%3E") no-repeat center/18px 18px;
}
.item .toggle-complete:hover{border-color:var(--accent);background:rgba(255,255,255,.08);transform:translateY(-1px)}
.item .toggle-complete:checked{background:var(--accent);color:#0d1c15;border-color:transparent;box-shadow:0 0 0 3px rgba(37,211,102,.18)}

/* Kategorie badge */
.category{
  display:inline-flex;align-items:center;gap:.45rem;margin-top:6px;font-size:.86rem;color:#0b281a;
  padding:.18rem .55rem;border-radius:999px;background:var(--accent);box-shadow:var(--shadow-1);
}

/* Poznámka */
.item .note{margin-top:8px;color:var(--muted);white-space:pre-line;font-style:italic;line-height:1.5}

/* ===== HLAVIČKA – mini náhled + text ===== */
.head{
  display:flex;align-items:center;gap:10px;margin-top:4px;
}
.head .mini{
  flex:0 0 88px;width:88px;aspect-ratio:1/1;border-radius:12px;overflow:hidden;
  background:rgba(255,255,255,.06);box-shadow:inset 0 0 0 1px var(--border), var(--shadow-1);position:relative
}
.head .mini img{width:100%;height:100%;object-fit:cover;display:block}
.head .mini .count{
  position:absolute;right:6px;bottom:6px;min-width:22px;height:22px;padding:0 6px;border-radius:999px;
  display:inline-flex;align-items:center;justify-content:center;font-size:.78rem;font-weight:700;
  background:rgba(0,0,0,.55);color:#fff;border:1px solid rgba(255,255,255,.18);backdrop-filter:blur(4px)
}
.head.no-thumb .mini{display:none}
.head .meta-wrap{min-width:0;display:flex;flex-direction:column;gap:6px;flex:1}
.head .title-label{display:flex;align-items:center;gap:.6rem;font-size:1.04rem;font-weight:700;line-height:1.25}
.head .title{overflow-wrap:anywhere}

/* Akce – v patičce karty */
.item .actions{display:flex;gap:.45rem;margin-top:10px;justify-content:flex-end}

/* Edit */
.edit-form{display:none;margin-top:12px;padding-top:12px;border-top:1px dashed var(--border)}
.edit-form input,.edit-form select,.edit-form textarea{
  width:100%;margin-bottom:8px;background:rgba(255,255,255,.06);
  border:1px solid var(--border);color:var(--fg);border-radius:12px;padding:.55rem .7rem;box-shadow:var(--shadow-1)
}
.edit-form .actions{display:flex;gap:10px;margin-top:10px;justify-content:center}
.btn-save{background:var(--accent);color:#0b281a;border-radius:var(--r-sm);padding:.5rem .75rem}

/* ===== Edit thumbs (čtverce + remove + rotate) ===== */
.edit-form .thumbs{display:grid;gap:6px;margin-top:8px;grid-template-columns:repeat(auto-fill,minmax(88px,1fr))}
.edit-form .thumbs .thumb{
  position:relative;aspect-ratio:1/1;overflow:hidden;border-radius:12px;background:rgba(255,255,255,.04);
  box-shadow:inset 0 0 0 1px var(--border), var(--shadow-1)
}
.edit-form .thumbs .thumb img{width:100%;height:100%;object-fit:cover}
.edit-form .thumbs .thumb .remove,
.edit-form .thumbs .thumb .rotate{
  display:inline-flex;position:absolute;top:6px;right:6px;width:24px;height:24px;border-radius:999px;
  background:#000a;color:#fff;border:0;align-items:center;justify-content:center;font-size:14px;line-height:1;box-shadow:var(--shadow-1)
}
.edit-form .thumbs .thumb .rotate{ right:36px }
/* One-row thumbnails collapse + toggle */
.thumbs{display:grid;gap:6px;grid-template-columns:repeat(auto-fill,minmax(88px,1fr))}
.thumbs.collapsed{max-height:var(--rowH,88px);overflow:hidden;position:relative}
.thumbs.collapsed::after{
  content:"";position:absolute;left:0;right:0;bottom:0;height:32px;
  background:linear-gradient(180deg, rgba(14,19,27,0), rgba(14,19,27,.85));
  pointer-events:none
}
.thumbs-toggle{display:flex;justify-content:center;margin-top:6px}
.thumbs-toggle .btn-outline{padding:.35rem .7rem;font-size:.9rem}


/* Meta / Soukromé */
.item .meta{display:none}
.item[data-private="1"] .title-label::after{content:"🔒";font-size:.95rem;margin-left:.35rem;opacity:.75}

/* Guest lock */
body.auth-guest .item .toggle-complete,
body.auth-guest .item .actions,
body.auth-guest .edit-form{display:none !important}
body.auth-guest #addForm{display:none}
body.auth-guest .locked{display:block}

/* ============ Kategorie panel ============ */
.cats-panel{grid-column:1 / -1}
.inline-form{display:flex;gap:.6rem;flex-wrap:wrap;align-items:center;margin-bottom:8px}
.inline-form input[type="text"]{min-width:220px}
.inline-form input[type="color"]{
  width:40px;height:36px;border-radius:8px;border:1px solid var(--border);background:transparent;padding:0;cursor:pointer
}
.inline-form .id-hint{color:var(--muted)}
.table-wrap{width:100%;overflow:auto;border-radius:12px;border:1px solid var(--border);box-shadow:var(--shadow-1)}
.cats-table{width:100%;border-collapse:collapse;min-width:560px}
.cats-table thead th{
  text-align:left;padding:10px 12px;font-weight:700;font-size:.95rem;background:rgba(255,255,255,.05);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:1
}
.cats-table tbody td{padding:10px 12px;border-bottom:1px solid var(--border);vertical-align:middle}
.cats-table tbody tr:hover{background:rgba(255,255,255,.04)}
.cats-table .muted{color:var(--muted);font-variant-numeric:tabular-nums}
.cats-table .actions{display:flex;gap:.4rem;justify-content:flex-end}
.cats-table .swatch{display:inline-block;width:1.05rem;height:1.05rem;border-radius:999px;border:1px solid rgba(0,0,0,.25);vertical-align:middle}

/* ============ Lightbox ============ */
.lightbox{position:fixed;inset:0;z-index:100;background:rgba(0,0,0,.74);display:flex;align-items:center;justify-content:center;opacity:0;pointer-events:none;transition:opacity var(--t-med) ease}
.lightbox.open,.lightbox:not(.hidden){opacity:1;pointer-events:auto}
.lightbox img{max-width:92vw;max-height:88vh;border-radius:12px;box-shadow:var(--shadow-2)}
.lb-nav{position:absolute;top:50%;transform:translateY(-50%);width:44px;height:44px;border-radius:999px;background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.2)}
.lb-nav:hover{background:rgba(255,255,255,.18)}
.lb-nav.prev{left:18px}
.lb-nav.next{right:18px}
.lb-nav::before{content:"";display:block;width:20px;height:20px;margin:auto;margin-top:12px;background:#fff;mask-size:20px 20px;mask-position:center;mask-repeat:no-repeat}
.lb-nav.prev::before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='m15.41 7.41l-1.41-1.41l-6 6l6 6l1.41-1.41l-4.58-4.59z'/%3E%3C/svg%3E")}
.lb-nav.next::before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='m8.59 16.59l1.41 1.41l6-6l-6-6l-1.41 1.41l4.59 4.59z'/%3E%3C/svg%3E")}
.lb-close{position:absolute;top:14px;right:14px;width:38px;height:38px;border-radius:999px;background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.2)}
.lb-close::before{content:"";display:block;width:20px;height:20px;margin:auto;margin-top:9px;background:#fff;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M18.3 5.71L12 12l6.3 6.29l-1.41 1.42L10.59 13.41L4.29 19.7L2.88 18.3L9.17 12L2.88 5.71L4.29 4.29l6.3 6.3l6.3-6.3z'/%3E%3C/svg%3E") no-repeat center/20px 20px}

/* Rotate button */
.lb-rotate{
  position:absolute;left:14px;top:14px;width:38px;height:38px;border-radius:999px;background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.2)
}
.lb-rotate::before{
  content:"";display:block;width:20px;height:20px;margin:auto;margin-top:9px;background:#fff;
  mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M12 6V3l-4 4l4 4V8c2.76 0 5 2.24 5 5c0 1.01-.3 1.95-.82 2.73l1.46 1.46A6.98 6.98 0 0 0 19 13c0-3.87-3.13-7-7-7zm-5 5c0-1.01.3-1.95.82-2.73L6.36 6.81A6.98 6.98 0 0 0 5 13c0 3.87 3.13 7 7 7v3l4-4l-4-4v3c-2.76 0-5-2.24-5-5z'/%3E%3C/svg%3E") no-repeat center/20px 20px
}

/* Loader / Toast */
.infinite-loader{display:flex;gap:.6rem;align-items:center;justify-content:center;color:var(--muted);padding:12px;margin:8px 14px 24px}
.infinite-loader.hidden{display:none}
.spinner{width:16px;height:16px;border-radius:50%;border:2px solid rgba(255,255,255,.25);border-top-color:var(--accent);animation:spin 1s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

#toast-container{position:fixed;right:16px;bottom:16px;display:flex;flex-direction:column;gap:8px;z-index:120}
.toast{background:rgba(16,21,28,.95);border:1px solid var(--border);padding:10px 12px;border-radius:10px;min-width:220px;transform:translateY(8px);opacity:0;transition:transform var(--t-med) ease, opacity var(--t-med) ease, border-color var(--t-med) ease, box-shadow var(--t-med) ease;box-shadow:var(--shadow-1)}
.toast.show{transform:translateY(0);opacity:1}
.toast.success{border-left:3px solid rgba(57,217,138,.75)}
.toast.error{border-left:3px solid rgba(255,91,110,.8)}


/* === Lightbox subtle transitions === */
#lightbox {
  /* ensure buttons and image are positioned correctly */
  position: fixed;
  inset: 0;
}
#lightbox-img {
  transition: transform 0.22s ease, opacity 0.22s ease;
  will-change: transform, opacity;
}
/* leaving states */
#lightbox-img.slide-left-out  { transform: translateX(-24px); opacity: 0; }
#lightbox-img.slide-right-out { transform: translateX( 24px); opacity: 0; }
/* entering states */
#lightbox-img.slide-left-in   { transform: translateX( 0); opacity: 1; }
#lightbox-img.slide-right-in  { transform: translateX( 0); opacity: 1; }
/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  #lightbox-img { transition: none; }
}


/* Hide old explicit upload button inside edit */
.edit-upload-send{display:none !important;}


/* === Označení fotek ke smazání (aplikuje se po Uložit) === */
.thumb.marked-delete { outline: 2px solid rgba(220, 38, 38, 0.9); position: relative; }
.thumb .del-badge {
  position: absolute; top: 6px; right: 6px;
  font-size: 11px; line-height: 1; padding: 4px 6px;
  background: rgba(220,38,38,.92); color: #fff; border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.2); pointer-events: none; user-select: none;
}



/* === Edit queued deletions === */
.thumb.to-delete {
  outline: 2px dashed rgba(255,0,0,.6);
  position: relative;
  opacity: .7;
}
.thumb .undo-remove{
  position:absolute;
  bottom:6px;
  right:6px;
  font-size:12px;
  line-height:1;
  padding:6px 8px;
  border-radius:6px;
  background: rgba(0,0,0,.6);
  color:#fff;
  border:0;
  cursor:pointer;
}



/* === Badge: Odstraní se po uložení === */
.thumb .to-delete-badge{
  position:absolute;
  top:6px;
  left:6px;
  font-size:12px;
  padding:4px 8px;
  border-radius:8px;
  background: rgba(220, 53, 69, .9);
  color:#fff;
  pointer-events:none;
}
.edit-form [type="submit"].is-busy,
.edit-form .btn-save.is-busy{
  opacity:.6;
  cursor:default;
}


/* === Edit queue info and ribbons === */
.edit-queue-info{
  margin-bottom: 8px;
  font-size: 13px;
  opacity: .9;
}
.edit-queue-info.empty{ display:none; }

.thumb.to-delete::after{
  content: "Odstranit po uložení";
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(220, 53, 69, .9);
  color: #fff;
  pointer-events: none;
}

.edit-reset-deletes{
  margin-left: 8px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 0;
  background: rgba(0,0,0,.12);
  cursor: pointer;
}


/* === Simplified delete mark === */
.thumb.to-delete { opacity: .7; outline: none; }
.thumb .undo-remove, .to-delete-badge, .edit-reset-deletes, .edit-queue-info { display: none !important; }
.thumb.to-delete::after { display:none !important; content:none !important; }



/* ===== Drag & drop reorder (edit thumbs) ===== */
.edit-form .thumbs .thumb{ cursor: grab; }
.edit-form .thumbs .thumb.dragging{ opacity:.65; cursor: grabbing; outline:2px dashed var(--accent); outline-offset:2px; }
.edit-form .thumbs .thumb::after{ content:""; position:absolute; inset:0; pointer-events:none; border-radius:12px; }



/* Lightbox content container (keeps original look; only ensures video fits) */
#lightbox-content{display:flex;align-items:center;justify-content:center;max-width:92vw;max-height:88vh}
#lightbox-content video{max-width:92vw;max-height:88vh;outline:0;border:0;border-radius:12px;display:block}


/* === Video overlay poster === */
.video-wrap{ position: relative; display: block; }
.video-wrap > video{ display:block; width:100%; height:auto; }
.video-wrap > .video-overlay{
  position:absolute; inset:0;
  width:100%; height:100%;
  object-fit:cover;
  transition: opacity .2s ease;
  opacity:1;
  cursor:pointer;
  background:#000;
}


/* === Busy overlay to block interactions during critical actions === */
body.is-busy { cursor: progress; }
#app-busy-overlay {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(0,0,0,0.35);
  z-index: 9999;
  backdrop-filter: blur(1px);

  /* nové */
  display: flex;
  align-items: center;
  justify-content: center;
}

#app-busy-overlay > div {
  display: flex;
  align-items: center;
  justify-content: center; /* nové – vycentruje text se spinnerem */
}

#app-busy-overlay .spinner{
  width: 28px; height: 28px; border: 3px solid #fff; border-top-color: transparent; border-radius: 50%;
  animation: spin 0.9s linear infinite; margin-right: 10px;
}
#app-busy-overlay .ovl{ background:rgba(0,0,0,.55); border:1px solid rgba(255,255,255,.18); border-radius:14px; padding:14px 16px; box-shadow: 0 12px 30px rgba(0,0,0,.35); display:flex; flex-direction:column; align-items:center; gap:8px; }
#app-busy-overlay .label{ color:#fff; font-weight:600; font-size:14px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#app-busy-overlay>div{ display:flex; align-items:center; }
@keyframes spin{ to{ transform: rotate(360deg); } }


/* Overlay progress bar */
#app-busy-overlay .progress{ width:min(520px, 82vw); height:6px; background:#0006; border-radius:999px; overflow:hidden; display:none }
#app-busy-overlay .progress.active{ display:block }
#app-busy-overlay .progress .bar{ height:100%; width:0%; background:var(--accent); transition: width .2s ease }

/* Multi-select nicer */
.form select[multiple]{ min-height: 116px; padding-right: .8rem; background-image: none; }
.form select[multiple] option{ padding: .35rem .5rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.form select[multiple] option:checked{ background: color-mix(in srgb, var(--accent) 40%, transparent); }

/* Inline tags next to each other */
.meta-wrap .tags{ display:flex; flex-wrap:wrap; gap:.4rem; margin-top:6px }
.meta-wrap .tags .category{ margin-top:0 }


/* === Top-forms grid-areas: keep Add & Filters side-by-side; Cats below === */
@media (min-width: 980px){
  body.auth-user .top-forms{
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "add filters"
      "cats cats";
    gap: 1.25rem;
  }
  body.auth-user #addForm{ grid-area: add; }
  body.auth-user #filters{ grid-area: filters; }
  body.auth-user #catsPanel{ grid-area: cats; }
}
/* Mobile/narrow: simple vertical flow (Add -> Filters -> Cats) */
@media (max-width: 979.98px){
  .top-forms{ display: grid; grid-template-columns: 1fr; gap: 1rem; }
  #addForm, #filters, #catsPanel{ grid-column: 1 / -1; }
}
/* Guests: single column with Filters full-width; Cats hidden elsewhere */
body.auth-guest .top-forms{ grid-template-columns: 1fr; }
body.auth-guest #filters{ grid-column: 1 / -1; width: 100%; }
.top-forms > *{ min-width: 0; width: 100%; box-sizing: border-box; }


/* === AddForm: responsive, well-balanced layout === */
#addForm .form{ width: 100%; }
#addForm .grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
/* Desktop: two columns by default; .full spans whole row */
@media (min-width: 980px){
  #addForm .grid{ grid-template-columns: repeat(12, minmax(0,1fr)); gap: 1.1rem; }
  #addForm .grid > .field{ grid-column: span 6; }          /* half width */
  #addForm .grid > .field.full{ grid-column: 1 / -1; }     /* full width for marked fields */
}

/* Compact labels and inputs */
#addForm .field{ display: flex; flex-direction: column; }
#addForm .field label{ font-size: .85rem; opacity: .85; margin-bottom: .35rem; }
#addForm .field .input{ min-width: 0; width: 100%; }

/* With-icon inputs alignment */
#addForm .input.with-icon{ position: relative; }
#addForm .input.with-icon .icon{ position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); pointer-events: none; }
#addForm .input.with-icon input{ padding-left: 2rem; }

/* Submit row centered if it's marked as full */
#addForm .grid > .field.full .btn{
  justify-self: center;
}

/* Media uploads / previews keep full row naturally if marked .full */
#addForm #addPreviews, #addForm .upload-progress, #addForm .saving-indicator{
  max-width: 100%;
}


/* === Lightbox – refined responsive style & controls === */
.lightbox{
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px circle at 50% 50%, rgba(0,0,0,.72), rgba(0,0,0,.9));
  backdrop-filter: blur(4px);
  z-index: 1000;
  padding: 20px; /* breathing room on tiny screens */
}
.lightbox.hidden{ display: none; }

/* Media */
#lightbox-img{
  max-width: min(96vw, 1200px);
  max-height: 86vh;
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,.55);
  animation: lb-zoom .18s ease-out both;
  user-select: none;
  -webkit-user-drag: none;
}
@keyframes lb-zoom{
  from{ opacity: 0; transform: translateY(8px) scale(.985); }
  to{ opacity: 1; transform: translateY(0) scale(1); }
}

/* Shared button base */
.lb-nav, .lb-close{
  display: inline-grid;
  place-items: center;
  width: clamp(40px, 6vw, 56px);
  height: clamp(40px, 6vw, 56px);
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  cursor: pointer;
  transition: transform .12s ease, background-color .12s ease, box-shadow .12s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
.lb-nav:hover, .lb-close:hover{ background: rgba(255,255,255,.20); transform: translateY(-1px); }
.lb-nav:focus-visible, .lb-close:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,.5); }

/* Arrows */
.lb-nav{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.lb-nav.prev{ left: clamp(10px, 3vw, 24px); }
.lb-nav.next{ right: clamp(10px, 3vw, 24px); }

/* Close */
.lb-close{
  position: absolute;
  top: clamp(8px, 2.5vw, 20px);
  right: clamp(8px, 2.5vw, 20px);
}

/* Caption */
#lightbox-caption{
  margin-top: .6rem;
  text-align: center;
  color: #f1f1f1;
  font-size: clamp(.85rem, .8rem + .25vw, 1rem);
  max-width: min(96vw, 1100px);
  text-wrap: balance;
}

/* Counter */
#lightbox-counter{
  position: absolute;
  bottom: clamp(8px, 2.5vw, 20px);
  right: clamp(10px, 3vw, 24px);
  font-size: .9rem;
  color: #e5e7eb;
  background: rgba(0,0,0,.35);
  padding: .25rem .6rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
}

/* Small screens: keep buttons near edges but not overlapping the image */
@media (max-width: 560px){
  .lb-nav.prev{ left: 8px; }
  .lb-nav.next{ right: 8px; }
  .lb-close{ top: 8px; right: 8px; }
}


/* === Auth-bar manage categories button === */
.auth-bar .btn-manage-cats{
  margin-left: .75rem;
  border-radius: 8px;
  padding: .45rem .9rem;
  font-size: .9rem;
  line-height: 1.2;
}
.auth-bar .btn-manage-cats:hover{
  background: rgba(255,255,255,.15);
}

/* (refresh) */

/* Auth bar manage-cats button */
.auth-bar .btn-manage-cats{
  margin-left: .75rem;
  border-radius: 10px;
  padding: .45rem .9rem;
  font-size: .9rem;
}
.auth-bar .btn-manage-cats:hover{
  background: rgba(255,255,255,.15);
}

/* Guests: no manage button */
body.auth-guest .btn-manage-cats{ display:none !important; }


/* === Multi-select improved styling === */
select[multiple]{
  background: var(--bg-input, rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: .4rem .5rem;
  min-height: 120px;
  color: #fff;
  font-size: .9rem;
  line-height: 1.4;
  resize: vertical;
  scrollbar-width: thin;             /* Firefox */
  scrollbar-color: rgba(255,255,255,.25) transparent;
}

/* Options */
select[multiple] option{
  padding: .25rem .4rem;
  border-radius: 6px;
  margin: 1px 0;
}
select[multiple] option:checked{
  background: rgba(59,130,246,.35);
  color: #fff;
}

/* WebKit scrollbars */
select[multiple]::-webkit-scrollbar{
  width: 8px;
}
select[multiple]::-webkit-scrollbar-track{
  background: transparent;
}
select[multiple]::-webkit-scrollbar-thumb{
  background-color: rgba(255,255,255,.25);
  border-radius: 6px;
}
select[multiple]::-webkit-scrollbar-thumb:hover{
  background-color: rgba(255,255,255,.35);
}


/* Guests: never show private items even if cached HTML slips through */
body.auth-guest #list .item[data-private="1"]{ display:none !important; }

/* =========================================================
   Responsive & Eye-Comfort Refinements — v2025-08-28
   Notes:
   - Appended overrides only (non-destructive). Original kept above.
   - Tuned for softer contrast, better spacing on mobile, and a calmer look.
   - Supports safe areas, thin scrollbars, and touch-friendly controls.
   ========================================================= */

/* Declare color scheme for native widgets (date, inputs, etc.) */
:root { color-scheme: dark; }

/* Fluid base sizes and gaps */
:root{
  /* Slightly larger, fluid body size; keeps headings proportional via existing vars */
  --fs-body: clamp(14.5px, 0.38vw + 13.2px, 16.5px);
  /* Fluid container and gaps for nicer breathing room on big/small screens */
  --container: min(1100px, 94vw);
  --gap: clamp(12px, 1.2vw, 18px);
}

/* Global rhythm: calmer reading */
body{ line-height: 1.6; letter-spacing: 0.01em; }

/* Headline balance on narrower screens */
@media (max-width: 520px){
  h1{ margin: 18px auto 8px; }
}

/* Touch targets: ensure comfortable height on mobile */
@media (max-width: 640px){
  .btn, .btn-outline{ min-height: 44px; }
  .action-btn{ width: 40px; height: 40px; }
  .field{ grid-column: 1 / -1; } /* Single column form on small screens */
  .top-forms{ gap: 12px; }
}

/* Better spacing between stacked blocks on very small screens */
@media (max-width: 380px){
  .form-card{ padding: 10px; }
  .item{ padding: 10px; }
}

/* Container padding tuned to safe areas */
#list, .top-forms{ padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }

/* Subtle hover for cards: respect reduced motion */
@media (prefers-reduced-motion: no-preference){
  .item:hover{ transform: translateY(-2px); }
}

/* Softer card backgrounds for eye comfort (slightly less contrast) */
.item{ background: color-mix(in srgb, var(--card) 85%, transparent); }
.item:hover{ background: color-mix(in srgb, var(--card-2) 88%, transparent); }

/* Inputs: bigger tap padding on small screens */
@media (max-width: 640px){
  .form input[type="text"],
  .form input[type="password"],
  .form textarea,
  .form select{ padding: .72rem .9rem; }
}

/* Selection highlight: align with accent */
::selection{ background: color-mix(in oklab, var(--accent) 36%, transparent); color: #eaf7ef; }

/* Thin, modern scrollbars (Firefox + WebKit) */
*{ scrollbar-width: thin; scrollbar-color: #3a475d transparent; }
::-webkit-scrollbar{ width: 10px; height: 10px; }
::-webkit-scrollbar-track{ background: transparent; }
::-webkit-scrollbar-thumb{ background: #3a475d; border-radius: 12px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover{ background: #4a5a73; }

/* Lightbox stage: ensure padding on tiny screens so media never hugs the edges */
@media (max-width: 480px){
  .lightbox img, #lightbox img, #lightbox video, #lightbox-content video{
    max-width: 94vw; max-height: 82vh;
  }
}

/* Thumbnails one-row collapse – ensure toggle area has a bit more space on mobile */
@media (max-width: 640px){
  .thumbs-toggle{ margin-top: 8px; }
  .thumbs .thumb{ border-radius: 10px; }
}

/* Table wrapper: smoother horizontal scroll on small screens */
.table-wrap{ -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }

/* Toaster messages: slightly calmer animation + readability */
#toast-container .toast{
  backdrop-filter: saturate(120%) blur(6px);
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* Busy overlay: clearer progress visibility on OLED dark */
#app-busy-overlay .ovl{
  background: rgba(10,14,20,.64);
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* Form help text readability */
.field .help{ line-height: 1.45; }

/* Category badge: reduce glare a bit */
.category{
  filter: saturate(0.96);
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
}

/* Auth bar: prevent wrap-jank on small screens */
@media (max-width: 520px){
  .auth-bar{ flex-wrap: wrap; row-gap: 8px; }
  .auth-bar .login-inline input[type="text"],
  .auth-bar .login-inline input[type="password"]{ min-width: 0; flex: 1 1 140px; }
}

/* Ensure grid never produces overly-wide cards on very large screens */
@media (min-width: 1440px){
  #list{ grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}


/* ===== Search Autocomplete ===== */
.ac-wrap{position:relative}
.ac-panel{
  position:absolute;left:0;right:0;top:100%;margin-top:6px;z-index:50;
  background:rgba(255,255,255,.06);border:1px solid var(--border);border-radius:12px;
  box-shadow:var(--shadow-2);backdrop-filter:saturate(120%) blur(6px);
  max-height:320px;overflow:auto;display:none
}
.ac-panel.open{display:block}
.ac-item{padding:.5rem .75rem;cursor:pointer;display:flex;align-items:center;gap:.5rem}
.ac-item:hover,.ac-item.active{background:rgba(255,255,255,.08)}
.ac-empty{padding:.55rem .75rem;color:var(--muted)}
/* ensure suggestions align with iconified input */
.input.with-icon.ac-wrap .ac-panel{left:0;right:0}


/* ===== RTE (poznámka) ===== */
.rte { border:1px solid var(--border); border-radius:12px; background:rgba(255,255,255,.03); }
.rte-toolbar{ display:flex; gap:.25rem; padding:.35rem; border-bottom:1px solid var(--border); 
  flex-wrap: wrap;
}
.rte-toolbar .btn{ font:inherit; padding:.25rem .5rem; border:1px solid var(--border); background:transparent; border-radius:8px; cursor:pointer }
.rte-toolbar .btn[aria-pressed="true"]{ outline:2px solid var(--primary); }
.rte-editor{ min-height:110px; padding:.6rem .75rem; outline:none; }
.rte-editor:empty:before{ content:attr(data-placeholder); color:var(--muted); }
.rte small.hint{ display:block; padding:.3rem .6rem; color:var(--muted); border-top:1px dashed var(--border); }


/* RTE + note list spacing */
.rte-editor ul, .rte-editor ol { margin: .4rem 0 .4rem 1.25rem; padding-left: 1.25rem; }
.rte-editor li { margin: .12rem 0; }
.note ul, .note ol { margin: .4rem 0 .4rem 1.25rem; padding-left: 1.25rem; list-style-position: outside; }
.note li { margin: .12rem 0; }
.note a { text-decoration: underline; }


/* Better link styling in editor and notes */
.rte-editor a {
  color: var(--primary, #3498db);
  text-decoration: underline;
  cursor: pointer;
}
.rte-editor a:hover {
  color: var(--primary-hover, #4da3ff);
}
.note a {
  color: var(--primary, #3498db);
  text-decoration: underline;
  font-weight: 500;
}
.note a:hover {
  color: var(--primary-hover, #4da3ff);
  text-decoration: none;
}

/* RTE toolbar polish */
.rte { overflow: hidden; }
.rte-toolbar { position: sticky; top: 0; background: rgba(0,0,0,.12); backdrop-filter: blur(4px); 
  flex-wrap: wrap;
}
.rte-toolbar .btn { transition: background .15s ease, border-color .15s ease; }
.rte-toolbar .btn:hover { background: rgba(255,255,255,.06); }
.rte-toolbar .sep { width:1px; height:22px; background: var(--border); margin: 0 .35rem; align-self:center; }
.rte-editor { line-height: 1.45; }
.rte-editor p { margin: .4rem 0; }

/* === Collapsible toolbar (auth-bar) === */
.auth-bar .burger{display:none;border:1px solid var(--border);border-radius:12px;padding:.45rem .6rem;line-height:1;background:rgba(255,255,255,.06)}
@media (max-width: 900px){
  .auth-bar{align-items:stretch}
  .auth-bar .burger{display:inline-flex;align-items:center;justify-content:center;margin-left:auto}
  .auth-bar #authControls{width:100%;overflow:hidden;max-height:0;transition:max-height var(--t-med) ease}
  .auth-bar #authControls.open{max-height:520px}
  .auth-bar .auth-side{flex-wrap:wrap}
}
/* === /Collapsible toolbar === */

/* === Random Picker Modal === */
.modal{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;z-index:100;pointer-events:none}
.modal.hidden{display:none}
.modal .modal-bg{position:absolute;inset:0;background:rgba(0,0,0,.5);backdrop-filter:blur(3px);pointer-events:auto}
.modal .modal-card{position:relative;width:min(960px, 94vw);max-height:88vh;background:var(--bg);border:1px solid var(--border);border-radius:18px;box-shadow:var(--shadow-2);display:flex;flex-direction:column;overflow:hidden;pointer-events:auto}
.modal .modal-head{display:flex;align-items:center;gap:.75rem;padding:12px 14px;border-bottom:1px solid var(--border)}
.modal .modal-head h3{font-size:1.1rem;margin:0}
.modal .modal-close{border:1px solid var(--border);border-radius:10px;padding:.3rem .5rem;background:transparent}
.modal .modal-body{display:grid;grid-template-columns: 280px 1fr;gap:14px;padding:14px;overflow:auto}
.modal .modal-foot{display:flex;gap:.5rem;align-items:center;padding:12px 14px;border-top:1px solid var(--border)}
.modal .modal-foot .spacer{flex:1}
.modal .modal-filters{border:1px dashed var(--border);border-radius:14px;padding:10px}
.modal .mf-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
.modal .mf-cats{display:grid;grid-template-columns:1fr 1fr;gap:8px;max-height:48vh;overflow:auto}
.modal .mf-cats label{display:flex;gap:.5rem;align-items:center;padding:6px 8px;border:1px solid var(--border);border-radius:10px;background:rgba(255,255,255,.03)}
.modal .mf-cats input{accent-color:var(--accent)}
.rp-result.empty{display:flex;align-items:center;justify-content:center;min-height:220px;color:var(--muted)}
.rp-result .item{margin:0}
.item.pulse{animation:pulseShadow .9s ease 0s 1}
@keyframes pulseShadow{0%{box-shadow:0 0 0 rgba(255,255,255,0)}40%{box-shadow:0 0 0 6px rgba(255,255,255,.08)}100%{box-shadow:0 0 0 rgba(255,255,255,0)}}
@media (max-width: 820px){ .modal .modal-body{grid-template-columns:1fr} }
/* === /Random Picker Modal === */



/* === Pulse highlight of chosen item === */
.item{transition: outline-color .25s ease, outline-offset .25s ease, box-shadow .25s ease;}
.item.pulse{
  position: relative;
  z-index: 1;
  outline: 2px solid color-mix(in srgb, var(--pulse, #0ea5e9) 75%, transparent);
  outline-offset: 2px;
}
.item.pulse::after{
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  pointer-events: none;
  background: color-mix(in srgb, var(--pulse, #0ea5e9) 18%, transparent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--pulse, #0ea5e9) 40%, transparent);
  animation: rpPulseOverlay 1.4s ease-out forwards;
}
@keyframes rpPulseOverlay{
  0%   { opacity: 0; box-shadow: 0 0 0 0 color-mix(in srgb, var(--pulse, #0ea5e9) 40%, transparent); }
  15%  { opacity: 1; }
  45%  { box-shadow: 0 0 0 8px color-mix(in srgb, var(--pulse, #0ea5e9) 26%, transparent); }
  75%  { opacity: .6; box-shadow: 0 0 0 4px color-mix(in srgb, var(--pulse, #0ea5e9) 18%, transparent); }
  100% { opacity: 0; box-shadow: 0 0 0 0 transparent; }
}
/* === /Pulse highlight of chosen item === */


/* Random Picker: multi-select categories */
.mf-select{
  width: 100%;
  min-height: 8rem;
  padding: .5rem;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(0,0,0,.2);
  color: inherit;
  border-radius: .5rem;
}
.mf-select option{ padding: .2rem .3rem; }
@media (min-width: 700px){
  .mf-select{ min-height: 12rem; }
}


/* Statistiky nad seznamem */
.stats {
  font-size: 0.9em;
  color: #aaa;
  margin: 0 0 10px 4px;
}
.stats span { margin-right: 8px; }


/* Top stats near the heading */
.top-stats{
  font-size:.9em;
  color: var(--muted, #a8b0bd);
  margin: 0 0 10px 2px;
  display:block;
  white-space: normal;
}
.top-stats .muted{ color: var(--muted, #a8b0bd); }


/* Stats Modal */
.stats-summary{ display:flex; gap:16px; margin-bottom:12px; flex-wrap:wrap }
.stats-summary .stat{ background:var(--card); border:1px solid var(--border); border-radius:12px; padding:10px 12px; min-width:120px; text-align:center; }
.stats-summary .stat .val{ font-size:20px; font-weight:700; }
.stats-summary .stat .lbl{ font-size:12px; color:var(--muted) }
.stats-table{ width:100%; border-collapse:collapse; }
.stats-table th, .stats-table td{ padding:8px 10px; border-bottom:1px solid var(--border); }
.stats-table th{ text-align:left; font-weight:600; }
.stats-table td.num, .stats-table th.num{ text-align:right; }
.cat-dot{ display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:6px; vertical-align:middle; }
.loading{ opacity:.8; }
.error{ color:#ff6b6b; }


/* Danger button style */
.btn-outline.danger{ border-color:#ff6b6b; color:#ff6b6b; }
.btn-outline.danger:hover{ background:rgba(255,107,107,.1); }

/* Prevent grid items from overflowing in #addForm */
#addForm .grid > .field{ min-width: 0; }

/* === Unified input styles === */
:where(input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="search"], input[type="number"], input[type="date"], input[type="time"], input[type="color"], select, textarea){
  appearance: none; -webkit-appearance: none;
  background: var(--card-1, rgba(255,255,255,.02));
  color: var(--fg, #e6e6e6);
  border: 1px solid var(--border, rgba(255,255,255,.14));
  border-radius: var(--r-sm, 10px);
  padding: .55rem .75rem;
  line-height: 1.2; box-sizing: border-box;
}
:where(input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="search"], input[type="number"], input[type="date"], input[type="time"], input[type="color"], select, textarea):focus-visible{
  outline: none; box-shadow: 0 0 0 3px rgba(37,211,102,.28); border-color: var(--accent, #25d366);
}
.inline-form{ display:flex; flex-wrap:wrap; gap:.5rem; align-items:center; }
.inline-form > *{ margin:0; }
select{ padding-right: 2rem; }
input[type="color"]{ padding:0; height:38px; width:46px; border-radius:var(--r-sm, 10px); }
.inline-form input, .inline-form select, .inline-form textarea{ max-width:100%; }

/* === #addForm responsive wrap (641–979px) === */
@media (min-width: 641px) and (max-width: 979px){
  #addForm .grid{ grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important; grid-auto-flow: row dense; }
  #addForm .grid > .field{ grid-column: auto; }
  #addForm .grid > .field.full{ grid-column: 1 / -1; }
}

/* === Field semantic states via :has() === */
@supports selector(:has(*)){
  .field:has(:focus-within) label{ opacity:1; color: var(--fg); }
  .field:has(:invalid) label{ color: var(--danger, #ff5b6e); }
  .field:has(:invalid) :where(input, select, textarea){
    border-color: var(--danger, #ff5b6e); box-shadow: 0 0 0 3px rgba(255,77,79,.18);
  }
}

/* === Cats table polish === */
.cats-table tbody td{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px){
  .cats-table{ min-width: 0; border-collapse: separate; border-spacing: 0; }
  .cats-table thead{ display: none; }
  .cats-table tbody{ display: grid; gap: .6rem; }
  .cats-table tbody tr{
    display: grid; grid-template-columns: 1fr auto; gap: .5rem .75rem;
    padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 12px;
    background: var(--card-1, rgba(255,255,255,.02));
  }
  .cats-table tbody td{ border: 0; padding: .2rem 0; }
  .cats-table tbody td:nth-child(3){ font-size: .9rem; color: var(--muted); }
  .cats-table .actions{ align-self: start; justify-content: flex-end; }
}

/* === Unified micro-animations === */ 
:where(button,.btn,:is(input,select,textarea),.form-card,.item){
  transition: background var(--t-med) ease, color var(--t-med) ease, border-color var(--t-med) ease, box-shadow var(--t-med) ease, transform var(--t-med) ease;
}
@media (prefers-reduced-motion: reduce){
  :where(button,.btn,:is(input,select,textarea),.form-card,.item){ transition: none; }
}

/* === Sticky filters + compact on scroll === */
#filters.form-card{ top: var(--auth-h, 54px); z-index: 30; backdrop-filter: saturate(120%) blur(4px); }
html.scrolled #filters.form-card{ padding: 10px 12px; }
html.scrolled #filters.form-card h2{ font-size: 1rem; margin-bottom: .4rem; }

/* === Unified checkbox-as-switch styling === */
@supports selector(label:has(> input[type="checkbox"])) {
  label:has(> input[type="checkbox"]):not(.switch):not(.action-toggle){
    display:inline-flex; gap:.55rem; align-items:center; color: var(--muted);
  }
  label:has(> input[type="checkbox"]):not(.switch):not(.action-toggle) > input[type="checkbox"]{
    appearance:none; -webkit-appearance:none; -moz-appearance:none;
    width:44px; height:24px; border-radius:999px; background:rgba(255,255,255,.08); border:1px solid var(--border);
    position:relative; transition:background var(--t-med), border-color var(--t-med), box-shadow var(--t-med);
    box-shadow:var(--shadow-1) inset;
  }
  label:has(> input[type="checkbox"]):not(.switch):not(.action-toggle) > input[type="checkbox"]::after{
    content:""; position:absolute; top:2px; left:2px; width:20px; height:20px; border-radius:50%; background:#cbd5e1;
    transition:transform var(--t-med), background var(--t-med);
  }
  label:has(> input[type="checkbox"]):not(.switch):not(.action-toggle) > input[type="checkbox"]:checked{ background:var(--accent); border-color:transparent; }
  label:has(> input[type="checkbox"]):not(.switch):not(.action-toggle) > input[type="checkbox"]:checked::after{ transform:translateX(20px); background:#0d1c15; }
  label:has(> input[type="checkbox"]):not(.switch):not(.action-toggle) > input[type="checkbox"]:focus-visible{ outline:none; box-shadow:0 0 0 3px var(--focus-ring); }
}
