/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { background: none; border: none; cursor: pointer; font: inherit; color: inherit; }
ul { list-style: none; }
svg { display: block; }
a { color: inherit; text-decoration: none; }

/* ── Variables ── */
:root {
  --bg: #000000;
  --surface: #1C1C1E;
  --surface2: #2C2C2E;
  --surface3: #3A3A3C;
  --border: rgba(84, 84, 88, 0.6);
  --text: #FFFFFF;
  --text2: #8E8E93;
  --text3: #48484A;
  --accent: #32D74B;
  --blue: #0A84FF;
  --orange: #FF9F0A;
  --red: #FF453A;
  --purple: #BF5AF2;
  --header-h: 60px;
  --tab-h: 50px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Base ── */
html {
  height: 100%;
  background: var(--bg);
}

body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ── App shell ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
}

/* ── Header ── */
#app-header {
  position: relative;
  z-index: 10;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--border);
  padding-top: var(--safe-top);
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--header-h);
}

#header-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.progress-badge {
  background: var(--surface2);
  color: var(--text2);
  font-size: 14px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 20px;
  transition: background 0.25s, color 0.25s;
}
.progress-badge.hidden { display: none; }
.progress-badge.complete {
  background: var(--accent);
  color: #000;
}

/* ── Main scroll ── */
#main-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ── Panels ── */
.panel {
  display: none;
  padding: 16px 16px;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 24px);
}
.panel.active { display: block; }

/* ── Tab Bar ── */
#tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: rgba(22, 22, 24, 0.88);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 0.5px solid var(--border);
  display: flex;
  padding-bottom: var(--safe-bottom);
  z-index: 20;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 0;
  color: var(--text3);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1px;
  transition: color 0.15s;
  min-height: var(--tab-h);
}
.tab.active { color: var(--blue); }
.tab-icon { width: 24px; height: 24px; }

/* ── Water Section ── */
.water-section {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
}

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

.section-title {
  font-size: 15px;
  font-weight: 600;
}

.water-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

.water-bar-track {
  height: 5px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}

.water-bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 3px;
  width: 0%;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.flask-row {
  display: flex;
  gap: 6px;
  justify-content: space-between;
}

.flask-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--surface3);
  border-radius: 10px;
  padding: 4px 2px;
  transition: color 0.2s, transform 0.12s;
  min-height: 52px;
}
.flask-btn svg { width: 100%; max-width: 44px; height: auto; }
.flask-btn.filled { color: var(--blue); }
.flask-btn:active { transform: scale(0.88); }

/* ── Schedule blocks ── */
.block-card {
  background: var(--surface);
  border-radius: 16px;
  margin-bottom: 12px;
  overflow: hidden;
}

.block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px 11px;
  border-left: 3px solid var(--block-color, var(--accent));
}

.block-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--block-color, var(--accent));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.block-label {
  font-size: 15px;
  font-weight: 600;
}

.block-items { padding: 0; }

.check-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  border-top: 0.5px solid var(--border);
  transition: background 0.1s;
  min-height: 60px;
}
.check-item:active { background: var(--surface2); }

.check-btn {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  padding: 0;
  color: var(--surface3);
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.check-btn svg { width: 28px; height: 28px; }

.check-ring {
  transition: stroke 0.2s;
}
.check-mark {
  opacity: 0;
  transition: opacity 0.2s;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: opacity 0.2s, stroke-dashoffset 0.25s ease;
}

.check-item.checked .check-btn { color: var(--accent); }
.check-item.checked .check-ring { stroke: var(--accent); }
.check-item.checked .check-mark {
  opacity: 1;
  stroke-dashoffset: 0;
}

.item-text { flex: 1; min-width: 0; }

.item-name {
  display: block;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.3;
  transition: color 0.2s;
}

.item-detail {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-top: 3px;
  line-height: 1.3;
}

.check-item.checked .item-name {
  text-decoration: line-through;
  color: var(--text2);
}

/* ── Meals Tab ── */
.macro-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 18px 16px;
  margin-bottom: 16px;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.macro-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.macro-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.macro-lbl {
  font-size: 11px;
  color: var(--text2);
  text-align: center;
  font-weight: 500;
}

.meal-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

.meal-head { margin-bottom: 12px; }

.meal-time-tag {
  display: inline-block;
  background: var(--surface2);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
}

.meal-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
}

.ingredient-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 11px 0;
  border-top: 0.5px solid var(--border);
  font-size: 15px;
  line-height: 1.3;
}
.ingredient-list li:first-child { border-top: none; padding-top: 0; }

.ing-detail {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Supplements Tab ── */
.supp-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  border-left: 3px solid var(--group-color, var(--accent));
}

.supp-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--group-color, var(--accent));
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.supp-list li {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 0;
  border-top: 0.5px solid var(--border);
}
.supp-list li:first-child { border-top: none; padding-top: 0; }

.supp-name {
  font-size: 16px;
  font-weight: 500;
}

.supp-dose {
  font-size: 13px;
  color: var(--text2);
}

/* ── Notification Bar ── */
.notif-bar {
  position: fixed;
  top: calc(var(--safe-top) + var(--header-h));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 398px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 30;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.notif-bar.hidden { display: none; }

.notif-text {
  flex: 1;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.3;
}

.notif-allow-btn {
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 9px;
  white-space: nowrap;
  flex-shrink: 0;
}

.notif-close-btn {
  color: var(--text2);
  font-size: 15px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}
.notif-close-btn:active { background: var(--surface2); }
