/* ========================================
   GREEN DAYS — Big Type / Grainy Gradient
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;900&display=swap');

:root {
  --black: #0a0a0a;
  --white: #f5f4f0;
  --card-bg: rgba(255, 255, 255, 0.5);
  --card-border: rgba(255, 255, 255, 0.25);
  --gray-200: #d4d0c8;
  --gray-400: #9e9a90;
  --gray-600: #6b6660;
  --red: #e04333;
  --yellow: #e0b82e;
  --green: #28a045;
  --sans: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: var(--sans);
  color: var(--black);
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
  background: #c8c0b4;
}

/* ============ BACKGROUND ============ */
#bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#bg-gradient canvas {
  width: 100%;
  height: 100%;
}

#grain-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
}

#grain-overlay svg { width: 100%; height: 100%; }

/* ============ APP ============ */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 2;
}

/* ============ NAV ============ */
#nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 390px;
  background: rgba(200, 192, 180, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 10;
}

.nav-btn {
  flex: 1;
  padding: 14px 0;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gray-400);
  cursor: pointer;
  transition: color 0.2s;
}

.nav-btn.active {
  color: var(--black);
  font-weight: 800;
}

/* ============ VIEWS ============ */
.view {
  display: none;
  padding: 16px 16px 56px 16px;
  flex: 1;
}

.view.active {
  display: flex;
  flex-direction: column;
}

/* ============ BRAND ============ */
.brand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.brand-name {
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.brand-date {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-600);
  font-variant-numeric: tabular-nums;
}

/* ============ LOG VIEW ============ */
.log-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Initial state: type selector fills screen */
.log-content > .log-section:first-child {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.log-content > .log-section:first-child .type-group {
  flex: 1;
}

/* Once a type is selected, shrink back */
.log-content.has-selection > .log-section:first-child {
  flex: none;
}

.log-content.has-selection > .log-section:first-child .type-group {
  flex: none;
}

.log-section {
  margin-bottom: 10px;
  animation: sectionIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.log-section:nth-child(2) { animation-delay: 0.04s; }
.log-section:nth-child(3) { animation-delay: 0.08s; }
.log-section:nth-child(4) { animation-delay: 0.12s; }

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

.section-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--black);
  margin-bottom: 6px;
  transition: color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.section-label.label-red { color: var(--red); }
.section-label.label-yellow { color: var(--yellow); }
.section-label.label-green { color: var(--green); }

/* --- Day type toggle (big) --- */
.type-group {
  display: flex;
  gap: 8px;
}

.type-btn {
  flex: 1;
  min-height: 48px;
  padding: 16px 8px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.type-btn:hover {
  border-color: var(--black);
  background: rgba(255, 255, 255, 0.7);
  transform: scale(1.02);
}

.type-btn.selected {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
  transform: scale(1.02);
}

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

/* --- Rest type (centered pair) --- */
.rest-group {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.rest-group .option-btn {
  flex: none;
  width: 140px;
}

/* --- Option buttons (training type) --- */
.opt-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.option-btn {
  padding: 10px 6px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}

.option-btn:hover {
  border-color: var(--black);
  background: rgba(255, 255, 255, 0.7);
  transform: scale(1.02);
}

.option-btn.selected {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
  transform: scale(1.02);
}

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

/* Full-width option for odd items */
.opt-group .option-btn.full-width {
  grid-column: 1 / -1;
}

/* --- Color buttons (big) --- */
.color-group {
  display: flex;
  gap: 8px;
}

.color-btn {
  flex: 1;
  height: 40px;
  border: 3px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0.22;
}

.color-btn.red { background: var(--red); }
.color-btn.yellow { background: var(--yellow); }
.color-btn.green { background: var(--green); }

.color-btn:hover {
  opacity: 0.5;
  transform: scale(1.04);
}

.color-btn.selected {
  opacity: 1;
  border-color: var(--black);
  transform: scale(1.04);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.color-btn:active {
  transform: scale(0.95);
}

/* --- Save button --- */
.save-btn {
  width: 100%;
  padding: 14px;
  margin-top: 4px;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 14px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.save-btn:not(:disabled):hover {
  opacity: 0.85;
  transform: scale(1.01);
}

.save-btn:not(:disabled):active {
  transform: scale(0.98);
}

/* --- Hidden sections (display toggled by JS) --- */
.log-section[data-section] {
  display: none;
}

.log-section[data-section].visible {
  display: block;
}

/* ============ LOGGED STATE ============ */
.logged-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}

.logged-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.12);
  animation: pop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.logged-icon.red { background: var(--red); }
.logged-icon.yellow { background: var(--yellow); }
.logged-icon.green { background: var(--green); }
.logged-icon.rest { background: var(--gray-400); }

.logged-label {
  font-size: 12px;
  color: var(--gray-600);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.logged-detail {
  font-size: 26px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.5px;
}

.undo-btn {
  margin-top: 8px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
}

.undo-btn:hover { border-color: var(--black); color: var(--black); }

/* ============ PREDICT VIEW ============ */
.predict-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.predict-hero {
  margin-bottom: 16px;
}

.big-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.mega-text {
  font-size: 48px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -2px;
  text-transform: uppercase;
  transition: color 0.6s ease;
}

.hero-number {
  font-size: 110px;
  font-weight: 900;
  line-height: 0.85;
  letter-spacing: -6px;
  transition: color 0.6s ease;
}

.hero-percent {
  font-size: 30px;
  font-weight: 300;
  letter-spacing: -1px;
  opacity: 0.35;
  vertical-align: super;
}

/* Rest alternative hint */
.rest-hint {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  padding: 10px 0;
  line-height: 1.4;
  animation: sectionIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.rest-hint:empty { display: none; }

.rest-hint .hint-prob {
  font-weight: 900;
  transition: color 0.4s ease;
}

/* Quote */
.quote-block {
  margin-top: 12px;
  padding: 18px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 14px;
  animation: sectionIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

.quote-text {
  display: block;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.3px;
}

.quote-sub {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gray-600);
}

/* Chart */
.chart-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px;
  margin-top: 12px;
  animation: sectionIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both;
}

.chart-container {
  position: relative;
  width: 100%;
  margin-top: 8px;
}

#week-chart {
  width: 100%;
  height: 100px;
  display: block;
}

.chart-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area { opacity: 0.1; }
.chart-dot-actual { fill: var(--black); }
.chart-dot-predicted { fill: var(--gray-400); stroke: var(--black); stroke-width: 1.5; }

.chart-labels {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px 0;
}

.chart-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-label.today {
  color: var(--black);
  font-weight: 800;
}

.chart-zone-line {
  stroke: rgba(0, 0, 0, 0.06);
  stroke-width: 0.5;
  stroke-dasharray: 3 4;
}

/* Factors */
#factors {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 4px 16px;
  animation: sectionIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both;
}

#factors:empty { display: none; }

.factor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  font-size: 13px;
}

.factor-row:last-child { border-bottom: none; }
.factor-label { color: var(--gray-600); font-weight: 500; }
.factor-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.factor-value.positive { color: var(--green); }
.factor-value.negative { color: var(--red); }
.factor-value.neutral { color: var(--yellow); }

/* ============ HISTORY / CALENDAR ============ */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 10px;
}

.calendar-card { margin-bottom: 14px; }

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.cal-nav {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--gray-600);
  cursor: pointer;
  padding: 4px 8px;
  font-weight: 700;
  transition: color 0.15s;
}

.cal-nav:hover { color: var(--black); }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gray-400);
  margin-bottom: 6px;
}

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

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  color: var(--gray-600);
}

.cal-day.empty { visibility: hidden; }
.cal-day.future { opacity: 0.25; }
.cal-day.today { font-weight: 900; color: var(--black); }
.cal-day.has-log { color: var(--white); font-weight: 700; }
.cal-day.log-green { background: var(--green); }
.cal-day.log-yellow { background: var(--yellow); color: var(--black); }
.cal-day.log-red { background: var(--red); }
.cal-day.log-rest { background: var(--gray-400); }

.cal-day.pastable, .cal-day.has-log { cursor: pointer; transition: all 0.15s; }
.cal-day.pastable:hover { background: rgba(0, 0, 0, 0.06); }
.cal-day.has-log:hover { opacity: 0.75; }

.history-row.clickable { cursor: pointer; transition: opacity 0.15s; }
.history-row.clickable:hover { opacity: 0.65; }

.history-list-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 4px 16px;
}

.history-list-card:empty { display: none; }

.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.history-row:last-child { border-bottom: none; }

.history-date {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  min-width: 72px;
  font-variant-numeric: tabular-nums;
}

.history-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.history-dot.red { background: var(--red); }
.history-dot.yellow { background: var(--yellow); }
.history-dot.green { background: var(--green); }
.history-dot.rest { background: var(--gray-400); }

.history-info { font-size: 13px; font-weight: 500; flex: 1; }

.history-empty {
  text-align: center;
  color: var(--gray-400);
  padding: 40px 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.data-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.data-btn {
  flex: 1;
  padding: 12px;
  background: rgba(255, 255, 255, 0.35);
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
}

.data-btn:hover { border-color: var(--black); color: var(--black); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 390px;
  padding: 24px 20px 32px;
  animation: slideModal 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal-title {
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
}

/* Modal uses same btn styles */
.modal .type-btn,
.modal .option-btn {
  padding: 12px 6px;
  font-size: 13px;
}

.modal .btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.modal .btn-group .type-btn,
.modal .btn-group .option-btn {
  flex: 1;
  min-width: 70px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.04);
  border: 2px solid rgba(0, 0, 0, 0.06);
}

.modal .btn-group .type-btn.selected,
.modal .btn-group .option-btn.selected {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

.modal .btn-group.tri { gap: 8px; }

.modal .color-btn {
  height: 40px;
  border-radius: 8px;
}

.modal .save-btn {
  border-radius: 12px;
}

/* ============ ONBOARDING ============ */
.onboarding {
  position: fixed;
  inset: 0;
  background: #c8c0b4;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 390px;
  margin: 0 auto;
  animation: fadeIn 0.4s ease;
}

.onboarding-content {
  width: 100%;
  height: 100%;
  padding: 60px 28px 40px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.onboarding-slide {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: slideUpFade 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.onboarding-slide.active { display: flex; }

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

.onboarding-num {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--gray-600);
  margin-bottom: 40px;
}

.onboarding-title {
  font-size: 56px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -2px;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.onboarding-body {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--gray-600);
  max-width: 320px;
}

.onb-green { color: var(--green); font-weight: 700; }
.onb-yellow { color: var(--yellow); font-weight: 700; }
.onb-red { color: var(--red); font-weight: 700; }

.onboarding-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.onboarding-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.15);
  transition: all 0.25s;
}

.onboarding-dots .dot.active {
  background: var(--black);
  width: 28px;
  border-radius: 4px;
}

.onboarding-next {
  width: 100%;
  padding: 18px;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 14px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s;
}

.onboarding-next:hover { opacity: 0.85; }
.onboarding-next:active { transform: scale(0.98); }

.onboarding-skip {
  position: absolute;
  top: 24px;
  right: 24px;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  cursor: pointer;
  padding: 8px;
}

/* ============ UPDATE BANNER ============ */
.update-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  width: 100%;
  max-width: 390px;
  background: var(--black);
  color: var(--white);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 150;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideDown {
  to { transform: translateX(-50%) translateY(0); }
}

.update-banner-text {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.update-banner-btn {
  background: var(--white);
  color: var(--black);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  cursor: pointer;
  flex-shrink: 0;
}

.update-banner-btn:active { opacity: 0.8; }

/* ============ CONFIRMATION ============ */
.saved-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 192, 180, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 100;
  animation: fadeIn 0.15s ease;
}

.saved-overlay .checkmark {
  font-size: 56px;
  animation: pop 0.3s ease;
}

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

@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
