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

:root {
  --bg: #1e2a3a;
  --bg-elevated: #26374a;
  --bg-elevated-2: #2f4258;
  --text: #f4f7fb;
  --text-dim: #a8b6c8;
  --text-faint: #6f8098;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #7c8cf8;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;

  --sleep: #7c8cf8;
  --love: #f87171;
  --hobbies: #fbbf24;
  --school: #34d399;
  --work: #60a5fa;
  --fitness: #fb923c;
  --social: #a78bfa;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100dvh;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(120% 120% at 50% -10%, #24374d 0%, var(--bg) 55%, #16202c 100%);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

button {
  font-family: inherit;
}

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

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

.btn-primary {
  background: var(--accent);
  color: #101728;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: default;
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  padding: 10px 16px;
}

.btn-block {
  width: 100%;
  display: block;
}

/* ---------- Onboarding ---------- */

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: fadeSlideIn 0.35s ease both;
}

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

.onboarding {
  padding: 32px 24px;
  justify-content: center;
  gap: 24px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.onboarding-progress {
  display: flex;
  gap: 6px;
  position: absolute;
  top: calc(16px + var(--safe-top));
  left: 24px;
  right: 24px;
}

.onboarding-progress-dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.onboarding-progress-dot.done {
  background: var(--accent);
}

.eyebrow {
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 4px;
}

h1.onb-title {
  font-size: 30px;
  font-weight: 800;
  margin: 0;
  line-height: 1.15;
}

p.onb-body {
  font-size: 16px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
}

.logo-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--sleep), var(--fitness));
  margin-bottom: 8px;
}

input.text-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 17px;
  color: var(--text);
}

input.text-input:focus {
  outline: 2px solid var(--accent);
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #ffffff;
  color: #1f1f1f;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-weight: 600;
  font-size: 15px;
  border: none;
  cursor: pointer;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.category-card {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.category-card.selected {
  border-color: var(--card-color, var(--accent));
  background: var(--bg-elevated-2);
}

.category-card:active {
  transform: scale(0.97);
}

.category-icon {
  font-size: 28px;
}

.category-label {
  font-weight: 600;
  font-size: 14px;
}

.selection-hint {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.slider-preview-row {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}

.config-row {
  display: flex;
  gap: 12px;
}

.config-field {
  flex: 1;
}

.config-field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.metric-choice {
  display: flex;
  gap: 10px;
}

.metric-choice .choice-btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  text-align: center;
  font-weight: 600;
  cursor: pointer;
}

.choice-btn.selected {
  border-color: var(--accent);
  background: var(--bg-elevated-2);
}

.onb-footer {
  display: flex;
  gap: 12px;
  margin-top: auto;
}

.time-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 20px;
  color: var(--text);
  width: 100%;
  text-align: center;
}

.platform-instructions {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 18px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-dim);
}

.platform-instructions b {
  color: var(--text);
}

/* ---------- Main screen ---------- */

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: none;
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.warning-banner {
  margin: 0 16px 8px;
  padding: 10px 14px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-sm);
  color: #fbbf24;
  font-size: 13px;
  text-align: center;
}

.override-row {
  display: flex;
  justify-content: center;
  padding: 4px 0 8px;
}

.override-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}

.override-toggle.active {
  background: rgba(124, 140, 248, 0.15);
  border-color: var(--accent);
  color: var(--text);
}

.slider-track-area {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  padding: 8px 14px 4px;
  overflow-x: auto;
}

.slider-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 90px;
  min-width: 44px;
}

.slider-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--slider-color, var(--text));
  margin-bottom: 6px;
  height: 16px;
}

.slider-shell {
  position: relative;
  width: 100%;
  flex: 1;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.slider-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--slider-color) 85%, white 15%), var(--slider-color));
  border-radius: 999px;
  transition: height 0.2s ease-out;
}

.slider-thumb {
  position: absolute;
  left: 50%;
  width: 28px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.85);
  transform: translate(-50%, 50%);
  transition: bottom 0.2s ease-out;
}

.slider-label {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
}

.slider-sub {
  font-size: 10px;
  color: var(--text-faint);
}

.submit-area {
  padding: 12px 18px calc(18px + var(--safe-bottom));
}

.submit-btn {
  width: 100%;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--accent);
  color: #101728;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.submit-btn:disabled {
  background: var(--bg-elevated);
  color: var(--text-faint);
  cursor: default;
}

.submit-btn.pulse {
  animation: pulse 0.5s ease;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -6px);
}

.phase3-banner {
  position: fixed;
  inset: 0;
  background: rgba(16, 23, 40, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
  text-align: center;
  padding: 24px;
}

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

/* ---------- Stats screen ---------- */

.stats-screen {
  padding: 16px 16px calc(24px + var(--safe-bottom));
  overflow-y: auto;
}

.stats-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.stats-title {
  font-size: 22px;
  font-weight: 800;
}

.overview-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 20px;
}

.overview-card {
  min-width: 120px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.overview-card .label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 6px;
}

.overview-card .value {
  font-size: 24px;
  font-weight: 800;
}

.overview-card .trend {
  font-size: 12px;
  margin-top: 4px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.green {
  background: var(--green);
}
.status-dot.yellow {
  background: var(--yellow);
}
.status-dot.red {
  background: var(--red);
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 20px 0 10px;
}

.balance-view {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 18px;
  border: 1px solid var(--border);
}

.balance-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.balance-bar-label {
  width: 70px;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.balance-bar-track {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: var(--bg-elevated-2);
  overflow: hidden;
}

.balance-bar-fill {
  height: 100%;
  border-radius: 5px;
}

.balance-bar-value {
  width: 40px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
}

.cadence-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.cadence-toggle button {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.cadence-toggle button.active {
  background: var(--accent);
  color: #101728;
  border-color: var(--accent);
}

.trend-chart {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--border);
}

/* ---------- Settings screen ---------- */

.settings-screen {
  padding: 16px 16px calc(24px + var(--safe-bottom));
  overflow-y: auto;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

.settings-row .row-label {
  font-size: 15px;
  font-weight: 500;
}

.settings-row.clickable {
  cursor: pointer;
}

.settings-row .chevron {
  color: var(--text-faint);
}

.danger-text {
  color: var(--red);
}

.slider-manage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

.slider-manage-row .swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--swatch-color);
  flex-shrink: 0;
}

.slider-manage-row .name {
  flex: 1;
  font-weight: 500;
}

.remove-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.modal-sheet {
  background: var(--bg-elevated);
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 24px;
  animation: slideUp 0.25s ease;
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
}

.modal-body {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}

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

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

.loading-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}

@media (min-width: 640px) {
  #app {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
