/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0e0e10;
  --bg-raised: #1a1a1f;
  --card: #1e1e24;
  --card-hover: #26262e;
  --text: #e8e8ed;
  --text-secondary: #8e8e93;
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --primary-dim: #4f46e5;
  --jonas: #60a5fa;
  --jonas-glow: rgba(96, 165, 250, 0.15);
  --antonia: #f472b6;
  --antonia-glow: rgba(244, 114, 182, 0.15);
  --success: #34d399;
  --danger: #ef4444;
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.04);
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html {
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
}

/* ── Screens ───────────────────────────────────────────────────── */
.screen { display: none; flex-direction: column; min-height: 100dvh; }
.screen:not([hidden]) { display: flex; }

/* ── Login ─────────────────────────────────────────────────────── */
#screen-login {
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-card h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--jonas) 0%, var(--primary) 50%, var(--antonia) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Inputs & buttons ──────────────────────────────────────────── */
input[type="text"],
input[type="password"],
input[type="date"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font);
  background: var(--bg-raised);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
}

textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s, box-shadow 0.2s;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dim) 100%);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  transition: color 0.15s;
}

.btn-icon:active { color: var(--primary); }

.error-text {
  color: var(--danger);
  font-size: 14px;
  margin-top: 8px;
}

/* ── Top bar ───────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.top-bar h1 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  text-align: center;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.btn-refresh svg.spin {
  animation: spin 0.5s ease;
}

/* ── Card list (challenges) ────────────────────────────────────── */
.card-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 80px;
}

.challenge-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}

.challenge-card:active {
  transform: scale(0.98);
  background: var(--card-hover);
  border-color: rgba(255, 255, 255, 0.12);
}

.challenge-card h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.challenge-card .card-dates {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.progress-row:last-child { margin-bottom: 0; }

.progress-label {
  font-size: 13px;
  font-weight: 700;
  width: 20px;
  text-align: center;
}

.progress-label.jonas { color: var(--jonas); }
.progress-label.antonia { color: var(--antonia); }

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-fill.jonas {
  background: linear-gradient(90deg, var(--jonas), #818cf8);
}

.progress-fill.antonia {
  background: linear-gradient(90deg, var(--antonia), #c084fc);
}

.progress-count {
  font-size: 12px;
  color: var(--text-secondary);
  width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── FAB ───────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 398px;
  width: calc(100% - 32px);
  padding: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dim) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 4px 16px var(--primary-glow);
  z-index: 20;
  transition: transform 0.1s, box-shadow 0.2s;
}

.fab:active {
  transform: translateX(-50%) scale(0.97);
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* ── Detail screen ─────────────────────────────────────────────── */
.detail-dates {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 14px 16px 6px;
}

.detail-descriptions {
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.desc-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.desc-block .desc-user {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.desc-block .desc-user.jonas { color: var(--jonas); }
.desc-block .desc-user.antonia { color: var(--antonia); }

.desc-block .desc-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ── Calendar ──────────────────────────────────────────────────── */
.calendar-container {
  padding: 8px 16px 0;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border-light);
  font-size: 13px;
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
  min-height: 44px;
}

.cal-day:active {
  background: var(--card-hover);
  transform: scale(0.93);
}

.cal-day.outside {
  background: transparent;
  border-color: transparent;
  cursor: default;
  visibility: hidden;
}

.cal-day.future {
  opacity: 0.3;
}

.cal-day .day-num {
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  color: var(--text);
}

.cal-day .day-markers {
  display: flex;
  gap: 2px;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.cal-day .marker-j {
  color: var(--jonas);
  text-shadow: 0 0 6px var(--jonas-glow);
}

.cal-day .marker-a {
  color: var(--antonia);
  text-shadow: 0 0 6px var(--antonia-glow);
}

.cal-day.today {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 0 8px var(--primary-glow);
}

/* Day with both completions gets a subtle background */
.cal-day.completed-both {
  background: rgba(99, 102, 241, 0.08);
}

/* ── Legend ─────────────────────────────────────────────────────── */
.legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 14px 16px 28px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-j {
  color: var(--jonas);
  font-weight: 800;
  font-size: 14px;
}

.legend-a {
  color: var(--antonia);
  font-weight: 800;
  font-size: 14px;
}

/* ── Form card ─────────────────────────────────────────────────── */
.form-card {
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-card label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-top: 10px;
}

.form-card label:first-child { margin-top: 0; }

.form-card .btn { margin-top: 20px; }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
}

/* ── Loading ───────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ── Scrollbar (webkit) ────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
