/* ==========================================================================
   건강노트 (HealthFit Mobile App) Design System
   ========================================================================== */

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  --primary: #0284c7;
  --primary-gradient: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  --primary-light: #e0f2fe;
  --primary-dark: #0369a1;

  --accent-green: #10b981;
  --accent-green-light: #d1fae5;
  --accent-orange: #f59e0b;
  --accent-orange-light: #fef3c7;
  --accent-red: #ef4444;
  --accent-red-light: #fee2e2;
  --accent-purple: #8b5cf6;
  --accent-purple-light: #ede9fe;

  --bg-app: #f1f5f9;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-sub: #334155;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(2, 132, 199, 0.12);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-full: 9999px;
}

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #e2e8f0;
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ==========================================================================
   App Shell & Layout (Mobile Viewport 520px container)
   ========================================================================== */

.app-container {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: calc(12px + var(--sat)) 18px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.brand-icon {
  width: 20px;
  height: 20px;
  color: #0284c7;
}

.brand-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
}

.header-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

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

.streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-orange-light);
  border: 1px solid #fde68a;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  color: #b45309;
}

.icon-btn {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:active {
  transform: scale(0.95);
  background: var(--border-color);
}

/* Main Content Area */
.app-content-viewport {
  flex: 1;
  padding: 18px 16px calc(80px + var(--sab));
  overflow-y: auto;
  overflow-x: hidden;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-panel.active {
  display: block;
}

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

/* ==========================================================================
   Tab 1: Home Dashboard Widgets
   ========================================================================== */

/* 1. Score Hero Card */
.score-hero-card {
  background: var(--primary-gradient);
  border-radius: var(--radius-lg);
  padding: 22px 18px;
  color: white;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.score-hero-card::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  pointer-events: none;
}

.score-visual {
  position: relative;
  width: 90px;
  height: 90px;
  flex-shrink: 0;
}

.score-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 9;
}

.score-ring-bar {
  fill: none;
  stroke: #ffffff;
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 314;
  stroke-dashoffset: 47; /* 85% */
  transition: stroke-dashoffset 0.8s ease;
}

.score-text-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.score-num {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.score-unit {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 6px;
}

.score-info {
  flex: 1;
}

.score-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}

.score-title {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 4px;
}

.score-desc {
  font-size: 0.8rem;
  opacity: 0.9;
  line-height: 1.4;
}

/* Card Widget Common */
.widget-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.widget-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.widget-icon-pill {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.widget-icon-pill.icon-water {
  background: var(--primary-light);
  color: var(--primary);
}

.widget-icon-pill.icon-routine {
  background: var(--accent-purple-light);
  color: var(--accent-purple);
}

.widget-icon-pill.icon-weight {
  background: var(--accent-green-light);
  color: var(--accent-green);
}

.widget-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.widget-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Water Widget */
.water-current-stat {
  text-align: right;
}

.water-val {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
}

.water-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-bar-wrap {
  width: 100%;
  height: 10px;
  background: var(--bg-app);
  border-radius: var(--radius-full);
  margin: 14px 0 12px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.water-quick-buttons {
  display: flex;
  gap: 8px;
}

.btn-water-add {
  flex: 1;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid #bae6fd;
  border-radius: var(--radius-sm);
  padding: 9px;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-water-add:active {
  transform: scale(0.97);
  background: #bae6fd;
}

.btn-water-reset {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Routine Quick Checklist */
.routine-quick-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.routine-check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.routine-check-item.done {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.routine-check-item.done .routine-label {
  text-decoration: line-through;
  color: #94a3b8;
}

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

.custom-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid #cbd5e1;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: transparent;
}

.routine-check-item.done .custom-checkbox {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: white;
}

.routine-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.routine-tag {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-muted);
  font-weight: 600;
}

/* Tip Card */
.tip-card {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
}

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

.tip-badge {
  font-size: 0.75rem;
  font-weight: 800;
  color: #b45309;
}

.tip-refresh-btn {
  background: none;
  border: none;
  color: #b45309;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.tip-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #78350f;
  margin-bottom: 6px;
}

.tip-body {
  font-size: 0.82rem;
  color: #92400e;
  line-height: 1.5;
}

/* ==========================================================================
   Tab 2: Calculators Hub
   ========================================================================== */

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.page-sub {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ==========================================================================
   Tab 2: Calculators Hub (Revamped 2-Column Grid & Bottom Sheet Modal)
   ========================================================================== */

.hub-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hub-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.hub-count-badge i {
  width: 14px;
  height: 14px;
}

/* Category Filter Bar */
.calc-filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.calc-filter-bar::-webkit-scrollbar {
  display: none;
}

.calc-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: white;
  border: 1.5px solid var(--border-color);
  color: var(--text-sub);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

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

.calc-filter-btn.active {
  background: var(--text-main);
  color: white;
  border-color: var(--text-main);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

/* 2-Column Visual Card Hub Grid */
.calc-hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.calc-hub-card {
  background: white;
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 156px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.calc-hub-card:active {
  transform: scale(0.96);
}

.calc-hub-card.hidden {
  display: none !important;
}

/* Card Badge Row */
.card-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.hub-tag {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: -0.2px;
}

.card-arrow-icon {
  width: 16px;
  height: 16px;
  color: #94a3b8;
  transition: transform 0.2s;
}

.calc-hub-card:hover .card-arrow-icon,
.calc-hub-card:active .card-arrow-icon {
  transform: translate(2px, -2px);
  color: var(--primary);
}

/* Icon Box */
.card-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  transition: transform 0.2s;
}

.card-icon-box i {
  width: 22px;
  height: 22px;
}

.calc-hub-card:hover .card-icon-box {
  transform: scale(1.08);
}

/* Card Title & Desc */
.card-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.card-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
  flex: 1;
}

/* Card Action Bar */
.card-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 700;
  color: #0284c7;
  border-top: 1px dashed #f1f5f9;
  padding-top: 8px;
}

.card-action-bar i {
  width: 14px;
  height: 14px;
}

/* Theme Colors */
.theme-sky {
  border-color: #bae6fd;
}
.theme-sky .hub-tag { background: #e0f2fe; color: #0284c7; }
.theme-sky .card-icon-box { background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%); color: #0284c7; }
.theme-sky .card-action-bar { color: #0284c7; }

.theme-orange {
  border-color: #fed7aa;
}
.theme-orange .hub-tag { background: #ffedd5; color: #ea580c; }
.theme-orange .card-icon-box { background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%); color: #ea580c; }
.theme-orange .card-action-bar { color: #ea580c; }

.theme-cyan {
  border-color: #a5f3fc;
}
.theme-cyan .hub-tag { background: #cffafe; color: #0891b2; }
.theme-cyan .card-icon-box { background: linear-gradient(135deg, #cffafe 0%, #a5f3fc 100%); color: #0891b2; }
.theme-cyan .card-action-bar { color: #0891b2; }

.theme-emerald {
  border-color: #a7f3d0;
}
.theme-emerald .hub-tag { background: #d1fae5; color: #059669; }
.theme-emerald .card-icon-box { background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%); color: #059669; }
.theme-emerald .card-action-bar { color: #059669; }

.theme-amber {
  border-color: #fde68a;
}
.theme-amber .hub-tag { background: #fef3c7; color: #d97706; }
.theme-amber .card-icon-box { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); color: #d97706; }
.theme-amber .card-action-bar { color: #d97706; }

.theme-rose {
  border-color: #fecdd3;
}
.theme-rose .hub-tag { background: #ffe4e6; color: #e11d48; }
.theme-rose .card-icon-box { background: linear-gradient(135deg, #ffe4e6 0%, #fecdd3 100%); color: #e11d48; }
.theme-rose .card-action-bar { color: #e11d48; }

.theme-violet {
  border-color: #ddd6fe;
}
.theme-violet .hub-tag { background: #ede9fe; color: #7c3aed; }
.theme-violet .card-icon-box { background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%); color: #7c3aed; }
.theme-violet .card-action-bar { color: #7c3aed; }

.theme-indigo {
  border-color: #c7d2fe;
}
.theme-indigo .hub-tag { background: #e0e7ff; color: #4f46e5; }
.theme-indigo .card-icon-box { background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%); color: #4f46e5; }
.theme-indigo .card-action-bar { color: #4f46e5; }

/* ==========================================================================
   Bottom Sheet Modal System for Calculators
   ========================================================================== */

.calc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.calc-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.calc-modal-sheet {
  background: white;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  border-radius: 28px 28px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom, 16px);
  overflow: hidden;
}

.calc-modal-backdrop.open .calc-modal-sheet {
  transform: translateY(0);
}

.modal-handle-bar {
  width: 38px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 4px;
  margin: 12px auto 6px;
  flex-shrink: 0;
}

.modal-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 14px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.btn-modal-back {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-modal-back:active {
  background: #e2e8f0;
}

.btn-modal-back i {
  width: 15px;
  height: 15px;
}

.modal-category-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.btn-modal-close {
  background: var(--bg-app);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-modal-close:hover,
.btn-modal-close:active {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-modal-close i {
  width: 18px;
  height: 18px;
}

.modal-scroll-content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 30px;
  flex: 1;
}

/* Individual Calc Box inside Modal */
.calc-box {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.calc-box.active {
  display: block;
}

.calc-box-header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.calc-box-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

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

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group.full-col {
  grid-column: span 2;
}

.input-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-sub);
}

.input-group input,
.select-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  background: var(--bg-app);
  transition: border-color 0.2s;
  font-family: inherit;
}

.input-group input:focus,
.select-input:focus {
  border-color: var(--primary);
  background: white;
}

.radio-pill-group {
  display: flex;
  gap: 8px;
}

.radio-pill {
  flex: 1;
  position: relative;
  cursor: pointer;
}

.radio-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-pill span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-color);
  background: var(--bg-app);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.2s;
}

.radio-pill input:checked + span {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

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

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.btn-secondary {
  background: var(--bg-app);
  color: var(--text-sub);
  border: 1px solid var(--border-color);
}

.btn-danger {
  background: var(--accent-red);
  color: white;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 5px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.text-link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}

/* Results Box */
.calc-result-area {
  margin-top: 18px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.result-main-val {
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  margin: 6px 0;
  line-height: 1;
}

.result-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.result-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
  text-align: left;
}

.result-detail-item {
  background: white;
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: 8px;
}

.result-detail-item .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
}

.result-detail-item .value {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

/* Drink Selector for Caffeine */
.drink-selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.drink-card {
  background: var(--bg-app);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drink-card:active {
  transform: scale(0.96);
}

.drink-card.selected {
  border-color: #f59e0b;
  background: #fef3c7;
}

.drink-emoji {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 4px;
}

.drink-name {
  font-size: 0.82rem;
  font-weight: 700;
  display: block;
}

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

/* Supplement Grid */
.supp-check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.supp-check-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-app);
  border: 1.5px solid var(--border-color);
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.supp-check-card input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.supp-check-card.checked {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 700;
}

/* ==========================================================================
   Tab 3: Routine Planner
   ========================================================================== */

.routine-progress-summary-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.summary-left {
  display: flex;
  flex-direction: column;
}

.summary-label {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.summary-percent {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
}

.summary-bar-container {
  flex: 1;
  height: 10px;
  background: var(--bg-app);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.summary-bar-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.routine-time-group {
  margin-bottom: 22px;
}

.time-group-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.routine-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.routine-card-item {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.routine-card-item.done {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.routine-card-item.done .card-routine-name {
  text-decoration: line-through;
  color: #94a3b8;
}

.routine-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-routine-name {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-routine-tip {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   Tab 4: Logs & Chart
   ========================================================================== */

.chart-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}

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

.chart-title {
  font-size: 1.05rem;
  font-weight: 800;
}

.chart-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chart-canvas-wrap {
  width: 100%;
  height: 200px;
}

.chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.log-timeline-section {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

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

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.timeline-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.timeline-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.timeline-content {
  flex: 1;
}

.timeline-title {
  font-size: 0.88rem;
  font-weight: 700;
}

.timeline-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.timeline-time {
  font-size: 0.72rem;
  color: #94a3b8;
  white-space: nowrap;
}

/* ==========================================================================
   Tab 5: Quiz & Encyclopedia
   ========================================================================== */

.quiz-hero-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 20px 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}

.quiz-badge {
  font-size: 0.76rem;
  font-weight: 800;
  color: #15803d;
  margin-bottom: 8px;
}

.quiz-question {
  font-size: 1.05rem;
  font-weight: 800;
  color: #14532d;
  line-height: 1.4;
  margin-bottom: 14px;
}

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

.btn-quiz {
  flex: 1;
  background: white;
  border: 1.5px solid #86efac;
  color: #15803d;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.quiz-explanation {
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.86rem;
  color: #14532d;
  line-height: 1.5;
}

.encyclopedia-heading {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.guide-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-card-item {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.guide-card-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.guide-card-title {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.guide-card-snippet {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ==========================================================================
   Bottom Navigation Bar
   ========================================================================== */

.bottom-nav-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  height: calc(62px + var(--sab));
  padding-bottom: var(--sab);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 12px;
  transition: all 0.2s;
  font-family: inherit;
}

.nav-item i {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

.nav-item.active {
  color: var(--primary);
  transform: translateY(-2px);
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: white;
  border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(24px + var(--sab));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-footer .btn {
  flex: 1;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.toggle-btn {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}

.toggle-btn.active {
  background: var(--accent-green);
  color: white;
  border-color: var(--accent-green);
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 12px 0;
}
