:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #6b7684;
    --border: #e6e9ef;
    --accent: #0e9f6e;
    --accent-dark: #0b7d57;
    --accent-soft: #e6f6ef;
    --danger: #e02424;
    --star: #f5a623;
    --star-empty: #dfe3ea;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(20, 30, 45, .06), 0 6px 24px rgba(20, 30, 45, .05);
    --shadow-hover: 0 4px 12px rgba(20, 30, 45, .10), 0 12px 32px rgba(20, 30, 45, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.main { padding-top: 28px; padding-bottom: 64px; }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; margin: 0 0 .2em; }
h2 { font-size: 1.25rem; }
h3 { margin: 0; font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* --- Topbar --- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 62px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.brand-icon { width: 1.25em; height: 1.25em; color: var(--accent); }
.brand:hover { text-decoration: none; }
.search { flex: 1; max-width: 420px; }
.search input { width: 100%; padding: 9px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); font-size: .95rem; }
.search input:focus { outline: none; border-color: var(--accent); background: #fff; }
.nav { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.nav-link { color: var(--muted); font-size: .93rem; white-space: nowrap; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-user { font-weight: 600; font-size: .93rem; white-space: nowrap; color: var(--text); }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 999px; border: 1px solid transparent; font-size: .95rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, box-shadow .15s, border-color .15s; }
.btn:hover { text-decoration: none; }
.btn-sm { padding: 7px 14px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--muted); color: var(--text); }
.btn-danger { background: #fff; border-color: #f3c4c4; color: var(--danger); }
.btn-danger:hover { background: #fdecec; }
.linkbtn { background: none; border: none; padding: 0; font: inherit; cursor: pointer; color: var(--muted); }
.linkbtn:hover { color: var(--text); text-decoration: underline; }
.linkbtn.danger, .danger.linkbtn { color: var(--danger); }
.inline { display: inline; }

/* --- Flash & Toast --- */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .95rem; word-break: break-word; }
.flash-success { background: var(--accent-soft); color: var(--accent-dark); border: 1px solid #bfe6d3; }
.flash-error { background: #fdecec; color: #a51111; border: 1px solid #f3c4c4; }
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; width: max-content; max-width: 90vw; }
.toast { background: #1f2933; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.2); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--danger); }

/* --- Page head / filters --- */
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: .9rem; }
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sort-label { font-size: .85rem; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.sort-form select, .form-card select, .import-table select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: .9rem; }

/* --- Tags --- */
.tag-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 22px; }
.tagchip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .82rem; cursor: pointer; }
.tagchip:hover { border-color: var(--accent); text-decoration: none; }
.tagchip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tagcount { color: var(--muted); font-size: .75rem; }
.tagchip.active .tagcount { color: #eafff5; }
.tag { display: inline-block; font-size: .8rem; color: var(--accent-dark); background: var(--accent-soft); padding: 2px 9px; border-radius: 999px; }
a.tag:hover { text-decoration: none; background: #d5efe2; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.dish-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -6px 0 16px; }

/* --- Grid & cards --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; color: var(--text); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); text-decoration: none; }
.card-photo { position: relative; aspect-ratio: 4 / 3; background: var(--accent-soft); }
.card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-photo-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.badge { position: absolute; top: 10px; left: 10px; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: rgba(255,255,255,.92); color: var(--text); backdrop-filter: blur(2px); }
.badge-gericht { color: #0b7d57; }
.badge-bowl { color: #1668c1; }
.badge-dessert { color: #b5347d; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- Sterne: read-only Balken (0,5-Schritte) --- */
.starbar { display: inline-block; position: relative; font-size: 1rem; line-height: 1; white-space: nowrap; }
.starbar::before { content: "★★★★★"; color: var(--star-empty); letter-spacing: 2px; }
.starbar::after { content: "★★★★★"; color: var(--star); letter-spacing: 2px; position: absolute; top: 0; left: 0; width: var(--val, 0%); overflow: hidden; }
.starbar.big { font-size: 1.4rem; }
.starbar.sm { font-size: .85rem; }

/* --- Sterne: interaktives Widget --- */
.rate-block { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.rate-label { font-weight: 600; }
.rate-current { color: var(--muted); font-size: .9rem; }
.rate { display: inline-flex; gap: 3px; }
.rate-star { position: relative; width: 1.9rem; height: 1.9rem; font-size: 1.9rem; line-height: 1; }
.rate-star::before { content: "★"; color: var(--star-empty); position: absolute; top: 0; left: 0; }
.rate-star::after { content: "★"; color: var(--star); position: absolute; top: 0; left: 0; width: var(--fill, 0%); overflow: hidden; }
.rate-hit { position: absolute; top: 0; height: 100%; width: 50%; background: transparent; border: none; cursor: pointer; padding: 0; z-index: 2; }
.rate-hit.left { left: 0; }
.rate-hit.right { right: 0; }

.rating-summary { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }

/* --- Empty state --- */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-emoji { font-size: 3rem; margin: 0 0 8px; }
.empty .btn { margin: 6px; }

/* --- Topliste --- */
.ranking { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.rank-link { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); color: var(--text); transition: transform .15s, box-shadow .15s; }
.rank-link:hover { text-decoration: none; box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.rank-pos { width: 2.3rem; height: 2.3rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; flex: none; background: #eef1f5; color: var(--muted); }
.rank-pos.rank-1 { background: linear-gradient(145deg, #fde68a, #f5c033); color: #7a5600; }
.rank-pos.rank-2 { background: linear-gradient(145deg, #eaeef3, #c3ccd8); color: #48515e; }
.rank-pos.rank-3 { background: linear-gradient(145deg, #f0cca8, #d99a5e); color: #6b3d16; }
.rank-photo { width: 60px; height: 60px; border-radius: 10px; overflow: hidden; flex: none; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; }
.rank-photo img { width: 100%; height: 100%; object-fit: cover; }
.rank-photo-empty { font-size: 1.8rem; }
.rank-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rank-name { font-weight: 600; }
.rank-score { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.rank-num { font-weight: 700; }

/* --- Dish detail --- */
.back { color: var(--muted); font-size: .9rem; }
.dish { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 30px; margin-bottom: 20px; }
.dish-main-wrap { }
.dish-main-photo { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); aspect-ratio: 4/3; object-fit: cover; background: var(--accent-soft); display: block; }
.dish-photo-empty { width: 100%; aspect-ratio: 4/3; border-radius: var(--radius); background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 4rem; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumb-item { position: relative; }
.thumb { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: none; width: 64px; height: 64px; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { border-color: var(--accent); }
.thumb-del { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: none; background: var(--danger); color: #fff; font-size: .7rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.dish-info { position: relative; }
.dish-info-actions { position: absolute; top: 0; right: 0; display: flex; gap: 10px; align-items: center; }
.dish-info .badge { position: static; display: inline-block; margin-bottom: 8px; border: 1px solid var(--border); }
.dish-desc { white-space: pre-line; }

/* --- Dropzone / Upload --- */
.dropzone { margin-top: 14px; border: 2px dashed var(--border); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-label { font-size: .9rem; }
.upload-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.upload-row { display: flex; align-items: center; gap: 10px; font-size: .82rem; text-align: left; }
.upload-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-bar { width: 120px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; flex: none; }
.upload-bar-in { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.upload-bar.failed { background: #f3c4c4; }
.upload-bar.failed .upload-bar-in { background: var(--danger); }

/* --- Comments --- */
.comments { border-top: 1px solid var(--border); padding-top: 24px; max-width: 720px; }
.comment-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; align-items: flex-start; }
.comment-form textarea, .edit-input { width: 100%; font-family: inherit; font-size: .95rem; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; }
.comment-form textarea:focus, .edit-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.comment-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 16px; }
.comment { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.comment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.comment-author { font-weight: 600; }
.comment-actions { margin-left: auto; display: flex; gap: 10px; }
.comment-body { margin: 0; white-space: pre-line; }
.edit-actions { display: flex; gap: 8px; margin-top: 8px; }

/* --- Forms / cards --- */
textarea, input[type=text], input[type=email], input[type=password], input[type=search] { font-family: inherit; font-size: .95rem; }
.form-card, .auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; max-width: 560px; }
.auth-card { max-width: 400px; margin: 24px auto; }
.field { display: block; margin-bottom: 16px; font-weight: 600; font-size: .92rem; }
.field input, .field select, .field textarea { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: #fff; font-weight: 400; }
.field input:disabled { background: var(--bg); color: var(--muted); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-subhead { font-size: 1.05rem; margin: 22px 0 12px; padding-top: 18px; border-top: 1px solid var(--border); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.or { text-align: center; color: var(--muted); font-size: .85rem; margin: 18px 0; }

/* --- Table (admin / import) --- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.row-actions { white-space: nowrap; display: flex; gap: 12px; flex-wrap: wrap; }
.role-badge { padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.role-admin { background: var(--accent-soft); color: var(--accent-dark); }
.role-user { background: #eef1f5; color: var(--muted); }
.import-table input.import-name { width: 100%; min-width: 200px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 7px; }
.row-exists { background: #fafbfc; }
.row-exists .import-name { color: var(--muted); }

/* --- Bewertungs-Formular & eigene Bewertungen --- */
.rate-area { margin: 16px 0; }
.rating-form { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.rf-field { font-size: .82rem; color: var(--muted); display: inline-flex; flex-direction: column; gap: 3px; }
.rf-field input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: .9rem; }
.rf-check { font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.my-ratings { margin-top: 14px; }
.mr-head { font-size: 1rem; margin: 0 0 8px; }
.mr-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.mr-item { display: flex; align-items: center; gap: 12px; font-size: .9rem; padding: 6px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.mr-date { color: var(--muted); min-width: 84px; }
.mr-cor { display: inline-flex; align-items: center; gap: 4px; color: #6b7280; font-size: .82rem; }
.mr-cor .icon { width: 1em; height: 1em; }
.mr-del { margin-left: auto; }

/* --- Koriander-Skala --- */
.coriander { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; flex-wrap: wrap; }
.coriander-head { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.coriander-meter { flex: 1; min-width: 120px; max-width: 200px; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.coriander-fill { height: 100%; width: 0; background: linear-gradient(90deg, #86efac, #16a34a); border-radius: 4px; transition: width .3s; }
.coriander-val { font-weight: 600; font-size: .85rem; min-width: 42px; }

/* --- Status (Admin) --- */
.status-active { color: var(--accent-dark); font-weight: 600; font-size: .82rem; }
.status-pending { color: #b45309; font-weight: 600; font-size: .82rem; }
.linkbtn.approve { color: var(--accent-dark); font-weight: 600; }

/* --- Icons --- */
.icon { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -0.18em; flex: none; }
.icon-xl { width: 2.75rem; height: 2.75rem; }
.with-icon { display: inline-flex; align-items: center; gap: 6px; }
.card-photo-empty .icon, .dish-photo-empty .icon, .rank-photo-empty .icon { color: var(--accent-dark); opacity: .5; }
.dish-photo-empty .icon { width: 3.5rem; height: 3.5rem; }
.rank-photo-empty .icon { width: 1.9rem; height: 1.9rem; }
.empty-icon { display: flex; justify-content: center; margin: 0 0 10px; }
.empty-icon .icon { width: 3rem; height: 3rem; color: var(--muted); }

/* --- Footer --- */
.footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .85rem; padding: 20px 0; }

/* --- Responsive --- */
@media (max-width: 760px) {
    .dish { grid-template-columns: 1fr; }
    .search { display: none; }
    .nav-user { display: none; }
    h1 { font-size: 1.45rem; }
    .dish-info-actions { position: static; margin-bottom: 8px; }
}
