* { box-sizing: border-box; }

:root {
  --bg: #F4F1E8;
  --surface: #FFFDF7;
  --ink: #14312D;
  --muted: #687975;
  --line: #D8DED9;
  --accent: #173F3A;
  --accent-2: #D8F06A;
  --danger: #A33A32;
  --shadow: 0 16px 40px rgba(20, 49, 45, .10);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 0%, rgba(216,240,106,.18), transparent 30%),
    var(--bg);
  min-height: 100vh;
  font-size: 16px;
}

body.editor-open { overflow: hidden; }

button, input, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(34px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-wrap { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 56px; height: 56px; border-radius: 17px; box-shadow: var(--shadow); }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 2px; font-size: 1.55rem; letter-spacing: -.04em; }
.brand-wrap p { margin: 0; color: var(--muted); font-size: .92rem; }

.hero { display: grid; gap: 14px; margin-bottom: 30px; }

.search-wrap {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 20px;
  min-height: 66px;
  display: flex;
  align-items: center;
  padding: 0 17px;
  box-shadow: 0 8px 24px rgba(20,49,45,.05);
}
.search-icon { font-size: 1.65rem; margin-right: 10px; color: var(--muted); }
.search-wrap input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  min-height: 60px;
  color: var(--ink);
  font-size: 1.1rem;
}

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn, .back-btn {
  border-radius: 17px;
  border: 2px solid transparent;
  min-height: 56px;
  padding: 0 20px;
  font-weight: 800;
  font-size: 1rem;
}
.primary-btn { background: var(--accent); color: white; }
.secondary-btn { background: var(--accent-2); color: var(--ink); }
.ghost-btn { background: transparent; color: var(--ink); border-color: var(--line); }
.danger-btn { color: white; background: var(--danger); }
.big-action { width: 100%; min-height: 62px; font-size: 1.08rem; }
.full-width { width: 100%; }

.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-head h2 { font-size: 1.08rem; margin: 0; }
.count-pill {
  min-width: 32px; height: 32px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(23,63,58,.09); border-radius: 999px; font-size: .9rem; font-weight: 800;
}

.items-list { display: grid; gap: 12px; }

.item-card {
  background: rgba(255,253,247,.9);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}
.item-main {
  width: 100%;
  min-height: 96px;
  border: 0;
  background: transparent;
  padding: 14px;
  display: grid;
  grid-template-columns: 70px minmax(0,1fr) 28px;
  gap: 14px;
  align-items: center;
  text-align: left;
  color: inherit;
}
.item-main:active { background: rgba(23,63,58,.05); }
.thumb-wrap {
  width: 70px; height: 70px; border-radius: 17px; overflow: hidden;
  background: var(--accent); position: relative;
}
.thumb { width: 100%; height: 100%; object-fit: cover; }
.thumb-fallback {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  color: var(--accent-2);
  font-weight: 900; font-size: 1.05rem; letter-spacing: -.05em;
}
.item-copy { min-width: 0; }
.item-name { margin: 0 0 5px; font-size: 1.08rem; line-height: 1.25; }
.item-location { margin: 0; color: var(--ink); font-size: .98rem; line-height: 1.35; }
.item-note { margin: 5px 0 0; color: var(--muted); font-size: .92rem; line-height: 1.35; }
.item-updated { margin: 7px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.2; }
.chevron { color: var(--muted); font-size: 2rem; font-weight: 400; justify-self: end; }

.empty-state {
  border: 1px dashed #BCC7C2;
  border-radius: 24px;
  padding: 36px 22px;
  text-align: center;
  background: rgba(255,253,247,.58);
}
.empty-state.compact { padding: 30px 18px; }
.empty-mark {
  width: 74px; height: 74px; margin: 0 auto 18px;
  border-radius: 22px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-2);
  font-weight: 900; font-size: 1.35rem;
}
.empty-state h3 { margin-bottom: 8px; font-size: 1.15rem; }
.empty-state p { color: var(--muted); margin-bottom: 20px; line-height: 1.45; }

/* Vollbild-Editor: zuverlässiger als <dialog> auf mobilen Browsern */
.editor-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0;
}
.editor-card {
  width: min(760px, 100%);
  margin: 0 auto;
  min-height: 100%;
  background: var(--surface);
}
.editor-card form { min-height: 100vh; display: flex; flex-direction: column; }

.editor-top {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 16px 13px;
  background: rgba(255,253,247,.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.back-btn {
  width: 56px;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
  font-size: 1.5rem;
}
.editor-title-wrap { min-width: 0; }
.editor-title-wrap h2 {
  margin: 2px 0 0;
  font-size: 1.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eyebrow { font-size: .76rem; font-weight: 900; letter-spacing: .12em; color: var(--muted); }

.form-body {
  display: grid;
  gap: 24px;
  padding: 22px 16px 110px;
}

.field { display: grid; gap: 9px; }
.field-label { font-weight: 850; font-size: 1rem; }
.field-label small { color: var(--muted); font-weight: 600; }

input, textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 15px 16px;
  background: white;
  color: var(--ink);
  outline: 0;
  font-size: 16px; /* verhindert iOS-Zoom */
  line-height: 1.35;
}
input { min-height: 58px; }
textarea { resize: vertical; min-height: 108px; }
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(23,63,58,.08);
}

.recent-locations {
  margin-top: 6px;
  padding: 14px;
  border-radius: 17px;
  background: #F2F4ED;
}
.recent-title {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: .92rem;
  font-weight: 800;
}
.location-chips {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}
.location-chip {
  min-height: 52px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #C8D1CC;
  border-radius: 14px;
  background: white;
  color: var(--ink);
  text-align: left;
  font-weight: 750;
  font-size: 1rem;
  line-height: 1.3;
}
.location-chip:active { background: var(--accent-2); }

.photo-label input[type=file] { display: none; }
.photo-preview {
  min-height: 178px;
  border: 2px dashed #AEBBB5;
  border-radius: 18px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  color: var(--ink);
  background-color: rgba(23,63,58,.025);
  background-size: cover;
  background-position: center;
  text-align: center;
  padding: 18px;
}
.photo-preview .photo-icon {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: white;
  font-size: 1.5rem;
  margin-bottom: 5px;
}
.photo-preview small { color: var(--muted); font-weight: 600; }
.photo-preview.has-image { min-height: 250px; }

.remove-photo-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  font-size: 1rem;
  font-weight: 700;
}
.remove-photo-row input { width: 24px; height: 24px; margin: 0; }

.editor-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1002;
  display: grid;
  grid-template-columns: .85fr 1.15fr;
  gap: 10px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: rgba(255,253,247,.97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.editor-actions button { min-height: 60px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  padding: 13px 17px;
  border-radius: 999px;
  color: white;
  background: #102B27;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 2000;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: .95rem;
  white-space: nowrap;
  max-width: calc(100% - 28px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }

@media (min-width: 640px) {
  .app-shell { padding-left: 22px; padding-right: 22px; }
  .location-chips { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-body { padding-left: 24px; padding-right: 24px; }
  .editor-actions {
    left: 50%;
    right: auto;
    width: min(760px, 100%);
    transform: translateX(-50%);
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (max-width: 420px) {
  .brand-wrap p { display: none; }
  .topbar { margin-bottom: 22px; }
  .brand-icon { width: 52px; height: 52px; }
  .item-main { grid-template-columns: 64px minmax(0,1fr) 24px; gap: 11px; padding: 12px; }
  .thumb-wrap { width: 64px; height: 64px; }
}


/* Konto / Anmeldung */
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.account-btn {
  width: 56px;
  height: 56px;
  border: 2px solid var(--line);
  border-radius: 17px;
  background: rgba(255,253,247,.8);
  color: var(--ink);
  display: grid;
  place-items: center;
  text-decoration: none;
  font-size: 1.35rem;
  font-weight: 900;
  -webkit-tap-highlight-color: transparent;
}
.account-btn:active { background: rgba(23,63,58,.08); }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.auth-shell {
  width: min(520px, 100%);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px 20px;
}
.auth-logo {
  display: block;
  width: 82px;
  height: 82px;
  border-radius: 24px;
  margin: 0 auto 20px;
  box-shadow: var(--shadow);
}
.auth-logo.small {
  width: 64px;
  height: 64px;
  border-radius: 19px;
  margin: 10px 0 18px;
}
.auth-card h1 {
  font-size: 1.65rem;
  margin-bottom: 9px;
  text-align: center;
}
.auth-card .auth-logo.small + h1 {
  text-align: left;
}
.auth-intro {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 22px;
  text-align: center;
}
.auth-logo.small ~ .auth-intro {
  text-align: left;
}
.auth-form {
  display: grid;
  gap: 20px;
}
.auth-error,
.auth-success {
  padding: 13px 15px;
  border-radius: 15px;
  margin-bottom: 18px;
  font-weight: 750;
  line-height: 1.4;
}
.auth-error {
  background: #FBE7E4;
  color: #7A2A24;
  border: 1px solid #EDC2BC;
}
.auth-success {
  background: #E7F4E8;
  color: #225C2A;
  border: 1px solid #BEDCBF;
}
.auth-back,
.logout-link {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}
.logout-link {
  margin-top: 18px;
  width: 100%;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 16px;
}


.logout-form {
  margin-top: 18px;
}
.logout-button {
  width: 100%;
  min-height: 60px;
  border: 2px solid var(--line);
  border-radius: 17px;
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-weight: 850;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}
.logout-button:active {
  background: #FBE7E4;
}


/* V5 – Filter, Sortierung und Orteverwaltung */
.compact-install { min-height: 50px; padding: 0 14px; }
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.control-box {
  display: grid;
  gap: 7px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  font-weight: 800;
  font-size: .86rem;
  color: var(--muted);
}
.control-box select {
  min-height: 50px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: #F2F4ED;
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
  font-size: 16px;
  font-weight: 750;
}
.text-btn {
  margin-left: auto;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 850;
  padding: 0 4px;
}
.app-shell.narrow { width: min(620px, 100%); }

.subpage-head {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.subpage-head h1 { margin: 2px 0 0; font-size: 1.55rem; }
.back-link {
  width: 56px;
  height: 56px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 900;
}
.manage-card,
.manage-location-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
}
.add-location-card { margin-bottom: 12px; }
.inline-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
}
.inline-add .primary-btn { min-height: 58px; }
.helper-text {
  color: var(--muted);
  line-height: 1.45;
  font-size: .92rem;
  margin: 14px 4px 16px;
}
.locations-manage-list {
  display: grid;
  gap: 12px;
  padding-bottom: 30px;
}
.manage-location-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}
.manage-location-meta strong { font-size: 1.05rem; }
.manage-location-meta span { color: var(--muted); font-size: .87rem; white-space: nowrap; }
.rename-input { margin-bottom: 10px; }
.manage-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.danger-outline {
  min-height: 56px;
  border: 2px solid #E1B6B1;
  border-radius: 17px;
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-weight: 850;
}
.danger-outline:disabled {
  opacity: .42;
  cursor: not-allowed;
}
.location-hint {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.4;
}
.settings-link {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  border: 2px solid var(--line);
  border-radius: 16px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 850;
}

@media (max-width: 560px) {
  .top-actions { gap: 6px; }
  .account-btn { width: 50px; height: 50px; border-radius: 15px; font-size: 1.15rem; }
  .compact-install { display: none !important; }
  .filter-grid { grid-template-columns: 1fr; }
  .control-box { padding: 11px 12px; }
  .inline-add { grid-template-columns: 1fr; }
  .inline-add .primary-btn { width: 100%; }
}
