/* Admin-Bereich – ruhig, hell, gut lesbar */
@font-face { font-family: "Jost"; src: url(../assets/fonts/jost-latin-wght-normal.woff2) format("woff2-variations"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Marcellus"; src: url(../assets/fonts/marcellus-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --bg: #F6F2EB; --surface: #fff; --ink: #2B2622; --ink-2: #4A433C; --muted: #857A6F;
  --line: #E6DED2; --line-2: #D6CBBB; --primary: #2B2622; --ok: #2F6B3A; --err: #A13A2B;
  --accent: #8A5A3A; --r: 14px;
  --sans: "Jost", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --serif: "Marcellus", Georgia, serif;
}
* { box-sizing: border-box; }
/* Versteckte Elemente bleiben versteckt – egal welche display-Regel sonst gilt */
[hidden] { display: none !important; }

body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2 { font-family: var(--serif); font-weight: 400; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(26px, 3vw, 34px); }
h2 { font-size: 20px; margin-bottom: 14px; }
a { color: inherit; }
img { max-width: 100%; display: block; }
small { font-size: 13px; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); margin: 4px 0 0; }
.hint { font-size: 14px; color: var(--muted); margin: 6px 0 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack { display: grid; gap: 16px; }
.narrow { max-width: 460px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; flex: none; }
.icon { flex: none; }
:focus-visible { outline: 2px solid #35759C; outline-offset: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 500 15px/1.2 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--ink); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #FBF8F3; }
.btn--primary:hover { background: #000; }
.btn--small { padding: 7px 12px; font-size: 14px; border-radius: 9px; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn--danger { color: var(--err); }
.btn--danger:hover { border-color: var(--err); background: #FBEFEC; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 9px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--bg); border-color: var(--line); }

/* Formulare */
label { display: grid; gap: 6px; font-weight: 500; font-size: 15px; margin-bottom: 14px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea {
  font: 400 16px/1.4 var(--sans); color: var(--ink); background: #FDFBF8;
  border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--ink); background: #fff; }
textarea { resize: vertical; }
label.big input { font: 400 24px/1.25 var(--serif) !important; padding: 12px 14px !important; }
.field { margin-bottom: 14px; }
.field__label { display: block; font-weight: 500; font-size: 15px; margin-bottom: 6px; }
.prefix { display: flex; align-items: stretch; }
.prefix span { padding: 10px 0 10px 12px; background: var(--bg); border: 1px solid var(--line-2); border-right: 0; border-radius: 10px 0 0 10px; color: var(--muted); font-weight: 400; font-size: 14px; display: flex; align-items: center; white-space: nowrap; }
.prefix input { border-radius: 0 10px 10px 0 !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; margin: 0 0 12px; }
.switch input { position: absolute; opacity: 0; }
.switch__ui { width: 42px; height: 24px; border-radius: 99px; background: var(--line-2); position: relative; flex: none; transition: background .2s; }
.switch__ui::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + .switch__ui { background: var(--ok); }
.switch input:checked + .switch__ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__ui { outline: 2px solid #35759C; outline-offset: 2px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login__box { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 36px; box-shadow: 0 20px 60px -30px rgba(60,40,20,.3); }
.login__box h1 { margin: 22px 0 6px; }
.login__box form { margin-top: 20px; }
.login__brand { font: 400 20px/1 var(--serif); margin: 0; }
.login__brand span, .side__brand span { font: 500 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-left: 6px; vertical-align: middle; }
.login__back { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 14px; }

/* Grundlayout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px; border-right: 1px solid var(--line); background: #FBF8F3; }
.side__brand { font: 400 20px/1 var(--serif); text-decoration: none; padding: 4px 10px 22px; }
.side__nav { display: grid; gap: 2px; }
.side a, .side button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font: 500 15px/1.2 var(--sans); background: none; border: 0; width: 100%; cursor: pointer; text-align: left; }
.side a:hover, .side button:hover { background: var(--bg); color: var(--ink); }
.side a.is-active { background: var(--ink); color: #FBF8F3; }
.side__foot { margin-top: auto; display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 12px; }
.main { padding: 28px clamp(18px, 3.5vw, 44px) 80px; min-width: 0; max-width: 1280px; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); gap: 4px; }
  .side__brand { display: none; }
  .side__nav, .side__foot { display: flex; gap: 2px; margin: 0; padding: 0; border: 0; }
  .side a, .side button { width: auto; white-space: nowrap; padding: 9px 11px; }
  .side a span, .side button span { display: none; }
  .side a.is-active span { display: inline; }
}

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head--sticky { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); margin: -28px calc(-1 * clamp(18px, 3.5vw, 44px)) 24px; padding: 20px clamp(18px, 3.5vw, 44px) 14px; border-bottom: 1px solid var(--line); }
@media (max-width: 900px) { .page-head--sticky { top: 53px; } }
.back { font-size: 14px; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 6px; }
.back:hover { color: var(--ink); }

.flash { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; background: #E9F3EA; color: var(--ok); border: 1px solid #CFE4D2; }
.flash--err { background: #FBEDEA; color: var(--err); border-color: #F0D2CB; }
.flash a { font-weight: 500; }

.callout { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; border-radius: var(--r); background: #FFF6E6; border: 1px solid #F0DDB5; margin-bottom: 22px; }
.callout p { margin: 4px 0 0; color: var(--ink-2); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; margin-bottom: 18px; }
.panel--flush { padding: 0; overflow: hidden; }
.panel--quiet { background: transparent; border-style: dashed; display: grid; gap: 8px; }
.panel__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.panel__head h2 { margin: 0; }
.panel > label:last-child { margin-bottom: 0; }

/* Kategorienliste */
.cat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cat-row { display: grid; grid-template-columns: 28px 26px 72px 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); border-left: 4px solid var(--accent); transition: box-shadow .15s, opacity .15s; }
.cat-row:hover { box-shadow: 0 6px 20px -12px rgba(60,40,20,.35); }
.cat-row.is-hidden { opacity: .55; }
.cat-row.is-dragging { opacity: .35; }
.cat-row.is-over { box-shadow: 0 -3px 0 0 var(--ink); }
.cat-row__grip { cursor: grab; color: var(--muted); display: grid; place-items: center; }
.cat-row__num { color: var(--muted); font-size: 14px; text-align: right; }
.cat-row__thumb { width: 72px; height: 54px; border-radius: 8px; overflow: hidden; background: color-mix(in srgb, var(--accent) 14%, var(--bg)); }
.cat-row__thumb img { width: 100%; height: 100%; object-fit: cover; }
.cat-row__main { text-decoration: none; min-width: 0; }
.cat-row__title { display: block; font: 400 19px/1.25 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row__meta { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--muted); }
.cat-row__actions { display: flex; align-items: center; gap: 6px; }
.grip-inline { display: inline-flex; vertical-align: middle; }
.save-state { min-height: 1.5em; }
@media (max-width: 640px) {
  .cat-row { grid-template-columns: 22px 56px 1fr; }
  .cat-row__num { display: none; }
  .cat-row__thumb { width: 56px; height: 44px; }
  .cat-row__actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* Editor-Layout */
.editor__grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.editor__side { position: sticky; top: 104px; }
@media (max-width: 1100px) { .editor__grid { grid-template-columns: 1fr; } .editor__side { position: static; } }

/* Farbauswahl */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.swatch { display: flex; align-items: center; gap: 8px; margin: 0; padding: 7px 8px; border-radius: 9px; border: 1px solid var(--line); cursor: pointer; font-weight: 400; font-size: 13px; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { width: 18px; height: 18px; border-radius: 50%; background: var(--c); flex: none; box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); }
.swatch em { font-style: normal; line-height: 1.2; }
.swatch:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, #fff); font-weight: 500; }
.swatch:has(input:focus-visible) { outline: 2px solid #35759C; }

/* Einzelbild-Feld */
.imgfield { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: start; }
@media (max-width: 640px) { .imgfield { grid-template-columns: 1fr; } }
.imgfield__preview { aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: var(--bg); border: 1px dashed var(--line-2); display: grid; place-items: center; position: relative; }
.imgfield__preview img { width: 100%; height: 100%; object-fit: cover; }
.imgfield__preview.is-drop { border-color: var(--ink); background: #fff; }
.imgfield__preview.is-loading::after, .gallery-ed__item.is-loading::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50'%3E%3Ccircle cx='25' cy='25' r='18' fill='none' stroke='%232B2622' stroke-width='3' stroke-dasharray='80 40'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") center / 36px no-repeat; }
.imgfield__empty { display: grid; justify-items: center; gap: 6px; color: var(--muted); font-size: 14px; text-align: center; padding: 10px; }
.imgfield__side .row { margin-bottom: 14px; }

/* Galerie-Editor */
.gallery-ed { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; min-height: 120px; padding: 12px; border: 1px dashed var(--line-2); border-radius: 12px; background: #FDFBF8; }
.gallery-ed.is-drop { border-color: var(--ink); background: #fff; }
.gallery-ed__empty { grid-column: 1 / -1; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.gallery-ed__item { position: relative; border-radius: 10px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); cursor: grab; }
.gallery-ed__item.is-dragging { opacity: .3; }
.gallery-ed__item.is-over { outline: 2px solid var(--ink); }
.gallery-ed__item img { width: 100%; aspect-ratio: 1; object-fit: cover; pointer-events: none; }
.gallery-ed__bar { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.gallery-ed__bar button { width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(255,255,255,.92); display: grid; place-items: center; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.gallery-ed__bar button:hover { background: #fff; color: var(--err); }
.gallery-ed__meta { padding: 8px; display: grid; gap: 6px; background: #fff; cursor: default; }
.gallery-ed__meta input { font-size: 13px !important; padding: 6px 8px !important; border-radius: 7px !important; }
.gallery-ed__flags { position: absolute; left: 6px; top: 6px; display: flex; gap: 4px; }
.gallery-ed__flags span { font-size: 11px; background: rgba(43,38,34,.8); color: #fff; padding: 2px 7px; border-radius: 99px; }

/* Links-Editor */
.links-ed { display: grid; gap: 8px; margin-top: 10px; }
.link-row { display: grid; grid-template-columns: 22px 1fr 1.2fr 36px; gap: 8px; align-items: center; }
.link-row__grip { cursor: grab; color: var(--muted); }
.link-row.is-dragging { opacity: .35; }
@media (max-width: 640px) { .link-row { grid-template-columns: 22px 1fr 36px; } .link-row input:nth-of-type(2) { grid-column: 2; } .link-row .icon-btn { grid-row: 1; grid-column: 3; } }

/* Texteditor */
.rte { border: 1px solid var(--line-2); border-radius: 12px; background: #fff; overflow: hidden; }
.rte:focus-within { border-color: var(--ink); }
.rte__bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: #FBF8F3; position: sticky; top: 0; }
.rte__bar button { min-width: 34px; height: 32px; padding: 0 8px; border: 0; background: none; border-radius: 7px; cursor: pointer; font: 500 14px/1 var(--sans); color: var(--ink-2); display: inline-grid; place-items: center; }
.rte__bar button:hover { background: #fff; box-shadow: 0 0 0 1px var(--line); }
.rte__bar button.is-on { background: var(--ink); color: #fff; }
.rte__sep { width: 1px; background: var(--line); margin: 4px 4px; }
.rte__spacer { flex: 1; }
.rte__area { min-height: 180px; max-height: 70vh; overflow-y: auto; padding: 16px 18px; outline: none; font-size: 16px; line-height: 1.65; }
.rte__area:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rte__src { display: block; width: 100%; min-height: 260px; border: 0 !important; border-radius: 0 !important; font: 13px/1.5 ui-monospace, Menlo, monospace !important; }
.rte.is-html .rte__area { display: none; }
.prose p { margin: 0 0 .8em; }
.prose h3, .prose h4 { font-family: var(--serif); font-weight: 400; font-size: 20px; margin: 1.2em 0 .4em; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 .8em; }
.prose blockquote { margin: .8em 0; padding-left: 14px; border-left: 3px solid var(--line-2); font-style: italic; }
.prose a { color: #35759C; }

/* Bilder-Bibliothek */
.dropzone { border: 2px dashed var(--line-2); border-radius: var(--r); padding: 26px; text-align: center; color: var(--muted); margin-bottom: 18px; transition: .15s; }
.dropzone.is-drop { border-color: var(--ink); background: #fff; color: var(--ink); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.media-item { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.media-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.media-item figcaption { padding: 10px; display: grid; gap: 4px; font-size: 13px; }
.media-item figcaption > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.media-item form { margin: 0; }
.tag { display: inline-block; justify-self: start; font: 500 12px/1 var(--sans); padding: 5px 9px; border-radius: 99px; border: 0; cursor: default; }
.tag--ok { background: #E9F3EA; color: var(--ok); }
.tag--danger { background: #FBEDEA; color: var(--err); cursor: pointer; }
.tag--danger:hover { background: var(--err); color: #fff; }

/* Auswahl-Dialog */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(43,38,34,.4); display: grid; place-items: center; padding: 20px; }
.modal__box { width: min(960px, 100%); max-height: calc(100vh - 40px); background: #fff; border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 80px -20px rgba(0,0,0,.4); }
.modal__head, .modal__foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal__head h2 { margin: 0; flex: 1; }
.modal__foot { border-bottom: 0; border-top: 1px solid var(--line); justify-content: flex-end; }
.modal__foot .muted { margin: 0 auto 0 0; }
.modal__body { overflow-y: auto; padding: 16px 18px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.picker-item { position: relative; border: 2px solid transparent; border-radius: 10px; overflow: hidden; cursor: pointer; padding: 0; background: var(--bg); }
.picker-item img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.picker-item.is-selected { border-color: var(--ink); }
.picker-item.is-selected::after { content: "✓"; position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 14px; }

/* Import */
.progress { height: 10px; border-radius: 99px; background: var(--bg); overflow: hidden; margin: 18px 0 10px; }
.progress span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .3s; }
.import-log { list-style: none; padding: 0; margin: 16px 0 0; font-size: 13px; color: var(--muted); max-height: 280px; overflow-y: auto; }
.import-log .err { color: var(--err); }

/* Tabellen & Listen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #FBF8F3; font-weight: 500; white-space: nowrap; }
.backup-list { list-style: none; margin: 0; padding: 0; }
.backup-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.backup-list li:last-child { border-bottom: 0; }
.backup-list form { margin: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; z-index: 200; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); }
.toast--err { background: var(--err); }
