:root{ --safe-top: env(safe-area-inset-top, 0px); }
:root{
  --bg: #0b1220;
  --card: rgba(255,255,255,0.06);
  --card2: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.10);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.70);
  --muted2: rgba(255,255,255,0.55);
  --danger: rgba(239,68,68,0.9);
  --ok: rgba(34,197,94,0.9);
  --warn: rgba(245,158,11,0.95);

  /* iOS Keyboard Fix: will be set by JS */
  --vh: 1vh;
}

*{ box-sizing: border-box; }

/* Always honor the HTML hidden attribute */
[hidden]{ display:none !important; }


html, body{
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 800px at 20% 0%, rgba(37,99,235,0.25), transparent 60%),
              radial-gradient(1200px 800px at 90% 10%, rgba(99,102,241,0.22), transparent 60%),
              var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* IMPORTANT: iOS zoom/viewport issues -> keep inputs >=16px */
input, select, textarea, button{
  font-size: 16px;
}

/* Container uses dynamic vh fix */
.container{
  width: min(920px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 12px 0 22px;
  min-height: calc(var(--vh) * 100);
  padding-bottom: calc(22px + env(safe-area-inset-bottom));
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(11,18,32,0.78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

/* editable title */
.topbar__titleInput{
  width: 100%;
  max-width: 520px;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-weight: 800;
  font-size: 20px;
  line-height: 1.2;
  padding: 6px 8px;
  border-radius: 10px;
}

.topbar__titleInput:focus{
  background: rgba(255,255,255,0.06);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12) inset;
}

.topbar__actions{
  display: flex;
  align-items: center;
  gap: 8px;
}

.iconbtn{
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
}

.tabs{
  display: flex;
  gap: 8px;
  padding: 10px 0 8px;
}

.tab{
  flex: 1;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
}

.tab.active{
  background: rgba(37,99,235,0.22);
  border-color: rgba(37,99,235,0.35);
}

.page{ display:none; }
.page.active{ display:block; }

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  margin: 10px 0;
}

.label{
  display: block;
  font-size: 12px;
  color: var(--muted2);
  margin-bottom: 6px;
}

.input{
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  padding: 12px 12px;
  outline: none;
}

.input:focus{
  border-color: rgba(37,99,235,0.55);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.grid2{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* keep side-by-side even on small screens (as requested) */
@media (max-width: 420px){
  .grid2{ gap: 10px; }
}

.hr{
  border: 0;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.row{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}

.row__left{ color: var(--muted); }
.row__right{ color: var(--text); }

.bold .row__left, .bold .row__right{ font-weight: 700; }
.headline .row__left, .headline .row__right{ font-weight: 800; font-size: 16px; }

.mono{ font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.hint{
  font-size: 12px;
  color: var(--muted2);
  margin-top: 8px;
}

.btn{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
}

.btn.primary{
  background: rgba(37,99,235,0.25);
  border-color: rgba(37,99,235,0.35);
}

.btn.danger{
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.35);
}

.limitBox{
  margin-top: 12px;
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
}

.limitBox.ok{ border-color: rgba(34,197,94,0.35); background: rgba(34,197,94,0.10); }
.limitBox.warn{ border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.10); }
.limitBox.danger{ border-color: rgba(239,68,68,0.45); background: rgba(239,68,68,0.12); color: rgba(255,255,255,0.92); }

/* Image picker */
.imagePicker{
  width: 100%;
  height: 180px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
}

.imagePicker img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.imagePicker__preview{
  width: 100%;
  height: 180px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
}

.imagePicker__preview img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.imagePicker__placeholder{
  text-align: center;
  color: var(--muted2);
  padding: 10px;
}

.bigicon{
  font-size: 28px;
  margin-bottom: 6px;
}

.tappable{
  cursor: pointer;
}

.tappable::after{
  content: "✎";
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 14px;
  padding: 6px 8px;
  border-radius: 999px;
}

/* Sections/items */
.sections{ margin-top: 10px; }

.section{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  border-radius: 18px;
  overflow: hidden;
  margin: 10px 0;
}

.section__header{
  padding: 12px 14px;
  display:flex;
  align-items:center;
  justify-content: space-between;
    background: rgba(255,255,255,0.03);
}

.section__title{ font-weight: 800; }
.section__meta{ color: var(--muted2); font-size: 12px; }

.section__body{ display:none; padding: 12px 14px; }
.section.expanded .section__body{ display:block; }

.item{
  display:flex;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.item:first-child{ border-top: 0; }

.item__check{
  width: 22px;
  height: 22px;
  margin-top: 4px;
}

.item__main{ flex: 1; }
.item__top{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item__name{ font-weight: 700; color: var(--text); }
.item__trail{ color: var(--muted2); font-size: 13px; }
.item__trail.warn{ color: var(--warn); }

.item__actions{
  display:flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.segmented{
  display:flex;
  gap: 8px;
  margin: 6px 0 10px;
}

.seg{
  flex: 1;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  cursor: pointer;
}

.seg.active{
  background: rgba(37,99,235,0.22);
  border-color: rgba(37,99,235,0.35);
}

.checkbox{
  display:flex;
  align-items:center;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
}

.ul{
  margin: 10px 0 0 18px;
  color: var(--muted);
}

.modal::backdrop{
  background: rgba(0,0,0,0.55);
}

.modal__card{
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(11,18,32,0.96);
  color: var(--text);
  padding: 14px;
  width: min(520px, calc(100vw - 24px));
}

.modal__title{
  font-weight: 900;
  font-size: 16px;
  margin-bottom: 8px;
}

.modal__actions{
  display:flex;
  justify-content:flex-end;
  gap: 10px;
  margin-top: 12px;
}

.modal__actions.stack{
  flex-direction: column;
}

/* ---------------- Snackbar (Undo) ---------------- */

.snackbar{
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(17,24,39,.95);
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
  backdrop-filter: blur(10px);

  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.snackbar--show{
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.snackbar__text{
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
}

.snackbar__btn{
  border: 1px solid rgba(37,99,235,.6);
  background: rgba(37,99,235,.18);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.snackbar__btn:active{
  transform: scale(0.98);
}

	  /* --- iOS/PWA Dialog-Overflow Fix --- */
dialog.modal{
  padding: 0;
  border: 0;
  background: transparent;
  max-width: calc(100vw - 16px);
  margin: 0 auto;
}

dialog.modal::backdrop{
  background: rgba(0,0,0,0.55);
}

/* Das eigentliche "Karten"-Layout im Dialog */
.modal__card{
  box-sizing: border-box;
  width: calc(100vw - 24px);
  max-width: 520px;
  margin: 0 auto;
}

/* Optional: bei sehr kleinen Geräten noch etwas enger */
@media (max-width: 380px){
  .modal__card{
    width: calc(100vw - 18px);
  }
}
/* --- Trial / Paywall Overlay --- */
.trialOverlay{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
}

.trialCard{
  width: min(520px, calc(100vw - 24px));
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(11,18,32,0.96);
  padding: 14px;
}

.trialTitle{
  font-weight: 900;
  font-size: 16px;
  margin-bottom: 8px;
}

.trialText{
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.35;
}

/* Floating Action Button (+) */
.fab{
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 18px;
  border: 1px solid rgba(37,99,235,0.6);
  background: rgba(37,99,235,0.22);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
}
.fab:active{ transform: scale(0.98); }

/* Bigger expand/collapse icon/button */
.section__toggle{
  border: 0;
  background: transparent;
  color: var(--muted2);
  font-size: 22px;
  line-height: 1;
  padding: 10px 8px;
  margin: -8px -6px -8px 0;
  border-radius: 12px;
  cursor: pointer;
}
.section__toggle:active{ transform: scale(0.98); }

/* -------- Touch drag & drop (long-press) -------- */
.dragGhost{
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(-9999px, -9999px);
  z-index: 10000;
  pointer-events: none;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(17,24,39,.95);
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
  max-width: min(320px, calc(100vw - 24px));
  font-weight: 700;
}

.item.dropTarget{
  outline: 2px solid rgba(37,99,235,0.55);
  outline-offset: 6px;
  border-radius: 14px;
}

.section.dropTarget{
  outline: 2px solid rgba(37,99,235,0.45);
  outline-offset: 6px;
}

.dropLine{
  height: 3px;
  border-radius: 999px;
  background: rgba(37,99,235,0.75);
  margin: 8px 0;
}

.grid2 .btn{
  width: 100%;
}

.app{ padding-top: var(--safe-top); }

/* v36: Bild größer + besseres Verhältnis */
.imagePicker{
  aspect-ratio: 16 / 9;
  min-height: 220px;
}
#caravanPreview img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* v47: Section rename/delete buttons (stable, no gestures) */
.section__right{
  display:flex;
  align-items:center;
  gap:10px;
}
.section__rename,.section__delete{
  border:0;
  background:transparent;
  font-size:18px;
  line-height:1;
  padding:6px 8px;
  cursor:pointer;
}
.section__rename:active,.section__delete:active{ transform: scale(0.96); }

.section__header{ cursor: pointer; }


/* v49: Compact item actions (icons) */
.item__right{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}
.item__icons{
  display:flex;
  align-items:center;
  gap: 10px;
}
.item__icon{
  border: 0;
  background: transparent;
  padding: 6px 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.item__icon:active{ transform: scale(0.96); }
