/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--background); color: var(--foreground);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 16px; line-height: 1.6; letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}
::selection { background: var(--primary); color: var(--primary-foreground); }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); }

h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
p  { color: var(--muted-foreground); font-size: 0.9rem; }

.container { max-width: 640px; margin: 0 auto; padding: 1rem; }

/* ─── Card ─── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: background 0.2s, border-color 0.2s;
}
.card + .card { margin-top: 0.75rem; }

/* ─── Entrance animations ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up {
  animation: fadeUp 0.35s ease both;
  animation-delay: var(--delay, 0s);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem; padding: 0.65rem 1.25rem; border-radius: var(--radius);
  border: 1px solid transparent; font-family: inherit; font-size: 0.9rem;
  font-weight: 600; line-height: 1; cursor: pointer;
  transition: all 0.15s ease; text-decoration: none; user-select: none;
}
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; color: var(--foreground); border-color: var(--border); }
.btn-outline:hover { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted-foreground); border-color: transparent; }
.btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; border-radius: calc(var(--radius) + 4px); width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* ─── Badge ─── */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; border: 1px solid transparent;
}
.badge-primary    { background: var(--secondary); color: var(--primary); border-color: var(--border); }
.badge-success    { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.badge-destructive{ background: color-mix(in srgb, var(--destructive) 12%, transparent); color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 25%, transparent); }
.badge-muted      { background: var(--muted); color: var(--muted-foreground); border-color: var(--border); }

/* ─── Input ─── */
.input-group { display: flex; flex-direction: column; gap: 0.4rem; }
.input-group label { font-size: 0.85rem; font-weight: 500; color: var(--foreground); }
.input {
  background: var(--background); border: 1px solid var(--input);
  border-radius: var(--radius); color: var(--foreground); font-family: inherit;
  font-size: 0.9rem; padding: 0.6rem 0.875rem; outline: none;
  transition: border-color 0.15s; width: 100%;
}
.input:focus { border-color: var(--ring); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 20%, transparent); }
.input::placeholder { color: var(--muted-foreground); }

/* ─── Header ─── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--card); position: sticky; top: 0; z-index: 10;
  transition: background 0.2s, border-color 0.2s;
}
.header-brand h1 { font-size: 1.05rem; color: var(--foreground); }
.header-brand .tagline { font-size: 0.7rem; color: var(--muted-foreground); font-weight: 400; }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }

/* ─── Tabs ─── */
.tabs { display: flex; gap: 0.25rem; background: var(--muted); border-radius: var(--radius); padding: 0.25rem; }
.tab {
  flex: 1; padding: 0.45rem 1rem; border-radius: calc(var(--radius) - 2px);
  background: transparent; border: none; font-family: inherit;
  font-size: 0.85rem; font-weight: 500; color: var(--muted-foreground); cursor: pointer; transition: all 0.15s;
}
.tab.active { background: var(--card); color: var(--foreground); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.tab:hover:not(.active) { color: var(--foreground); }

/* ─── Stat cards ─── */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
@media (min-width: 480px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem; text-align: center; transition: background 0.2s, border-color 0.2s; }
.stat-card .stat-value { font-size: 1.65rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-card .stat-label { font-size: 0.7rem; color: var(--muted-foreground); margin-top: 0.25rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }


/* ─── Checkin buttons ─── */
.checkin-buttons {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 1rem 0;
  transition: opacity 0.2s;
}
.checkin-buttons.locked { opacity: 0.6; pointer-events: none; }
.checkin-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 1.25rem 1rem; border-radius: calc(var(--radius) + 4px);
  border: 2px solid var(--border); background: var(--card); cursor: pointer;
  font-family: inherit; font-size: 0.875rem; font-weight: 600; color: var(--foreground);
  transition: all 0.15s ease; user-select: none;
}
.checkin-btn .btn-emoji { font-size: 1.85rem; line-height: 1; }
.checkin-btn:hover { border-color: var(--primary); background: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.07); }
.checkin-btn:active { transform: scale(0.97) translateY(0); }
.checkin-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.checkin-btn.selected-yes { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--card)); color: var(--primary); }
.checkin-btn.selected-no  { border-color: var(--destructive); background: color-mix(in srgb, var(--destructive) 8%, var(--card)); color: var(--destructive); }

/* ─── Result message card ─── */
.result-card {
  background: var(--secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem; text-align: center;
}
.result-card .result-emoji { font-size: 1.6rem; line-height: 1; display: block; margin-bottom: 0.4rem; }
.result-card .result-text { font-size: 0.9rem; font-weight: 500; color: var(--foreground); }

/* ─── Workout type picker ─── */
.workout-picker { max-height: 0; overflow: hidden; transition: max-height 0.35s ease, opacity 0.3s ease; opacity: 0; }
.workout-picker.open { max-height: 220px; opacity: 1; }
.workout-picker-inner { padding-top: 0.75rem; border-top: 1px solid var(--border); margin-top: 0.75rem; }
.workout-types { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.35rem; }
.workout-type-btn {
  padding: 0.35rem 0.75rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--muted); color: var(--foreground); font-family: inherit;
  font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all 0.15s;
}
.workout-type-btn:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--muted)); color: var(--primary); }
.workout-type-btn.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 15%, var(--card)); color: var(--primary); font-weight: 600; }
.note-row { margin-top: 0.6rem; }
.note-row textarea.input { resize: vertical; min-height: 52px; font-size: 0.85rem; }
.save-note-btn { margin-top: 0.35rem; font-size: 0.78rem; }


/* ─── Milestone toast ─── */
.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(120px);
  background: var(--card); border: 1px solid var(--primary);
  border-radius: calc(var(--radius) + 4px); padding: 0.875rem 1.5rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15); z-index: 200;
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s;
  opacity: 0; white-space: nowrap; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast-emoji { font-size: 1.5rem; display: block; margin-bottom: 0.25rem; }
.toast-title { font-weight: 700; font-size: 0.95rem; color: var(--primary); }
.toast-sub   { font-size: 0.8rem; color: var(--muted-foreground); margin-top: 0.1rem; }

/* ─── Last weekday badge ─── */
.last-weekday-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.7rem; border-radius: 999px; font-size: 0.78rem; font-weight: 500;
  background: var(--muted); color: var(--muted-foreground); border: 1px solid var(--border);
}


/* ─── Log table ─── */
.log-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.log-table th { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 2px solid var(--border); color: var(--foreground); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.log-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); color: var(--foreground); }
.log-table tbody tr:last-child td { border-bottom: none; }
.log-table tbody tr:hover { background: var(--accent); }
.log-table td.note-cell { color: var(--muted-foreground); font-size: 0.78rem; font-style: italic; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Divider ─── */
.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* ─── Login screen ─── */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); padding: 2rem; width: 100%; max-width: 380px; box-shadow: 0 4px 24px rgba(0,0,0,0.07); }
.login-logo { font-size: 3rem; text-align: center; margin-bottom: 0.5rem; }
.login-title { text-align: center; font-size: 1.25rem; font-weight: 700; color: var(--foreground); }
.login-sub { text-align: center; color: var(--muted-foreground); font-size: 0.85rem; margin: 0.35rem 0 1.5rem; }
.login-error { background: color-mix(in srgb, var(--destructive) 10%, transparent); color: var(--destructive); border: 1px solid color-mix(in srgb, var(--destructive) 25%, transparent); border-radius: var(--radius); padding: 0.6rem 0.875rem; font-size: 0.85rem; margin-bottom: 1rem; }

@keyframes slideIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }
.anim-slidein { animation: slideIn 0.25s ease; }

/* ─── Theme toggle ─── */
.theme-toggle { background: var(--muted); border: 1px solid var(--border); border-radius: 999px; width: 2.2rem; height: 2.2rem; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 0.9rem; transition: background 0.15s; flex-shrink: 0; }
.theme-toggle:hover { background: var(--accent); }

/* ─── Chart container ─── */
.chart-container { position: relative; height: 190px; }
.chart-container-sm { position: relative; height: 150px; }

/* ─── Calendar ─── */
.cal-day { width: 18px; height: 18px; border-radius: 3px; flex-shrink: 0; background: var(--muted); cursor: default; transition: transform 0.1s; position: relative; }
.cal-day:hover { transform: scale(1.3); z-index: 1; }
.cal-day.went  { background: var(--primary); }
.cal-day.no-go { background: var(--accent); border: 1px solid var(--border); }
.cal-day.future { background: transparent; }
.cal-legend { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.cal-legend-item { display: flex; align-items: center; gap: 0.35rem; font-size: 0.73rem; color: var(--muted-foreground); }
.cal-legend-dot { width: 12px; height: 12px; border-radius: 2px; }

/* ─── Footer ─── */
.app-footer { text-align: center; color: var(--muted-foreground); font-size: 0.7rem; padding: 1.5rem 1rem; border-top: 1px solid var(--border); margin-top: 1.5rem; }

/* ─── Utilities ─── */
.hidden { display: none !important; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-3 { margin-top: 0.75rem; } .mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 0.75rem; } .mb-4 { margin-bottom: 1rem; }
.text-center { text-align: center; } .text-muted { color: var(--muted-foreground); font-size: 0.84rem; }
.text-sm { font-size: 0.84rem; } .font-semibold { font-weight: 600; }
