/* Flachsmarkt Fotowettbewerb – Farbwelt von foto.flachsmarkt.de
   Schriften: nur Systemschriften – keine Webfont-Dateien, keine externen Abrufe (Datenschutz, Ladezeit). */

:root {
  --bg: #F2EABB;
  --bg-soft: #f8f3d6;
  --card: #fffdf2;
  --text: #4d4d4d;
  --muted: #7a7560;
  --primary: #407101;
  --primary-dark: #2f5401;
  --primary-light: #e3f0d3;
  --line: #e2d89d;
  --heart: #d23c4b;
  --danger: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 14px rgba(0, 0, 0, .06);
  --font: 'Segoe UI', Arial, sans-serif;          /* Überschriften, Menü, Knöpfe */
  --font-body: 'Segoe UI', Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* hidden-Attribut gewinnt immer gegen display-Regeln */
[id] { scroll-margin-top: 80px; } /* Sprungziele nicht unter dem fixierten Kopf verstecken */
html { -webkit-text-size-adjust: 100%; }
html.lb-open { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font-body);
}
h1, h2, h3, h4, .brand, .mainnav, .chip, .btn, .rank, .lb-title { font-family: var(--font); font-weight: 500; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: .2em 0 .4em; color: var(--primary-dark); }
h2 { font-size: 1.4rem; margin: 1.4em 0 .5em; color: var(--primary-dark); }
h3 { font-size: 1.15rem; margin: 1.2em 0 .4em; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
small, .muted { color: var(--muted); font-weight: 400; }
h1 small { font-size: .5em; margin-left: .4em; }

.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 18px; padding-bottom: 48px; min-height: 60vh; }

/* ---------------------------------------------------------- Kopf */
.site-header { background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 1.3rem; letter-spacing: .02em; margin-right: auto; white-space: nowrap; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; }
.brand:hover { color: #fff; }
.brand img { height: 44px; width: auto; max-width: 160px; object-fit: contain; flex: none; }
@media (max-width: 420px) {
  .brand { font-size: 1.08rem; gap: 8px; }
  .brand img { height: 38px; }
  .header-inner { gap: 8px; }
}
.mainnav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mainnav a, .mainnav .linklike {
  color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: 1.02rem;
  background: none; border: 0; cursor: pointer; font-family: var(--font); font-weight: 400;
}
.mainnav a:hover, .mainnav .linklike:hover { background: rgba(255,255,255,.14); }
.mainnav a.active { background: var(--bg); color: var(--primary-dark); }
.nav-form { margin: 0; }
.nav-toggle { display: none; background: none; border: 0; padding: 10px; cursor: pointer; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: #fff; margin: 5px 0; border-radius: 2px; }

@media (max-width: 1120px) {
  .nav-toggle { display: block; }
  .mainnav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--primary-dark);
             flex-direction: column; align-items: stretch; padding: 8px 16px 14px; gap: 2px; }
  .mainnav.open { display: flex; }
  .mainnav a, .mainnav .linklike { padding: 12px; font-size: 1.1rem; text-align: left; width: 100%; }
}

.contest-bar { background: var(--primary-light); border-bottom: 1px solid #cfe2b8; font-size: .92rem; }
.contest-bar .wrap { padding-top: 8px; padding-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: space-between; }
.whoami { color: var(--muted); }
.countdown { display: inline-block; margin-left: 8px; padding: 1px 10px; border-radius: 999px; background: var(--primary);
             color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------------------------------------------------- Footer */
.site-footer { border-top: 1px solid var(--line); padding: 20px 0 28px; font-size: .9rem; }
.site-footer .wrap { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.site-footer a { color: var(--muted); }

/* ---------------------------------------------------------- Meldungen, Formulare */
/* Meldungen: eigene Hintergrundfarbe + Symbol, damit sie auch in hellen Boxen auffallen */
.msg {
  position: relative; padding: 12px 16px 12px 48px; margin: 0 0 16px; border-radius: 8px;
  border: 1px solid; border-left-width: 6px; font-weight: 600; line-height: 1.45;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.msg::before {
  position: absolute; left: 14px; top: 11px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font: 700 .85rem/1 var(--font-body); color: #fff;
}
.msg-ok   { background: #dcedc8; border-color: #407101; color: #23400a; }
.msg-ok::before   { content: '\2713'; background: #407101; }
.msg-err  { background: #fbdcd9; border-color: #b3261e; color: #6e130e; }
.msg-err::before  { content: '!'; background: #b3261e; }
.msg-info { background: #d9f0fa; border-color: #1a87b5; color: #0b4560; }
.msg-info::before { content: 'i'; background: #1a87b5; font-style: italic; font-family: Georgia, serif; }
.empty { padding: 28px; text-align: center; background: var(--card); border-radius: var(--radius); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2:first-child { margin-top: 0; }
.cols { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); align-items: start; }

form label { display: block; margin: 0 0 14px; font-weight: 600; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], input[type=file], select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-weight: 400;
  border: 1px solid #d3c98d; border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
textarea { min-height: 320px; font-family: Consolas, monospace; font-size: .9rem; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: 4px; width: 20px; height: 20px; flex: none; accent-color: var(--primary); }
.hint { font-size: .9rem; color: var(--muted); margin: -6px 0 14px; font-weight: 400; }
.hint.err { color: var(--danger); }
.hint.ok { color: var(--primary); }
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

.btn {
  display: inline-block; padding: 10px 20px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 1.05rem; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-ghost:hover { background: var(--primary); }
.btn-small { padding: 6px 12px; font-size: .92rem; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8c1d17; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; margin: 0; }
details summary { cursor: pointer; color: var(--primary); font-weight: 600; }

/* ---------------------------------------------------------- Galerie */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 20px; margin-bottom: 14px; }
.page-head p { margin: 0 0 6px; flex-basis: 100%; }
.sortbar { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 14px; border-radius: 999px; background: var(--card); color: var(--text); text-decoration: none; border: 1px solid var(--line); font-size: .98rem; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
@media (max-width: 600px) { .grid { gap: 8px; grid-template-columns: repeat(2, 1fr); } }
.grid-top { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.tile { position: relative; margin: 0; border-radius: var(--radius); overflow: hidden; background: #e8dfa8; box-shadow: var(--shadow); aspect-ratio: 1 / 1; }
.tile-link { display: block; width: 100%; height: 100%; }
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.tile:hover img { transform: scale(1.04); }
.tile figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 64px 8px 10px; pointer-events: none;
  background: linear-gradient(transparent, rgba(0,0,0,.65)); color: #fff; line-height: 1.25;
}
.cap-title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.cap-user { display: block; font-size: .8rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank { position: absolute; top: 8px; left: 8px; z-index: 2; background: var(--primary); color: #fff; min-width: 36px; height: 36px;
        border-radius: 18px; display: grid; place-items: center; font-size: 1.15rem; padding: 0 8px; box-shadow: var(--shadow); }
.grid-top .tile:nth-child(1) .rank { background: #c9a227; }
.grid-top .tile:nth-child(2) .rank { background: #9aa0a6; }
.grid-top .tile:nth-child(3) .rank { background: #b07a3d; }

.heart {
  position: absolute; right: 8px; bottom: 8px; z-index: 2; display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.92); color: var(--text); border: 0; border-radius: 999px; padding: 6px 10px 6px 8px;
  cursor: pointer; font: 600 .92rem var(--font-body); box-shadow: 0 1px 4px rgba(0,0,0,.2); min-height: 36px;
}
.heart svg { width: 20px; height: 20px; fill: none; stroke: var(--heart); stroke-width: 2; transition: fill .15s; }
.heart:hover svg, .heart.on svg { fill: var(--heart); }
.heart.pop svg { animation: pop .45s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }
.more-wrap { text-align: center; margin: 24px 0; }

/* ---------------------------------------------------------- Lightbox */
.lb { position: fixed; inset: 0; z-index: 100; background: rgba(20, 22, 14, .96); display: flex; flex-direction: column; }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 56px 64px 8px; position: relative; }
.lb-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 10px 40px rgba(0,0,0,.5); user-select: none; }
.lb-spinner { position: absolute; width: 40px; height: 40px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%;
              animation: spin .8s linear infinite; display: none; }
.lb.loading .lb-spinner { display: block; }
.lb.loading .lb-img { opacity: .4; }
@keyframes spin { to { transform: rotate(360deg); } }
.lb-btn { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; cursor: pointer; border-radius: 50%;
          width: 48px; height: 48px; font-size: 2rem; line-height: 1; display: grid; place-items: center; }
.lb-btn:hover { background: rgba(255,255,255,.25); }
.lb-btn:disabled { opacity: .2; cursor: default; }
.lb-close { top: 10px; right: 12px; }
.lb-prev { left: 10px; top: 45%; }
.lb-next { right: 10px; top: 45%; }
.lb-info { display: flex; align-items: center; gap: 16px; justify-content: center; padding: 12px 16px 18px; color: #fff; }
.lb-text { min-width: 0; text-align: left; }
.lb-title { font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-author { opacity: .8; font-size: .95rem; }
.heart-lg { position: static; padding: 10px 16px 10px 12px; font-size: 1.05rem; }
.heart-lg svg { width: 26px; height: 26px; }
@media (max-width: 700px) {
  .lb-stage { padding: 52px 0 4px; }
  .lb-prev, .lb-next { top: auto; bottom: 18px; width: 44px; height: 44px; }
  .lb-info { padding: 10px 60px 16px; justify-content: space-between; }
  .lb-title { font-size: 1.05rem; }
}
.lb-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; transition: .25s;
            background: #222; color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 120; pointer-events: none;
            max-width: calc(100% - 32px); text-align: center; font-size: .95rem; }
.lb-toast.show { opacity: 1; transform: translate(-50%, 0); }
.lb-toast.in-lb { bottom: 96px; }

/* Großer Countdown bis zum Start (Bilder, Top 10) */
.bigcount { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff; text-align: center;
            border-radius: 16px; padding: clamp(22px, 4vw, 44px) clamp(14px, 3vw, 40px); margin: 4px 0 24px; box-shadow: var(--shadow); }
.bigcount-kicker { font: 500 clamp(1.25rem, 3.2vw, 1.9rem)/1.2 var(--font); margin: 0 0 clamp(14px, 2.5vw, 24px); letter-spacing: .02em; }
.bigcount-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(6px, 2vw, 18px); max-width: 760px; margin: 0 auto; }
.bigcount-grid > div { background: rgba(255, 255, 255, .13); border: 1px solid rgba(255, 255, 255, .18); border-radius: 12px;
                       padding: clamp(10px, 2.6vw, 24px) 2px; min-width: 0; }
.bigcount-grid b { display: block; font: 600 clamp(2rem, 9vw, 5.2rem)/1 var(--font); font-variant-numeric: tabular-nums; }
.bigcount-grid span { display: block; margin-top: 8px; font-size: clamp(.68rem, 1.9vw, .95rem); text-transform: uppercase;
                      letter-spacing: .07em; opacity: .85; }
.bigcount-date { margin: clamp(16px, 3vw, 26px) 0 4px; font-size: clamp(.92rem, 2.2vw, 1.05rem); }
.bigcount-sep { margin: 0 6px; opacity: .6; }
.bigcount-text { margin: 0; opacity: .85; font-size: .95rem; }
.bigcount-cta { justify-content: center; margin-top: 20px; }
.btn-light { background: #fff; color: var(--primary-dark); }
.btn-light:hover { background: var(--bg); color: var(--primary-dark); }
.btn-outline-light { background: transparent; color: #fff; border: 2px solid rgba(255, 255, 255, .75); }
.btn-outline-light:hover { background: rgba(255, 255, 255, .15); color: #fff; }

/* Fehlerseite 404 – die 0 ist ein Kameraobjektiv */
.notfound { text-align: center; padding: clamp(10px, 4vw, 40px) 0 10px; max-width: 680px; margin: 0 auto; }
.notfound-code { display: flex; align-items: center; justify-content: center; gap: clamp(6px, 2vw, 16px);
                 font: 600 clamp(5rem, 22vw, 10rem)/1 var(--font); color: var(--primary); }
.notfound-lens { width: .78em; height: .78em; border-radius: 50%; flex: none; position: relative;
                 background: radial-gradient(circle at 35% 35%, #8fb35a 0 8%, #2f5401 9% 38%, #1d3400 39% 56%, var(--primary) 57% 100%);
                 box-shadow: inset 0 0 0 .07em #fff, 0 6px 18px rgba(0, 0, 0, .18); }
.notfound h1 { margin-top: 18px; }
.notfound-cta { justify-content: center; margin-top: 20px; }
.notfound-tips { margin-top: 40px; }
.notfound-tips h2 { text-align: center; }

/* Teilen-Knopf in der Lightbox */
.lb-share { background: rgba(255,255,255,.14); border: 0; border-radius: 50%; width: 44px; height: 44px; cursor: pointer;
            display: grid; place-items: center; flex: none; }
.lb-share:hover { background: rgba(255,255,255,.28); }
.lb-share svg { width: 22px; height: 22px; fill: #fff; stroke: #fff; stroke-width: 1.8; }

/* Einzelseite eines Fotos (foto.php, Ziel beim Teilen) */
.single { display: grid; gap: 20px; grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); align-items: start; }
.single-photo { margin: 0; background: #222; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-align: center; }
.single-photo img { display: block; max-width: 100%; max-height: 78vh; margin: 0 auto; width: auto; height: auto; }
.single-info h1 { margin-top: 0; overflow-wrap: anywhere; }
.single-meta { margin: 0 0 16px; }
.single .heart-lg { box-shadow: var(--shadow); }
@media (max-width: 800px) { .single { grid-template-columns: 1fr; } .single-photo img { max-height: 70vh; } }

/* Upload-Fortschritt */
#upload-progress { margin-top: 14px; }

/* ---------------------------------------------------------- Inhalte, Upload, Meine Bilder */
.content { background: var(--card); border-radius: var(--radius); padding: 8px 24px 20px; box-shadow: var(--shadow); max-width: 860px; }
.content ul, .content ol { padding-left: 1.3em; }
.content li { margin: 4px 0; }
.upload-preview { max-height: 260px; border-radius: 8px; margin-bottom: 14px; display: block; }
.slots { font-size: 1.05rem; }
.slots strong { color: var(--primary-dark); }

.mylist { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.myitem { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.myitem img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.myitem .body { padding: 12px; }
.myitem form label { margin-bottom: 8px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--primary-light); color: var(--primary-dark); }
.badge-wait { background: #fdebc8; color: #7a5200; }
.badge-off { background: #f6d4d1; color: #7c1913; }

/* ---------------------------------------------------------- Admin */
.admin-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eee5b8; vertical-align: middle; }
th { background: var(--bg-soft); font-family: var(--font); font-weight: 500; white-space: nowrap; }
td img.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; display: block; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 20px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font: 500 1.8rem var(--font); color: var(--primary-dark); }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.preview-box { background: #fff; border: 1px dashed var(--line); border-radius: 8px; padding: 4px 16px; max-height: 480px; overflow: auto; }
/* Filterleiste (Admin → Bewertungen) */
.filter-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); }
.filter-grid label { margin-bottom: 10px; font-size: .88rem; }
.filter-grid input, .filter-grid select { padding: 7px 10px; }
tr.row-revoked td { background: #fbeceb; }
tr.row-expired td { opacity: .55; }
tr.row-revoked td:nth-child(n+2):nth-child(-n+4) { text-decoration: line-through; text-decoration-color: rgba(179, 38, 30, .5); }
td img.thumb-sm { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; display: block; flex: none; }

/* Länderflaggen (Admin) – Name erscheint beim Darüberfahren */
.flag { display: inline-flex; vertical-align: middle; cursor: help; line-height: 0; }
.flag svg { display: block; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); }
.flag-code { line-height: 1; font: 600 .75rem/1 var(--font-body); padding: 3px 5px; border-radius: 3px;
             background: #e8e2c4; color: var(--text); box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }

/* Schlüssel/Wert-Liste (z. B. Logo-Infos) */
table.kv { width: auto; margin: 14px 0; font-size: .92rem; }
table.kv th, table.kv td { padding: 4px 16px 4px 0; border: 0; background: none; vertical-align: top; }
table.kv th { font-family: var(--font-body); font-weight: 600; color: var(--muted); white-space: nowrap; }
.progress { height: 14px; background: #eee5b8; border-radius: 7px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
