/* Luna Feeding Tracker — night kitchen palette.
   Warm near-black ground so package photos carry the colour;
   one cool accent reserved exclusively for medication. */

:root {
  --ground:   #1A1614;
  --surface:  #241F1C;
  --surface-2:#2E2825;
  --line:     #3A322E;
  --text:     #F0EBE4;
  --muted:    #A8998F;
  --faint:    #786A62;

  --food:     #E9A93F;   /* wet food yellow — the primary action colour */
  --med:      #9B8CC7;   /* the only cool hue in the palette */

  --a3:       #7FA86A;   /* ate everything */
  --a2:       #C9B94E;
  --a1:       #D0834A;
  --a0:       #B4514A;   /* refused */

  --radius:   14px;
  --pad:      16px;
  --display:  'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  --body:     'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--food); }

:focus-visible {
  outline: 2px solid var(--food);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------- chrome ---- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--pad) 10px;
  max-width: 620px; margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); }

/* A waxing crescent: Luna. Drawn with two overlapping circles. */
.brand-mark {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--food);
  box-shadow: inset -6px 0 0 0 var(--ground);
  flex: none;
}
.brand-mark--big { width: 44px; height: 44px; box-shadow: inset -13px 0 0 0 var(--ground); }

.brand-name { font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }

.whoami {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--muted); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 11px; border-radius: 999px;
}

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.tabs {
  display: flex; gap: 4px; overflow-x: auto;
  padding: 0 var(--pad) 10px;
  max-width: 620px; margin: 0 auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs a {
  flex: 1 0 auto; text-align: center;
  padding: 8px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 500; text-decoration: none;
  color: var(--muted); background: var(--surface);
  border: 1px solid transparent;
  white-space: nowrap;
}
.tabs a.is-active { color: var(--ground); background: var(--text); font-weight: 600; }

main { max-width: 620px; margin: 0 auto; padding: 4px var(--pad) 64px; }

.flash {
  background: var(--surface-2); border-left: 3px solid var(--food);
  padding: 10px 14px; border-radius: 0 8px 8px 0; margin: 0 0 18px;
  font-size: 14px;
}

/* -------------------------------------------------------------- today ---- */

.today-head { margin: 6px 0 26px; }

.today-head h1 {
  font-family: var(--display); font-weight: 500;
  font-size: 22px; letter-spacing: -0.02em; margin: 0;
}

.today-sum { margin: 2px 0 16px; color: var(--muted); font-size: 15px; }
.today-sum strong { color: var(--text); font-family: var(--display); font-size: 17px; }

/* Signature element: the whole day as one 24-hour track. */
.daybar { margin: 0 0 6px; }

.daybar-track {
  position: relative; height: 34px;
  background: var(--surface); border-radius: 8px;
  overflow: hidden;
}

.daybar-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }

.daybar-mark {
  position: absolute; top: 7px;
  width: 8px; height: 20px; margin-left: -4px;
  border-radius: 3px; background: var(--faint);
}
.daybar-mark.a3 { background: var(--a3); }
.daybar-mark.a2 { background: var(--a2); }
.daybar-mark.a1 { background: var(--a1); }
.daybar-mark.a0 { background: var(--a0); }
.daybar-mark.open { background: transparent; border: 1.5px dashed var(--faint); }
.daybar-mark.is-med {
  top: 0; height: 6px; width: 6px; margin-left: -3px;
  border-radius: 0 0 3px 3px; background: var(--med);
}

.daybar-now {
  position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  background: var(--text); opacity: 0.55;
}

.daybar-scale {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--faint); padding: 3px 0 0;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- blocks --- */

.block { margin: 0 0 30px; }

.block-title {
  font-family: var(--display); font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--faint); margin: 0 0 10px;
}

.page-title { font-family: var(--display); font-size: 26px; letter-spacing: -0.02em; margin: 8px 0 4px; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

.hint { color: var(--faint); font-size: 13px; margin: 10px 0 0; }
.empty { color: var(--muted); font-size: 14px; background: var(--surface); padding: 14px; border-radius: var(--radius); margin: 0; }

/* ---------------------------------------------------------- medication --- */

.med-list { display: flex; flex-direction: column; gap: 8px; }

.med-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--med);
  border-radius: var(--radius); padding: 12px 12px 12px 14px;
}
.med-row.is-due { background: color-mix(in srgb, var(--med) 12%, var(--surface)); }

.med-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.med-name { font-weight: 600; font-size: 15px; }
.med-dose { color: var(--muted); font-weight: 400; }
.med-last { font-size: 12.5px; color: var(--muted); }

.btn-med {
  flex: none; font: inherit; font-weight: 600; font-size: 14px;
  color: var(--ground); background: var(--med);
  border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer;
}
.btn-med:active { transform: scale(0.97); }

.med-today { font-size: 13px; color: var(--muted); margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill { background: var(--surface-2); border-radius: 999px; padding: 3px 9px; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- tiles --- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); gap: 10px; }

.tile-form { display: contents; }

.tile {
  display: flex; flex-direction: column; width: 100%;
  font: inherit; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0; overflow: hidden;
  transition: border-color 0.12s ease, transform 0.08s ease;
}
.tile:active { transform: scale(0.97); }
.tile:hover { border-color: var(--food); }

.tile-photo { display: block; aspect-ratio: 1 / 1; background: var(--surface-2); }
.tile-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.tile-noimg {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-family: var(--display); font-size: 24px; color: var(--faint);
  text-transform: uppercase;
}

.tile-label { display: block; padding: 8px 9px 10px; }
.tile-brand { display: block; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; }
.tile-name { display: block; font-size: 13.5px; font-weight: 500; line-height: 1.25; }

/* ----------------------------------------------------------------- log --- */

.log { display: flex; flex-direction: column; gap: 8px; }

.log-row {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px 12px;
}
.log-row.is-open { border-color: color-mix(in srgb, var(--food) 40%, var(--line)); }
.log-row.is-med { border-left: 3px solid var(--med); }

.log-main { display: flex; align-items: center; gap: 11px; }

.log-time {
  font-family: var(--display); font-size: 16px; font-weight: 700;
  font-variant-numeric: tabular-nums; flex: none; min-width: 44px;
}
.log-time em { display: block; font-style: normal; font-size: 11px; font-weight: 500; color: var(--faint); }

.log-what { flex: 1; min-width: 0; }
.log-name { display: block; font-size: 15px; font-weight: 500; }
.log-meta { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); }

.log-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); font-style: italic; }

.stepper { display: flex; align-items: center; gap: 2px; flex: none; }
.stepper form { display: contents; }
.stepper button {
  font: inherit; font-size: 17px; line-height: 1;
  width: 32px; height: 32px; cursor: pointer;
  color: var(--text); background: var(--surface-2);
  border: 0; border-radius: 8px;
}
.stepper b {
  font-family: var(--display); font-size: 15px;
  min-width: 26px; text-align: center; font-variant-numeric: tabular-nums;
}

.log-accept {
  display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
.log-accept form { display: contents; }
.accept-q { font-size: 12.5px; color: var(--faint); margin-right: 3px; }

.chip {
  font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
  padding: 6px 11px; border-radius: 999px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line);
}
.chip.is-on { color: var(--ground); font-weight: 600; border-color: transparent; }
.chip.a3.is-on { background: var(--a3); }
.chip.a2.is-on { background: var(--a2); }
.chip.a1.is-on { background: var(--a1); }
.chip.a0.is-on { background: var(--a0); }

.log-del { margin-left: auto; }
.log-del button {
  font: inherit; font-size: 12px; cursor: pointer;
  background: none; border: 0; color: var(--faint); padding: 6px 2px;
  text-decoration: underline; text-underline-offset: 2px;
}

.acc-badge {
  flex: none; font-size: 11.5px; font-weight: 600;
  padding: 4px 9px; border-radius: 999px; color: var(--ground);
}
.acc-badge.a3 { background: var(--a3); }
.acc-badge.a2 { background: var(--a2); }
.acc-badge.a1 { background: var(--a1); }
.acc-badge.a0 { background: var(--a0); }
.acc-badge.open { background: transparent; color: var(--faint); border: 1px dashed var(--line); }

/* --------------------------------------------------------------- forms --- */

.editor { margin: 0 0 16px; }
.editor summary { list-style: none; cursor: pointer; display: inline-block; }
.editor summary::-webkit-details-marker { display: none; }
.editor--inline { margin: 8px 0 0; }

.btn-add {
  font-size: 14px; font-weight: 600; color: var(--food);
  border: 1px dashed color-mix(in srgb, var(--food) 45%, var(--line));
  border-radius: var(--radius); padding: 10px 16px;
}

.btn-small {
  font: inherit; font-size: 13px; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 13px; text-decoration: none; display: inline-block;
}
.btn-danger { color: var(--a0); }

.btn-primary {
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--food); color: var(--ground);
  border: 0; border-radius: 10px; padding: 12px 20px; width: 100%;
}
.btn-primary:active { transform: scale(0.99); }

.form {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 10px 0 0;
  display: flex; flex-direction: column; gap: 12px;
}
.form--row { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.form-title { font-family: var(--display); font-size: 15px; margin: 0; }
.form-pair { display: grid; gap: 12px; }
.form-actions { display: flex; gap: 8px; }

.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--muted); }
.field > span i { color: var(--food); font-style: normal; }
.field--color { flex: 0 0 70px; }

.field input, .field select {
  font: inherit; font-size: 16px; /* 16px keeps iOS from zooming on focus */
  color: var(--text); background: var(--ground);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 11px; width: 100%;
}
.field input[type="color"] { padding: 4px; height: 42px; }
.field input[type="file"] { font-size: 14px; padding: 9px; }
.field-row { display: flex; gap: 10px; }

/* --------------------------------------------------------------- cards --- */

.cards { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
}
.card.is-archived { opacity: 0.55; }

.card-head { display: flex; gap: 12px; }
.card-photo { flex: none; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-text { min-width: 0; }
.card-text h3 { font-family: var(--display); font-size: 16px; font-weight: 500; margin: 0; }
.card-brand { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; }
.card-meta { font-size: 12.5px; color: var(--muted); margin: 3px 0 0; }
.card-note { font-size: 13px; color: var(--muted); font-style: italic; margin: 5px 0 0; }

.card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-top: 10px; }

.archive { margin-top: 22px; }
.archive summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 8px 0; }

/* ------------------------------------------------------------- verlauf --- */

.day { margin: 0 0 26px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 8px; }
.day-head h2 { font-family: var(--display); font-size: 17px; font-weight: 700; margin: 0; }
.day-sum { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.day .daybar { margin-bottom: 10px; }

.more { display: flex; gap: 8px; justify-content: center; margin: 26px 0 0; }
.more a {
  font-size: 13px; text-decoration: none; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px;
}
.more a.is-active { color: var(--ground); background: var(--text); }

/* ----------------------------------------------------------- statistik --- */

.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rank-row { display: flex; gap: 12px; align-items: flex-start; }
.rank-photo { flex: none; width: 52px; height: 52px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.rank-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rank-body { flex: 1; min-width: 0; }
.rank-name { display: block; font-size: 14.5px; font-weight: 500; }
.rank-name em { font-style: normal; color: var(--faint); }
.rank-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.rank-meta strong { color: var(--text); font-family: var(--display); }
.warn { color: var(--a1); }
.tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }

.bar { display: block; height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 6px 0 0; }
.bar-fill { display: block; height: 100%; background: var(--food); border-radius: 4px; }
.bar-fill.is-thin { background: repeating-linear-gradient(90deg, var(--food) 0 4px, transparent 4px 8px); }

.trend { display: inline-flex; gap: 3px; margin-top: 6px; }
.trend i { width: 9px; height: 9px; border-radius: 2px; display: block; background: var(--faint); }
.trend i.a3 { background: var(--a3); }
.trend i.a2 { background: var(--a2); }
.trend i.a1 { background: var(--a1); }
.trend i.a0 { background: var(--a0); }

.daychart, .hourchart {
  display: flex; align-items: flex-end; gap: 3px;
  height: 130px; background: var(--surface);
  border-radius: var(--radius); padding: 12px 10px 6px;
}
.daychart-col, .hourchart-col {
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; height: 100%; gap: 3px;
}
.daychart-bar, .hourchart-bar {
  width: 100%; max-width: 18px; background: var(--food);
  border-radius: 3px 3px 0 0; min-height: 2px;
}
.hourchart-bar { background: color-mix(in srgb, var(--food) 38%, var(--surface-2)); }
.daychart-med { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.daychart-med.is-on { background: var(--med); }
.daychart-lbl, .hourchart-lbl {
  font-size: 9.5px; color: var(--faint); font-variant-numeric: tabular-nums; height: 12px;
}

.split { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.split li { display: flex; align-items: center; gap: 10px; }
.split-name { display: flex; align-items: center; gap: 6px; font-size: 14px; flex: 0 0 110px; }
.split .bar { flex: 1; margin: 0; }
.split-n { font-family: var(--display); font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- login --- */

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100dvh; }

.login { width: 100%; max-width: 340px; padding: 24px; text-align: center; }
.login h1 { font-family: var(--display); font-size: 30px; letter-spacing: -0.02em; margin: 14px 0 0; }
.login-sub { color: var(--muted); font-size: 14px; margin: 2px 0 26px; }
.login form { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.login .field input { text-align: left; }
.login-note { font-size: 12px; color: var(--faint); text-align: center; margin: 0; }

.who { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.who legend { font-size: 12.5px; color: var(--muted); padding: 0 0 8px; }
.who label { display: block; }
.who input { position: absolute; opacity: 0; pointer-events: none; }
.who span {
  display: block; padding: 12px 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 500; cursor: pointer;
}
.who input:checked + span {
  border-color: var(--who); background: color-mix(in srgb, var(--who) 18%, var(--surface));
}
.who input:focus-visible + span { outline: 2px solid var(--food); outline-offset: 2px; }

.error { color: var(--a0); font-size: 13.5px; margin: 0; }

/* ------------------------------------------------------------ niceties --- */

@media (min-width: 560px) {
  .form-pair { grid-template-columns: 1fr 1fr; align-items: start; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .tile:active, .btn-med:active, .btn-primary:active { transform: none; }
}
