:root {
  --green: #14532d;
  --green-2: #166534;
  --red: #b91c1c;
  --red-2: #991b1b;
  --gold: #f4c95d;
  --bg: #fbf7ef;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e7e0d0;
  --radius: 14px;
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.topbar {
  background: var(--green);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 4px solid var(--red);
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
#userbar { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
#whoami { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Gumbi */
.btn {
  font: inherit;
  font-weight: 600;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--red); color: #fff; border-color: var(--red); }
.btn-primary:hover { background: var(--red-2); filter: none; }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-small { min-height: 40px; padding: 8px 12px; font-size: .9rem; }
.topbar .btn { min-height: 38px; padding: 6px 12px; }

:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}
.topbar :focus-visible { outline-color: var(--gold); }

/* Obrazci */
label { display: block; font-weight: 600; margin: 12px 0; }
input, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  font: inherit;
  font-weight: 400;
  padding: 10px 12px;
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
input:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: #2563eb; }
.form-error { color: var(--red); min-height: 1.4em; margin: 6px 0; font-weight: 600; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .05);
}
.login { max-width: 420px; margin: 24px auto; }
.login h2 { margin-top: 0; }
.login .btn { width: 100%; }

/* Osebe */
.person { margin-bottom: 32px; }
.person-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px dashed var(--line);
}
.person-head h2 { margin: 0; font-size: 1.3rem; color: var(--green); }
.person.mine .person-head h2::after {
  content: "moj seznam";
  margin-left: 8px;
  font-size: .75rem;
  background: var(--gold);
  color: #422006;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}
.person-empty { margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  main { padding: 12px; }
}

/* Kartice */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}
.card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #eee;
  display: block;
}
.card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.card-desc { margin: 0; color: var(--muted); font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.card-link { font-weight: 600; color: var(--green-2); overflow-wrap: anywhere; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.card-actions .btn { flex: 1 1 auto; }

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  width: fit-content;
  max-width: calc(100% - 20px);
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  padding: 5px 10px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card.claimed { background: #f1efe8; }
.card.claimed .card-img { filter: grayscale(.7) brightness(.6); }
.card.claimed .card-title { text-decoration: line-through; text-decoration-thickness: 1px; }
.card.claimed-by-me .badge { background: var(--red); }

/* Dialog */
dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog h2 { margin-top: 0; }
#image-preview { max-width: 100%; max-height: 220px; border-radius: 10px; display: block; margin: 8px 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* Obvestilo */
#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 20px);
  background: #111827;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  max-width: calc(100vw - 32px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--red-2); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
