:root {
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-card-alt: #1e293b;
  --border-color: #1f2937;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #10b981;
  --primary-dark: #059669;
  --accent: #3b82f6;
  --warning: #f59e0b;
  --danger: #ef4444;
  --water: #06b6d4;
  --radius: 18px;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 92px;
  overflow-x: hidden;
}

a {
  color: var(--accent);
}

.hidden {
  display: none !important;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(9, 13, 22, 0.92);
  backdrop-filter: blur(12px);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-color);
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-size: 1.7rem;
}

.brand h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.badge-a57 {
  font-size: 0.7rem;
  background: linear-gradient(135deg, #10b981, #3b82f6);
  color: #fff;
  padding: 2px 7px;
  border-radius: 99px;
  vertical-align: middle;
}

.subtitle {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.streak-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  padding: 6px 11px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 0.88rem;
}

.date-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 5px 8px;
}

.date-display {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

#datePicker {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
  outline: none;
}

.date-label {
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 700;
}

.icon-btn {
  background: var(--bg-card-alt);
  border: none;
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Main & Cards */
.app-main {
  padding: 14px;
}

.tab-section {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.tab-section.active {
  display: flex;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
}

.card h2, .card h3 {
  font-size: 1.02rem;
  margin-bottom: 4px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

.muted {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

/* Alert Banner */
.alert-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.82rem;
}

/* Hero Calorie Card */
.hero-card {
  background: radial-gradient(circle at top, #17253b 0%, #111827 70%);
}

.calorie-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.cal-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.cal-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.cal-val {
  font-size: 1.45rem;
  font-weight: 800;
}

.cal-val.burned {
  color: var(--warning);
}

.ring-container {
  position: relative;
  width: 142px;
  height: 142px;
}

.progress-ring {
  width: 142px;
  height: 142px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 11;
}

.ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 11;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
}

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

.ring-sub {
  font-size: 0.65rem;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 700;
}

.ring-number {
  font-size: 1.75rem;
  font-weight: 900;
  color: #fff;
  line-height: 1.15;
}

.ring-target {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Macros */
.macros-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.macro-box {
  background: rgba(15, 23, 42, 0.6);
  padding: 9px 10px;
  border-radius: 12px;
}

.macro-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  margin-bottom: 6px;
}

.progress-bar {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar.lg {
  height: 11px;
  margin: 10px 0;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  transition: width 0.4s ease;
}

.progress-fill.protein { background: #10b981; }
.progress-fill.carbs { background: #3b82f6; }
.progress-fill.fat { background: #f59e0b; }
.progress-fill.exercise { background: linear-gradient(90deg, #f59e0b, #10b981); }
.progress-fill.water { background: var(--water); }

/* Camera Quick CTA */
.camera-cta-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: linear-gradient(135deg, #059669 0%, #0284c7 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 15px 18px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.25);
}

.camera-cta-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.camera-cta-icon {
  font-size: 2rem;
}

.camera-cta-left strong {
  display: block;
  font-size: 1.02rem;
}

.camera-cta-left small {
  font-size: 0.78rem;
  opacity: 0.9;
}

.camera-cta-arrow {
  font-size: 1.3rem;
  font-weight: 700;
}

/* Chips & Quick Buttons */
.quick-workout-btns, .duration-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip-btn {
  background: var(--bg-card-alt);
  border: 1px solid #334155;
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 11px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  flex: 1 1 auto;
  text-align: center;
}

.chip-btn:active {
  transform: scale(0.97);
}

.status-pill {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.success {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

/* Entries List */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(30, 41, 59, 0.55);
  padding: 11px 12px;
  border-radius: 13px;
}

.entry-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.entry-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #0f172a;
}

.entry-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.entry-info strong {
  display: block;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
}

.entry-info small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.entry-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.entry-kcal {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary);
}

.entry-kcal.burn {
  color: var(--warning);
}

.delete-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
}

/* Forms & Buttons */
.form-group {
  margin-bottom: 12px;
  flex: 1;
}

.form-row {
  display: flex;
  gap: 10px;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 600;
}

.input-field {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  color: var(--text-main);
  padding: 11px 12px;
  border-radius: 11px;
  font-size: 0.92rem;
  outline: none;
}

.input-field:focus {
  border-color: var(--primary);
}

.compact-select {
  width: auto;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-lg {
  padding: 14px 18px;
  font-size: 0.96rem;
}

.btn-sm {
  padding: 7px 11px;
  font-size: 0.78rem;
  border-radius: 9px;
}

.full-width {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #052e16;
}

.btn-secondary {
  background: var(--bg-card-alt);
  color: var(--text-main);
  border: 1px solid #334155;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-water {
  background: rgba(6, 182, 212, 0.2);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.4);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid #334155;
}

/* Camera Tab */
.camera-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.photo-preview-wrap {
  position: relative;
  margin-bottom: 14px;
  border-radius: 14px;
  overflow: hidden;
  max-height: 260px;
  background: #000;
  display: flex;
  justify-content: center;
}

#photoPreviewImg {
  max-height: 260px;
  width: 100%;
  object-fit: contain;
}

.remove-photo-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.res-macros-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.detected-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.detected-item-row {
  display: flex;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.7);
  padding: 8px 11px;
  border-radius: 9px;
  font-size: 0.82rem;
}

.advice-box {
  background: rgba(16, 185, 129, 0.12);
  border-left: 3px solid var(--primary);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.83rem;
  margin-bottom: 14px;
  line-height: 1.4;
}

.refine-box {
  background: rgba(30, 41, 59, 0.6);
  padding: 11px;
  border-radius: 12px;
  margin-bottom: 12px;
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--text-main);
  font-size: 0.85rem;
  cursor: pointer;
}

.favorites-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

/* Workout Tab & Live GPS Map */
.timer-card {
  background: linear-gradient(145deg, #111827, #17253b);
}

.walk-map-wrap {
  margin-bottom: 12px;
}

.walk-map {
  width: 100%;
  height: 230px;
  border-radius: 14px;
  border: 1px solid #334155;
  overflow: hidden;
  background: #0f172a;
  z-index: 5;
}

.map-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.live-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.live-metric-box {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
}

.live-metric-box small {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 3px;
}

.live-metric-box strong {
  font-size: 1.3rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.live-metric-box.highlight strong {
  color: #fbbf24;
}

.route-modal-card {
  max-width: 460px;
  text-align: left;
}

/* Super AMOLED Cep Modu (Pocket Lock) */
.pocket-overlay {
  position: fixed;
  inset: 0;
  background: #000000;
  color: #64748b;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  user-select: none;
}

.pocket-content {
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.pocket-badge {
  font-size: 0.72rem;
  letter-spacing: 1px;
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 5px 12px;
  border-radius: 99px;
}

.pocket-clock {
  font-size: 3.1rem;
  font-weight: 900;
  color: #475569;
  font-variant-numeric: tabular-nums;
}

.pocket-stats {
  display: flex;
  gap: 12px;
  font-size: 1.15rem;
  color: #64748b;
}

.pocket-stats strong {
  color: #94a3b8;
}

.pocket-hint {
  font-size: 0.75rem;
  color: #334155;
  line-height: 1.4;
}

.pocket-unlock-btn {
  margin-top: 20px;
  background: #090d16;
  border: 1px solid #1e293b;
  color: #64748b;
  padding: 14px 22px;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.timer-controls {
  display: flex;
  gap: 8px;
}

.timer-controls .btn {
  flex: 1;
}

.workout-type-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.wtype-btn {
  background: #0f172a;
  border: 1px solid #334155;
  color: var(--text-muted);
  border-radius: 13px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.wtype-btn span {
  font-size: 1.5rem;
}

.wtype-btn strong {
  font-size: 0.78rem;
}

.wtype-btn.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--primary);
  color: #fff;
}

/* Weekly Bars */
.weekly-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 12px;
  align-items: end;
  height: 120px;
  padding-top: 16px;
}

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

.wbar-track {
  width: 100%;
  max-width: 24px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  height: 75px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.wbar-fill {
  width: 100%;
  background: var(--primary);
  border-radius: 6px;
}

.wbar-day {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Profile & Weight Goal */
.weight-journey {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
  background: rgba(15, 23, 42, 0.6);
  padding: 12px;
  border-radius: 13px;
  margin-top: 10px;
}

.wj-item small {
  display: block;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.wj-item strong {
  font-size: 1.15rem;
}

.wj-item.current strong {
  color: var(--primary);
  font-size: 1.3rem;
}

.weight-log-box {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.weight-chart-wrap {
  margin-top: 14px;
}

.center-text {
  text-align: center;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 520px;
  margin: 0 auto;
  background: rgba(17, 24, 39, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 12px;
  cursor: pointer;
}

.nav-item.active {
  color: var(--primary);
  background: rgba(16, 185, 129, 0.1);
}

.nav-icon {
  font-size: 1.25rem;
}

.nav-label {
  font-size: 0.72rem;
  font-weight: 700;
}

/* Modal & Toast */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pin-icon {
  font-size: 2.5rem;
}

.error-text {
  color: var(--danger);
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--primary);
  padding: 10px 18px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 90;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.45);
  max-width: 92vw;
  text-align: center;
  line-height: 1.35;
}
