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

:root {
  --bg: #0d1b0d;
  --surface: #1a3320;
  --surface2: #224422;
  --primary: #4CAF50;
  --primary-dark: #388E3C;
  --accent: #81C784;
  --text: #e8f5e9;
  --text2: #a5d6a7;
  --border: rgba(76,175,80,0.2);
  --danger: #ef5350;
  --warning: #ff9800;
  --success: #66BB6A;
}

body.theme-light {
  --bg: #f1f8e9;
  --surface: #ffffff;
  --surface2: #f0f4f0;
  --text: #1b5e20;
  --text2: #388e3c;
  --border: rgba(76,175,80,0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { color: var(--text); }

/* Layout */
#app { height: 100vh; display: flex; flex-direction: column; }

.app-header {
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-brand { font-size: 1.1rem; font-weight: 700; color: var(--primary); }

.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 80px;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  padding: 4px 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.nav-item.active { color: var(--primary); }
.nav-item:active { opacity: 0.7; }
.nav-icon { font-size: 1.3rem; line-height: 1; }
.nav-label { font-size: 0.6rem; margin-top: 2px; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  animation: fadeIn 0.2s ease;
}

.card-title {
  font-size: 0.8rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

/* Buttons */
.btn {
  padding: 11px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
  width: 100%;
  display: block;
  text-align: center;
  font-family: inherit;
}

.btn:active { transform: scale(0.98); opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn + .btn { margin-top: 8px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: 7px 12px; width: auto; display: inline-block; font-size: 0.85rem; }
.btn-group { display: flex; flex-direction: column; gap: 8px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.82rem; color: var(--text2); margin-bottom: 5px; }
.form-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--primary); }

/* Grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* Stats */
.stat-box {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.72rem; color: var(--text2); margin-top: 2px; }

/* Badges */
.badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  margin: 3px 3px 3px 0;
}
.badge-chip.earned { border-color: var(--primary); color: var(--primary); background: rgba(76,175,80,0.1); }
.badge-chip.locked { opacity: 0.35; }

/* Progress */
.progress-bar { height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.4s; }

/* View headers */
.view-header { margin-bottom: 16px; }
.view-title { font-size: 1.35rem; font-weight: 700; }
.view-subtitle { font-size: 0.85rem; color: var(--text2); margin-top: 3px; }
.section-title { font-size: 0.95rem; font-weight: 600; color: var(--text); margin: 14px 0 8px; }

/* Loading */
.loading-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 60vh; gap: 12px; color: var(--text2);
}
.loading-icon { font-size: 3.5rem; animation: pulse 1.5s infinite; }

/* Exercise */
.exercise-card {
  background: var(--surface2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  border-left: 3px solid var(--primary);
  animation: fadeIn 0.2s ease;
}
.exercise-name { font-size: 1rem; font-weight: 600; }
.exercise-reps { font-size: 0.85rem; color: var(--primary); margin-top: 3px; }
.exercise-sets { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.set-chip {
  background: rgba(76,175,80,0.18);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.78rem;
  color: var(--primary);
}

/* Timer */
.timer-display {
  font-size: 3.5rem;
  font-weight: 700;
  text-align: center;
  color: var(--primary);
  font-family: monospace;
  letter-spacing: 0.06em;
  padding: 16px 0;
}
.timer-warning { color: var(--warning); }

/* Garden */
#garden-canvas { display: block; border-radius: 10px; }
.garden-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.plot-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin: 8px 0; }
.plot-btn {
  aspect-ratio: 1;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
}
.plot-btn.selected { border-color: var(--primary); background: rgba(76,175,80,0.15); }

/* Quests */
.quest-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.quest-desc { font-size: 0.9rem; margin-bottom: 6px; }
.quest-reward { font-size: 0.78rem; color: var(--text2); }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.photo-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; display: block; }
.photo-date-group { margin-bottom: 14px; }
.photo-date-label { font-size: 0.82rem; color: var(--text2); margin-bottom: 5px; }

/* Table */
table { width: 100%; border-collapse: collapse; }
td, th { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
th { color: var(--text2); font-weight: 600; }

/* Utilities */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text2); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.empty-state { text-align: center; padding: 28px 16px; color: var(--text2); font-size: 0.9rem; }

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.08); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
