:root {
  --bg-base: #08090c;
  --bg-card: #12151e;
  --bg-elevated: #191d29;
  --bg-pill: #222736;
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text-primary: #f5f7fa;
  --text-secondary: #9aa3b5;
  --text-muted: #5e677a;

  --lime: #b8ff01;
  --lime-dim: rgba(184, 255, 1, 0.14);
  --lime-glow: rgba(184, 255, 1, 0.32);

  --orange: #ff5e1a;
  --orange-dim: rgba(255, 94, 26, 0.15);
  --orange-glow: rgba(255, 94, 26, 0.35);

  --cyan: #00e5ff;
  --cyan-dim: rgba(0, 229, 255, 0.14);
  --cyan-glow: rgba(0, 229, 255, 0.32);

  --pink: #ff2d6f;
  --pink-dim: rgba(255, 45, 111, 0.15);

  --amber: #ffb800;
  --danger: #ff4757;

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  height: 100%;
  background: #040507;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Mobile shell centered on desktop, full screen on phone */
#app-shell {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  margin: 0 auto;
  background: radial-gradient(circle at 50% -10%, rgba(184, 255, 1, 0.06), transparent 45%), var(--bg-base);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.85);
}

@media (min-width: 500px) {
  #app-shell {
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
  }
}

/* Top Bar */
.top-bar {
  padding: calc(12px + var(--safe-top)) 16px 10px;
  background: rgba(8, 9, 12, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 20;
  flex-shrink: 0;
}

.top-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 12px var(--lime);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--lime);
  background: var(--lime-dim);
  padding: 2px 7px;
  border-radius: 99px;
}

.date-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 99px;
  padding: 3px 5px;
}

.date-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.date-nav-btn:active {
  background: var(--bg-pill);
  color: var(--lime);
}

.date-label-btn {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 8px;
  cursor: pointer;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.94);
  color: var(--lime);
}

/* Main View */
.main-view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 15px calc(92px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.main-view::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 16px;
  position: relative;
}

.card-glow-lime {
  background: linear-gradient(155deg, rgba(184, 255, 1, 0.08) 0%, var(--bg-card) 48%);
  border-color: rgba(184, 255, 1, 0.18);
}

.card-glow-orange {
  background: linear-gradient(155deg, rgba(255, 94, 26, 0.09) 0%, var(--bg-card) 50%);
  border-color: rgba(255, 94, 26, 0.2);
}

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

.card-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}

.badge-lime {
  background: var(--lime-dim);
  color: var(--lime);
}

.badge-orange {
  background: var(--orange-dim);
  color: var(--orange);
}

.badge-cyan {
  background: var(--cyan-dim);
  color: var(--cyan);
}

.badge-muted {
  background: var(--bg-pill);
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.15s ease;
}

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

.btn-lime {
  background: var(--lime);
  color: #090b0e;
  box-shadow: 0 4px 18px rgba(184, 255, 1, 0.22);
}

.btn-orange {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 4px 18px rgba(255, 94, 26, 0.25);
}

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 99px;
}

.btn-block {
  width: 100%;
}

/* Apple Fitness Triple Ring Hero */
.rings-hero {
  display: grid;
  grid-template-columns: 146px 1fr;
  align-items: center;
  gap: 16px;
}

.rings-svg-wrap {
  position: relative;
  width: 146px;
  height: 146px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rings-center-label {
  position: absolute;
  text-align: center;
  pointer-events: none;
}

.rings-center-val {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}

.rings-center-unit {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.rings-metrics {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ring-stat-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ring-stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.ring-stat-val {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.ring-stat-val small {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Deficit Banner */
.deficit-strip {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.deficit-cell-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.deficit-cell-val {
  font-size: 15px;
  font-weight: 800;
  margin-top: 2px;
}

/* Macro Bars */
.macro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.macro-box {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 10px;
  border: 1px solid var(--border-subtle);
}

.macro-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  margin-bottom: 6px;
}

.macro-name {
  font-weight: 700;
  color: var(--text-secondary);
}

.macro-nums {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}

.macro-nums span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Steps & Cardio */
.steps-box {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 12px;
  border: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}

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

.steps-big {
  font-size: 22px;
  font-weight: 800;
  color: var(--cyan);
}

.steps-big small {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.quick-chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 9px;
}

.chip-btn {
  background: var(--bg-pill);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 5px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip-btn:active {
  background: var(--cyan-dim);
  color: var(--cyan);
  border-color: var(--cyan);
}

.cardio-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 8px;
}

.cardio-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
}

/* Weekly Split Strip */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 3px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.day-pill.active {
  background: var(--lime-dim);
  border-color: var(--lime);
  box-shadow: 0 0 14px rgba(184, 255, 1, 0.15);
}

.day-pill-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.day-pill.active .day-pill-name {
  color: var(--lime);
}

.day-pill-tag {
  font-size: 10px;
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Workout Exercise Cards */
.exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 14px;
}

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

.exercise-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exercise-name {
  font-size: 15px;
  font-weight: 800;
}

.sets-header,
.set-row {
  display: grid;
  grid-template-columns: 38px 1fr 1fr 44px;
  gap: 8px;
  align-items: center;
}

.sets-header {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 4px 6px;
  text-align: center;
}

.set-row {
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 5px;
  background: var(--bg-elevated);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.set-row.completed {
  background: rgba(184, 255, 1, 0.08);
  border-color: rgba(184, 255, 1, 0.24);
}

.set-index {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary);
  text-align: center;
}

.set-row.completed .set-index {
  color: var(--lime);
}

.set-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 16px; /* Prevents iOS zoom on focus */
  font-weight: 700;
  text-align: center;
  padding: 6px 4px;
  font-family: inherit;
}

.set-input:focus {
  outline: none;
  border-color: var(--lime);
}

.check-btn {
  width: 36px;
  height: 34px;
  margin: 0 auto;
  border-radius: 9px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.check-btn.done {
  background: var(--lime);
  border-color: var(--lime);
  color: #08090c;
  box-shadow: 0 0 12px var(--lime-glow);
}

.exercise-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

/* Diet Meals */
.meal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.food-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  gap: 10px;
}

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

.food-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.food-macros {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.food-kcal {
  font-size: 14px;
  font-weight: 800;
  color: var(--orange);
  white-space: nowrap;
}

.del-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px 6px;
  cursor: pointer;
}

.del-btn:active {
  color: var(--danger);
}

/* Segmented Tabs (Charts / Filters) */
.seg-tabs {
  display: flex;
  background: var(--bg-elevated);
  border-radius: 11px;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--border-subtle);
}

.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn.active {
  background: var(--bg-pill);
  color: var(--lime);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* SVG Chart Container */
.chart-box {
  margin-top: 12px;
  width: 100%;
  overflow: hidden;
}

.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 8px;
  justify-content: center;
}

/* Bottom Navigation */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 10px calc(10px + var(--safe-bottom));
  background: rgba(12, 14, 20, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 30;
}

.nav-item {
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 0;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.12s ease;
}

.nav-item .nav-icon {
  width: 23px;
  height: 23px;
}

.nav-item.active {
  color: var(--lime);
}

.nav-item.active .nav-icon {
  filter: drop-shadow(0 0 8px var(--lime-glow));
}

.nav-item:active {
  transform: scale(0.92);
}

/* Bottom Sheet Modal */
.modal-root {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.16s ease;
}

.modal-root.hidden {
  display: none;
}

.sheet {
  width: 100%;
  max-height: 88dvh;
  background: var(--bg-card);
  border-top: 1px solid var(--border-strong);
  border-radius: 24px 24px 0 0;
  padding: 14px 18px calc(22px + var(--safe-bottom));
  overflow-y: auto;
  animation: slideUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 99px;
  margin: 0 auto 14px;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.sheet-title {
  font-size: 17px;
  font-weight: 800;
}

/* Forms */
.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-input,
.form-select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 16px; /* Prevents iOS auto-zoom */
  padding: 10px 12px;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--lime);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

/* Preset Library Grid */
.preset-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
}

.preset-item:active,
.preset-item.selected {
  border-color: var(--lime);
  background: var(--lime-dim);
}

/* Empty State */
.empty-hint {
  text-align: center;
  padding: 16px 10px;
  color: var(--text-muted);
  font-size: 12.5px;
}

/* Toast */
.toast-root {
  position: absolute;
  top: calc(64px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: max-content;
  max-width: 90%;
}

.toast {
  background: rgba(25, 29, 41, 0.96);
  border: 1px solid var(--lime);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 99px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
