:root {
  --bg: #ffffff;
  --text: #17191c;
  --muted: #777c82;
  --line: #e0e3e7;
  --card: #eef6ff;
  --card-2: #ffffff;
  --green: #e4fae8;
  --yellow: #f2c84b;
  --blue: #789bb9;
  --blue-soft: #d7e7f7;
  --pink: #d9438c;
  --shadow: 0 6px 20px rgba(20, 30, 40, .055);
  --radius: 14px;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.app {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
  padding-bottom: 132px;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  padding: 6px 18px 1px;
}

.icon-btn {
  font-size: 23px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 12px;
}

.date-title {
  justify-self: start;
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chev {
  font-size: 15px;
}

.top-spacer {
  width: 32px;
  height: 32px;
}

.week-strip-wrap {
  padding: 0 0 5px;
  overflow: hidden;
}

.week-strip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0 18px 2px;
  scrollbar-width: none;
}

.week-strip::-webkit-scrollbar {
  display: none;
}

.day-pill {
  flex: 0 0 50px;
  scroll-snap-align: center;
  border-radius: 13px;
  padding: 4px 0 5px;
  min-height: 43px;
  display: grid;
  place-items: center;
  gap: 0;
  color: #2f3337;
  background: transparent;
  border: 2px solid transparent;
  position: relative;
}

.day-pill.has-entry {
  background: var(--green);
}

.day-pill.active {
  border-color: var(--yellow);
  background: #fffdf2;
}

.day-pill.active.has-entry {
  background: var(--green);
}

.day-pill .weekday {
  font-size: 12px;
}

.day-pill .daynum {
  font-size: 17px;
  line-height: 1;
}

.content {
  padding: 0 18px 14px;
}

.summary-carousel {
  overflow: hidden;
  touch-action: pan-y;
}

.summary-track {
  display: flex;
  width: 200%;
  transition: transform .22s ease;
  will-change: transform;
}

.summary-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 9px 11px 9px;
  box-shadow: var(--shadow);
  min-height: 102px;
}

.summary-panel {
  width: 50%;
  flex: 0 0 50%;
}

.summary-card h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.macro-title {
  display: flex;
  align-items: center;
  gap: 7px;
}

.macro-logo {
  color: var(--pink);
  font-size: 22px;
  line-height: .8;
}

.progress {
  border-radius: 100px;
  background: var(--blue-soft);
  overflow: hidden;
}

.big-progress {
  height: 5px;
  margin: 9px 0 8px;
}

.small-progress {
  height: 5px;
  margin: 7px 0 6px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--blue);
  transition: width .2s ease;
}

.kcal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.kcal-grid span,
.macro-item span {
  display: block;
  font-size: 12px;
  color: #25292d;
}

.kcal-grid strong {
  display: block;
  margin-top: 1px;
  font-size: 18px;
  line-height: 1.05;
}

.macro-bars {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 17px;
}

.macro-item {
  min-width: 0;
}

.macro-item strong {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-size: clamp(13px, 3.8vw, 17px);
  line-height: 1.05;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: -.2px;
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 6px 0 4px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: #dfe8ef;
  padding: 0;
  transition: width .2s ease, background .2s ease;
}

.dot.active {
  width: 25px;
  background: var(--blue);
}

.entries-shell {
  position: relative;
  overflow: hidden;
  min-height: calc(100dvh - 292px);
  padding-bottom: 18px;
  touch-action: pan-y;
}

.entries {
  display: grid;
  gap: 11px;
  margin-top: 7px;
  min-height: calc(100dvh - 292px);
  will-change: transform;
}

.entries.animated {
  transition: transform .22s ease;
}

.entries-ghost {
  position: absolute;
  top: 0;
  width: 100%;
  min-height: calc(100dvh - 292px);
  will-change: transform;
  pointer-events: none;
}

.empty {
  margin-top: 42px;
  text-align: center;
  color: var(--muted);
  line-height: 1.45;
  font-size: 15px;
}

.entry-card {
  background: var(--card-2);
  border: 1px solid #d9dde2;
  border-radius: var(--radius);
  padding: 9px;
  box-shadow: var(--shadow);
}

.entry-card:active {
  transform: scale(.995);
}

.entry-main {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: start;
}

.entry-image,
.entry-placeholder {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  object-fit: cover;
  background: #eef2f5;
  display: grid;
  place-items: center;
  font-size: 21px;
}

.entry-title {
  margin: 1px 0 6px;
  font-size: 16px;
  line-height: 1.18;
  font-weight: 500;
}

.entry-type {
  display: inline-flex;
  border-radius: 999px;
  background: #f2f5f8;
  color: #55616d;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 700;
}

.nutrition-row {
  border-top: 1px solid var(--line);
  margin-top: 9px;
  padding-top: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.metric span {
  display: block;
  color: #222;
  font-size: 11px;
}

.metric strong {
  display: block;
  font-size: 14px;
}

.mini-bar {
  width: 100%;
  height: 4px;
  background: var(--blue-soft);
  border-radius: 50px;
  margin-top: 4px;
  overflow: hidden;
}

.mini-bar > i {
  display: block;
  height: 100%;
  background: var(--blue);
  width: 0%;
}

.entry-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #30343a;
  margin-top: 8px;
  font-size: 13px;
}

.entry-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.edit-btn,
.delete-btn {
  font-size: 17px;
  padding: 4px;
  border-radius: 10px;
}

.delete-btn {
  color: #a54040;
}

.composer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 520px);
  z-index: 10;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  padding: 8px 18px calc(12px + env(safe-area-inset-bottom));
}

.limit-line {
  color: #9a9da1;
  font-size: 14px;
  margin-bottom: 7px;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 40px 42px;
  align-items: end;
  gap: 6px;
}

textarea {
  width: 100%;
  min-height: 76px;
  max-height: 140px;
  resize: none;
  border: 0;
  outline: 0;
  border-radius: 24px;
  background: #f0f0f1;
  padding: 12px 15px;
  font-size: 17px;
  line-height: 1.3;
}

.media-btn,
.send-btn {
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
}

.media-btn svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #3b4148;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send-btn {
  background: #1e75ad;
  color: white;
  font-size: 20px;
}

.icon-btn:active,
.media-btn:active,
.send-btn:active,
.drawer-item:active {
  transform: scale(.96);
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, .28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.drawer.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  width: min(82vw, 330px);
  height: 100%;
  background: white;
  box-shadow: 15px 0 50px rgba(0,0,0,.2);
  transform: translateX(-105%);
  transition: transform .24s ease;
  padding: 18px;
}

.drawer.open .drawer-panel {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  font-size: 21px;
}

.drawer-head button {
  font-size: 31px;
}

.drawer-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 14px;
  background: #f5f7f9;
  text-align: left;
  font-weight: 700;
}

.detail-dialog {
  width: min(calc(100vw - 24px), 500px);
  border: 0;
  padding: 0;
  background: transparent;
}

.detail-dialog::backdrop {
  background: rgba(0, 0, 0, .35);
}

.dialog-card {
  background: white;
  border-radius: 22px;
  padding: 18px;
  max-height: 86dvh;
  overflow: auto;
  box-shadow: 0 20px 70px rgba(0,0,0,.2);
}

.close-btn {
  float: right;
  font-size: 30px;
  line-height: 1;
  padding: 0 3px 8px 10px;
}

.detail-title {
  margin: 0 32px 12px 0;
  font-size: 22px;
  line-height: 1.15;
}

.analysis-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px;
  margin-top: 13px;
}

.analysis-box h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #333;
}

.analysis-box p {
  margin: 0;
  font-size: 16px;
  line-height: 1.42;
}

.nutrition-list {
  margin-top: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.nutrition-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}

.nutrition-list div:last-child {
  border-bottom: 0;
}

.setting-label {
  display: grid;
  gap: 7px;
  margin: 14px 0;
  font-weight: 700;
}

.setting-label input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  font-size: 17px;
}

.primary-btn {
  width: 100%;
  border-radius: 16px;
  background: #1e75ad;
  color: white;
  padding: 13px;
  font-weight: 800;
  margin-top: 8px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.calendar-head {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.calendar-head h2 {
  margin: 0;
  text-align: center;
  font-size: 20px;
}

.calendar-head button {
  font-size: 30px;
  border-radius: 12px;
  background: #f3f5f7;
  height: 40px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
}

.calendar-weekdays {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-bottom: 7px;
}

.calendar-day {
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  border: 2px solid transparent;
  background: #f5f7f9;
  position: relative;
}

.calendar-day.other-month {
  opacity: .35;
}

.calendar-day.has-entry {
  background: var(--green);
}

.calendar-day.selected {
  border-color: var(--yellow);
  background: #fffdf2;
}

.calendar-day.selected.has-entry {
  background: var(--green);
}

@media (orientation: landscape) and (max-height: 520px) {
  body::before {
    content: "Bitte Hochformat nutzen";
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    background: white;
    color: #17191c;
    font-size: 24px;
    font-weight: 800;
  }
}

@media (max-width: 390px) {
  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .week-strip {
    padding-left: 12px;
    padding-right: 12px;
  }

  .content,
  .composer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .macro-bars {
    gap: 6px;
  }

  .macro-item strong {
    font-size: clamp(12px, 3.7vw, 15px);
  }

  .entries-shell,
  .entries,
  .entries-ghost {
    min-height: calc(100dvh - 286px);
  }

  textarea {
    font-size: 16px;
  }
}
