:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --line: #e2e2de;
  --text: #1d1d1b;
  --muted: #7a7a74;
  --accent: #2f5bea;
  --accent-soft: #e8eefd;
  --danger: #c8372d;
  --radius: 10px;
  --st-koncept: #8a8a84;
  --st-ke-schvaleni: #d98a00;
  --st-schvaleno: #2a9d55;
  --st-publikovano: #2f5bea;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.muted { color: var(--muted); }

/* ---------- horní lišta ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; margin: 0; }
.nav { display: flex; align-items: center; gap: 6px; flex: 1; }
.week-label { margin-left: 12px; font-size: 16px; font-weight: 600; display: flex; gap: 10px; align-items: baseline; }
.week-label .muted { font-size: 13px; font-weight: 400; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f0f0ec; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
#prevWeek, #nextWeek { font-size: 18px; padding: 3px 12px; }

/* ---------- týden ---------- */
.week {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, minmax(170px, 1fr));
  gap: 10px;
  padding: 14px 20px 20px;
  overflow-x: auto;
  min-height: 0;
}

.day {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: border-color .15s, background .15s;
}
.day.today { border-color: var(--accent); }
.day.dragover { background: var(--accent-soft); border-color: var(--accent); border-style: dashed; }

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.day-name { font-weight: 600; text-transform: capitalize; }
.day-date { color: var(--muted); font-size: 13px; }
.day.today .day-date { color: var(--accent); font-weight: 600; }
.day-add {
  border: none; background: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.day-add:hover { color: var(--accent); }

.day-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.day-empty { color: var(--muted); font-size: 12px; text-align: center; margin-top: 16px; }

/* ---------- karta ---------- */
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  cursor: grab;
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.card.dragging { opacity: .4; }
.card-img {
  aspect-ratio: 4 / 5;
  background: #ecece8 center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-weight: 600; font-size: 13px;
}
.card-body { padding: 7px 9px 8px; }
.card-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 4px; }

.status {
  font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--muted);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status[data-s="koncept"] { color: var(--st-koncept); }
.status[data-s="ke-schvaleni"] { color: var(--st-ke-schvaleni); }
.status[data-s="schvaleno"] { color: var(--st-schvaleno); }
.status[data-s="publikovano"] { color: var(--st-publikovano); }

.badge {
  font-size: 10px; font-weight: 700;
  background: #31a8ff22; color: #0b6fb8;
  border-radius: 4px; padding: 1px 5px;
}

.drop-indicator { height: 3px; background: var(--accent); border-radius: 2px; }

/* ---------- modaly ---------- */
.modal {
  border: none;
  border-radius: 14px;
  padding: 22px;
  width: min(760px, 94vw);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal.wide { width: min(1000px, 96vw); }
.modal::backdrop { background: rgba(20,20,18,.45); }
.modal h2 { margin: 0 0 16px; font-size: 18px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.fields { display: flex; flex-direction: column; gap: 12px; }
.fields > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="date"], textarea, select {
  font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: #fff;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  min-height: 300px;
  display: flex; align-items: center; justify-content: center;
  text-align: center; color: var(--muted);
  cursor: pointer; position: relative; overflow: hidden;
  background: #fafaf8;
}
.drop.small { min-height: 74px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.has-file { border-style: solid; }
.drop.small.has-file { color: var(--text); background: #fff; }
.drop-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #ecece8; }

.detail { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.detail-img {
  background: #ecece8; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  min-height: 420px; max-height: 70vh; overflow: hidden;
}
.detail-img img { max-width: 100%; max-height: 70vh; object-fit: contain; display: block; }
.placeholder { color: var(--muted); }

.files { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.file-row { display: flex; align-items: center; gap: 10px; }
.file-label { width: 64px; font-size: 12px; font-weight: 600; color: var(--muted); }
.file-link { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); text-decoration: none; font-size: 13px; }
.file-link:hover { text-decoration: underline; }
.file-link.none { color: var(--muted); pointer-events: none; }

.progress { position: relative; height: 22px; background: #ecece8; border-radius: 6px; overflow: hidden; margin-top: 14px; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.progress .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; mix-blend-mode: difference; color: #fff; }

.error { color: var(--danger); margin: 10px 0 0; }

.actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 18px; }
.actions .spacer { flex: 1; }

/* ---------- role ---------- */
body:not(.admin) .admin-only { display: none !important; }
body:not(.viewer) .viewer-only { display: none !important; }
body.viewer .card { cursor: pointer; }
body.viewer .day-add { display: none; }
body.locked .topbar, body.locked .week { display: none; }

/* ---------- přihlášení ---------- */
.auth { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth[hidden] { display: none; }
.auth-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; width: min(380px, 100%);
  display: flex; flex-direction: column; gap: 14px;
}
.auth-box h2 { margin: 0; }
.auth-box p { margin: 0; }
.auth-box label, .row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
input[type="password"] { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

/* ---------- sdílení ---------- */
.modal h3 { font-size: 14px; margin: 22px 0 10px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 180px; }
.row label.check { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 9px; font-weight: 400; color: var(--text); }
.small { font-size: 12px; }
.share-list { list-style: none; padding: 0; margin: 12px 0 6px; display: flex; flex-direction: column; gap: 6px; }
.share-list li { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.share-list .s-label { font-weight: 600; }
.share-list .s-meta { flex: 1; color: var(--muted); font-size: 12px; }
.share-list:empty::after { content: "Zatím žádné odkazy."; color: var(--muted); font-size: 13px; }

.export-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.export-row[hidden], .source-info[hidden] { display: none; }
.source-info { margin: 0; }
.source-info.warn { color: var(--st-ke-schvaleni); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px;
  z-index: 1000;
}

@media (max-width: 760px) {
  .grid2, .detail { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; }
}
