* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
  background: #f5f3ef; 
  color: #383632; 
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); 
  -webkit-tap-highlight-color: transparent;
}
.inner { max-width: 620px; margin: 0 auto; }

header { 
  background: #eae6df; 
  color: #383632; 
  border-bottom: 1px solid #ddd7cd;
  padding: 16px; 
  font-size: 1.2rem; 
  font-weight: 600; 
  position: sticky; 
  top: 0; 
  z-index: 10; 
  padding-top: max(16px, env(safe-area-inset-top));
}
main { padding: 12px 14px; }
.screen { display: none; }
.screen.active { display: block; }
h2 { font-size: 1.05rem; margin: 14px 0 10px; color: #4f6155; }

/* Karten */
.card { 
  background: #fff; 
  border-radius: 14px; 
  padding: 14px; 
  margin-bottom: 10px; 
  box-shadow: 0 1px 3px rgba(0,0,0,.03); 
  border: 1px solid #e5e0d7; 
}

/* Eingabefelder */
input, select, textarea { 
  width: 100%; 
  padding: 10px 12px; 
  border: 1px solid #d9d3c7; 
  border-radius: 10px; 
  font-size: 16px; 
  background: #faf9f6; 
  color: #383632; 
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #7b8f80;
  background: #fff;
}
textarea { resize: vertical; min-height: 48px; font-family: inherit; }
label { font-size: .78rem; color: #78736a; display: block; margin-bottom: 3px; font-weight: 500; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 6px; margin-top: 6px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

/* Buttons */
button { 
  border: 1px solid #d9d3c7; 
  border-radius: 10px; 
  padding: 10px 14px; 
  font-size: .95rem; 
  cursor: pointer; 
  background: #ede9e1; 
  color: #383632; 
  font-weight: 500;
  touch-action: manipulation;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:active { background: #e2ddd4; }

.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row > * { flex: 1; }

.btn-stack { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.btn-wide { width: 100%; font-weight: 600; }

.btn-primary { background: #6c8072; border-color: #6c8072; color: #fff; }
.btn-primary:active { background: #5a6d60; }

.btn-danger { background: #f7eded; border-color: #e8d5d5; color: #8c4b4b; }
.btn-danger:active { background: #eedcdc; }

.btn-print { background: #52504b; border-color: #52504b; color: #fff; }
.btn-outline { background: #faf9f6; border: 1.5px solid #7b8f80; color: #55675b; }
.btn-icon { flex: 0 0 44px; padding: 0; min-height: 44px; width: 44px; }

.btn-subtle {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 0.78rem;
  background: #faf9f6;
  border: 1px solid #d9d3c7;
  color: #5c574f;
  margin-top: 8px;
}
.btn-subtle:active { background: #eee9df; }

/* Drag & Drop */
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 44px;
  font-size: 1.3rem;
  color: #8c8275;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; color: #4a6b57; }

.card.dragging { opacity: 0.4; background: #f0ede8; border-style: dashed; }
.card.drop-target { border-top: 3px solid #6c8072; }

/* Filter-Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { 
  padding: 8px 14px; 
  min-height: 38px;
  border-radius: 99px; 
  background: #fff; 
  border: 1px solid #d9d3c7; 
  font-size: .85rem; 
  color: #5c574f; 
}
.chip.active { background: #6c8072; border-color: #6c8072; color: #fff; font-weight: 600; }

/* Plan Elemente & Badges */
.plan-item { padding: 12px 14px; }
.item-header { display: flex; align-items: center; gap: 6px; }
.item-header h3 { font-size: 0.98rem; flex: 1; }
.compact-note { margin-top: 6px; }
.compact-note input { padding: 6px 10px; font-size: 15px; }

.desc { font-size: .82rem; color: #696359; margin: 4px 0 6px; line-height: 1.3; }

.badge-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 6px; }
.cat { 
  display: inline-block; 
  font-size: .72rem; 
  background: #eef1ee; 
  color: #4a5c4f; 
  border: 1px solid #dbe2dc;
  padding: 2px 8px; 
  border-radius: 99px; 
}
.cat-region { background: #f4ede4; color: #735338; border-color: #e5d8cb; }
.cat-tag-eigen { background: #eaf0eb; color: #355239; border-color: #d1ded3; }
.cat-tag-edit { background: #f0ede8; color: #615a4f; border-color: #ded8ce; }

/* Navigation Tabbar */
.tabbar { 
  position: fixed; 
  bottom: 0; left: 0; right: 0; 
  background: #faf9f6; 
  border-top: 1px solid #e0dad0; 
  z-index: 10; 
  padding-bottom: env(safe-area-inset-bottom);
}
.tabinner { display: flex; }
.tabbar button { 
  flex: 1; background: none; border: none; border-radius: 0; 
  padding: 14px 4px; font-size: .9rem; color: #78736a; 
}
.tabbar button.active { color: #4f6155; font-weight: 700; }
.badge { display: none; min-width: 20px; background: #6c8072; color: #fff; border-radius: 99px; font-size: .72rem; padding: 2px 6px; margin-left: 4px; }

.empty { text-align: center; color: #948e83; padding: 30px 10px; }
.small { font-size: .85rem; color: #78736a; }
.hint { font-size: .82rem; color: #78736a; text-align: center; margin-bottom: 12px; }
.tplrow .tplhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }

/* Toast */
.toast { 
  position: fixed; 
  bottom: calc(84px + env(safe-area-inset-bottom)); 
  left: 50%; 
  transform: translateX(-50%) translateY(14px); 
  background: #4a4742; 
  color: #faf9f6; 
  padding: 12px 18px; 
  border-radius: 12px; 
  font-size: .88rem; 
  opacity: 0; 
  transition: opacity .25s, transform .25s; 
  z-index: 100; 
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
/* Modals & Android Bottom Sheet */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(30, 28, 25, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 env(safe-area-inset-bottom);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px 24px;
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  border: 1px solid #e5e0d7;
  border-bottom: none;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.modal-backdrop.show .modal-card {
  transform: translateY(0);
}
@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
    padding: 16px;
  }
  .modal-card {
    border-radius: 18px;
    border-bottom: 1px solid #e5e0d7;
    max-height: 80vh;
    transform: translateY(20px);
  }
  .modal-backdrop.show .modal-card {
    transform: translateY(0);
  }
}

#printArea { display: none; }

/* Druck-Layout */
@media print {
  @page { margin: 1.2cm; size: portrait; }
  body { background: #fff; padding: 0; color: #000; }
  header, main, .tabbar, .toast { display: none !important; }
  #printArea { display: block !important; }
  #printArea h1 { font-size: 16pt; margin-bottom: 6px; }
  #printArea table { width: 100%; border-collapse: collapse; margin-top: 10px; table-layout: fixed; page-break-inside: auto; }
  #printArea thead { display: table-header-group; }
  #printArea th, #printArea td { border: 1pt solid #000; padding: 6px; font-size: 10pt; text-align: left; vertical-align: top; }
  #printArea th { background: #f6f5f2; font-weight: 700; white-space: nowrap; }
  #printArea .num { text-align: center; }
  #printArea tr { page-break-inside: avoid; }
  #printArea .pdesc { font-size: 8.5pt; color: #333; display: block; margin-top: 2px; }
  #printArea .ptags { font-size: 8pt; color: #555; display: block; margin-top: 2px; }
}