:root {
  --petrol: #123C45;
  --petrol-soft: #2B5A63;
  --fuel: #F0B429;
  --over: #E4572E;
  --paper: #E8F0EE;
  --line: #C9D8D5;
  --ink: #12282D;
  --muted: #557076;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --level: 0%;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--paper); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 "Golos Text", system-ui, sans-serif;
  padding-bottom: calc(120px + var(--safe-bottom));
}

button, input, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--over); outline-offset: 2px; }

/* The number is drawn twice: the copy over the fuel is clipped to the fuel level */
.tank {
  position: relative;
  height: calc(300px + var(--safe-top));
  overflow: hidden;
  background: var(--petrol);
  color: var(--paper);
  cursor: pointer;
}

.tank-fill {
  position: absolute;
  inset: auto 0 0 0;
  height: var(--level);
  background: var(--fuel);
  transition: height .7s cubic-bezier(.2, .8, .2, 1), background-color .3s;
}

.tank.is-over .tank-fill { background: var(--over); }

.tank-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: calc(16px + var(--safe-top)) 20px 20px;
}

.tank-text-over {
  color: var(--petrol);
  clip-path: inset(calc(100% - var(--level)) 0 0 0);
  transition: clip-path .7s cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}

.tank-day, .tank-cal {
  position: absolute;
  top: calc(6px + var(--safe-top));
  min-height: 48px;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

.tank-day { left: 8px; padding: 0 12px; font-weight: 500; }

.tank-cal {
  right: 8px;
  display: grid;
  place-items: center;
  width: 48px;
  padding: 0;
}

.tank-num {
  font: 700 clamp(64px, 24vw, 104px)/1 "Unbounded", sans-serif;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.tank-sub { font-size: 18px; font-weight: 500; margin-top: 6px; }
.tank-macros { font-size: 15px; margin-top: 2px; }

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.week button {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 72px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.week .bar {
  position: relative;
  width: 14px;
  height: 44px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--line);
}

.week .bar i {
  position: absolute;
  inset: auto 0 0 0;
  background: var(--petrol-soft);
}

.week .is-over .bar i { background: var(--over); }
.week .is-active { color: var(--ink); font-weight: 600; }

.list { padding: 4px 20px; }

.empty { color: var(--muted); padding: 28px 0; }

.row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 14px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  cursor: pointer;
}

.row-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-kcal { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.is-pending { color: var(--muted); cursor: default; }
.row.is-pending .row-name { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .45; } }

.dock {
  position: fixed;
  inset: auto 0 0 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 20px calc(12px + var(--safe-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.side {
  min-height: 48px;
  border: 0;
  background: none;
  font-weight: 500;
  cursor: pointer;
}

.shutter {
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid var(--petrol);
  cursor: pointer;
}

.shutter input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.shutter span { width: 62px; height: 62px; border-radius: 50%; background: var(--fuel); }
.shutter:active span { background: var(--over); }
.shutter:focus-within { outline: 3px solid var(--over); outline-offset: 2px; }

dialog {
  width: min(100% - 32px, 420px);
  max-height: 80dvh;
  border: 0;
  border-radius: 12px;
  padding: 20px;
  background: var(--paper);
  color: var(--ink);
}

dialog::backdrop { background: rgba(18, 60, 69, .6); }
dialog h2 { margin: 0 0 12px; font: 500 20px/1.3 "Golos Text", sans-serif; }
dialog p { margin: 0 0 12px; color: var(--muted); }

.field { display: block; margin-bottom: 12px; font-size: 15px; font-weight: 500; }

.field input, .field textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 11px 12px;
  border: 1px solid var(--muted);
  border-radius: 6px;
  background: #fff;
  font-size: 16px;
  font-weight: 400;
}

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.btn {
  min-height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: none;
  font-weight: 600;
  cursor: pointer;
}

.btn-main { background: var(--petrol); color: var(--paper); }
.btn-danger { color: #B23A17; margin-right: auto; }

.parts { margin: 0 0 12px; padding: 0; list-style: none; }

.parts li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.parts b { font-weight: 600; white-space: nowrap; }
.parts small { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }

.cal-head {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  margin-bottom: 8px;
}

.cal-head h2 { margin: 0; text-align: center; }
.cal-head .btn { padding: 0; font-size: 24px; }
.cal-head .btn:disabled { opacity: .3; cursor: default; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-week { margin-bottom: 4px; color: var(--muted); font-size: 13px; text-align: center; }

.cal-day {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.cal-day:disabled { color: var(--line); cursor: default; }
.cal-day.is-today { font-weight: 600; }
.cal-day.is-active { background: var(--petrol); color: var(--paper); }

.cal-day.has-food::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 16px;
  height: 3px;
  margin-left: -8px;
  border-radius: 2px;
  background: var(--fuel);
}

.cal-day.is-over::after { background: var(--over); }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(118px + var(--safe-bottom));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.toast.is-on { opacity: 1; pointer-events: auto; }

.toast button {
  margin-left: 10px;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--fuel);
  font-weight: 600;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
