:root {
  --bg: #0b0c0f;
  --bg-elevated: #16181d;
  --border: #262930;
  --text: #f2f1ec;
  --text-soft: #9a9a94;
  --flame-1: #ff5f3d;
  --flame-2: #ffb800;
  --danger: #e0483f;
  --success: #2fbf71;
  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.back-link {
  position: fixed;
  top: 20px;
  left: 24px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  z-index: 5;
}
.back-link:hover { color: var(--text); }

/* ---------- AUTH ---------- */

.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0 0 6px;
}

.auth-subtitle {
  color: var(--text-soft);
  font-size: 14px;
  margin: 0 0 24px;
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 22px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 0;
  border-radius: 9px;
  cursor: pointer;
  font-family: var(--font-body);
}

.tab-btn.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form label {
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-form .hint { color: #6d6d67; font-weight: 400; }

.auth-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 14.5px;
  font-family: var(--font-body);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--flame-1);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin: -6px 0 0;
  min-height: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--flame-1), var(--flame-2));
  border: none;
  color: #14120f;
  font-weight: 700;
  font-size: 14.5px;
  padding: 12px 0;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-body);
}

.btn-primary.btn-large {
  padding: 15px 0;
  font-size: 16px;
  width: 100%;
}

.btn-link {
  background: none;
  border: none;
  color: var(--flame-1);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
  text-decoration: underline;
  padding: 0;
  margin-top: 12px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-body);
}
.btn-ghost:hover { color: var(--text); border-color: #3a3d45; }

.btn-danger {
  background: var(--danger);
  border: none;
  color: white;
  font-weight: 700;
  font-size: 14.5px;
  padding: 13px 22px;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-body);
}

/* ---------- DASHBOARD ---------- */

.dashboard {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 24px 60px;
}

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

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--flame-1);
  margin: 0 0 4px;
}

.user-email {
  color: var(--text-soft);
  font-size: 13px;
  margin: 0;
}

.streak-hero {
  text-align: center;
  background: radial-gradient(circle at 50% 0%, rgba(255, 95, 61, 0.12), transparent 60%);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 44px 20px 34px;
  margin-bottom: 20px;
}

.streak-count { display: flex; flex-direction: column; align-items: center; }

.streak-number {
  font-family: var(--font-display);
  font-size: 88px;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, var(--flame-1), var(--flame-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.streak-label {
  color: var(--text-soft);
  font-size: 14px;
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
  margin-top: 22px;
  font-weight: 700;
  font-family: var(--font-display);
}

.next-tier {
  color: var(--text-soft);
  font-size: 13px;
  margin: 14px 0 0;
}

/* ---------- START CARD (décompte non lancé) ---------- */

.start-card {
  text-align: center;
  background: radial-gradient(circle at 50% 0%, rgba(255, 95, 61, 0.12), transparent 60%);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 44px 24px;
  margin-bottom: 20px;
}

.start-emoji {
  font-size: 40px;
  display: block;
  margin-bottom: 12px;
}

.start-card h2 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 8px;
}

.start-card p {
  color: var(--text-soft);
  font-size: 14px;
  margin: 0 0 22px;
}

/* ---------- LIVE TIMER ---------- */

.live-timer-section {
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}

.live-timer-section h2 {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin: 0 0 16px;
  text-align: left;
}

.live-timer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.timer-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timer-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer-label {
  color: var(--text-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.adjust-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.adjust-form label {
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.adjust-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14.5px;
  font-family: var(--font-body);
}

.adjust-form input:focus {
  outline: none;
  border-color: var(--flame-1);
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 28px;
}

.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
}

.stat-label {
  color: var(--text-soft);
  font-size: 12.5px;
}

.calendar-section, .history-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 20px;
}

.calendar-section h2, .history-section h2 {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 0 0 16px;
}

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

.cal-day {
  aspect-ratio: 1;
  border-radius: 6px;
  background: #1e2026;
}

.cal-day.held {
  background: linear-gradient(135deg, var(--flame-1), var(--flame-2));
}

.cal-day.relapse {
  background: var(--danger);
}

.calendar-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-soft);
}

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

.dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
}
.dot-held { background: linear-gradient(135deg, var(--flame-1), var(--flame-2)); }
.dot-relapse { background: var(--danger); }
.dot-neutral { background: #1e2026; }

.relapse-section {
  text-align: center;
  margin-bottom: 24px;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.history-list li:last-child { border-bottom: none; padding-bottom: 0; }

.history-empty { color: var(--text-soft); font-style: italic; }

/* ---------- MODAL ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  max-width: 380px;
}

.modal-card h3 {
  font-family: var(--font-display);
  margin: 0 0 10px;
}

.modal-card p {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 20px;
}

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

/* ---------- TOAST ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--flame-1);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 20;
}
