/* ===================== APPLE FITNESS STYLE ===================== */

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

:root {
  --bg: #000000;
  --bg-card: #1C1C1E;
  --bg-card-elevated: #2C2C2E;
  --bg-grouped: #1C1C1E;
  --text-primary: #FFFFFF;
  --text-secondary: #8E8E93;
  --text-tertiary: #636366;
  --accent: #FF375F;
  --accent-orange: #FF9F0A;
  --accent-green: #30D158;
  --accent-blue: #0A84FF;
  --accent-purple: #BF5AF2;
  --separator: rgba(84, 84, 88, 0.36);
  --fill: rgba(120, 120, 128, 0.24);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-rounded: -apple-system, 'SF Pro Rounded', 'SF Pro Display', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.4;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  max-width: 100vw;
}

/* ===================== LOGIN ===================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-card {
  text-align: center;
  padding: 48px 32px;
}

.login-title {
  font-family: var(--font-rounded);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.5;
}

#google-signin-btn {
  display: flex;
  justify-content: center;
}

/* ===================== USER BAR ===================== */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg);
}

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

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: none;
}

.user-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.signout-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 400;
  cursor: pointer;
  padding: 4px 0;
}

/* ===================== SUMMARY HEADER ===================== */
.hero {
  padding: 0 16px 16px;
  background: var(--bg);
  overflow: hidden;
}

.hero::before { display: none; }

.hero-inner {
  max-width: 680px;
  margin: 0 auto;
  position: relative;
}

.hero-title {
  font-family: var(--font-rounded);
  font-size: 2.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-primary);
}

.hero-tag {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 4px;
  letter-spacing: 0;
  text-transform: none;
}

.hero-fade { display: none; }

.hero-stats {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-stat-value {
  font-family: var(--font-rounded);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.hero-stat-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0;
}

/* ===================== W/KG BADGE ===================== */
.wtp-badge {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

.wtp-label {
  font-size: 0.5625rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.wtp-value {
  font-family: var(--font-rounded);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent-orange);
  line-height: 1;
}

/* ===================== THEME TOGGLE ===================== */
.theme-toggle { display: none; }
.theme-dot { display: none; }

/* ===================== TAB NAV ===================== */
.tab-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 8px 16px;
}

.tab-nav-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  background: var(--fill);
  border-radius: 8px;
  padding: 2px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 7px 16px;
  cursor: pointer;
  border-radius: 7px;
  transition: all var(--transition);
  text-transform: none;
  letter-spacing: 0;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ===================== TAB CONTENT ===================== */
.tab-content {
  display: none !important;
}

.tab-content.active {
  display: flex !important;
}

/* ===================== CONTAINER ===================== */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-x: hidden;
}

/* ===================== CARDS ===================== */
.card {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  transition: none;
}

.card:hover {
  border-color: transparent;
}

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

.card h2 {
  font-family: var(--font-rounded);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.card-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--fill);
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

/* ===================== SEGMENTED CONTROLS ===================== */
.chart-toggle,
.unit-toggle {
  display: flex;
  background: var(--fill);
  border-radius: 8px;
  padding: 2px;
  width: fit-content;
}

.unit-toggle {
  margin-top: 12px;
}

.toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-btn.active {
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.toggle-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* Timeline toggles */
.timeline-toggle {
  display: flex;
  background: var(--fill);
  border-radius: 8px;
  padding: 2px;
  width: fit-content;
  margin-bottom: 12px;
}

.tl-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.tl-btn.active {
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.tl-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* ===================== FORMS ===================== */
.form-row {
  display: flex;
  gap: 12px;
}

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

.form-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
}

input[type="date"],
input[type="number"],
input[type="text"] {
  background: var(--fill);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
  width: 100%;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

input:focus {
  background: rgba(120, 120, 128, 0.36);
}

input::placeholder {
  color: var(--text-tertiary);
}

input::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
}

button[type="submit"],
.btn-primary {
  width: 100%;
  margin-top: 16px;
  padding: 14px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button[type="submit"]:hover,
.btn-primary:hover {
  opacity: 0.85;
}

button[type="submit"]:active,
.btn-primary:active {
  transform: scale(0.98);
}

.form-message {
  margin-top: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  min-height: 20px;
}

.form-message.success {
  color: var(--accent-green);
}

.form-message.error {
  color: var(--accent);
}

/* ===================== WHEEL PICKER ===================== */
.desktop-only { display: block; }
.wheel-display { display: none; }

@media (max-width: 640px) {
  .desktop-only { display: none !important; }
  .wheel-display { display: flex !important; }
}

.wheel-display {
  background: var(--fill);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  align-items: baseline;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
}

.wheel-display span:first-child {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

.wheel-unit {
  font-size: 13px;
  color: var(--text-secondary);
}

.wheel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.wheel-overlay.active {
  display: flex;
}

.wheel-modal {
  width: 100%;
  max-width: 500px;
  background: #2C2C2E;
  border-radius: 14px 14px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 20px);
  animation: slideUp 0.3s ease;
}

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

.wheel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--separator);
}

.wheel-cancel {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.9375rem;
  cursor: pointer;
}

.wheel-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.wheel-done {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.wheel-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
  position: relative;
  overflow: hidden;
  gap: 0;
}

.wheel-col {
  height: 100%;
  width: 80px;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: y mandatory;
  overscroll-behavior-x: none;
  touch-action: pan-y;
  -ms-overflow-style: none;
  scrollbar-width: none;
  text-align: center;
}

.wheel-col::-webkit-scrollbar {
  display: none;
}

.wheel-col .wheel-item {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  font-weight: 500;
  color: var(--text-tertiary);
  scroll-snap-align: center;
  transition: color 0.15s, transform 0.15s;
  font-variant-numeric: tabular-nums;
}

.wheel-col .wheel-item.selected {
  color: var(--text-primary);
  font-weight: 600;
  transform: scale(1.05);
}

.wheel-dot {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 2px;
  align-self: center;
}

.wheel-label-overlay {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 8px;
  align-self: center;
}

.wheel-highlight {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 85%;
  height: 44px;
  background: rgba(120, 120, 128, 0.2);
  border-radius: 8px;
  pointer-events: none;
  z-index: -1;
}

.wheel-modal {
  position: relative;
}

.wheel-body {
  position: relative;
}

/* ===================== CHART ===================== */
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 280px;
  margin-top: 4px;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-empty,
.table-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 40px 0;
}

/* ===================== TABLE ===================== */
.table-wrapper {
  overflow-x: auto;
  margin-top: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0 8px 12px;
  border-bottom: 1px solid var(--separator);
}

thead th:last-child {
  text-align: right;
}

tbody tr {
  border-bottom: 1px solid var(--separator);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody td {
  padding: 12px 8px;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

tbody td:last-child {
  text-align: right;
}

.change-positive {
  color: var(--accent-green);
  font-weight: 600;
}

.change-negative {
  color: var(--accent);
  font-weight: 600;
}

.change-neutral {
  color: var(--text-tertiary);
}

.pr-badge {
  display: inline-block;
  background: var(--accent-orange);
  color: #000;
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: middle;
}

.btn-edit {
  background: var(--fill);
  border: none;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-edit:hover {
  color: var(--text-primary);
  background: rgba(120, 120, 128, 0.36);
}

/* ===================== WEIGHT TARGET ===================== */
.goal-toggle-btn {
  background: var(--fill);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.goal-toggle-btn:hover {
  color: var(--text-primary);
  background: rgba(120, 120, 128, 0.36);
}

.goal-form {
  margin-top: 12px;
}

.goal-save-btn {
  width: 100%;
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}

.goal-save-btn:hover {
  opacity: 0.85;
}

.goal-display {
  margin-top: 4px;
}

.goal-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.goal-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.goal-stat-value {
  font-family: var(--font-rounded);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
}

.goal-stat-value.accent {
  color: var(--accent-green);
}

.goal-stat-label {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.goal-stat-arrow {
  font-size: 1.125rem;
  color: var(--text-tertiary);
  margin-top: -12px;
}

.goal-stat-divider {
  width: 1px;
  height: 32px;
  background: var(--separator);
  margin-top: -8px;
}

.goal-detail {
  margin-top: 10px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.goal-detail strong {
  color: var(--accent-green);
}

.goal-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  padding: 8px 0;
}

/* ===================== DELETE BUTTON ===================== */
.btn-delete {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: transparent;
  color: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition);
}

.btn-delete:hover {
  background: rgba(255, 55, 95, 0.1);
}

/* ===================== MODAL ===================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: var(--bg-card-elevated);
  border: none;
  border-radius: 20px;
  padding: 28px;
  width: 90%;
  max-width: 380px;
  animation: modal-in 0.25s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal h3 {
  font-family: var(--font-rounded);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.edit-date {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

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

.modal-actions button {
  flex: 1;
  margin-top: 0;
}

.btn-secondary {
  padding: 12px;
  background: var(--fill);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition);
}

.btn-secondary:hover {
  background: rgba(120, 120, 128, 0.36);
}

/* ===================== FOOTER ===================== */
footer {
  border-top: 1px solid var(--separator);
  margin-top: 0;
}

.footer-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.footer-brand {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.ig-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 400;
  transition: color var(--transition);
}

.ig-link:hover {
  color: var(--accent);
}

footer p:last-child {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 640px) {
  .hero {
    padding: 0 16px 16px;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-stats {
    gap: 16px;
  }

  .hero-stat-value {
    font-size: 1.25rem;
  }

  .user-bar {
    padding: 10px 16px;
  }

  .tab-nav {
    padding: 6px 16px;
  }

  .container {
    padding: 10px 16px 80px;
    gap: 10px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
  }

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

  .chart-wrapper {
    height: 200px;
  }

  thead th:nth-child(3),
  tbody td:nth-child(3) {
    display: none;
  }

  #erg-table thead th:nth-child(4),
  #erg-table tbody td:nth-child(4) {
    display: none;
  }

  .wtp-badge {
    top: 0;
    right: 0;
    padding: 5px 8px;
  }

  .wtp-label {
    font-size: 0.5rem;
  }

  .wtp-value {
    font-size: 0.875rem;
  }

  .hero-tag {
    max-width: 70%;
  }

  .goal-stats {
    gap: 12px;
  }

  .modal {
    width: 92%;
    padding: 24px;
  }
}

/* ===================== ANIMATIONS ===================== */
.card {
  animation: fadeUp 0.35s ease both;
}

.card:nth-child(1) { animation-delay: 0.03s; }
.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.13s; }

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