@import url("fonts.css");

:root {
  --cream: #fff6ec;
  --paper: #fffdf9;
  --ink: #4b3a33;
  --ink-soft: #7c675d;
  --muted: #a99389;
  --line: #f1dfd3;
  --peach: #f6b094;
  --peach-deep: #de7a57;
  --rose: #f8cfd6;
  --rose-deep: #d9798c;
  --sage: #bddcc8;
  --sage-deep: #5f9c7b;
  --sky: #d5e6f0;
  --butter: #fbe7a9;
  --radius: 26px;
  --shadow: 0 8px 24px rgba(120, 80, 60, 0.08);
  --tabs-h: 72px;
}

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

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 17px;
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 12px 12px, rgba(249, 196, 180, 0.35) 2.5px, transparent 3px),
    radial-gradient(circle at 46px 40px, rgba(189, 220, 200, 0.35) 2px, transparent 2.5px);
  background-size: 68px 68px, 68px 68px;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  overscroll-behavior-y: contain;
}

h1, h2, .big, .num, .tab, .tile, .btn {
  font-family: "Fredoka", "Nunito", sans-serif;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }

/* Kopf */
header.top {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 4px;
}
header.top h1 {
  margin: 0;
  font-size: 34px; font-weight: 600; letter-spacing: 0.5px;
  color: var(--peach-deep);
}
header.top svg { width: 30px; height: 30px; }

main { padding: 8px 16px 24px; max-width: 560px; margin: 0 auto; }
section[hidden] { display: none; }

/* Karten */
.card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

/* Hero */
.hero { text-align: center; padding: 22px 16px 16px; position: relative; overflow: hidden; }
.hero .big {
  font-size: 52px; font-weight: 600; line-height: 1; color: var(--ink);
}
.hero .big small { font-size: 26px; font-weight: 500; color: var(--ink-soft); margin-left: 4px; }
.hero .when { color: var(--muted); margin-top: 6px; font-weight: 700; }
.hero .empty { color: var(--muted); font-weight: 700; padding: 10px 0; }
.deltas { display: flex; gap: 8px; margin-top: 18px; }
.delta {
  flex: 1; border-radius: 18px; padding: 10px 6px;
  background: var(--cream);
}
.delta span { display: block; font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: 0.3px; }
.delta b { display: block; font-family: "Fredoka", sans-serif; font-size: 22px; font-weight: 500; margin-top: 2px; }
.delta.up b { color: var(--sage-deep); }
.delta.down b { color: var(--rose-deep); }
.delta.none b { color: var(--muted); }

/* Diagramm */
.chart { padding: 12px 8px 6px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 12px; font-weight: 700; font-family: "Nunito", sans-serif; }
.chart .area { fill: url(#areaFill); }
.chart .line { fill: none; stroke: var(--peach-deep); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--paper); stroke: var(--peach-deep); stroke-width: 2.5; }
.chart .cursor line { stroke: var(--peach); stroke-width: 1.5; stroke-dasharray: 3 4; }
.chart .cursor circle { fill: var(--peach-deep); stroke: var(--paper); stroke-width: 3; }
.chart .tip { pointer-events: none; }
.chart .tip rect { fill: var(--ink); rx: 10; }
.chart .tip text { fill: #fff; font-size: 13px; font-weight: 700; font-family: "Nunito", sans-serif; }
.chart .empty { color: var(--muted); text-align: center; padding: 60px 0; font-weight: 700; }

/* Eingabe */
.entry { display: grid; grid-template-columns: 1fr; gap: 10px; }
.entry .field { position: relative; }
.entry input, .sheet input[type="number"], .sheet input[type="datetime-local"], .sheet input[type="text"] {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--cream);
  border-radius: 16px;
  padding: 14px 14px;
  font-size: 18px; font-weight: 700;
  color: var(--ink);
  outline: none;
  min-height: 54px;
}
.entry input:focus, .sheet input:focus { border-color: var(--peach); }
.entry input[type="number"] { font-family: "Fredoka", sans-serif; font-size: 22px; font-weight: 500; padding-right: 42px; }
.entry .unit {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-weight: 800;
}
.entry input { min-width: 0; }

.btn {
  display: block; width: 100%;
  border-radius: 18px; padding: 15px;
  font-size: 19px; font-weight: 500;
  background: var(--peach); color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,0.08);
  box-shadow: 0 4px 0 #e39a7c;
  transition: transform .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #e39a7c; }
.btn.quiet { background: var(--cream); color: var(--ink-soft); box-shadow: 0 4px 0 var(--line); }
.btn.quiet:active { box-shadow: 0 1px 0 var(--line); }
.btn.danger { background: var(--rose); color: #8a3b4b; box-shadow: 0 4px 0 #e5b2bb; }
.btn.danger:active { box-shadow: 0 1px 0 #e5b2bb; }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list li.day {
  font-weight: 800; color: var(--muted); font-size: 14px;
  padding: 14px 8px 6px; letter-spacing: 0.4px; text-transform: uppercase;
}
.list li.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--paper); border: 1.5px solid var(--line);
  border-radius: 20px; padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer;
}
.list li.row:active { background: var(--cream); }
.list .ico {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center; font-size: 22px;
  background: var(--cream);
}
.list .txt { flex: 1; min-width: 0; }
.list .txt b { display: block; font-weight: 800; }
.list .txt span { color: var(--muted); font-size: 14px; font-weight: 700; }
.list .num { font-size: 22px; font-weight: 500; }
.list .time { font-weight: 800; color: var(--ink-soft); }
.list .diff { font-size: 13px; font-weight: 800; color: var(--muted); display: block; text-align: right; }
.list .diff.up { color: var(--sage-deep); }
.list .diff.down { color: var(--rose-deep); }

/* Ereignis-Kacheln */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 12px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--paper); border: 1.5px solid var(--line);
  border-radius: 24px; padding: 16px 8px 14px; min-height: 104px;
  box-shadow: var(--shadow);
  font-size: 16px; font-weight: 500; color: var(--ink);
  transition: transform .08s;
}
.tile:active { transform: scale(0.96); background: var(--cream); }
.tile .emo {
  font-size: 34px; line-height: 1;
}
.tile.more { background: transparent; border-style: dashed; box-shadow: none; color: var(--muted); }
.tile.more .emo { color: var(--peach-deep); font-size: 36px; }

/* Tabs */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 249, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1.5px solid var(--line);
}
nav.tabs .inner {
  max-width: 560px; margin: 0 auto; height: 100%;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  background: var(--cream); border-radius: 20px; padding: 5px;
}
.tab {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 16px; font-size: 18px; font-weight: 500; color: var(--muted);
}
.tab svg { width: 22px; height: 22px; }
.tab.on { background: var(--paper); color: var(--peach-deep); box-shadow: 0 2px 8px rgba(120,80,60,0.1); }

/* Bottom-Sheet */
dialog.sheet {
  border: 0; padding: 0; margin: 0;
  width: 100%; max-width: 560px;
  position: fixed; left: 50%; bottom: 0; top: auto; transform: translateX(-50%);
  background: var(--paper);
  border-radius: 30px 30px 0 0;
  box-shadow: 0 -10px 40px rgba(80, 50, 40, 0.18);
  color: var(--ink);
  max-height: 88vh; overflow: auto;
}
dialog.sheet::backdrop { background: rgba(75, 58, 51, 0.35); }
.sheet .in { padding: 12px 20px calc(22px + env(safe-area-inset-bottom)); }
.sheet .grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 {
  margin: 0 0 16px; font-size: 26px; font-weight: 500; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.sheet h2 .emo { font-size: 30px; }
.sheet .stack { display: grid; gap: 10px; }
.sheet .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet input[type="number"] { font-family: "Fredoka", sans-serif; font-size: 22px; font-weight: 500; }

/* Typen verwalten */
.types { list-style: none; margin: 0 0 14px; padding: 0; }
.types li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 6px; border-bottom: 1.5px solid var(--line);
}
.types li .emo { font-size: 26px; width: 36px; text-align: center; }
.types li .name { flex: 1; font-weight: 800; }
.types li button.x {
  width: 40px; height: 40px; border-radius: 14px; background: var(--cream);
  color: var(--rose-deep); font-size: 20px; font-weight: 800;
}
.types li button.x.sure { background: var(--rose); color: #8a3b4b; }
.emojis { display: flex; flex-wrap: wrap; gap: 6px; }
.emojis button {
  width: 46px; height: 46px; border-radius: 14px; font-size: 24px;
  background: var(--cream); border: 2px solid transparent;
}
.emojis button.on { border-color: var(--peach-deep); background: #fdebe2; }

/* Login */
body.login { display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 30px 24px 26px; }
.login-card h1 { margin: 8px 0 22px; font-size: 44px; font-weight: 600; color: var(--peach-deep); }
.login-card .logo { width: 84px; height: 84px; }
.login-card .stack { display: grid; gap: 10px; }
.login-card input {
  width: 100%; border: 1.5px solid var(--line); background: var(--cream);
  border-radius: 16px; padding: 14px; font-size: 18px; font-weight: 700; outline: none;
}
.login-card input:focus { border-color: var(--peach); }
.login-card .err { color: var(--rose-deep); font-weight: 800; min-height: 24px; margin-top: 10px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; font-weight: 800;
  padding: 12px 20px; border-radius: 18px; opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 9; white-space: nowrap;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
