/* Mobile-first styles for the food & symptom diary. */

:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #2b2b2b;
  --muted: #767268;
  --line: #e2ded4;
  --primary: #2f7d5d;
  --primary-dark: #256349;
  --secondary: #eceae2;
  --danger: #b3402f;
  --vague: #b07a1e;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 1.4rem; margin: 8px 0 16px; }
h2 { font-size: 1.1rem; margin: 20px 0 10px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 0 12px; }

/* Top navigation */
.topbar {
  background: var(--primary);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topnav {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}
.topnav a { color: #fff; text-decoration: none; font-weight: 500; }
.brand { font-size: 1.1rem; }
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.92rem;
}
.nav-links a { opacity: 0.92; }
.nav-links a:hover { opacity: 1; text-decoration: underline; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

/* Forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  margin: 6px 0;
}
input[type="text"], input[type="password"], input[type="date"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; }
fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 14px 0;
  padding: 8px 12px 12px;
}
legend { font-weight: 600; padding: 0 4px; }
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}
.category-grid legend { grid-column: 1 / -1; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: var(--ink); }
.btn-block { width: 100%; margin-top: 14px; }
.btn-big { padding: 18px; font-size: 1.05rem; }
.btn-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  color: var(--primary);
  text-decoration: underline;
}
.btn-link.danger { color: var(--danger); }
.form-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}
.inline-form { display: inline; }

/* Flash messages */
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.flash-success { background: #e2f0e8; color: #1d5c41; }
.flash-error { background: #f7e3df; color: #8a2f21; }

/* Login */
.login-card { max-width: 380px; margin: 10vh auto 0; }
.login-card h1 { text-align: center; font-size: 1.2rem; }

/* Dashboard quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0 20px;
}

/* Entry cards */
.entry-card { padding: 12px 14px; }
.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.88rem;
}
.entry-kind { font-weight: 700; }
.entry-head time { color: var(--muted); }
.entry-body { margin: 8px 0; }
.entry-comments { margin: 8px 0 0; white-space: pre-wrap; }
.entry-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.entry-actions { display: flex; gap: 12px; }
.entry-actions a { color: var(--primary); }

/* Chips */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--secondary);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.9rem;
}
.chip-vague {
  border-style: dashed;
  border-color: var(--vague);
  color: var(--vague);
  background: #fdf6ea;
}
.chip-vague::after { content: " ~"; }
.chip-symptom { background: #f2e4e0; border-color: #e0c5be; }

/* Food entry: mode tabs */
.mode-tabs {
  display: flex;
  gap: 6px;
  margin: 14px 0 10px;
}
.mode-tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--secondary);
  font: inherit;
  cursor: pointer;
}
.mode-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* Food entry: item review editor */
.review-title { margin-top: 18px; }
.item-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.item-row { display: flex; gap: 6px; align-items: center; }
.item-row .item-text { flex: 1; }
.vague-toggle, .remove-item {
  flex: 0 0 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--secondary);
  font-size: 1.1rem;
  cursor: pointer;
}
.vague-toggle.active {
  background: #fdf6ea;
  border-color: var(--vague);
  color: var(--vague);
  font-weight: 700;
}
.remove-item { color: var(--danger); }
.raw-input-details { margin-top: 14px; font-size: 0.9rem; }
.raw-input-details pre {
  background: var(--secondary);
  padding: 10px;
  border-radius: 8px;
  white-space: pre-wrap;
}

/* Entries filter */
.filter-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}
.filter-fields label:first-child { grid-column: 1 / -1; }
.filter-buttons { display: flex; gap: 10px; margin-top: 12px; }

/* Settings */
.subnav { display: flex; gap: 16px; margin-bottom: 14px; }
.subnav a { color: var(--primary); text-decoration: none; padding-bottom: 2px; }
.subnav a.active { font-weight: 700; border-bottom: 2px solid var(--primary); }
.settings-list { list-style: none; margin: 0; padding: 0; }
.settings-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.settings-list li:last-child { border-bottom: none; }
.settings-list .inline-add-form { flex: 1; }
.inactive-row { opacity: 0.55; }
.inline-add-form { display: flex; gap: 8px; }
.inline-add-form input { flex: 1; }

/* Foods & composition */
.disclaimer {
  background: #fdf3e4;
  border: 1px solid var(--vague);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}
.btn-small { padding: 6px 10px; font-size: 0.85rem; }
.review-list { list-style: none; margin: 0; padding: 0; }
.review-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.review-row:last-child { border-bottom: none; }
.review-actions { display: flex; gap: 6px; align-items: center; }
.status-rejected .review-ingredient { opacity: 0.55; text-decoration: line-through; }
.conf-badge, .status-badge {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 4px;
  background: var(--secondary);
  color: var(--muted);
}
.conf-likely { background: #e2f0e8; color: #1d5c41; }
.conf-possible { background: #fdf6ea; color: var(--vague); }
.status-badge.ok { background: #e2f0e8; color: #1d5c41; }
.status-badge.bad { background: #f7e3df; color: #8a2f21; }
.status-badge.warn { background: #fdf6ea; color: var(--vague); }
.suggest-form { margin-top: 14px; }
.foods-list li { flex-direction: column; align-items: flex-start; gap: 2px; }
.food-name { color: var(--ink); font-weight: 600; text-decoration: none; }
.food-meta { font-size: 0.85rem; }
.chip-component { background: #eef3f8; border-color: #cfdceb; font-size: 0.8rem; }
.chip-unreviewed { border-style: dashed; }
a.chip { text-decoration: none; color: var(--ink); }

/* Timeline */
.timeline-controls .filter-fields { grid-template-columns: 1fr 1fr; }
.legend-fieldset { margin-top: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 2px 0; }
.legend-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  color: #fff; font-size: 0.75rem; font-weight: 700;
}
.timeline-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.timeline-svg { display: block; font-family: inherit; }
.timeline-svg .grid { stroke: var(--line); stroke-width: 1; }
.timeline-svg .axis-label { font-size: 11px; fill: var(--muted); }
.timeline-svg .band { fill: #f3e9d8; opacity: 0.55; }
.timeline-svg .lane-bg { fill: transparent; }
.timeline-svg .lane:nth-child(even) .lane-bg { fill: #f8f7f3; }
.timeline-svg .lane.highlighted .lane-bg { fill: #fff3c4; }
.timeline-svg .lane-label { font-size: 12px; fill: var(--ink); }
.timeline-svg .lane.derived .lane-label { fill: #555; font-style: italic; }
.timeline-svg .lane-count { font-size: 11px; fill: var(--muted); }
.timeline-svg .mark { stroke: var(--primary); stroke-width: 1.5; fill: #fff; cursor: pointer; }
.timeline-svg .mark.related { fill: var(--primary); }
.timeline-svg .mark.unreviewed { stroke-dasharray: 2 1.5; }
.timeline-svg .symptom-line { stroke: #c0392b; stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.6; }
.timeline-svg .symptom { cursor: pointer; }
.timeline-svg .symptom-letter { font-size: 10px; font-weight: 700; fill: #fff; pointer-events: none; }
.detail-panel {
  margin-top: 10px; padding: 10px 12px;
  background: var(--secondary); border-radius: 8px; font-size: 0.9rem;
}
.symptom-block { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.symptom-head { font-size: 1rem; margin: 4px 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.before-list { list-style: none; margin: 0; padding: 0; }
.before-list li { padding: 6px 0; }

/* Wider screens */
@media (min-width: 560px) {
  h1 { font-size: 1.6rem; }
  .category-grid { grid-template-columns: 1fr 1fr 1fr; }
  .filter-fields { grid-template-columns: auto 1fr 1fr; align-items: end; }
  .filter-fields label:first-child { grid-column: auto; }
}

/* Footer */
.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 10px 16px 20px;
}
