:root {
  --bg: #f8f2e7;
  --surface: #fffdf9;
  --surface-2: #f3eadb;
  --ink: #2d1f16;
  --muted: #7c6857;
  --line: #e7dac5;
  --apple: #b3352b;
  --apple-dark: #8b241c;
  --apple-soft: #f6dcd6;
  --caramel: #c58a3e;
  --leaf: #5b7a35;
  --leaf-soft: #e3ebd5;
  --gold: #d6a21e;
  --silver: #9aa3ab;
  --bronze: #b4713a;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(70, 45, 20, .06), 0 10px 30px -12px rgba(70, 45, 20, .18);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 15% -10%, #fbe7d3 0, transparent 45%),
                    radial-gradient(circle at 110% 10%, #f1e4cf 0, transparent 40%);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
main.wrap { width: 100%; padding-bottom: 56px; }
a { color: var(--apple-dark); }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); }
h2 { font-size: 1.45rem; }
small { font-size: .8em; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 640px; margin: 0 auto; }
.inline { display: inline; margin: 0; }

/* Header & Footer ---------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 253, 249, .88);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--serif); font-weight: 700; font-size: 1.2rem; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); padding: 8px 14px; border-radius: 999px; font-weight: 550; font-size: .95rem; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a.active { color: var(--apple-dark); background: var(--apple-soft); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--apple); color: #fff; font-size: .75rem; line-height: 1.4em; text-align: center; font-weight: 700; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 18px; padding-bottom: 18px; flex-wrap: wrap; }
.site-footer a, .linklike { color: var(--muted); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }

/* Allgemein --------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.flashes { margin: 20px 0 0; display: grid; gap: 8px; }
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 550; }
.flash-success { background: var(--leaf-soft); color: #33501a; }
.flash-error { background: var(--apple-soft); color: var(--apple-dark); }
.notice { background: #fdf0d3; border: 1px solid #f0d89c; color: #6d4c0c; padding: 12px 16px; border-radius: var(--radius-sm); }
.errors { background: var(--apple-soft); color: var(--apple-dark); border-radius: var(--radius-sm); padding: 10px 16px; margin-bottom: 16px; }
.errors p { margin: 4px 0; }
.hint { color: var(--muted); font-size: .88rem; }
.back { display: inline-block; margin: 24px 0 12px; color: var(--muted); text-decoration: none; font-weight: 550; }
.back:hover { color: var(--ink); }
.count { display: inline-block; font-family: var(--sans); font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 2px 9px; vertical-align: middle; }
.empty { text-align: center; padding: 48px 24px; }
.empty-icon { font-size: 3rem; }
.empty-inline { color: var(--muted); font-style: italic; }

/* Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 999px; border: 1px solid transparent;
  font: 600 .93rem/1.2 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .05s, box-shadow .15s, color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--apple); color: #fff; box-shadow: 0 2px 0 var(--apple-dark); }
.btn-primary:hover { background: var(--apple-dark); }
.btn-soft { background: var(--leaf-soft); color: #3b5a1f; }
.btn-soft:hover { background: #d4e1c0; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; color: var(--apple-dark); border-color: #ecc4bd; }
.btn-danger-ghost:hover { background: var(--apple-soft); }
.btn-lg { padding: 13px 24px; font-size: 1.02rem; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn[disabled], fieldset[disabled] .btn { opacity: .55; cursor: not-allowed; }
.btn-icon { border: 0; background: transparent; cursor: pointer; font-size: 1rem; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.btn-icon.danger:hover { color: var(--apple-dark); background: var(--apple-soft); }

/* Hero -------------------------------------------------------------- */
.hero { padding: 40px 0 16px; max-width: 720px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 700; color: var(--apple); margin: 0 0 8px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--apple); box-shadow: 0 0 0 0 rgba(179, 53, 43, .5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(179, 53, 43, .45); } 70% { box-shadow: 0 0 0 9px rgba(179, 53, 43, 0); } 100% { box-shadow: 0 0 0 0 rgba(179, 53, 43, 0); } }
.lead { font-size: 1.08rem; color: var(--muted); margin-top: 0; }
.progress-note { color: var(--muted); margin: 8px 0 16px; }

/* Rangliste --------------------------------------------------------- */
.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.cake-card {
  position: relative;
  display: grid;
  grid-template-columns: 56px 150px minmax(0, 1fr) 190px;
  grid-template-areas:
    "rank thumb title score"
    "rank thumb bars  actions";
  column-gap: 22px; row-gap: 10px;
  align-items: center;
  padding: 18px 22px 18px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .2s ease;
}
.cake-card.place-1 { border-color: #ecd38a; background: linear-gradient(135deg, #fffaf0 0%, var(--surface) 60%); box-shadow: 0 0 0 3px rgba(214, 162, 30, .18), var(--shadow); }
.rank { grid-area: rank; align-self: center; display: flex; justify-content: center; }
.rank-num {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  font-family: var(--serif); font-weight: 700; font-size: 1.45rem;
  background: var(--surface-2); color: var(--muted);
}
.place-1 .rank-num { background: radial-gradient(circle at 30% 30%, #f6d873, var(--gold)); color: #4f3a00; box-shadow: 0 2px 8px rgba(214, 162, 30, .45); }
.place-2 .rank-num { background: radial-gradient(circle at 30% 30%, #e8ecef, var(--silver)); color: #2f3439; }
.place-3 .rank-num { background: radial-gradient(circle at 30% 30%, #e7b58a, var(--bronze)); color: #3d2109; }
.rank-none { font-size: 1.1rem; }
.thumb { grid-area: thumb; display: block; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.thumb:hover img { transform: scale(1.04); }
.thumb-placeholder { display: grid; place-items: center; width: 100%; height: 100%; font-size: 2.5rem; background: var(--surface-2); }
.thumb-placeholder.big { aspect-ratio: 4 / 3; font-size: 4rem; border-radius: var(--radius); }
.title { grid-area: title; align-self: end; min-width: 0; }
.title h2 { margin: 0; font-size: 1.4rem; overflow-wrap: break-word; hyphens: auto; }
.title h2 a { color: var(--ink); text-decoration: none; }
.title h2 a:hover { color: var(--apple-dark); }
.baker { margin: 2px 0 0; color: var(--muted); font-style: italic; }
.score { grid-area: score; text-align: right; align-self: end; }
.score-big { font-family: var(--serif); font-weight: 700; font-size: 2.6rem; line-height: 1; color: var(--apple); font-variant-numeric: tabular-nums; }
.score-big.score-none { color: var(--line); }
.score-sub { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.actions { grid-area: actions; display: flex; flex-direction: column; gap: 6px; align-self: start; }
.cat-bars { grid-area: bars; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 22px; align-self: start; }
.cat-bars li { display: grid; grid-template-columns: minmax(0, 1fr) 70px 30px; align-items: center; gap: 8px; font-size: .82rem; }
.cat-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--caramel), var(--apple)); transition: width .6s ease; }
.cat-val { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.cat-bars.large { grid-area: auto; grid-template-columns: 1fr; gap: 9px; }
.cat-bars.large li { grid-template-columns: 170px minmax(0, 1fr) 40px; font-size: .95rem; }
.cat-bars.large .bar { height: 10px; }

/* Detailseite ------------------------------------------------------- */
.cake-hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 0; overflow: hidden; }
.cake-hero-img img { width: 100%; height: 100%; max-height: 460px; object-fit: cover; }
.cake-hero-img .thumb-placeholder.big { border-radius: 0; height: 100%; }
.cake-hero-body { padding: 28px 32px; display: flex; flex-direction: column; justify-content: center; }
.cake-hero-body .baker { font-size: 1.05rem; }
.description { white-space: pre-line; margin: 16px 0 0; }
.hero-actions { margin-top: 24px; display: flex; gap: 10px; flex-wrap: wrap; }
.summary { margin-top: 20px; padding: 24px 28px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: center; }
.summary-score .score-big { font-size: 3.6rem; }
.rank-pill { display: inline-block; margin-bottom: 10px; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); font-weight: 700; font-size: .85rem; color: var(--muted); }
.rank-pill-1 { background: #fbecc0; color: #6a4d00; }
.rank-pill-2 { background: #e8ecef; color: #3a4148; }
.rank-pill-3 { background: #f2d9c3; color: #5a3212; }
.ratings-section { margin-top: 36px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ratings { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.ratings th, .ratings td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ratings thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: var(--surface); white-space: nowrap; vertical-align: bottom; }
.ratings thead th small { display: block; text-transform: none; letter-spacing: 0; }
.ratings tfoot th { background: var(--surface-2); border-bottom: 0; font-variant-numeric: tabular-nums; }
.ratings .num { text-align: center; font-variant-numeric: tabular-nums; }
.ratings .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; box-shadow: 1px 0 0 var(--line); }
.ratings tfoot .sticky { background: var(--surface-2); }
.ratings tr.mine td { background: #fff6e6; }
.name-cell { font-weight: 650; white-space: nowrap; }
.you { font-size: .7rem; background: var(--caramel); color: #fff; padding: 1px 7px; border-radius: 99px; vertical-align: middle; font-weight: 700; }
.total-col { background: rgba(243, 234, 219, .45); }
.ratings .comment { min-width: 200px; max-width: 360px; white-space: pre-line; color: #4a3a2e; }
.ratings .time { white-space: nowrap; color: var(--muted); font-size: .82rem; }
.chip { display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 6px; border-radius: 8px; font-weight: 700; }
.chip.hi { background: #e2ecd3; color: #36521a; }
.chip.mid { background: #f7ead0; color: #6b4a0e; }
.chip.lo { background: #f6dcd6; color: #8b241c; }

/* Formulare --------------------------------------------------------- */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.form-card { padding: 26px 28px; display: grid; gap: 18px; margin-top: 12px; }
.field { display: grid; gap: 6px; }
.label { font-weight: 650; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--ink);
  padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--caramel); box-shadow: 0 0 0 3px rgba(197, 138, 62, .2); }
textarea { resize: vertical; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--apple); }
.grid-form { grid-template-columns: 1fr 1fr; }
.span-2 { grid-column: span 2; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.dropzone {
  position: relative; display: grid; place-items: center; min-height: 160px;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface-2);
  cursor: pointer; overflow: hidden; transition: border-color .15s;
}
.dropzone:hover { border-color: var(--caramel); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .preview { max-height: 320px; width: 100%; object-fit: cover; }
.dropzone .preview:not([hidden]) + .dropzone-text { position: absolute; bottom: 10px; background: rgba(255, 255, 255, .9); padding: 6px 12px; border-radius: 99px; font-size: .85rem; }
.dropzone-text { color: var(--muted); font-weight: 600; pointer-events: none; }
.dropzone.busy::after { content: "Bild wird vorbereitet …"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255, 253, 249, .85); font-weight: 600; }

/* Bewertungsformular ------------------------------------------------ */
.rate-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.rate-cake { position: sticky; top: 84px; overflow: hidden; }
.rate-cake img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.rate-cake-body { padding: 16px 20px; }
.rate-cake-body h2 { margin: 0; }
.rate-form { padding: 26px 30px; }
.rate-form > fieldset { display: grid; gap: 22px; }
.scale-legend { display: flex; justify-content: space-between; margin: 0; padding: 8px 14px; font-size: .82rem; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm); }
.score-row { padding-bottom: 18px; border-bottom: 1px dashed var(--line); }
.score-head { display: flex; align-items: baseline; gap: 10px; }
.score-title { font-family: var(--serif); font-size: 1.2rem; font-weight: 700; }
.weight-tag { font-size: .75rem; font-weight: 700; color: var(--caramel); background: #fbefdc; padding: 2px 8px; border-radius: 99px; }
.score-current { margin-left: auto; font-family: var(--serif); font-weight: 700; font-size: 1.2rem; color: var(--apple); }
.score-desc { margin: 2px 0 10px; color: var(--muted); font-size: .9rem; }
.pills { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pill span {
  display: grid; place-items: center; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; font-weight: 700; color: var(--muted);
  transition: background .12s, color .12s, border-color .12s, transform .08s;
  font-variant-numeric: tabular-nums;
}
.pill:hover span { border-color: var(--caramel); color: var(--ink); }
.pill input:checked + span { background: var(--apple); border-color: var(--apple); color: #fff; transform: scale(1.06); box-shadow: 0 3px 10px -3px rgba(139, 36, 28, .6); }
.pill input:focus-visible + span { outline: 3px solid rgba(197, 138, 62, .45); outline-offset: 2px; }
.score-row.missing .pills span { border-color: #e7a99f; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); padding: 14px 0 4px; border-top: 1px solid var(--line); }
.live-total { display: flex; align-items: baseline; gap: 10px; color: var(--muted); font-weight: 600; }
.live-total strong { font-family: var(--serif); font-size: 2rem; color: var(--apple); }

/* Admin ------------------------------------------------------------- */
.admin-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; padding-top: 32px; }
.admin-jump { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-jump a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
.admin-jump a:hover { color: var(--ink); }
.admin-section { margin-top: 36px; scroll-margin-top: 80px; }
.admin-list { overflow: hidden; }
.admin-cake { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.admin-cake:last-child { border-bottom: 0; }
.admin-thumb { display: block; width: 72px; height: 72px; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.admin-thumb img { width: 100%; height: 100%; object-fit: cover; }
.admin-thumb .thumb-placeholder { font-size: 1.8rem; }
.admin-cake-info { display: grid; gap: 2px; min-width: 0; }
.admin-cake-info .muted { font-size: .85rem; }
.admin-desc { font-size: .88rem; color: #4a3a2e; white-space: pre-line; }
.admin-cake-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.cat-table-wrap { padding: 8px 12px; overflow-x: auto; }
.cat-grid { display: grid; grid-template-columns: 90px 190px minmax(200px, 1fr) 90px 56px 210px; gap: 8px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--line); min-width: 860px; margin: 0; }
.cat-grid:last-child { border-bottom: 0; }
.cat-grid input[type=text], .cat-grid input[type=number] { padding: 8px 10px; }
.cat-grid-head { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.cat-grid.inactive input[type=text] { color: var(--muted); text-decoration: line-through; }
.cat-new { background: var(--surface-2); border-radius: var(--radius-sm); }
.check { display: flex; justify-content: center; }
.check input { width: 20px; height: 20px; accent-color: var(--apple); }
.cat-actions { display: flex; gap: 6px; justify-content: flex-end; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.danger-zone .hint { margin: 2px 0 0; }
.login { padding-top: 48px; }

/* Responsive -------------------------------------------------------- */
@media (max-width: 860px) {
  .cake-card {
    grid-template-columns: 76px minmax(0, 1fr) auto;
    grid-template-areas:
      "thumb title score"
      "bars bars bars"
      "actions actions actions";
    column-gap: 14px; padding: 14px;
  }
  .rank { position: absolute; top: 6px; left: 6px; z-index: 2; }
  .rank-num { width: 30px; height: 30px; font-size: .95rem; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
  .rank-none { display: none; }
  .title { align-self: center; }
  .title h2 { font-size: 1.12rem; }
  .baker { font-size: .9rem; }
  .score { align-self: center; }
  .score-big { font-size: 1.8rem; }
  .cake-card .score-sub { font-size: .75rem; max-width: 90px; margin-left: auto; }
  .actions { flex-direction: row; }
  .actions .btn { flex: 1; }
  .cake-hero { grid-template-columns: 1fr; }
  .cake-hero-img img { max-height: 340px; }
  .cake-hero-body { padding: 22px; }
  .summary { grid-template-columns: 1fr; gap: 18px; padding: 20px; }
  .rate-layout { grid-template-columns: 1fr; }
  .rate-cake { position: static; display: grid; grid-template-columns: 96px 1fr; align-items: center; }
  .rate-cake img, .rate-cake .thumb-placeholder.big { aspect-ratio: 1; height: 96px; border-radius: 0; font-size: 2rem; }
  .rate-form { padding: 20px 18px; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .cat-bars { grid-template-columns: 1fr; }
  .cat-bars.large li { grid-template-columns: 120px minmax(0, 1fr) 36px; }
  .pills { gap: 4px; }
  .pill span { height: 40px; border-radius: 9px; font-size: .9rem; }
  .grid-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .admin-cake { grid-template-columns: 56px minmax(0, 1fr); }
  .admin-thumb { width: 56px; height: 56px; }
  .admin-cake-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .form-card { padding: 20px; }
  .nav a { padding: 6px 10px; }
}
