/* ═══════════════════════════════════════════
   FIT — Dark utilitarian stylesheet
   Barlow Condensed (display) + DM Mono (data)
═══════════════════════════════════════════ */

:root {
  --bg:        #0a0a0a;
  --bg2:       #111111;
  --bg3:       #1a1a1a;
  --border:    #2a2a2a;
  --border2:   #333333;
  --text:      #e8e8e8;
  --muted:     #555555;
  --accent:    #c8ff00;       /* electric lime */
  --accent2:   #ff4444;       /* red for delete/danger */
  --accent3:   #00d4ff;       /* cyan for AI */
  --nav-h:     64px;
  --header-h:  96px;
  --radius:    4px;
  --mono:      'DM Mono', monospace;
  --display:   'Barlow Condensed', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  height: 100%;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ═══ NAV ═══ */
#nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--nav-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  flex-shrink: 0;
  z-index: 10;
}

#nav-logo {
  font-family: var(--display);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.15em;
  color: var(--accent);
  flex-shrink: 0;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: color 0.15s;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.1em;
  flex: 1;
}

.nav-btn .nav-icon { font-size: 18px; }
.nav-btn .nav-label { font-size: 10px; }

.nav-btn.active,
.nav-btn:hover { color: var(--accent); }

/* ═══ MAIN ═══ */
#main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 32px;
}

.view.hidden { display: none; }
.view.active { display: block; }

/* ═══ VIEW HEADER ═══ */
.view-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 0;
}

.date-display {
  font-family: var(--display);
  font-weight: 300;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.view-tabs {
  display: flex;
  gap: 0;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.1em;
  padding: 8px 16px 10px;
  transition: all 0.15s;
}

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

.tab-btn:hover:not(.active) { color: var(--text); }

.tab-content { padding: 16px; }
.tab-content.hidden { display: none; }

/* ═══ BUTTONS ═══ */
.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.1em;
  padding: 12px 20px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary.full-width { width: 100%; }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 10px 16px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: var(--radius);
  font-family: var(--display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--accent2); color: var(--accent2); }
.btn-sm { padding: 4px 10px; font-size: 11px; }

.btn-ai {
  background: transparent;
  border: 1px solid var(--accent3);
  color: var(--accent3);
  border-radius: var(--radius);
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-ai:hover { background: var(--accent3); color: #000; }
.btn-ai.loading { opacity: 0.5; cursor: wait; }

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: var(--radius);
  transition: color 0.15s;
  line-height: 1;
}
.btn-icon:hover { color: var(--accent2); }

/* ═══ INPUTS ═══ */
input[type="text"],
input[type="number"] {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
input:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted); }

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field-group label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* ═══ AUTOCOMPLETE ═══ */
.autocomplete-wrap { position: relative; width: 100%; }

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  list-style: none;
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}
.suggestions.hidden { display: none; }
.suggestions li {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.suggestions li:last-child { border-bottom: none; }
.suggestions li:hover { background: var(--bg3); color: var(--accent); }
.suggestions li .sug-cal { color: var(--muted); font-size: 12px; }

/* ═══ FITNESS — SESSION ═══ */
#no-session {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 60px 0;
}

.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

.session-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

#session-label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

/* Exercise block */
.exercise-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.exercise-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

.exercise-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sets-table {
  width: 100%;
}

.set-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr 32px;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.set-row:last-child { border-bottom: none; }

.set-num {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--display);
  font-weight: 700;
}

.set-row input[type="number"] {
  padding: 6px 8px;
  font-size: 13px;
  text-align: center;
}

.add-set-row {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}

.add-set-row button {
  width: 100%;
  background: none;
  border: 1px dashed var(--border2);
  color: var(--muted);
  font-family: var(--display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.1em;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}
.add-set-row button:hover { border-color: var(--accent); color: var(--accent); }

.set-labels {
  display: grid;
  grid-template-columns: 28px 1fr 1fr 32px;
  gap: 8px;
  padding: 6px 14px 4px;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* add exercise row */
.add-exercise-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ═══ FITNESS — HISTORY ═══ */
.session-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.session-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--bg3);
}

.session-card-date {
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
}

.session-card-summary {
  font-size: 11px;
  color: var(--muted);
}

.session-card-body {
  padding: 12px 14px;
  display: none;
}
.session-card-body.open { display: block; }

.session-exercise-row {
  margin-bottom: 10px;
}

.session-exercise-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 4px;
}

.session-sets-summary {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

/* ═══ PROGRESS ═══ */
.progress-controls {
  margin-bottom: 16px;
}

.chart-wrap {
  margin-top: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.chart-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: 20px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip.active { background: var(--accent); color: #000; border-color: var(--accent); }
.chip:hover:not(.active) { border-color: var(--text); color: var(--text); }

/* ═══ CALORIES — TOTAL BAR ═══ */
.calorie-total-bar {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.total-label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.total-num {
  font-family: var(--display);
  font-weight: 900;
  font-size: 52px;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.02em;
  transition: color 0.3s;
}

.total-num.over { color: var(--accent2); }

.total-unit {
  font-family: var(--display);
  font-weight: 300;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ═══ CALORIES — MEAL SLOTS ═══ */
.meal-slot {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.meal-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

.slot-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.slot-total {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}

.slot-total.has-entries { color: var(--accent); }

.meal-entries-list {
  list-style: none;
}

.meal-entry-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.meal-entry-row:last-child { border-bottom: none; }

.entry-name { font-size: 13px; }
.entry-right { display: flex; align-items: center; gap: 10px; }
.entry-cal { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.add-meal-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.1em;
  padding: 10px 14px;
  cursor: pointer;
  transition: color 0.15s;
  text-align: left;
}
.add-meal-btn:hover { color: var(--accent); }
.add-meal-btn .plus { font-size: 16px; line-height: 1; }

/* ═══ MODAL ═══ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 50;
}
.modal-backdrop.hidden { display: none; }

.modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 51;
  background: var(--bg2);
  border-top: 1px solid var(--border2);
  border-radius: 16px 16px 0 0;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal:not(.hidden) { transform: translateY(0); }
.modal.hidden { transform: translateY(100%); display: block !important; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.12em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; }
.modal-footer { padding: 0 20px 32px; }

/* ═══ AI SECTION ═══ */
.ai-section {
  margin-bottom: 16px;
  background: rgba(0,212,255,0.04);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: var(--radius);
  padding: 12px;
}

.ai-input-row {
  display: flex;
  gap: 8px;
}

.ai-result {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent3);
}

.ai-result.hidden { display: none; }

.ai-result-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--text);
}

.ai-result-cal {
  font-family: var(--display);
  font-weight: 900;
  font-size: 28px;
  color: var(--accent3);
  line-height: 1.1;
}

.ai-result-breakdown {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.ai-result-confidence {
  font-size: 10px;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 6px;
}
.ai-result-confidence.high { color: var(--accent); }
.ai-result-confidence.medium { color: #ffbb00; }
.ai-result-confidence.low { color: var(--accent2); }

.use-estimate-btn {
  margin-top: 10px;
  width: 100%;
  background: rgba(0,212,255,0.1);
  border: 1px solid var(--accent3);
  color: var(--accent3);
  border-radius: var(--radius);
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.use-estimate-btn:hover { background: var(--accent3); color: #000; }

.divider-label {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin: 14px 0;
  letter-spacing: 0.08em;
}

.save-template-row { flex-direction: row; align-items: center; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--accent); }

/* ═══ CAL HISTORY ═══ */
.cal-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cal-history-row:last-child { border-bottom: none; }
.cal-history-date { color: var(--muted); font-family: var(--display); font-weight: 600; letter-spacing: 0.06em; }
.cal-history-num { font-family: var(--mono); color: var(--accent); }

/* ═══ WEIGHT ═══ */
.weight-log-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.weight-today-label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 12px;
}

.weight-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.weight-input-row input {
  font-family: var(--display);
  font-weight: 900;
  font-size: 40px;
  text-align: center;
  width: 140px;
  flex-shrink: 0;
  padding: 8px 12px;
  letter-spacing: -0.02em;
}

.weight-unit-label {
  font-family: var(--display);
  font-weight: 300;
  font-size: 16px;
  letter-spacing: 0.1em;
  color: var(--muted);
  flex-shrink: 0;
}

.weight-saved-msg {
  margin-top: 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.weight-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.weight-chart-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.weight-stats {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.weight-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.weight-history-row:last-child { border-bottom: none; }
.weight-history-date { color: var(--muted); font-family: var(--display); font-weight: 600; letter-spacing: 0.06em; font-size: 13px; }
.weight-history-num { font-family: var(--mono); font-size: 13px; color: var(--text); }
.weight-history-right { display: flex; align-items: center; gap: 10px; }
.weight-delta { font-size: 11px; }
.weight-delta.up { color: var(--accent2); }
.weight-delta.down { color: var(--accent); }

.loading-msg { padding: 40px 0; text-align: center; }
