/* ====== Wasser-Wecker — Aqua/Cyan Theme ====== */
:root {
  --c-primary: #0891b2;
  --c-primary-strong: #0e7490;
  --c-primary-soft: #67e8f9;
  --c-accent: #22d3ee;

  --bg: #ecfeff;
  --bg-grad-a: #ecfeff;
  --bg-grad-b: #cffafe;
  --surface: #ffffff;
  --surface-2: #f0fdff;
  --border: #b9e8f2;
  --text: #083344;
  --text-soft: #2c6b7c;
  --text-faint: #5b97a7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --good: #059669;

  --shadow: 0 6px 22px rgba(8, 145, 178, 0.14);
  --shadow-sm: 0 2px 8px rgba(8, 145, 178, 0.12);
  --radius: 20px;
  --radius-sm: 12px;
  --focus: #0369a1;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

[data-theme="dark"] {
  --bg: #042530;
  --bg-grad-a: #042530;
  --bg-grad-b: #06303d;
  --surface: #0a3a49;
  --surface-2: #0d4456;
  --border: #155e75;
  --text: #e6fbff;
  --text-soft: #a8dbe8;
  --text-faint: #7bb4c4;
  --danger: #f87171;
  --danger-soft: #4c1d1d;
  --good: #34d399;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --focus: #67e8f9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(140% 90% at 50% -10%, var(--bg-grad-b) 0%, var(--bg-grad-a) 60%) fixed;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  line-height: 1.45;
  padding:
    var(--safe-top)
    var(--safe-right)
    var(--safe-bottom)
    var(--safe-left);
}

.visually-hidden {
  position: absolute !important;
  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: 8px; top: -48px;
  background: var(--c-primary);
  color: #fff;
  padding: 10px 14px;
  border-radius: 0 0 10px 10px;
  z-index: 100;
  transition: top .2s ease;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ====== Header ====== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 8px;
  max-width: 560px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 {
  font-size: 1.3rem;
  margin: 0;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-drop {
  display: inline-flex;
  color: var(--c-primary);
  filter: drop-shadow(0 2px 4px rgba(8,145,178,.3));
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

/* ====== Layout ====== */
.app-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 20px;
}
.card-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  color: var(--text-soft);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 700;
}

/* ====== Wasserstand-Karte ====== */
.water-card { text-align: center; }

.gauge-wrap {
  position: relative;
  width: 200px;
  max-width: 70vw;
  margin: 4px auto 10px;
}
.gauge { width: 100%; height: auto; display: block; }

.drop-bg { fill: var(--surface-2); }
.drop-frame {
  fill: none;
  stroke: var(--c-primary);
  stroke-width: 4;
  opacity: 0.85;
}

.water-layer {
  /* translateY animiert von 240 (leer) bis 0 (voll) via JS-Var */
  transform: translateY(var(--water-offset, 240px));
  transition: transform 0.9s cubic-bezier(.22,.61,.36,1);
  will-change: transform;
}

.wave {
  animation: waveMove 3.2s linear infinite;
}
.wave-2 { animation-duration: 4.6s; animation-direction: reverse; }

@keyframes waveMove {
  from { transform: translateX(0); }
  to   { transform: translateX(200px); }
}

.gauge-readout {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.pct {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text);
  text-shadow: 0 1px 6px rgba(255,255,255,.65);
  letter-spacing: -0.03em;
}
[data-theme="dark"] .pct { text-shadow: 0 1px 8px rgba(0,0,0,.55); }

.amount-line {
  font-size: 1.15rem;
  margin: 6px 0 2px;
  color: var(--text);
}
.amount-line strong { color: var(--c-primary-strong); }
[data-theme="dark"] .amount-line strong { color: var(--c-accent); }

.remain-line {
  margin: 0 0 16px;
  color: var(--text-faint);
  font-size: 0.95rem;
}
.remain-line.done { color: var(--good); font-weight: 700; }

/* ====== Buttons ====== */
.big-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--c-accent), var(--c-primary) 60%, var(--c-primary-strong));
  color: #fff;
  border-radius: 999px;
  padding: 16px 30px;
  font-size: 1.2rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(8,145,178,.38);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
  max-width: 100%;
}
.big-btn:hover { filter: brightness(1.05); }
.big-btn:active { transform: translateY(2px) scale(.99); box-shadow: 0 4px 12px rgba(8,145,178,.34); }
.big-btn.small { padding: 12px 22px; font-size: 1rem; }
.big-btn-plus {
  font-size: 1.5rem;
  line-height: 1;
  background: rgba(255,255,255,.22);
  border-radius: 50%;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
}
.big-btn-text { letter-spacing: -0.01em; }
.big-btn-hint {
  font-size: .8rem;
  font-weight: 600;
  opacity: .85;
  background: rgba(255,255,255,.18);
  padding: 3px 9px;
  border-radius: 999px;
}
.big-btn.pop { animation: pop .4s ease; }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.action-row { margin: 4px 0 14px; }

.secondary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.ghost-btn {
  appearance: none;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: .9rem;
  font-weight: 600;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.ghost-btn:hover:not(:disabled) { background: var(--c-primary-soft); color: var(--text); }
.ghost-btn:active:not(:disabled) { transform: translateY(1px); }
.ghost-btn:disabled { opacity: .45; cursor: default; }
.ghost-btn.danger { color: var(--danger); border-color: var(--danger); }
.ghost-btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }

.danger-btn {
  background: linear-gradient(135deg, #f87171, var(--danger));
  box-shadow: 0 8px 20px rgba(220,38,38,.34);
}

/* ====== Form-Felder ====== */
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}
.field-row + .field-row { border-top: 1px dashed var(--border); }
.field-row label, .switch-label {
  font-weight: 600;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
}

input[type="number"], select {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 130px;
  max-width: 45%;
  text-align: right;
}
select { text-align: left; width: 150px; }

input[type="number"]:focus, select:focus,
.big-btn:focus-visible, .ghost-btn:focus-visible,
.icon-btn:focus-visible, .chip:focus-visible,
.switch:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chip {
  appearance: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: .9rem;
  transition: all .15s ease;
}
.chip:hover { background: var(--c-primary-soft); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
}

/* ====== Switch ====== */
.switch {
  position: relative;
  width: 54px; height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .2s ease;
  padding: 0;
}
.switch-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform .2s ease, background .2s ease;
}
.switch[aria-checked="true"] { background: var(--c-primary); border-color: var(--c-primary); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(24px); background: #fff; }

/* ====== Hinweise ====== */
.hint { color: var(--text-faint); font-size: .9rem; margin: 10px 0 0; }
.note {
  margin: 12px 0 0;
  font-size: .82rem;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.4;
}
.note strong { color: var(--text-soft); }

/* ====== Historie ====== */
.history-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  height: 130px;
  padding-top: 6px;
}
.hbar {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.hbar-track {
  width: 100%;
  max-width: 34px;
  height: 92px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.hbar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--c-accent), var(--c-primary));
  border-radius: 0 0 7px 7px;
  transition: height .6s ease;
  min-height: 2px;
}
.hbar-fill.reached { background: linear-gradient(180deg, #34d399, var(--good)); }
.hbar-day { font-size: .72rem; color: var(--text-faint); font-weight: 700; }
.hbar-val { font-size: .68rem; color: var(--text-faint); }
.hbar.today .hbar-day { color: var(--c-primary-strong); }
[data-theme="dark"] .hbar.today .hbar-day { color: var(--c-accent); }

/* ====== Footer ====== */
.app-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: .8rem;
  padding: 8px 4px 0;
}
.app-footer p { margin: 0; }

/* ====== Modals ====== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 37, 48, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fadeIn .18s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  width: 100%;
  max-width: 360px;
  animation: slideUp .22s ease;
}
.modal-title { margin: 0 0 8px; font-size: 1.2rem; }
.modal-text, .modal-label { color: var(--text-soft); margin: 0 0 14px; font-size: .95rem; display: block; }
.modal input[type="number"] {
  width: 100%;
  max-width: 100%;
  text-align: left;
  font-size: 1.1rem;
  margin-bottom: 18px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* ====== Toasts ====== */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 5px solid var(--c-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 13px 16px;
  font-size: .95rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn .3s ease;
  pointer-events: auto;
}
.toast.reminder { border-left-color: var(--c-accent); }
.toast.success { border-left-color: var(--good); }
.toast .toast-emoji { font-size: 1.2rem; flex: 0 0 auto; }
.toast.leaving { animation: toastOut .3s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(16px); } }

/* ====== Responsive ====== */
@media (max-width: 360px) {
  .brand h1 { font-size: 1.15rem; }
  .big-btn { padding: 14px 22px; font-size: 1.1rem; }
  input[type="number"], select { width: 110px; }
}

/* ====== Reduced Motion ====== */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
  .water-layer { transition: transform 0.2s linear; }
  .wave { animation: none !important; }
  .modal, .modal-overlay, .toast { animation: none !important; }
  .big-btn.pop { animation: none !important; }
}
