/* ------------------------------------------------------------------ *
 * Sample Log — clinical strip-chart aesthetic
 * Palette:  paper #ECEDE7 · ink #23302E · teal #2C6E6A · ochre #C68A2E
 * ------------------------------------------------------------------ */
:root {
  --paper:  #ECEDE7;
  --surface:#FBFBF8;
  --ink:    #23302E;
  --ink-soft:#5A6763;
  --teal:   #2C6E6A;
  --teal-dk:#1F514E;
  --ochre:  #C68A2E;
  --rule:   #CBCEC4;
  --rule-soft:#DFE1D9;
  --danger: #9B3B34;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(35,48,46,.06), 0 8px 24px rgba(35,48,46,.06);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace; }

a { color: var(--teal-dk); }

.wrap { max-width: 90vw; margin: 0 auto; padding: 0 20px 72px; }

/* ---- masthead --------------------------------------------------- */
.masthead {
  border-bottom: 2px solid var(--ink);
  padding: 28px 0 18px;
  margin-bottom: 26px;
}
.masthead .eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--teal);
  margin: 0 0 6px;
}
.masthead h1 {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(26px, 6vw, 38px);
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.04;
}
.masthead p { margin: 8px 0 0; color: var(--ink-soft); max-width: 46ch; }

/* ---- generic card ----------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 20px; }
.card.bottom-links {
  border: none; box-shadow: none; background: none;
  border-top: 2px solid var(--ink); border-radius: 0;
  margin-top: 12px; padding: 16px 0 0;
}

.section-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 14px;
  display: flex; align-items: baseline; gap: 10px;
}
.section-label::after {
  content: ""; flex: 1; height: 1px; background: var(--rule-soft);
}

/* ---- upload row ------------------------------------------------- */
.upload-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.file-field {
  flex: 1 1 auto; min-width: 200px;
  border: 1.5px dashed var(--rule); border-radius: var(--radius);
  padding: 14px 16px; background: #fff;
  color: var(--ink-soft);
}
.file-field input { width: 100%; }
.no-photo-row { margin-top: 10px; }
.no-photo-row .btn { width: 100%; text-align: center; }
.probe-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.probe-actions form { flex: 1 1 0; }
.probe-actions .btn { width: 100%; text-align: center; }
.plans-link {
  margin-top: 12px; font-size: 14px;
}
.plans-link a { font-weight: 600; }

.btn {
  font: inherit; font-weight: 600;
  border: none; border-radius: var(--radius);
  padding: 13px 22px; cursor: pointer;
  background: var(--teal); color: #fff;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--teal-dk); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: transparent; color: var(--teal-dk); border: 1.5px solid var(--rule); }
.btn.secondary:hover { background: #fff; border-color: var(--teal); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid #E4C9C6; }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(44,110,106,.4); outline-offset: 2px;
}

/* ---- share chip ------------------------------------------------- */
.share {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; font-size: 14px; color: var(--ink-soft);
}
.share code {
  font-family: "IBM Plex Mono", monospace; font-size: 13px;
  background: #fff; border: 1px solid var(--rule-soft); border-radius: 6px;
  padding: 6px 10px; color: var(--ink); word-break: break-all;
}
.share .copy { border: none; background: none; color: var(--teal-dk);
  font: inherit; font-weight: 600; cursor: pointer; padding: 6px 4px; }

.notice {
  background: #FBEFE9; border: 1px solid #E7C6B7; color: #8a4a2f;
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 14px;
}

/* ================================================================= *
 *  TIMELINE — the signature strip-chart
 * ================================================================= */
.chart { margin-top: 26px; }
.chart-head {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 2px solid var(--ink); padding-bottom: 8px; margin-bottom: 4px;
}
.chart-head h2 {
  font-family: "Space Grotesk", sans-serif; font-weight: 600;
  font-size: 18px; margin: 0;
}
.chart-head-right {
  display: flex; align-items: baseline; gap: 14px;
}
.chart-head .legend {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--ink-soft);
  letter-spacing: .04em;
}

/* hour scale across the top */
.scale {
  display: grid; grid-template-columns: 40px 92px calc(var(--plan-cols, 1) * 29px + 1px) 1fr; align-items: center;
  font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--ink-soft);
  padding: 8px 0 2px;
}
.scale .ticks { display: flex; justify-content: space-between; border-left: 1px solid transparent; }
.scale .ticks span { transform: translateX(-50%); }
.scale .ticks span:first-child { transform: none; }
.scale .ticks span:last-child { transform: none; }

.lane {
  display: grid; grid-template-columns: 40px 92px calc(var(--plan-cols, 1) * 29px + 1px) 1fr; align-items: stretch;
  border-top: 1px solid var(--rule-soft); min-height: 62px;
}
.lane:last-child { border-bottom: 1px solid var(--rule-soft); }
.lane.today { background: rgba(0, 0, 0, 0.04); }
.lane.today .day-label { color: var(--teal-dk); font-weight: 600; }
.lane.empty .track { opacity: .55; }

.day-label {
  font-family: "IBM Plex Mono", monospace; font-size: 11px;
  color: var(--ink); padding: 10px 12px 0 0; text-align: right;
  letter-spacing: .02em; line-height: 1.25;
}
.day-label .dow { display: block; color: var(--ink-soft); font-size: 10px; }

.track {
  position: relative;
  border-left: 1px solid var(--rule);
  /* faint noon guide via a single mid gridline */
  background-image: linear-gradient(90deg, var(--rule-soft) 1px, transparent 1px);
  background-size: 25% 100%;
  background-position: 0 0;
}
.track .baseline {
  position: absolute; left: 0; right: 0; top: 50%; height: 2px;
  background: var(--rule); transform: translateY(-50%);
}

.marker {
  position: absolute; top: 62%; transform: translate(-50%, -50%);
  width: 40px; height: 40px; padding: 0; cursor: pointer;
  border-radius: 8px; border: 2px solid var(--surface);
  background-size: cover; background-position: center;
  box-shadow: 0 1px 3px rgba(35,48,46,.25);
  transition: transform .1s ease, box-shadow .1s ease;
}
.marker:hover, .marker:focus-visible {
  transform: translate(-50%, -50%) scale(1.15); z-index: 3;
  box-shadow: 0 3px 10px rgba(35,48,46,.35);
}
.marker .dot {
  position: absolute; right: -5px; bottom: -5px;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--surface);
  font-size: 9px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace;
}

.marker .dot.multi {
  width: auto; min-width: 15px; height: 15px; border-radius: 8px;
  padding: 0 5px; letter-spacing: .02em;
}

.marker.no-photo {
  background: var(--rule-soft);
  border-color: var(--rule);
  display: flex; align-items: center; justify-content: center;
}
.marker.no-photo::before {
  content: "—";
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
}

.marker.meal-marker {
  background: var(--teal);
  border-color: var(--surface);
  border-radius: 50%;
  width: 28px; height: 28px;
  top: 35%;
  display: flex; align-items: center; justify-content: center;
}
.marker.meal-marker::before {
  content: "F";
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px; font-weight: 700; color: #fff;
}
.marker.meal-marker.has-photo {
  background-size: cover; background-position: center;
}
.marker.meal-marker.has-photo::before { content: none; }

.marker .photo-count {
  position: absolute; left: -5px; top: -5px;
  min-width: 15px; height: 15px; border-radius: 50%;
  background: var(--teal); color: #fff; border: 2px solid var(--surface);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.empty-state {
  padding: 40px 8px; color: var(--ink-soft); font-size: 15px;
  border-top: 1px solid var(--rule-soft);
}

/* ---- plan bar --------------------------------------------------- */
.plan-bars { display: flex; gap: 1px; }
.plan-bar { position: relative; flex: 0 0 28px; }
.plan-bar.active { background: rgba(44, 110, 106, 0.22); cursor: default; }
.plan-bar.active.type-treats { background: rgba(200, 155, 44, 0.28); }
.plan-bar.active.type-medications { background: rgba(155, 59, 52, 0.25); }
.plan-bar.bar-top { border-radius: 4px 4px 0 0; }
.plan-bar.bar-bottom { border-radius: 0 0 4px 4px; }
.plan-bar.bar-top.bar-bottom { border-radius: 4px; }
.plan-bar-label {
  position: absolute; inset: 0; overflow: hidden;
  writing-mode: vertical-rl; text-orientation: mixed;
  transform: rotate(180deg);
  display: flex; align-items: center; justify-content: center;
  white-space: nowrap; pointer-events: none; z-index: 1;
  font-family: "IBM Plex Mono", monospace; font-size: 9px;
  color: var(--teal-dk); opacity: 0.7;
  letter-spacing: .02em;
}

/* ---- now marker ------------------------------------------------- */
.now-marker {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: #d32f2f; z-index: 2; pointer-events: none;
  border-radius: 1px;
}
.now-marker::before {
  content: ''; position: absolute; top: -3px; left: -3px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #d32f2f;
}
.future-meal { opacity: 0.35; }

/* ---- photo toggle ----------------------------------------------- */
.gallery-placeholder {
  display: flex !important; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
  min-height: 200px;
  background: var(--surface);
}
.gallery-placeholder::before {
  content: '';
  width: 48px; height: 48px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A6763' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z'/%3E%3Ccircle cx='12' cy='13' r='4'/%3E%3C/svg%3E") center/contain no-repeat;
}
.gallery-placeholder::after {
  content: 'Fotos ausgeblendet';
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 13px; color: var(--ink-soft);
}
.gallery-placeholder img, .gallery-placeholder button, .gallery-placeholder span { display: none !important; }

.chart.hide-thumbs .marker:not(.meal-marker):not(.no-photo) {
  background-image: none !important;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A6763' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z'/%3E%3Ccircle cx='12' cy='13' r='4'/%3E%3C/svg%3E") center/20px no-repeat !important;
  border-color: var(--rule);
}

/* ---- hover tooltip ---------------------------------------------- */
.tip {
  position: absolute; z-index: 40; pointer-events: none;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 10px; box-shadow: 0 4px 16px rgba(35,48,46,.18);
  padding: 10px 14px; font-size: 13px; line-height: 1.45;
  max-width: 260px; opacity: 0; transition: opacity .12s ease;
}
.tip.visible { opacity: 1; }
.tip strong { font-size: 14px; }
.tip-when {
  font-family: "IBM Plex Mono", monospace; font-size: 11px;
  color: var(--ink-soft); letter-spacing: .02em;
}
.tip-rule {
  border: none; border-top: 1px solid var(--rule-soft);
  margin: 6px 0;
}
.tip-dim { color: var(--ink-soft); }
.tip-label { font-size: 11px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.tip-score {
  font-family: "IBM Plex Mono", monospace; font-weight: 700;
  background: var(--ochre); color: #fff; border-radius: 4px;
  padding: 0 5px; font-size: 11px;
}
.tip-sw {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.15); vertical-align: middle;
}

/* score colour ramp (ochre = firmer→looser handled inline) */

/* ---- lightbox --------------------------------------------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20,28,26,.72); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 18px;
}
.lightbox.open { display: flex; }
.lightbox .panel {
  background: var(--surface); border-radius: 14px; overflow: hidden;
  max-width: 460px; width: 100%; max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.lightbox .gallery {
  position: relative;
}
.lightbox img { width: 100%; max-height: 56vh; object-fit: contain; background: #11201d; }
.gallery-prev, .gallery-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.45); color: #fff; border: none;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.gallery-prev:hover, .gallery-next:hover { background: rgba(0,0,0,.7); }
.gallery-prev { left: 8px; }
.gallery-next { right: 8px; }
.gallery-counter {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.55); color: #fff; border-radius: 999px;
  padding: 3px 10px; font-size: 11px;
}
.lightbox .meta { padding: 16px 18px 18px; }
.lightbox .meta .lb-title {
  font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 17px;
  margin: 0 0 4px;
}
.lightbox .meta .when {
  font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--ink-soft);
  margin-bottom: 10px;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--rule-soft); border-radius: 999px;
  padding: 5px 11px; font-size: 13px; background: #fff;
}
.chip .sw { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
.chip .num {
  font-family: "IBM Plex Mono", monospace; font-weight: 700;
  color: #fff; background: var(--ochre); border-radius: 5px;
  padding: 1px 6px; font-size: 12px;
}
.lightbox .note { font-size: 14px; color: var(--ink); white-space: pre-wrap; margin: 4px 0 0; }
.lightbox .note:empty::before { content: "Keine Notiz."; color: var(--ink-soft); font-style: italic; }
.lightbox .actions { display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 12px 18px; border-top: 1px solid var(--rule-soft); }
.lightbox .close { background: none; border: none; font: inherit; color: var(--ink-soft);
  cursor: pointer; font-weight: 600; }

/* ================================================================= *
 *  CONFIRM OVERLAY (step 2)
 * ================================================================= */
.overlay {
  min-height: 100vh; display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px 48px;
}
.overlay-card {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow);
  max-width: 440px; width: 100%; overflow: hidden; border: 1px solid var(--rule-soft);
}
/* preview grid for multi-photo staging */
.preview-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 4px;
}
.preview-grid.single { grid-template-columns: 1fr; }
.preview-item { position: relative; }
.preview-item .preview {
  aspect-ratio: 1; background: #11201d center/cover no-repeat;
}
.preview-grid.single .preview { aspect-ratio: 16/10; }
.remove-btn {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; border: none;
  font-size: 16px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.remove-btn:hover { background: var(--danger); }
.remove-form { display: contents; }

.add-photos {
  padding: 12px 20px;
  border-bottom: 1px solid var(--rule-soft);
}
.add-photos-form {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.add-photos-form input { flex: 1; min-width: 140px; }

.overlay-body { padding: 20px; }
.overlay-body h2 {
  font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 20px;
  margin: 0 0 2px;
}
.overlay-body .sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 18px; }

.field { margin-bottom: 18px; }
.field > label {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 7px;
}
.field > label .opt { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .8; }
.field input[type="datetime-local"], .field textarea {
  width: 100%; font: inherit; color: var(--ink);
  border: 1.5px solid var(--rule); border-radius: 9px; padding: 11px 12px; background: #fff;
}
.field textarea { resize: vertical; min-height: 66px; }

/* score picker */
.scorebar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.scorebar input { position: absolute; opacity: 0; pointer-events: none; }
.scorebar label {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; border: 1.5px solid var(--rule); border-radius: 8px;
  font-family: "IBM Plex Mono", monospace; font-weight: 700; cursor: pointer;
  background: #fff; transition: all .12s ease;
}
.scorebar input:checked + label {
  background: var(--ochre); border-color: var(--ochre); color: #fff;
  transform: translateY(-1px);
}
.scorebar input:focus-visible + label { outline: 3px solid rgba(198,138,46,.45); outline-offset: 2px; }
.score-hint { font-size: 13px; color: var(--ink-soft); margin: 8px 2px 0; min-height: 1.3em; }

/* colour picker */
.colorgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.colorgrid input { position: absolute; opacity: 0; pointer-events: none; }
.colorgrid label {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1.5px solid var(--rule); border-radius: 9px; padding: 9px 10px;
  font-size: 13px; background: #fff; transition: border-color .12s ease, box-shadow .12s ease;
}
.colorgrid label .sw { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); flex: none; }
.colorgrid input:checked + label { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.colorgrid input:focus-visible + label { outline: 3px solid rgba(44,110,106,.4); outline-offset: 2px; }

.overlay-actions { display: flex; gap: 12px; margin-top: 22px; }
.overlay-actions .btn { flex: 1; text-align: center; }
.overlay-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

.footnote {
  margin-top: 22px; font-size: 12px; color: var(--ink-soft);
  font-family: "IBM Plex Mono", monospace; letter-spacing: .02em;
}

/* ================================================================= *
 *  FOOD PLAN PAGES
 * ================================================================= */
.plan-nav {
  display: flex; gap: 18px; margin-bottom: 20px; font-size: 14px;
}
.plan-nav a { font-weight: 600; }

/* plans list */
.new-plan-form { display: flex; flex-direction: column; gap: 12px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field.compact { flex: 1 1 180px; margin-bottom: 0; }
.field.compact label {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 5px;
}
.field.compact input {
  width: 100%; font: inherit; color: var(--ink);
  border: 1.5px solid var(--rule); border-radius: 9px; padding: 10px 12px; background: #fff;
}
.copy-label {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  cursor: pointer; color: var(--ink-soft);
}
.copy-label input { width: 16px; height: 16px; }
.copy-select {
  font: inherit; color: var(--ink); border: 1.5px solid var(--rule);
  border-radius: 9px; padding: 10px 12px; background: #fff; margin-top: 6px;
  width: 100%;
}
.plan-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.plan-row .mono { font-size: 13px; color: var(--ink-soft); margin-left: 8px; }
.plan-actions { display: flex; gap: 8px; align-items: center; }
.inline-form { display: inline; }
.badge {
  display: inline-block; font-family: "IBM Plex Mono", monospace;
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  background: var(--teal); color: #fff; border-radius: 4px;
  padding: 2px 7px; margin-left: 8px; vertical-align: middle;
}
.active-plan { border-color: var(--teal); }
.plan-date { font-size: 13px; }

/* plan editor — meals */
.meal-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.meal-head-form { display: contents; }
.meal-time-input {
  font: inherit; font-size: 15px; font-weight: 700; color: var(--teal-dk);
  border: 1.5px solid var(--rule); border-radius: 7px; padding: 4px 8px;
  width: 6em; background: #fff;
}
.meal-name-input {
  font: inherit; font-weight: 600; font-size: 15px;
  border: 1.5px solid var(--rule); border-radius: 7px; padding: 4px 8px;
  flex: 1; min-width: 80px; background: #fff; color: var(--ink);
}
.parts-inline {
  display: flex; align-items: center; gap: 4px; font-size: 13px;
  font-weight: 600; color: var(--ink-soft); white-space: nowrap;
}
.parts-input {
  font: inherit; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--rule); border-radius: 7px; padding: 4px 6px;
  width: 4.5em; background: #fff; color: var(--ink); text-align: right;
}
.meal-delete { position: absolute; top: 12px; right: 12px; }
.card:has(.meal-head-form) { position: relative; }
.meal-recurrence-edit {
  margin-top: 6px; padding-left: 2px;
}
.meal-recurrence-edit .recurrence-picker select {
  font: inherit; font-size: 13px; border: 1.5px solid var(--rule);
  border-radius: 7px; padding: 4px 8px; background: #fff; color: var(--ink);
}
.btn-icon {
  background: none; border: 1px solid var(--rule-soft); border-radius: 6px;
  width: 28px; height: 28px; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-soft); transition: all .12s ease;
}
.btn-icon:hover { border-color: var(--rule); color: var(--ink); }
.btn-icon.danger:hover { border-color: var(--danger); color: var(--danger); }

.ingredient-list {
  list-style: none; margin: 0 0 8px; padding: 0;
}
.ingredient-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px solid var(--rule-soft);
  font-size: 14px;
}
.ingredient-list li:last-child { border-bottom: none; }
.ing-amount { font-size: 13px; color: var(--ink-soft); }

.add-ingredient-form {
  display: flex; gap: 8px; align-items: center; margin-top: 6px;
}
.add-ingredient-form input {
  flex: 1; font: inherit; color: var(--ink);
  border: 1.5px solid var(--rule); border-radius: 8px; padding: 7px 10px;
  background: #fff; font-size: 13px;
}
.add-ingredient-form input[name="amount"] { max-width: 100px; }

.add-meal-form { display: flex; flex-direction: column; gap: 12px; }
.empty-hint { color: var(--ink-soft); font-size: 14px; margin: 4px 0 12px; }

/* recurrence picker */
.recurrence-picker { display: flex; flex-direction: column; gap: 10px; }
.recurrence-picker select {
  font: inherit; color: var(--ink);
  border: 1.5px solid var(--rule); border-radius: 9px; padding: 10px 12px;
  background: #fff; width: 100%;
}
.rfield { margin-top: 4px; }
.interval-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--ink-soft);
}
.interval-input {
  width: 60px !important; text-align: center; font: inherit;
  border: 1.5px solid var(--rule); border-radius: 8px; padding: 7px 8px;
  background: #fff;
}
.weekday-checks {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.weekday-checks label {
  display: flex; align-items: center; gap: 5px; cursor: pointer;
  border: 1.5px solid var(--rule); border-radius: 8px; padding: 7px 12px;
  font-size: 13px; font-weight: 600; background: #fff;
  transition: border-color .12s ease;
}
.weekday-checks input { width: 14px; height: 14px; }
.weekday-checks label:has(input:checked) {
  border-color: var(--teal); color: var(--teal-dk);
}

/* mode picker (plans create form) */
.mode-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.mode-option {
  flex: 1 1 200px; display: flex; flex-direction: column; gap: 2px;
  cursor: pointer; border: 1.5px solid var(--rule); border-radius: 9px;
  padding: 12px 14px; background: #fff; transition: border-color .12s ease;
}
.mode-option:has(input:checked) { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-label { font-weight: 600; font-size: 14px; }
.mode-desc { font-size: 12px; color: var(--ink-soft); }
.mode-badge { background: var(--rule); color: var(--ink-soft); }

/* plan editor — daily mode extras */
/* plan meta form (name + dates in header) */
.plan-meta-form { margin: 0; }
.plan-name-input {
  font: inherit; font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 600; font-size: clamp(26px, 6vw, 38px);
  letter-spacing: -0.01em; line-height: 1.04;
  color: var(--ink); background: none; border: none; border-bottom: 2px solid transparent;
  padding: 0; width: 100%; margin: 0;
  transition: border-color .15s ease;
}
.plan-name-input:focus { border-bottom-color: var(--teal); outline: none; }
.plan-date-fields {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 6px;
}
.plan-date-label {
  font-size: 13px; color: var(--ink-soft);
  display: flex; align-items: center; gap: 6px;
}
.plan-date-label input {
  font: inherit; font-size: 13px; color: var(--ink);
  border: 1.5px solid var(--rule); border-radius: 8px; padding: 6px 10px;
  background: #fff;
}

.card.recipe-card { border-left: 4px solid var(--teal); }

.calc-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0 0 4px;
}
.additive-label { margin-top: 12px; }
.ingredient-list.calculated li { color: var(--ink-soft); }
.parts-badge { background: var(--ochre); }
.unit-select {
  font: inherit; font-size: 13px; color: var(--ink);
  border: 1.5px solid var(--rule); border-radius: 8px;
  padding: 7px 8px; background: #fff; max-width: 90px;
}
.recipe-form input[name="amount"] { max-width: 100px; }

/* entity photo upload (plan + meal) */
.entity-photo-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.entity-photo-row.compact { margin-bottom: 10px; }
.entity-photo-thumb {
  width: 64px; height: 64px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--rule-soft);
}
.entity-photo-thumb.small { width: 40px; height: 40px; border-radius: 50%; }
.photo-upload-inline {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.photo-upload-inline input[type="file"] {
  font-size: 12px; color: var(--ink-soft); max-width: 180px;
}

/* ---- symptom icons & picker ---- */
.day-symptoms {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 6px 2px; overflow: hidden;
  cursor: pointer; min-height: 100%;
}
.day-symptoms .sym-icon {
  width: 16px; height: 16px; opacity: .75;
}
.symptom-picker {
  display: none; grid-column: 1 / -1;
  padding: 8px 12px; gap: 6px;
  flex-wrap: wrap; background: var(--surface);
  border-top: 1px solid var(--rule-soft);
  width: 100%;
}
.symptom-picker.open { display: flex !important; }
.sym-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface); padding: 6px 8px; cursor: pointer;
  opacity: .5; transition: opacity .15s, border-color .15s;
}
.sym-btn img { width: 24px; height: 24px; }
.sym-btn span { font-size: 9px; color: var(--ink-soft); text-align: center; max-width: 64px; line-height: 1.2; }
.sym-btn:hover { opacity: .8; }
.sym-btn.active {
  opacity: 1; border-color: var(--teal); background: rgba(44,110,106,.08);
}

/* ================================================================= *
 *  VERTICAL TIMELINE
 * ================================================================= */
.vtl { margin-top: 16px; padding-left: 0; }

/* day header — centered on the spine */
.vtl-day-head {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap;
  padding: 18px 0 10px; font-weight: 600;
  border-bottom: 2px solid var(--ink);
}
.vtl-day-head.today .vtl-date-label { color: var(--teal-dk); }
.vtl-date-label { font-family: "IBM Plex Mono", monospace; font-size: 13px; }
.vtl-plan-badge {
  font-family: "IBM Plex Mono", monospace; font-size: 10px;
  letter-spacing: .08em; text-transform: uppercase;
  background: rgba(44,110,106,.15); color: var(--teal-dk);
  border-radius: 4px; padding: 2px 8px;
}
.vtl-plan-badge.type-treats { background: rgba(200,155,44,.2); color: #8a6a10; }
.vtl-plan-badge.type-medications { background: rgba(155,59,52,.18); color: #9B3B34; }

/* each row: left | spine | right — meals left, samples right */
.vtl-row {
  display: grid; grid-template-columns: 1fr 40px 1fr;
  gap: 0; min-height: 48px;
}

/* spine — continuous vertical line with dot + time */
.vtl-spine {
  position: relative; display: flex; flex-direction: column; align-items: center;
  padding-top: 12px;
}
.vtl-spine::before {
  content: ''; position: absolute; top: 0; bottom: 0;
  width: 2px; background: var(--rule);
}
.vtl-dot {
  position: relative; z-index: 1;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--ochre); border: 2px solid var(--surface);
  flex-shrink: 0;
}
.vtl-dot.meal { background: var(--teal); }
.vtl-time {
  font-size: 10px; color: var(--ink-soft);
  margin-top: 2px; position: relative; z-index: 1;
  background: var(--paper); padding: 0 2px;
}

/* empty placeholders for the opposite side */
.vtl-left, .vtl-right { min-height: 1px; }

/* card styling */
.vtl-card {
  background: var(--surface); border: 1px solid var(--rule-soft);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer;
  transition: box-shadow .15s ease;
  margin: 6px;
}
.vtl-card:hover { box-shadow: 0 2px 8px rgba(35,48,46,.12); }

/* meals (left side) — right-align text toward spine */
.vtl-row-left .vtl-card { text-align: right; }
.vtl-row-left .vtl-chips { justify-content: flex-end; }

.vtl-photo-wrap { position: relative; }
.vtl-photo {
  width: 100%; max-height: 360px; object-fit: cover; display: block;
  background: #11201d;
}
.vtl-photo-count {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 999px;
  padding: 2px 10px; font-size: 11px;
}
.vtl-photo-hidden { display: none !important; }
.vtl-gallery { position: relative; }
.vtl-gallery-prev, .vtl-gallery-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.45); color: #fff; border: none;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.vtl-gallery-prev:hover, .vtl-gallery-next:hover { background: rgba(0,0,0,.7); }
.vtl-gallery-prev { left: 8px; }
.vtl-gallery-next { right: 8px; }
.vtl-card-body { padding: 10px 14px; }
.vtl-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.vtl-note { font-size: 14px; color: var(--ink); margin: 8px 0 0; white-space: pre-wrap; }
.vtl-note:empty { display: none; }
/* plan badge inside meal card body — top left */
.vtl-row-left .vtl-card-body { display: flex; flex-direction: column; align-items: flex-end; }
.vtl-row-left .vtl-card-body > .vtl-plan-badge { align-self: flex-start; margin-bottom: 6px; }
.vtl-meal-name {
  font-weight: 600; font-size: 15px; margin-bottom: 6px;
  color: var(--teal-dk);
}
.vtl-supplements { margin-top: 8px; }
.vtl-supplements .tip-label { display: block; margin-bottom: 4px; }

/* photo toggle in vertical view */
.chart.hide-thumbs .vtl-photo-wrap img,
.chart.hide-thumbs .vtl-photo-wrap .vtl-photo-count { display: none; }
.chart.hide-thumbs .vtl-photo-wrap {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
  min-height: 120px; background: var(--surface);
}
.chart.hide-thumbs .vtl-photo-wrap::before {
  content: '';
  width: 36px; height: 36px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A6763' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z'/%3E%3Ccircle cx='12' cy='13' r='4'/%3E%3C/svg%3E") center/contain no-repeat;
}
.chart.hide-thumbs .vtl-photo-wrap::after {
  content: 'Foto ausgeblendet';
  font-size: 12px; color: var(--ink-soft);
}

@media (max-width: 560px) {
  .vtl-row, .vtl-row.vtl-row-right, .vtl-row.vtl-row-left {
    grid-template-columns: 30px 1fr;
  }
  .vtl-row .vtl-left, .vtl-row .vtl-right { display: none; }
  .vtl-row .vtl-spine { order: -1; grid-row: 1; grid-column: 1; }
  .vtl-row .vtl-card { grid-row: 1; grid-column: 2; }
  .vtl-row-left .vtl-card { text-align: left; }
  .vtl-row-left .vtl-chips { justify-content: flex-start; }
  .vtl-row-left .vtl-card-body { align-items: flex-start; }
  .vtl-day-head { justify-content: flex-start; margin-left: 38px; }
  .vtl-time { font-size: 9px; }
  .vtl-photo { max-height: 240px; }
}

/* ================================================================= *
 *  GRAPH VIEW
 * ================================================================= */
.graph-view { margin-top: 16px; }
.graph-panel {
  background: var(--surface); border: 1px solid var(--rule-soft);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 20px; margin-bottom: 16px;
}
.graph-panel h3 {
  font-family: "Space Grotesk", sans-serif; font-weight: 600;
  font-size: 15px; margin: 0;
}
.graph-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.graph-wrap { position: relative; height: 220px; }
.graph-panel:first-child .graph-wrap { height: 280px; }
.graph-wrap-colors { height: 80px; }
.active-toggle { background: var(--teal) !important; color: #fff !important; border-color: var(--teal) !important; }
.experimental-section { margin-top: 32px; }

@media (max-width: 560px) {
  .lane, .scale { grid-template-columns: 32px 62px calc(var(--plan-cols, 1) * 29px + 1px) 1fr; }
  .plan-bars { min-width: 10px; }
  .plan-bar { flex: 0 0 10px; }
  .day-label { font-size: 10px; }
  .marker { width: 34px; height: 34px; }
  .colorgrid { grid-template-columns: repeat(2, 1fr); }
  .day-symptoms { max-width: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---- fullsize overlay ---- */
.fullsize-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,.92);
  overflow: auto;
  justify-content: center;
  align-items: center;
}
.fullsize-overlay.open { display: flex; }
.fullsize-overlay img {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
  cursor: zoom-in;
  transition: max-width .2s, max-height .2s;
  touch-action: none;
}
.fullsize-overlay.zoomed { align-items: flex-start; justify-content: flex-start; }
.fullsize-overlay.zoomed img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}
.fs-close {
  position: fixed;
  top: 12px; right: 12px;
  z-index: 2001;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  font-size: 28px;
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.fs-close:hover { background: rgba(0,0,0,.8); }
.fs-spinner {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 32px; height: 32px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fs-spin .7s linear infinite;
}
@keyframes fs-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ---- reimport page ---- */
.reimport-page { max-width: 800px; margin: 0 auto; padding: 32px 16px; }
.reimport-header h1 { margin: 16px 0 4px; }
.reimport-header p { color: var(--ink-soft); margin-bottom: 24px; }
.drop-zone {
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--rule); border-radius: var(--radius);
  padding: 48px 24px; cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
  margin-bottom: 16px;
}
.drop-zone.drag, .drop-zone:hover { border-color: var(--teal); background: rgba(44,110,106,.06); }
.drop-label { color: var(--ink-soft); font-size: 15px; }
.file-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; background: var(--paper); border-radius: 6px;
}
.file-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.file-item-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { font-size: 12px; color: var(--ink-soft); flex-shrink: 0; }
.reimport-results { margin-top: 32px; }
.reimport-results h2 { margin-bottom: 16px; }
.reimport-row {
  padding: 12px; border: 1px solid var(--rule-soft); border-radius: var(--radius);
  margin-bottom: 8px; background: var(--surface);
}
.reimport-row.no-match { opacity: .5; }
.reimport-row.applied { opacity: .4; }
.match-filename {
  font-size: 12px; color: var(--ink-soft); margin-bottom: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.match-body {
  display: flex; align-items: center; gap: 12px;
}
.match-body input[type=checkbox] { width: 20px; height: 20px; flex-shrink: 0; }
.match-new, .match-existing { display: flex; align-items: center; gap: 8px; }
.match-new img, .match-existing img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.match-arrow { font-size: 20px; color: var(--ink-soft); flex-shrink: 0; }
.match-time { font-size: 12px; }
.match-photo-options { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.match-photo-option {
  position: relative; cursor: pointer; border: 2px solid transparent;
  border-radius: 6px; transition: border-color .15s;
}
.match-photo-option img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; display: block; }
.match-photo-option.selected { border-color: #3B82F6; box-shadow: 0 0 0 1px #3B82F6; }
.match-photo-option.has-orig { opacity: .5; }
.orig-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--teal); color: #fff; font-size: 10px;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.match-none { color: var(--ink-soft); font-style: italic; }
.reimport-actions { margin-top: 16px; display: flex; align-items: center; gap: 12px; }
#apply-status { color: var(--teal); font-size: 14px; }
