:root {
  --orange: #e8732e;
  --orange-dark: #c75d1d;
  --orange-light: #f6a667;
  --green: #3f7d3a;
  --green-dark: #2c5a28;
  --green-light: #6fb168;
  --bg: #fdf6ef;
  --surface: #ffffff;
  --surface-2: #fbf1e6;
  --text: #2a2118;
  --text-muted: #6b5d4f;
  --border: #e7d8c6;
  --danger: #b3261e;
  --warn-bg: #fff2e2;
  --warn-text: #8a4a10;
  --shadow: 0 2px 12px rgba(199, 93, 29, 0.10);
  --radius: 14px;
  --focus: #b14e12;
}

[data-theme="dark"] {
  --orange: #f08a44;
  --orange-dark: #e8732e;
  --orange-light: #f6a667;
  --green: #74b86c;
  --green-dark: #4f8c47;
  --green-light: #8fcd88;
  --bg: #1a1611;
  --surface: #241e17;
  --surface-2: #2c241a;
  --text: #f4ece1;
  --text-muted: #c2b3a2;
  --border: #3a3024;
  --danger: #ff8a82;
  --warn-bg: #34281a;
  --warn-text: #f0c290;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
  --focus: #f6a667;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--orange);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 50;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(120deg, var(--orange), var(--orange-dark));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.brand-logo { display: block; flex: none; }
.app-header h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  flex: none;
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.30); }

.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
  color: var(--text);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.card-head h2 { margin: 0; }

.honesty-card {
  border-left: 5px solid var(--green);
  background: var(--surface-2);
}
.honesty-card h2 { color: var(--green-dark); }
.honesty-card p { margin: 0.4rem 0; }

.hint {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0.7rem;
}
.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.field { margin-bottom: 0.7rem; }
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text);
}
.req { color: var(--danger); }

input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
}
textarea { resize: vertical; min-height: 64px; }
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.chip:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.field-error {
  color: var(--danger);
  font-size: 0.82rem;
  margin: 0.2rem 0 0;
  font-weight: 600;
}

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  line-height: 1.2;
}
.btn.small { padding: 0.4rem 0.7rem; font-size: 0.82rem; }
.btn.primary { background: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-dark); }
.btn.secondary { background: var(--green); color: #fff; }
.btn.secondary:hover { background: var(--green-dark); }
.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-outline {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn.danger-outline:hover { background: var(--danger); color: #fff; }

.loc-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.manual-loc { margin-top: 0.4rem; }
.loc-status {
  margin: 0.6rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
}

.form-actions,
.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.filter-row {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.chip {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.38rem 0.85rem;
  cursor: pointer;
}
.chip.is-active {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}

.count-badge {
  background: var(--green);
  color: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 1.6rem;
  text-align: center;
}

.results-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.6rem;
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.entry {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: var(--surface-2);
}
.entry-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}
.entry-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.entry-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.3rem; }
.type-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  color: #fff;
}
.type-fairteiler { background: var(--green); }
.type-tafel { background: var(--orange); }
.type-suppenkueche { background: #8a5a2b; }
.type-sonstiges { background: var(--text-muted); }
.dist-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.entry-place,
.entry-note {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.entry-place { color: var(--text); }
.entry-note { color: var(--text-muted); white-space: pre-wrap; }

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.6rem;
}
.entry-actions .btn { padding: 0.4rem 0.75rem; font-size: 0.82rem; }
.entry-actions a.btn { text-decoration: none; display: inline-block; }

.empty-note {
  color: var(--text-muted);
  font-size: 0.92rem;
  text-align: center;
  padding: 0.6rem 0;
  margin: 0 0 0.6rem;
}

.app-footer {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.2rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.modal-title { margin: 0 0 0.5rem; font-size: 1.1rem; }
.modal-text { margin: 0 0 1rem; color: var(--text-muted); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 120;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

@media (max-width: 380px) {
  .grid-2 { grid-template-columns: 1fr; }
  .app-header h1 { font-size: 1.05rem; }
}

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