/* ── Reset ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:      #f4f4f8;
  --card:    #ffffff;
  --text:    #111827;
  --muted:   #6b7280;
  --border:  #e5e7eb;
  --radius:  14px;
  --shadow:  0 2px 16px rgba(0,0,0,.07);
  --brand:   #4f46e5;
  --hc:      #4f46e5;
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { text-decoration: none; color: inherit; }
input, button { font-family: inherit; }

/* ── Brand ───────────────────────────────────────────────────────── */
.brand { font-weight: 800; font-size: 1.15rem; color: var(--brand); letter-spacing: -.5px; }
.brand-pro { color: var(--hc, var(--brand)); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .65rem 1.25rem; border-radius: 50px; font-size: .9rem; font-weight: 600; cursor: pointer; border: none; transition: transform .15s, box-shadow .15s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,.13); }
.btn:active { transform: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-sm { padding: .45rem 1rem; font-size: .82rem; background: var(--brand); color: #fff; }

/* ── Navbar ──────────────────────────────────────────────────────── */
.navbar { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.nav-right { display: flex; align-items: center; gap: .9rem; }
.nav-link { font-size: .88rem; color: var(--muted); font-weight: 500; }
.nav-link:hover { color: var(--brand); }
.nav-back { font-size: .88rem; color: var(--muted); font-weight: 600; }
.nav-back:hover { color: var(--brand); }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; display: none; }

/* ── Landing ─────────────────────────────────────────────────────── */
.landing { min-height: 100vh; background: #0d1117; color: #fff; }
.landing-nav { padding: 1.25rem 2rem; display: flex; align-items: center; }
.landing-nav .brand, .landing-nav .brand-pro { color: #fff; }

.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: center; max-width: 1100px; margin: 0 auto; padding: 4rem 2rem 5rem; }
.hero-badge { display: inline-block; background: #22c55e22; color: #22c55e; padding: .35rem .9rem; border-radius: 50px; font-size: .8rem; font-weight: 700; letter-spacing: .05em; margin-bottom: 1.25rem; }
.hero h1 { font-size: 3rem; font-weight: 800; line-height: 1.15; margin-bottom: 1rem; }
.hero h1 em { color: #818cf8; font-style: normal; }
.hero p { color: #94a3b8; font-size: 1.05rem; line-height: 1.7; margin-bottom: 2rem; }
.btn-hero { background: #fff; color: #111; font-size: 1rem; padding: .85rem 1.75rem; border-radius: 50px; font-weight: 700; box-shadow: 0 4px 24px rgba(255,255,255,.15); }
.btn-hero:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(255,255,255,.2); }

.hero-preview { display: flex; flex-direction: column; gap: .85rem; }
.preview-card { background: #1e293b; border-radius: 14px; padding: 1rem 1.25rem; display: flex; align-items: center; gap: .85rem; border-left: 4px solid var(--c); }
.preview-icon { font-size: 1.6rem; }
.preview-info { flex: 1; }
.preview-name { font-weight: 700; font-size: .95rem; }
.preview-streak { font-size: .78rem; color: #94a3b8; margin-top: .2rem; }
.preview-done { color: #22c55e; font-weight: 800; font-size: 1.2rem; }
.preview-pass { color: #475569; font-weight: 800; font-size: 1.2rem; }

.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; max-width: 1100px; margin: 0 auto; padding: 0 2rem 5rem; }
.feature { background: #1e293b; border-radius: 14px; padding: 1.5rem; }
.feature-icon { font-size: 2rem; margin-bottom: .75rem; }
.feature h3 { font-size: 1rem; font-weight: 700; margin-bottom: .4rem; }
.feature p { font-size: .85rem; color: #94a3b8; line-height: 1.5; }

/* ── App shell ───────────────────────────────────────────────────── */
.app { min-height: 100vh; }

/* ── Dashboard ───────────────────────────────────────────────────── */
.dashboard-main { max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.dash-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.dash-greeting { font-size: 1.4rem; font-weight: 800; }
.dash-date { font-size: .85rem; color: var(--muted); margin-top: .2rem; }

.habit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }

.skeleton-card { background: linear-gradient(90deg, #e8e8e8 25%, #f0f0f0 50%, #e8e8e8 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius); height: 160px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

.habit-card { background: var(--card); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); border-left: 4px solid var(--hc); transition: transform .2s, box-shadow .2s; display: block; cursor: pointer; }
.habit-card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(0,0,0,.11); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.card-icon { font-size: 1.6rem; }
.card-status { font-size: .75rem; font-weight: 700; padding: .25rem .65rem; border-radius: 50px; }
.status-good   { background: #d1fae5; color: #065f46; }
.status-bad    { background: #fee2e2; color: #991b1b; }
.status-warn   { background: #fef3c7; color: #92400e; }
.status-neutral { background: var(--bg); color: var(--muted); }
.card-name { font-size: 1.1rem; font-weight: 700; margin: .4rem 0; }
.card-streak { font-size: .82rem; margin-bottom: .75rem; }
.streak-fire { color: #f59e0b; font-weight: 700; }
.streak-zero { color: var(--muted); font-style: italic; }
.mini-cal { display: flex; gap: 3px; }
.mc-day { width: 14px; height: 14px; border-radius: 3px; }
.mc-good   { background: var(--hc, #22c55e); }
.mc-bad    { background: #fecaca; }
.mc-warn   { background: #fca5a5; }
.mc-empty  { background: #e5e7eb; }
.mc-future { background: transparent; border: 1px solid #e5e7eb; }
.mc-today  { outline: 2px solid var(--hc); outline-offset: 1px; }

.empty-state { flex-direction: column; align-items: center; padding: 4rem 1rem; text-align: center; gap: 1rem; }
.empty-icon { font-size: 3rem; }
.empty-state h3 { font-size: 1.3rem; }
.empty-state p { color: var(--muted); }

/* ── Habit page ──────────────────────────────────────────────────── */
.habit-nav { background: var(--card); }
.habit-nav-title { font-weight: 700; font-size: .95rem; }

.habit-hero { padding: 2rem 1.5rem 1.75rem; text-align: center; color: #fff; }
.habit-hero-icon { font-size: 3rem; margin-bottom: .5rem; }
.habit-hero-name { font-size: 1.6rem; font-weight: 800; }

.habit-main { max-width: 700px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

/* Check-in section */
.checkin-section { background: var(--card); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); text-align: center; }
.checkin-date { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: .35rem; }
.checkin-question { font-size: 1.2rem; font-weight: 700; margin-bottom: .75rem; }
.checkin-status { font-size: 1rem; font-weight: 600; min-height: 1.5rem; margin-bottom: .5rem; }
.st-good { color: #16a34a; }
.st-bad  { color: #dc2626; }
.st-warn { color: #d97706; }

.checkin-btns { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: .75rem; }
.btn-checkin { padding: .85rem 1.75rem; border-radius: 50px; font-size: 1rem; font-weight: 700; cursor: pointer; border: 2.5px solid transparent; transition: transform .15s, box-shadow .15s, opacity .15s; opacity: .55; }
.btn-checkin:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.14); opacity: 1; }
.btn-checkin.btn-active { opacity: 1; border-color: rgba(0,0,0,.18); box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.btn-yes  { background: #22c55e; color: #fff; }
.btn-no   { background: #fee2e2; color: #dc2626; }
.btn-warn { background: #fca5a5; color: #7f1d1d; }

/* Stats */
.stats-section { margin-bottom: 1.25rem; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
@media (min-width: 500px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 1rem; text-align: center; box-shadow: var(--shadow); }
.stat-card.accent       { background: var(--brand); color: #fff; }
.stat-card.accent-green { background: #22c55e; color: #fff; }
.stat-num { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; margin-top: .3rem; opacity: .75; }

/* Calendar */
.cal-section { margin-bottom: 1.25rem; }
.section-title { font-size: 1rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .85rem; }
.section-sub { font-size: .88rem; color: var(--muted); margin-bottom: 1rem; }

.cal-month { background: var(--card); border-radius: var(--radius); padding: 1.25rem; margin-bottom: .85rem; box-shadow: var(--shadow); }
.cal-month-title { font-size: .85rem; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .85rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: .65rem; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: .25rem 0; }
.cal-cell { aspect-ratio: 1; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; cursor: default; transition: transform .12s; }
.cal-cell.clickable { cursor: pointer; }
.cal-cell.clickable:hover { transform: scale(1.15); }
.cal-cell.c-empty   { background: transparent; }
.cal-cell.c-before  { background: transparent; color: #e5e7eb; }
.cal-cell.c-future  { background: #f3f4f6; color: #d1d5db; }
.cal-cell.c-good    { background: var(--hc, #22c55e); color: #fff; }
.cal-cell.c-bad     { background: #fee2e2; color: #dc2626; }
.cal-cell.c-sober   { background: #d1fae5; color: #065f46; }
.cal-cell.c-eth-low { background: #fef3c7; color: #92400e; }
.cal-cell.c-eth-mid { background: #fca5a5; color: #7f1d1d; }
.cal-cell.c-eth-hi  { background: #ef4444; color: #fff; }
.cal-cell.c-today   { outline: 2px solid var(--hc); outline-offset: 2px; }

/* ── Alcohol form ─────────────────────────────────────────────────── */
.drink-form { text-align: left; border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.drink-form-title { font-weight: 700; font-size: .95rem; margin-bottom: .75rem; }
.drink-entry { background: var(--bg); border-radius: 10px; padding: .85rem 1rem; margin-bottom: .6rem; }
.drink-entry-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.drink-entry-num { font-size: .82rem; font-weight: 700; color: var(--muted); }
.rm-btn { background: none; border: none; cursor: pointer; color: var(--muted); font-size: .9rem; }
.drink-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
.drink-fields label { font-size: .78rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: .3rem; }
.drink-fields input { border: 1px solid var(--border); border-radius: 8px; padding: .45rem .65rem; font-size: .88rem; width: 100%; }
.btn-add-drink { background: none; border: 2px dashed var(--border); border-radius: 10px; width: 100%; padding: .65rem; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; margin-bottom: .75rem; }
.btn-add-drink:hover { border-color: var(--brand); color: var(--brand); }
.ethanol-summary { font-size: .9rem; text-align: center; margin-bottom: .75rem; min-height: 1.4rem; }
.btn-save-drinks { width: 100%; background: var(--brand); color: #fff; border: none; border-radius: 50px; padding: .85rem; font-size: 1rem; font-weight: 700; cursor: pointer; }

/* ── Chart ───────────────────────────────────────────────────────── */
.chart-section { background: var(--card); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.chart-wrap { height: 180px; }

/* ── Settings ────────────────────────────────────────────────────── */
.settings-main { max-width: 640px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.settings-section { background: var(--card); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }

.habit-row { display: flex; align-items: center; justify-content: space-between; padding: .85rem 0; border-bottom: 1px solid var(--border); }
.habit-row:last-child { border-bottom: none; }
.habit-row-off { opacity: .5; }
.habit-row-left { display: flex; align-items: center; gap: .85rem; }
.habit-row-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; border: 1px solid; }
.habit-row-name { font-weight: 700; }
.habit-row-type { font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.habit-row-actions { display: flex; align-items: center; gap: .75rem; }

/* Toggle switch */
.toggle { position: relative; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { display: inline-block; width: 44px; height: 24px; background: #e5e7eb; border-radius: 50px; transition: background .2s; position: relative; }
.toggle input:checked + .toggle-track { background: var(--brand); }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: transform .2s; }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }

.btn-icon-danger { background: none; border: none; cursor: pointer; font-size: 1rem; opacity: .5; }
.btn-icon-danger:hover { opacity: 1; }

.add-habit-form { display: flex; flex-direction: column; gap: .85rem; }
.form-row { display: flex; gap: .75rem; align-items: flex-end; }
.form-row label { font-size: .82rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: .35rem; }
.input-sm { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; font-size: 1rem; width: 64px; text-align: center; }
.input-md { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; font-size: .95rem; width: 100%; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 500; opacity: 0; transition: opacity .15s; }
.modal-overlay.visible { opacity: 1; }
.modal-box { background: var(--card); border-radius: var(--radius); padding: 1.75rem 1.5rem; max-width: 320px; width: 90%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.22); }
.modal-date { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: .3rem; }
.modal-q { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-btns { display: flex; flex-direction: column; gap: .6rem; }
.modal-btn { width: 100%; padding: .8rem; border-radius: 50px; font-size: .95rem; font-weight: 700; border: 2px solid transparent; cursor: pointer; }
.modal-btn.active { box-shadow: inset 0 0 0 3px rgba(0,0,0,.12); }
.modal-yes { background: #22c55e; color: #fff; }
.modal-no  { background: #fee2e2; color: #dc2626; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .hero { grid-template-columns: 1fr; padding: 2rem 1.25rem 3rem; }
  .hero h1 { font-size: 2rem; }
  .features { grid-template-columns: 1fr 1fr; }
  .drink-fields { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
  .features { grid-template-columns: 1fr; }
  .drink-fields { grid-template-columns: 1fr; }
}

/* ── Blog ────────────────────────────────────────────────────────────────── */
.blog-site { min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
.blog-nav { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.5rem; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.blog-main { flex: 1; max-width: 780px; margin: 0 auto; width: 100%; padding: 2rem 1.25rem 4rem; }
.blog-post-main { flex: 1; }
.blog-post-wrap { max-width: 720px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.blog-footer { text-align: center; padding: 1.5rem; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--border); display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.blog-footer a { color: var(--muted); text-decoration: none; }
.blog-footer a:hover { color: var(--accent); }

/* Blog index */
.blog-header { margin-bottom: 2.5rem; }
.blog-index-h1 { font-size: 2rem; font-weight: 800; margin-bottom: .5rem; }
.blog-index-sub { color: var(--muted); font-size: 1.05rem; }
.blog-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.blog-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.4rem; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: .5rem; transition: box-shadow .15s, transform .15s; }
.blog-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.08); transform: translateY(-2px); }
.blog-card-meta { font-size: .78rem; color: var(--muted); }
.blog-card-title { font-size: 1.1rem; font-weight: 700; line-height: 1.35; }
.blog-card-desc { font-size: .9rem; color: var(--muted); line-height: 1.5; flex: 1; }
.blog-card-link { font-size: .88rem; color: var(--accent); font-weight: 600; margin-top: .25rem; }

/* Blog post */
.blog-breadcrumb { font-size: .82rem; color: var(--muted); margin-bottom: 1.75rem; }
.blog-breadcrumb a { color: var(--accent); text-decoration: none; }
.blog-post-header { margin-bottom: 2rem; }
.blog-post-h1 { font-size: 2rem; font-weight: 800; line-height: 1.25; margin-bottom: .6rem; }
.blog-post-byline { font-size: .82rem; color: var(--muted); }
.blog-body { font-size: 1rem; line-height: 1.75; color: var(--text); }
.blog-body h2 { font-size: 1.35rem; font-weight: 700; margin: 2rem 0 .75rem; }
.blog-body h3 { font-size: 1.1rem; font-weight: 700; margin: 1.5rem 0 .5rem; }
.blog-body p { margin-bottom: 1.1rem; }
.blog-body ul, .blog-body ol { padding-left: 1.5rem; margin-bottom: 1.1rem; }
.blog-body li { margin-bottom: .4rem; line-height: 1.6; }
.blog-body a { color: var(--accent); }
.blog-body a.blog-cta { display: inline-block; background: var(--accent); color: #fff; padding: .7rem 1.5rem; border-radius: 50px; font-weight: 700; text-decoration: none; margin-top: .5rem; transition: opacity .15s; }
.blog-body a.blog-cta:hover { opacity: .9; }
.blog-table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; font-size: .9rem; }
.blog-table th, .blog-table td { border: 1px solid var(--border); padding: .5rem .75rem; text-align: left; }
.blog-table th { background: var(--bg); font-weight: 700; }
.blog-table tr:nth-child(even) td { background: var(--bg); }

/* CTA box */
.blog-post-cta-box { display: flex; align-items: center; gap: 1rem; background: linear-gradient(135deg, #4f46e511, #7c3aed11); border: 1.5px solid #4f46e133; border-radius: 16px; padding: 1.25rem 1.5rem; margin: 2.5rem 0; flex-wrap: wrap; }
.bpcta-icon { font-size: 2rem; }
.bpcta-text { flex: 1; display: flex; flex-direction: column; gap: .2rem; font-size: .95rem; }
.bpcta-text strong { font-weight: 700; }
.bpcta-text span { color: var(--muted); font-size: .85rem; }

/* Blog post nav */
.blog-post-nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; font-size: .88rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.blog-post-nav a { color: var(--accent); text-decoration: none; }
.blog-related { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; color: var(--muted); }

/* Landing blog preview */
.blog-preview-section { max-width: 900px; margin: 0 auto; padding: 2.5rem 1.25rem 3rem; }
.blog-preview-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 1.25rem; }
.blog-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.blog-preview-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.25rem; text-decoration: none; color: inherit; transition: box-shadow .15s; }
.blog-preview-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.07); }
.bpc-label { font-size: .75rem; color: var(--accent); font-weight: 600; margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.bpc-title { font-size: .95rem; font-weight: 700; line-height: 1.4; }
.blog-preview-more { font-size: .9rem; color: var(--accent); text-decoration: none; font-weight: 600; }
.blog-preview-more:hover { text-decoration: underline; }

/* Landing nav blog link */
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; }
.landing-nav-blog { color: var(--muted); text-decoration: none; font-size: .9rem; }
.landing-nav-blog:hover { color: var(--text); }
