:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #1d2533;
  --muted: #6b7587;
  --line: #e1e5ec;
  --brand: #0b4f9c;
  --brand-ink: #ffffff;
  --danger: #c62828;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 Poppins, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 16px; font-weight: 600; }
h1 small { color: var(--muted); font-weight: 400; font-size: 15px; margin-left: 6px; }
h2 { font-size: 18px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; display: block; }
[hidden] { display: none !important; }

/* hlavička */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a {
  text-decoration: none; color: var(--ink); padding: 7px 12px; border-radius: 8px; font-weight: 500;
}
.top nav a:hover { background: var(--bg); }
.top nav a.on { background: var(--brand); color: var(--brand-ink); }
.top nav a.muted { color: var(--muted); }
main { padding: 24px; max-width: 1500px; margin: 0 auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* tlačítka a formuláře */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #c5ccd8; background: #fafbfc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: wait; }

label { display: block; font-weight: 500; font-size: 13.5px; margin-bottom: 12px; }
input[type=text], input[type=search], input[type=password], input[type=number], textarea, select {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; font-weight: 400;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 44px; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(11, 79, 156, .25); border-color: var(--brand); }
input[type=color] { display: block; width: 100%; height: 38px; margin-top: 4px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input[type=range] { width: 100%; }
label.chk { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.chk.inline { margin-top: 26px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
fieldset + fieldset { border-top: 1px solid var(--line); padding-top: 16px; }
.btn-bottom { display: flex; align-items: flex-end; padding-bottom: 12px; }

/* segmentový přepínač šablon */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.seg button {
  padding: 9px 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  font: inherit; font-size: 13px; cursor: pointer;
}
.seg button.on { border-color: var(--brand); background: rgba(11, 79, 156, .08); color: var(--brand); font-weight: 600; }

/* přehled */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.toolbar h1 { margin: 0; margin-right: auto; }
.filters { display: flex; gap: 8px; }
.filters input, .filters select { margin: 0; width: auto; }
.filters input { width: 240px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.post { overflow: hidden; display: flex; flex-direction: column; }
.post .thumb { display: block; background: #e9edf3; aspect-ratio: 1 / 1; }
.post .thumb.fmt-portrait { aspect-ratio: 4 / 5; }
.post .thumb.fmt-story { aspect-ratio: 9 / 16; }
.post .thumb.fmt-landscape { aspect-ratio: 1200 / 630; }
.post .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post .meta { padding: 10px 12px 4px; flex: 1; }
.post h3 { font-size: 14px; margin: 6px 0 2px; font-weight: 600; line-height: 1.35; }
.post .meta p { margin: 0; font-size: 12px; }
.post .actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px 12px; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.empty { padding: 40px; text-align: center; }
.pager { display: flex; gap: 4px; margin-top: 24px; justify-content: center; }
.pager a { padding: 6px 11px; border-radius: 8px; text-decoration: none; background: #fff; border: 1px solid var(--line); }
.pager a.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* editor */
.editor { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: 24px; align-items: start; }
.panel { padding: 20px; }
.preview { position: sticky; top: 76px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; margin-bottom: 16px; }
.bar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.status { color: var(--muted); font-size: 13px; margin-left: auto; padding-right: 6px; }
.canvas-wrap {
  display: flex; justify-content: center; align-items: flex-start; padding: 24px; border-radius: var(--radius);
  background: repeating-conic-gradient(#e7eaf0 0% 25%, #f1f3f7 0% 50%) 50% / 24px 24px;
}
#cv { max-width: 100%; max-height: calc(100vh - 220px); width: auto; height: auto; box-shadow: 0 8px 30px rgba(0, 0, 0, .18); background: #fff; }
.icon-pick { display: flex; gap: 8px; align-items: center; }
.icon-pick select { flex: 1; }
#icon-prev { width: 40px; height: 40px; margin-top: 4px; border: 1px solid var(--line); border-radius: 8px; flex: none; }
.photo-row { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.photo-row input[type=file] { font-size: 13px; margin-bottom: 6px; display: block; }
.photo-prev { width: 84px; height: 84px; border-radius: 8px; background: #e9edf3 center / cover no-repeat; border: 1px solid var(--line); flex: none; }
.photo-box > label { margin-bottom: 6px; }

/* nastavení */
.settings { display: grid; gap: 24px; }
.settings section { padding: 24px; }
.logos { margin: 8px 0; }
.logo-slot { border: 1px dashed var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.logo-prev { height: 90px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: #f3f5f8; color: var(--muted); font-size: 13px; }
.logo-prev.dark { background: #16365c; color: #9fb3cc; }
.logo-prev img { max-height: 70px; max-width: 90%; }
.cat-head, .cat-row {
  display: grid; grid-template-columns: 52px 1.3fr 1fr 1.2fr 64px 64px 64px 70px 56px 120px; gap: 8px; align-items: center;
}
.cat-head { font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 0 6px; }
.cat-row { padding: 8px 0; border-top: 1px solid var(--line); }
.cat-row input, .cat-row select { margin: 0; }
.cat-row input[type=checkbox] { justify-self: center; width: 18px; height: 18px; }
.cat-row.off { opacity: .55; }
.cat-row.dirty [data-save] { box-shadow: 0 0 0 3px rgba(11, 79, 156, .25); }
.cat-row .sw { width: 52px; height: 52px; border-radius: 8px; }
.cat-act { display: flex; gap: 4px; }
#cat-add { margin-top: 12px; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: #1d2533; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast.err { background: var(--danger); }

/* přihlášení */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-box { padding: 32px; width: 340px; }
.login-box .btn { width: 100%; justify-content: center; }
.err { color: var(--danger); }

@media (max-width: 980px) {
  .editor { grid-template-columns: 1fr; }
  .preview { position: static; order: -1; }
  .cat-head { display: none; }
  .cat-row { grid-template-columns: 52px 1fr 1fr; }
  main { padding: 16px; }
}
.logo-slot .btn { align-self: flex-start; }
