/* Fibr — botanical dark theme. Rebuilt 2026-10-23 (B-101): deliberate design,
   no framework, self-contained game-shell file. */

:root {
  --bg: #0c1a12;
  --bg-raised: #122419;
  --bg-card: #16301f;
  --bg-input: #0f2117;
  --line: #234632;
  --line-soft: #1b3826;
  --text: #eef5ee;
  --text-dim: #9db8a5;
  --text-faint: #5f7a67;
  --accent: #34d399;
  --accent-strong: #10b981;
  --accent-deep: #065f46;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --gold: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Inter", "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Screens ─────────────────────────────────────────────── */

.screen {
  display: none;
  flex: 1;
  padding: 20px 18px 96px;
  animation: screen-in 220ms ease;
}

.screen.active { display: block; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.screen-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.screen-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 20px;
}

/* ── Cards ───────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  margin-bottom: 12px;
}

/* ── Today ring ──────────────────────────────────────────── */

.today-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
}

.greeting {
  color: var(--text-dim);
  font-size: 13px;
  text-transform: capitalize;
}

.date-line {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  padding: 7px 13px;
  border-radius: 999px;
  white-space: nowrap;
}

.streak-pill svg { width: 15px; height: 15px; }

.ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0 2px;
}

.ring { position: relative; width: 208px; height: 208px; }

.ring svg { transform: rotate(-90deg); display: block; }

.ring-track { stroke: var(--line-soft); }

.ring-fill {
  stroke: url(#ringGradient);
  stroke-linecap: round;
  transition: stroke-dashoffset 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ring-value {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.ring-goal { color: var(--text-dim); font-size: 13px; margin-top: 6px; }

.ring-togo {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.ring-togo.done { color: var(--gold); }

.goal-banner {
  display: none;
  margin-top: 14px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.16), rgba(52, 211, 153, 0.12));
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--gold);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
}

.goal-banner.show { display: block; }

/* ── 7-day chart ─────────────────────────────────────────── */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 96px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar-track {
  width: 100%;
  max-width: 30px;
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--bg-input);
  border-radius: 7px;
  overflow: hidden;
}

.chart-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  border-radius: 7px;
  min-height: 4px;
  transition: height 500ms ease;
}

.chart-col.today .chart-bar { background: linear-gradient(180deg, var(--gold), #b45309); }

.chart-val { font-size: 10px; color: var(--text-faint); }

.chart-col.today .chart-val { color: var(--gold); font-weight: 700; }

.chart-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; }

.chart-col.today .chart-label { color: var(--text); font-weight: 700; }

.chart-goal-mark {
  position: relative;
}

/* ── Suggestions ─────────────────────────────────────────── */

.sprout-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.sprout-row:last-child { border-bottom: none; }

.sprout-emoji {
  font-size: 22px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: 11px;
  flex-shrink: 0;
}

.sprout-info { flex: 1; min-width: 0; }

.sprout-name { font-weight: 600; font-size: 15px; }

.sprout-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.sprout-fiber {
  font-weight: 700;
  color: var(--accent);
  font-size: 14px;
  white-space: nowrap;
}

.sprout-actions { display: flex; gap: 8px; margin-top: 8px; }

.mini-btn {
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
}

.mini-btn.primary { background: var(--accent-strong); color: #06281c; }

.mini-btn.ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
}

/* ── Entries ─────────────────────────────────────────────── */

.entry-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.entry-row:last-child { border-bottom: none; }

.entry-info { flex: 1; min-width: 0; }

.entry-name { font-weight: 600; font-size: 15px; }

.entry-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.entry-fiber { font-weight: 700; color: var(--accent); white-space: nowrap; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
}

.icon-btn:hover { color: var(--danger); background: var(--bg-input); }

.icon-btn svg { width: 16px; height: 16px; }

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 26px 12px;
  font-size: 14px;
}

.empty-state .big { font-size: 30px; display: block; margin-bottom: 8px; }

.empty-cta {
  margin-top: 14px;
  background: var(--accent-strong);
  border: none;
  color: #06281c;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 22px;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-body);
}

/* ── Search ──────────────────────────────────────────────── */

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.search-box:focus-within { border-color: var(--accent-strong); }

.search-box svg { width: 17px; height: 17px; color: var(--text-faint); flex-shrink: 0; }

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  font-family: var(--font-body);
}

.search-box input::placeholder { color: var(--text-faint); }

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 6px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar { display: none; }

.chip {
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  font-family: var(--font-body);
}

.chip.active { background: var(--accent-soft); border-color: var(--accent-strong); color: var(--accent); }

.usda-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px 16px;
  font-size: 13px;
  color: var(--text-dim);
}

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  background: var(--line);
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: background 160ms;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 160ms;
}

.toggle.on { background: var(--accent-strong); }

.toggle.on::after { transform: translateX(18px); background: #06281c; }

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  margin: 14px 0 4px;
}

.food-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 2px;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-body);
}

.food-row:last-child { border-bottom: none; }

.food-row:hover { background: var(--bg-raised); }

.food-emoji {
  font-size: 20px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: 11px;
  flex-shrink: 0;
}

.food-info { flex: 1; min-width: 0; }

.food-name {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.food-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.food-fiber { text-align: right; white-space: nowrap; }

.food-fiber .val { font-weight: 700; color: var(--accent); font-size: 15px; }

.food-fiber .unit { font-size: 11px; color: var(--text-faint); }

.search-note { font-size: 13px; color: var(--text-faint); padding: 14px 2px; text-align: center; }

.search-note.error { color: var(--danger); }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  margin: 16px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── History ─────────────────────────────────────────────── */

.day-card { margin-bottom: 14px; }

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.day-title { font-weight: 700; font-size: 15px; }

.day-total { font-size: 13px; color: var(--text-dim); }

.day-total.hit { color: var(--accent); font-weight: 700; }

/* ── Settings ────────────────────────────────────────────── */

.setting-row { margin-bottom: 22px; }

.setting-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.goal-editor { display: flex; align-items: center; gap: 12px; }

.goal-editor input {
  width: 90px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  padding: 10px 12px;
  text-align: center;
  outline: none;
  font-family: var(--font-body);
}

.goal-editor input:focus { border-color: var(--accent-strong); }

.goal-editor .unit { color: var(--text-dim); font-size: 14px; }

.stat-grid { display: flex; gap: 10px; }

.stat-box {
  flex: 1;
  background: var(--bg-input);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.stat-box .val { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--accent); }

.stat-box .lbl { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }

.wide-btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  margin-bottom: 10px;
}

.wide-btn.accent { background: var(--accent-strong); color: #06281c; }

.wide-btn.danger { background: transparent; border: 1px solid var(--line); color: var(--danger); }

.attribution {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  padding: 18px 20px 6px;
  line-height: 1.5;
}

/* ── Tab bar ─────────────────────────────────────────────── */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: rgba(12, 26, 18, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line-soft);
  z-index: 20;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 12px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: var(--font-body);
}

.tab svg { width: 21px; height: 21px; }

.tab.active { color: var(--accent); }

/* ── Log sheet (modal) ───────────────────────────────────── */

.sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 12, 8, 0.7);
  backdrop-filter: blur(3px);
  z-index: 40;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop.open { display: flex; }

.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 22px 20px 30px;
  animation: sheet-up 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

.sheet-food { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin-bottom: 2px; }

.sheet-meta { font-size: 13px; color: var(--text-dim); margin-bottom: 18px; }

.grams-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.stepper-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font-body);
}

.stepper-btn:hover { border-color: var(--accent-strong); color: var(--accent); }

.grams-input-wrap { flex: 1; display: flex; align-items: baseline; justify-content: center; gap: 6px; }

.grams-input-wrap input {
  width: 90px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  padding: 9px 10px;
  text-align: center;
  outline: none;
  font-family: var(--font-body);
}

.grams-input-wrap input:focus { border-color: var(--accent-strong); }

.grams-input-wrap .unit { color: var(--text-dim); font-weight: 600; }

.sheet-preview {
  text-align: center;
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 18px;
}

.sheet-preview strong { color: var(--accent); font-size: 18px; }

.sheet-actions { display: flex; gap: 10px; }

.sheet-actions .wide-btn { margin-bottom: 0; }

/* ── Toast ───────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
  z-index: 50;
  max-width: 88%;
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Light theme (system preference) ─────────────────────── */

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f1e8;
    --bg-raised: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #edeadd;
    --line: #d9d2bf;
    --line-soft: #e7e1d1;
    --text: #1d2b22;
    --text-dim: #5c6f61;
    --text-faint: #8b9a8d;
    --accent: #0e9f6e;
    --accent-strong: #0b9c6b;
    --accent-deep: #0b7a55;
    --accent-soft: rgba(14, 159, 110, 0.1);
  }

  .tabbar { background: rgba(244, 241, 232, 0.92); }

  .mini-btn.primary, .empty-cta, .wide-btn.accent { color: #ffffff; }

  .toggle.on::after { background: #ffffff; }

  .sheet { background: #ffffff; }
}

@media (min-width: 480px) {
  .app { border-left: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }
}
