:root {
  --text: #0f3049;
  --muted: #557d93;
  --card: rgba(255, 255, 255, .72);
  --card-border: rgba(255, 255, 255, .65);
  --glass-blur: saturate(1.4) blur(16px);
  --shadow: 0 10px 30px rgba(7, 89, 133, .14);
  --ocean: #0284c7;
  --ocean-light: #38bdf8;
  --sun: #fbbf24;
  --amber: #f59e0b;
  --sunset-grad: linear-gradient(135deg, #ffb347, #ff7b54);
  --ocean-grad: linear-gradient(180deg, #38bdf8, #0284c7);
  --amber-grad: linear-gradient(180deg, #fcd34d, #f59e0b);
  --danger: #e05c4b;
  --radius: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Das Dokument scrollt NIE – nur .view scrollt innen. Verhindert den
   iOS-Scroll-Edge-Blur über der Kopfzeile in der Homescreen-App. */
html, body { height: 100%; overflow: hidden; }

body {
  margin: 0;
  background: linear-gradient(175deg, #0ea5e9 0%, #7dd3f8 45%, #fdeec9 100%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#app {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); font-weight: 600; }

/* PIN */
.screen {
  height: 100%; height: 100dvh;
  display: flex; align-items: center; justify-content: center;
}
.pin-box {
  text-align: center; width: 270px; padding: 28px 24px;
  background: var(--card); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border); border-radius: 28px; box-shadow: var(--shadow);
}
.pin-logo { font-size: 64px; filter: drop-shadow(0 6px 12px rgba(245, 158, 11, .35)); }
.pin-box h1 { margin: 8px 0 24px; letter-spacing: 4px; font-weight: 800; }
.pin-box input {
  width: 100%; padding: 14px; font-size: 24px; text-align: center;
  border-radius: 16px; border: 1.5px solid #cfe6f2;
  background: rgba(255, 255, 255, .9); color: var(--text); letter-spacing: 8px;
}
.pin-box .btn { width: 100%; margin-top: 12px; }

/* Header: fest über dem Scroll-Bereich, wird nie überscrollt */
header {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(28px + env(safe-area-inset-top)) 20px 4px;
  font-weight: 800; font-size: 18px; letter-spacing: .2px;
}
.badge {
  font-size: 12px; font-weight: 700; color: #7c4a03;
  background: var(--sun); border-radius: 999px; padding: 4px 12px;
  box-shadow: 0 3px 10px rgba(251, 191, 36, .4);
}

/* Views: der einzige Scroll-Container der App */
.view {
  flex: 1; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 16px calc(96px + env(safe-area-inset-bottom));
}
h2 {
  font-size: 13px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 1.5px; margin: 26px 4px 10px; font-weight: 700;
}

.counter-card {
  background: var(--card); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border); border-radius: 26px;
  padding: 24px 20px; text-align: center; box-shadow: var(--shadow);
}
.beer-big { font-size: 76px; font-weight: 800; line-height: 1; color: var(--amber); text-shadow: 0 4px 18px rgba(245, 158, 11, .25); }
.beer-big .beer-emoji { font-size: 50px; margin-left: 8px; }
.counter-sub { display: flex; justify-content: space-around; margin-top: 18px; }
.counter-sub b, .stat-grid b { display: block; font-size: 20px; }
.counter-sub small, .stat-grid small { color: var(--muted); font-size: 12px; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 8px; }
.stat-grid b { font-size: 26px; }

/* Eingabe-Buttons: 2x2, alle exakt gleich groß */
.actions {
  display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: 1fr;
  gap: 12px; margin-top: 16px;
}
.action-btn {
  min-height: 104px;
  background: var(--card); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border); border-radius: var(--radius);
  color: var(--text); font-size: 30px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; cursor: pointer; transition: transform .1s ease;
}
.action-btn span { font-size: 13px; font-weight: 700; color: var(--muted); line-height: 1.25; }
.action-btn.camera { background: var(--sunset-grad); border: none; }
.action-btn.camera span { color: rgba(255, 255, 255, .95); }
.action-btn.quick { background: rgba(255, 255, 255, .88); }
.action-btn:active { transform: scale(.95); }

/* Einträge */
.entry {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 13px 14px; margin-bottom: 10px; box-shadow: 0 4px 16px rgba(7, 89, 133, .08);
}
.entry .e-icon { font-size: 22px; }
.entry .e-main { flex: 1; min-width: 0; }
.entry .e-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .e-sub { font-size: 12px; color: var(--muted); }
.entry .e-amount { text-align: right; font-weight: 800; }
.entry .e-amount small { display: block; color: var(--amber); font-weight: 700; }
.entry .e-del { background: none; border: none; color: #a9c2cf; font-size: 17px; padding: 6px; }

/* Charts */
.chart {
  display: flex; align-items: flex-end; gap: 6px; height: 150px;
  background: var(--card); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 14px 12px 10px; box-shadow: var(--shadow);
}
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; max-width: 44px; background: var(--amber-grad); border-radius: 8px 8px 3px 3px; min-height: 3px; }
.chart .bar.spent { background: var(--ocean-grad); }
.chart .bar-val { font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.chart .bar-day { font-size: 10px; color: var(--muted); font-weight: 600; margin-top: 5px; }

/* Trips */
.trip-item {
  background: var(--card); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.trip-item.active-trip { outline: 2.5px solid var(--sun); }
.trip-item .t-main { flex: 1; min-width: 0; }
.trip-item .t-edit, .trip-item .t-delete {
  background: none; border: none; font-size: 17px; padding: 6px 2px; flex-shrink: 0;
}
.trip-item .t-name { font-weight: 800; }
.trip-item .t-sub { font-size: 12px; color: var(--muted); }
.new-trip { display: flex; gap: 8px; margin-top: 14px; }
.new-trip input { flex: 1; }

/* Formulare & Buttons */
input[type=text], input[type=number], input[type=password], input[type=date] {
  background: rgba(255, 255, 255, .9); border: 1.5px solid #cfe6f2; color: var(--text);
  border-radius: 14px; padding: 12px; font-size: 16px; width: 100%;
  -webkit-appearance: none; appearance: none;
}
input:focus { outline: 2px solid var(--ocean-light); border-color: transparent; }
label { display: block; margin: 12px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); }
label input { margin-top: 5px; }
.btn {
  background: rgba(255, 255, 255, .9); color: var(--text); border: 1px solid #d8ebf4;
  border-radius: 14px; padding: 12px 18px; font-size: 16px; font-weight: 700;
}
.btn.primary { background: var(--sunset-grad); color: #fff; border: none; box-shadow: 0 6px 18px rgba(255, 123, 84, .35); }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn:active { transform: scale(.97); }

/* Tab-Bar: schwebende Glas-Leiste */
nav {
  position: fixed; left: 14px; right: 14px;
  bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 10;
  display: flex; background: rgba(255, 255, 255, .78); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border); border-radius: 24px;
  box-shadow: 0 12px 32px rgba(7, 89, 133, .18); overflow: hidden;
}
nav .tab {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 22px; padding: 10px 0 8px;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
}
nav .tab span { font-size: 11px; font-weight: 700; }
nav .tab.active { color: var(--ocean); background: rgba(56, 189, 248, .14); }

/* Overlays & Modals */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 48, 73, .35);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  padding: 16px;
}
.busy-box {
  text-align: center; background: var(--card); backdrop-filter: var(--glass-blur);
  border-radius: 24px; padding: 28px 36px; box-shadow: var(--shadow);
}
.spin { font-size: 56px; animation: wobble 1s ease-in-out infinite; }
@keyframes wobble {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(12deg) translateY(-6px); }
}
.modal {
  background: rgba(255, 255, 255, .93); backdrop-filter: var(--glass-blur);
  border-radius: 26px; padding: 22px;
  width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(7, 89, 133, .3);
}
.modal h2 { margin: 0 0 4px; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 21px; font-weight: 800; }
.modal-btns { display: flex; gap: 10px; margin-top: 18px; }
.modal-btns .btn { flex: 1; }

.item-list { margin: 10px 0; font-size: 14px; }
.item-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid #e8f3f8; }
.item-row.beer { color: var(--amber); font-weight: 700; }

.stepper { display: flex; gap: 8px; margin-top: 5px; }
.stepper button {
  width: 52px; font-size: 24px; border: 1px solid #d8ebf4; border-radius: 14px;
  background: rgba(255, 255, 255, .9); color: var(--ocean); font-weight: 700;
}
.stepper input { text-align: center; font-size: 20px; font-weight: 800; }

/* Metrik-Chips für das Tages-Chart */
.chips { display: flex; gap: 8px; margin-bottom: 10px; }
.chip {
  flex: 1; white-space: nowrap; font-size: 13px; font-weight: 700;
  background: rgba(255, 255, 255, .6); color: var(--muted);
  border: 1px solid var(--card-border); border-radius: 999px; padding: 9px 6px;
}
.chip.active {
  background: var(--ocean); color: #fff; border-color: transparent;
  box-shadow: 0 5px 14px rgba(2, 132, 199, .35);
}

/* Personen-Anteil */
.share-hint {
  background: rgba(56, 189, 248, .16); border-radius: 12px;
  padding: 10px 12px; margin: 10px 0 0; font-size: 14px; font-weight: 700;
  color: var(--ocean);
}

/* Schnell-Bier Größenwahl */
.quick-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.quick-size {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 20px 8px; font-size: 18px; font-weight: 800;
  background: linear-gradient(160deg, #fdf6e3, #fde9c8); border: 1.5px solid #f8ddab;
}
.quick-size .q-emoji { font-size: 38px; }
.quick-size small { color: var(--muted); font-weight: 600; }

#photo-view { max-width: 100%; max-height: 80vh; border-radius: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }

/* Zum-Homescreen-Hinweis */
.a2hs {
  position: fixed; left: 14px; right: 14px;
  bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 9;
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #fff; border-radius: 18px;
  padding: 14px 16px; font-size: 14px; line-height: 1.45;
  box-shadow: 0 14px 34px rgba(2, 132, 199, .45);
  animation: a2hs-in .5s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes a2hs-in {
  from { transform: translateY(28px); opacity: 0; }
}
.a2hs .a2hs-big { font-size: 32px; flex-shrink: 0; }
.a2hs #a2hs-text b:first-child { display: block; font-size: 16px; margin-bottom: 3px; }
.a2hs button {
  background: rgba(255, 255, 255, .2); border: none; border-radius: 50%;
  width: 28px; height: 28px; color: #fff;
  font-size: 14px; padding: 0; flex-shrink: 0;
}
