:root {
  --bg:     #f2c76e;
  --cream:  #fdf8f0;
  --text:   #1a1714;
  --muted:  #9a9189;
  --track:  rgba(26,23,20,0.08);
  --danger: #c0392b;
  --font:   'Inter', -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ─── Auth ──────────────────────────────────────────────────────────────── */

.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.auth-top {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 28px 40px;
}

.auth-wordmark {
  font-size: 52px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--text);
}

.auth-tagline {
  margin-top: 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  opacity: 0.55;
}

.auth-sheet {
  background: var(--cream);
  border-radius: 28px 28px 0 0;
  padding: 32px 24px 52px;
}

.auth-tabs {
  display: flex;
  background: rgba(26,23,20,0.07);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
  background: var(--cream);
  color: var(--text);
  box-shadow: 0 1px 6px rgba(26,23,20,0.10);
}

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

.auth-form input {
  width: 100%;
  padding: 15px 16px;
  border-radius: 14px;
  border: 1.5px solid rgba(26,23,20,0.10);
  background: #fff;
  color: var(--text);
  font-size: 16px;
  font-family: var(--font);
}

.auth-form input::placeholder { color: var(--muted); }
.auth-form input:focus { outline: none; border-color: var(--text); }

.auth-error {
  font-size: 13px;
  color: var(--danger);
  text-align: center;
  font-weight: 500;
}

/* ─── Shared buttons ────────────────────────────────────────────────────── */

.btn-submit {
  width: 100%;
  padding: 16px;
  border-radius: 16px;
  border: none;
  background: var(--text);
  color: var(--cream);
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s;
}

.btn-submit:active { opacity: 0.8; }

.btn-ghost {
  flex: 1;
  padding: 15px;
  border-radius: 14px;
  border: none;
  background: rgba(26,23,20,0.06);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
}

/* ─── App shell ─────────────────────────────────────────────────────────── */

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 60px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 60px 20px 24px;
}

.greeting {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  opacity: 0.45;
  margin-bottom: 4px;
}

.app-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 4px;
}

.btn-add {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--text);
  color: var(--cream);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(26,23,20,0.25);
  transition: transform 0.12s;
}

.btn-add:active { transform: scale(0.92); }

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(26,23,20,0.08);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}

.btn-icon:active { background: rgba(26,23,20,0.15); }

/* ─── Streak cards ──────────────────────────────────────────────────────── */

.streak-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px;
}

.streak-card {
  background: var(--cream);
  border-radius: 20px;
  padding: 18px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 16px rgba(26,23,20,0.07);
  transition: transform 0.14s, box-shadow 0.14s;
}

.streak-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 6px rgba(26,23,20,0.06);
}

.mini-ring {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}

.mini-ring-track { fill: none; stroke: var(--track); stroke-width: 4; }
.mini-ring-fill  { fill: none; stroke: var(--text);  stroke-width: 4; stroke-linecap: round; }

.streak-info { flex: 1; min-width: 0; }

.streak-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.streak-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.streak-count { text-align: right; flex-shrink: 0; }

.streak-num {
  display: block;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
}

.streak-lbl {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

/* ─── Empty state ───────────────────────────────────────────────────────── */

.empty-state {
  padding: 64px 32px 0;
  text-align: center;
}

.empty-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
}

/* ─── Modal / sheet ─────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.sheet {
  background: var(--cream);
  border-radius: 28px 28px 0 0;
  padding: 14px 24px 52px;
  width: 100%;
  max-width: 480px;
  max-height: 94vh;
  max-height: 94dvh;
  overflow-y: auto;
  position: relative;
}

.sheet-handle {
  width: 32px;
  height: 4px;
  background: rgba(26,23,20,0.12);
  border-radius: 2px;
  margin: 0 auto 28px;
}

.sheet h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 24px;
}

.sheet label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.sheet input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1.5px solid rgba(26,23,20,0.10);
  background: #fff;
  color: var(--text);
  font-size: 16px;
  font-family: var(--font);
  margin-bottom: 20px;
}

.sheet input:focus { outline: none; border-color: var(--text); }

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.sheet-actions .btn-submit { margin-top: 0; flex: 1; width: auto; }

/* ─── Detail sheet ──────────────────────────────────────────────────────── */

.detail-sheet { padding-bottom: 52px; }

.btn-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(26,23,20,0.07);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-since {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.detail-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 0;
  padding-right: 36px;
}

.ring-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 24px auto 8px;
}

.ring-wrap svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track { fill: none; stroke: var(--track); stroke-width: 10; }

.ring-fill {
  fill: none;
  stroke: var(--text);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4,0,0.2,1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.ring-days {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

.ring-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.next-milestone {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 8px 0 4px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 28px 0 14px;
}

/* ─── Badges ────────────────────────────────────────────────────────────── */

.badge-row { display: flex; flex-wrap: wrap; gap: 10px; }

.badge {
  width: 58px;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.badge .emoji {
  display: block;
  font-size: 22px;
  width: 50px;
  height: 50px;
  line-height: 50px;
  border-radius: 50%;
  background: rgba(26,23,20,0.05);
  margin: 0 auto 5px;
  filter: grayscale(1) opacity(0.3);
}

.badge.unlocked .emoji {
  background: var(--bg);
  filter: none;
  box-shadow: 0 3px 10px rgba(26,23,20,0.14);
}

.badge.unlocked { color: var(--text); font-weight: 700; }

/* ─── Rewards ───────────────────────────────────────────────────────────── */

.reward-list { display: flex; flex-direction: column; gap: 8px; }

.reward-card {
  background: rgba(26,23,20,0.04);
  border-radius: 14px;
  padding: 14px 16px;
  opacity: 0.45;
}

.reward-card.unlocked {
  opacity: 1;
  background: var(--bg);
  box-shadow: 0 4px 16px rgba(26,23,20,0.09);
}

.reward-title { font-size: 14px; font-weight: 700; margin-bottom: 3px; }

.reward-sub { font-size: 13px; color: var(--muted); }

.reward-tag {
  display: inline-block;
  margin-top: 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--text);
  color: var(--cream);
  padding: 4px 12px;
  border-radius: 20px;
}

.locked-tag { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ─── End streak ────────────────────────────────────────────────────────── */

.btn-end {
  display: block;
  width: 100%;
  margin-top: 28px;
  padding: 15px;
  border-radius: 14px;
  border: 1.5px solid rgba(192,57,43,0.3);
  background: transparent;
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
}
