/* ===========================================================
   Vapeless — calm, motivational quit-vaping dashboard
   Palette: lavender #8B5CF6 + wellness green #10B981
   =========================================================== */

:root {
  --primary: #8B5CF6;
  --primary-soft: #C4B5FD;
  --primary-deep: #6D28D9;
  --success: #10B981;
  --success-deep: #059669;
  --danger: #F43F5E;
  --amber: #F59E0B;

  --bg: #FAF5FF;
  --bg-grad-1: #F5F0FF;
  --bg-grad-2: #ECFDF5;
  --surface: #FFFFFF;
  --surface-2: #FBF8FF;
  --text: #2E1065;
  --text-soft: #5B4B8A;
  --muted: #8B7FB0;
  --line: #ECE4FB;
  --ring-track: #EDE4FC;

  --shadow-sm: 0 1px 2px rgba(76, 29, 149, .06);
  --shadow: 0 8px 30px rgba(109, 40, 217, .08);
  --shadow-lg: 0 20px 50px rgba(109, 40, 217, .14);
  --radius: 22px;
  --radius-sm: 14px;
  --maxw: 1080px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

[data-theme="dark"] {
  --bg: #120B22;
  --bg-grad-1: #1A1033;
  --bg-grad-2: #0C2A22;
  --surface: #1C1335;
  --surface-2: #221842;
  --text: #F3EEFF;
  --text-soft: #C9BEEC;
  --muted: #8E81B8;
  --line: #2E2350;
  --ring-track: #2A2048;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Raleway", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: "Lora", Georgia, serif; font-weight: 600; line-height: 1.2; margin: 0; }

.aurora {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 50% at 15% 0%, var(--bg-grad-1) 0%, transparent 60%),
    radial-gradient(55% 45% at 100% 10%, var(--bg-grad-2) 0%, transparent 55%),
    radial-gradient(40% 40% at 80% 100%, rgba(139, 92, 246, .10) 0%, transparent 60%),
    var(--bg);
}

/* ---------- Top bar ---------- */
.topbar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 20px 6px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 14px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--success));
  box-shadow: var(--shadow);
}
.brand-text h1 { font-size: 1.5rem; letter-spacing: -.01em; }
.brand-text p { margin: 0; font-size: .82rem; color: var(--muted); font-weight: 500; }

.topbar-actions { display: flex; gap: 10px; }
.icon-btn {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-soft);
  cursor: pointer; transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
  box-shadow: var(--shadow-sm);
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary-soft); }
.icon-btn:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 2px; }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 16px 20px 60px; display: grid; gap: 22px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}

.muted { color: var(--muted); font-size: .9rem; margin: 4px 0 0; }
.eyebrow { font-family: "Raleway", sans-serif; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 36px; align-items: center;
  overflow: hidden; position: relative;
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 80% at 0% 0%, rgba(139, 92, 246, .07), transparent 50%);
}
.ring-wrap { position: relative; display: grid; place-items: center; }
.ring { width: 100%; max-width: 260px; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--ring-track); stroke-width: 16; }
.ring-progress {
  fill: none; stroke: url(#ringGrad); stroke-width: 16; stroke-linecap: round;
  stroke-dasharray: 540.4; stroke-dashoffset: 540.4;
  transition: stroke-dashoffset .9s var(--ease), stroke .5s var(--ease);
}
.ring-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px;
}
.ring-count { font-family: "Lora", serif; font-size: 3.4rem; font-weight: 700; color: var(--text); line-height: 1; }
.ring-label { font-size: .8rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.ring-goal { margin-top: 8px; font-size: .85rem; font-weight: 600; color: var(--primary); }

.hero-side { display: grid; gap: 14px; align-content: center; }
.motivation { font-family: "Lora", serif; font-size: 1.5rem; line-height: 1.35; margin: 0; color: var(--text); max-width: 36ch; }

.logger { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.log-btn {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 14px 24px; border: none; border-radius: 16px; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff; font-family: "Raleway", sans-serif; font-weight: 700; font-size: 1.02rem;
  box-shadow: 0 10px 24px rgba(109, 40, 217, .32);
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), filter .2s var(--ease);
}
.log-btn:hover { filter: brightness(1.05); box-shadow: 0 14px 30px rgba(109, 40, 217, .4); }
.log-btn:active { transform: scale(.97); }
.log-plus { font-size: 1.3rem; font-weight: 800; }
.circle-btn {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-soft); cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}
.circle-btn:hover { color: var(--danger); border-color: var(--danger); }
.quick-add { display: flex; gap: 8px; }
.chip {
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--primary-soft);
  background: transparent; color: var(--primary); font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.chip:hover { background: var(--primary); color: #fff; }
.goal-progress { font-size: .92rem; color: var(--text-soft); font-weight: 500; margin: 0; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 18px; }
.stat-value { font-family: "Lora", serif; font-size: 1.45rem; font-weight: 700; margin: 0; color: var(--text); line-height: 1; }
.stat-key { margin: 4px 0 0; font-size: .76rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.stat-icon { width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px; background-position: center; background-repeat: no-repeat; background-size: 20px; }
.stat-icon.trend  { background-color: rgba(245, 158, 11, .14); }
.stat-icon.avg    { background-color: rgba(139, 92, 246, .14); }
.stat-icon.best   { background-color: rgba(16, 185, 129, .14); }
.stat-icon.money  { background-color: rgba(16, 185, 129, .14); }
.stat-icon.streak { background-color: rgba(244, 63, 94, .12); }
.stat-icon.drop   { background-color: rgba(139, 92, 246, .14); }
.stat-icon.trend  { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F59E0B' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M23 18l-9.5-9.5-5 5L1 6'/%3E%3Cpath d='M17 18h6v-6'/%3E%3C/svg%3E"); }
.stat-icon.avg    { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B5CF6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12h4l3 8 4-16 3 8h4'/%3E%3C/svg%3E"); }
.stat-icon.best   { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2310B981' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2l2.4 7.4H22l-6 4.5 2.3 7.1-6.3-4.6L5.7 21 8 14 2 9.4h7.6z'/%3E%3C/svg%3E"); }
.stat-icon.money  { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2310B981' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 1v22M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'/%3E%3C/svg%3E"); }
.stat-icon.streak { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F43F5E' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8.5 14.5A4.5 4.5 0 0 0 13 19c2.5 0 4.5-2 4.5-5 0-3-2.5-4.5-3.5-7-.7 1.7-2 2.7-3 3.7s-2 2.3-2 4.1c0 .2 0 .4.1.7Z'/%3E%3C/svg%3E"); }
.stat-icon.drop   { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B5CF6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22a7 7 0 0 0 7-7c0-5-7-13-7-13S5 10 5 15a7 7 0 0 0 7 7Z'/%3E%3C/svg%3E"); }

/* ---------- Chart ---------- */
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.chart-head h2 { font-size: 1.4rem; }
.legend { display: flex; gap: 16px; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--text-soft); font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.dot.bars { background: linear-gradient(180deg, var(--primary), var(--primary-deep)); }
.dot.goal { background: var(--success); border-radius: 50%; }
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-empty { text-align: center; color: var(--muted); padding: 30px 0; margin: 0; }

.bar { transition: opacity .2s var(--ease); cursor: default; }
.bar:hover { opacity: .8; }
.bar-rect { transition: height .6s var(--ease), y .6s var(--ease); }

/* ---------- Milestones ---------- */
.milestones { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.ms {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
  transition: border-color .25s var(--ease), background .25s var(--ease), transform .25s var(--ease);
}
.ms.done { border-color: var(--success); background: linear-gradient(135deg, rgba(16,185,129,.10), transparent); }
.ms .ms-badge {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 38px; display: grid; place-items: center;
  background: var(--ring-track); color: var(--muted);
}
.ms.done .ms-badge { background: var(--success); color: #fff; }
.ms-title { font-weight: 700; font-size: .92rem; margin: 0; color: var(--text); }
.ms-desc { font-size: .78rem; color: var(--muted); margin: 2px 0 0; }

.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 8px 0 0; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(46, 16, 101, .4); backdrop-filter: blur(4px); }
.modal-card { position: relative; width: min(480px, 100%); max-height: 90vh; overflow-y: auto; animation: pop .25s var(--ease); }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { font-size: 1.4rem; }
.settings-form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: .9rem; color: var(--text-soft); }
.field small { color: var(--muted); font-size: .78rem; }
.field input {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-family: inherit; font-size: 1rem;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.btn { padding: 12px 22px; border-radius: 13px; border: none; cursor: pointer; font-family: inherit; font-weight: 700; font-size: .95rem; transition: filter .2s var(--ease), background .2s var(--ease), color .2s var(--ease); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-deep)); color: #fff; box-shadow: 0 8px 20px rgba(109,40,217,.3); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger-ghost { background: transparent; color: var(--danger); border: 1px solid transparent; }
.btn.danger-ghost:hover { border-color: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 14px;
  font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg); z-index: 60;
  opacity: 0; transition: opacity .3s var(--ease), transform .3s var(--ease); pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: block; }

/* ---------- Celebrate burst ---------- */
.spark { position: fixed; width: 9px; height: 9px; border-radius: 2px; pointer-events: none; z-index: 70; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; text-align: center; }
  .ring-wrap { max-width: 240px; margin: 0 auto; }
  .hero-side { justify-items: center; }
  .motivation { margin: 0 auto; }
  .logger { justify-content: center; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 540px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .brand-text p { display: none; }
  .card { padding: 20px; }
  .ring-count { font-size: 2.8rem; }
  .motivation { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
