/* ============================================================
   NutriTrack — style.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #09090f;
  --bg1:       rgba(255,255,255,0.04);
  --bg2:       rgba(255,255,255,0.07);
  --border:    rgba(255,255,255,0.08);
  --border2:   rgba(255,255,255,0.14);

  --text:      #f1f5f9;
  --muted:     #64748b;
  --sub:       #94a3b8;

  --green:  #4ade80;
  --blue:   #60a5fa;
  --orange: #fb923c;
  --pink:   #f472b6;
  --purple: #a78bfa;
  --yellow: #facc15;
  --red:    #f87171;
  --cyan:   #22d3ee;

  --r: 16px;
  --rs: 10px;
  --font: 'Inter', system-ui, sans-serif;
  --hh: 62px;
  --nh: 70px;
}

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); overflow: hidden; }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 500px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* Ambient glow */
#app::before {
  content: '';
  position: fixed;
  top: -150px; left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(74,222,128,0.05) 0%, transparent 65%);
  pointer-events: none; z-index: 0;
}

/* ── Header ── */
.app-header {
  height: var(--hh);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(9,9,15,0.85);
  backdrop-filter: blur(20px);
  flex-shrink: 0; z-index: 50; position: relative;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 22px; }
.logo-img  { width: 34px; height: 34px; object-fit: contain; }
.logo-text {
  font-size: 18px; font-weight: 800;
  background: linear-gradient(120deg, var(--green) 0%, var(--red) 50%, var(--blue) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.date-nav { display: flex; align-items: center; gap: 10px; }
.date-btn {
  width: 28px; height: 28px; border: none;
  background: var(--bg1); color: var(--text);
  border-radius: 8px; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.date-btn:hover { background: var(--bg2); }
.current-date { font-size: 12px; font-weight: 600; color: var(--sub); min-width: 86px; text-align: center; }
.streak-badge {
  display: flex; align-items: center; gap: 4px;
  background: rgba(251,146,60,0.12);
  border: 1px solid rgba(251,146,60,0.25);
  padding: 4px 10px; border-radius: 20px;
  font-size: 13px; font-weight: 700; color: var(--orange);
}

/* ── Main ── */
.main-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding-bottom: calc(var(--nh) + 16px);
  position: relative; z-index: 1;
}
.tab-panel { display: none; padding: 18px; animation: fadeUp .28s ease; }
.tab-panel.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Section label ── */
.section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--muted);
  margin: 22px 0 10px;
}

/* ── Calorie Hero ── */
.calorie-hero {
  display: flex; align-items: center; gap: 16px;
}
.ring-wrap { position: relative; width: 176px; height: 176px; flex-shrink: 0; }
.big-ring { width: 176px; height: 176px; transform: rotate(-90deg); display: block; }
.big-ring .ring-track { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 12; }
.big-ring .ring-prog {
  fill: none; stroke: var(--green); stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 527.8;
  stroke-dashoffset: 527.8;
  transition: stroke-dashoffset .8s cubic-bezier(.4,0,.2,1);
  filter: drop-shadow(0 0 8px rgba(74,222,128,.55));
}
.ring-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%); text-align: center;
}
.ring-num  { font-size: 30px; font-weight: 800; line-height: 1; }
.ring-of   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ring-tag  { font-size: 9px; font-weight: 700; letter-spacing: 1.5px; color: var(--green); margin-top: 4px; }
.cal-chips { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.cal-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 14px;
  transition: background .2s, border-color .2s;
}
.cal-chip:hover { background: var(--bg2); border-color: var(--border2); }
.chip-icon { font-size: 22px; }
.chip-val  { font-size: 20px; font-weight: 700; line-height: 1; }
.chip-lbl  { font-size: 10px; color: var(--muted); margin-top: 1px; }

/* ── Macro Grid ── */
.macro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.macro-card {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px;
  display: flex; align-items: center; gap: 10px;
  transition: background .2s, border-color .2s, transform .2s;
}
.macro-card:hover { background: var(--bg2); border-color: var(--border2); transform: translateY(-1px); }
.mring-wrap { position: relative; width: 48px; height: 48px; flex-shrink: 0; }
.mring { width: 48px; height: 48px; transform: rotate(-90deg); display: block; }
.mring .ring-track { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 5; }
.mring .ring-prog {
  fill: none; stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 150.8; stroke-dashoffset: 150.8;
  transition: stroke-dashoffset .7s ease;
}
.mring .ring-prog.blue   { stroke: var(--blue);   filter: drop-shadow(0 0 4px rgba(96,165,250,.5)); }
.mring .ring-prog.orange { stroke: var(--orange);  filter: drop-shadow(0 0 4px rgba(251,146,60,.5)); }
.mring .ring-prog.pink   { stroke: var(--pink);    filter: drop-shadow(0 0 4px rgba(244,114,182,.5)); }
.mring .ring-prog.purple { stroke: var(--purple);  filter: drop-shadow(0 0 4px rgba(167,139,250,.5)); }
.mring-icon {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%) rotate(90deg);
  font-size: 15px; line-height: 1;
}
.macro-info { flex: 1; min-width: 0; }
.macro-name { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.macro-val  { font-size: 15px; font-weight: 700; }
.macro-of   { font-size: 11px; font-weight: 400; color: var(--muted); }
.mbar-track { height: 4px; background: rgba(255,255,255,0.06); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.mbar { height: 100%; border-radius: 2px; width: 0%; transition: width .6s ease; max-width: 100%; }
.mbar.blue   { background: var(--blue); }
.mbar.orange { background: var(--orange); }
.mbar.pink   { background: var(--pink); }
.mbar.purple { background: var(--purple); }
.mbar.yellow { background: var(--yellow); }
.mbar.red    { background: var(--red); }
.mbar.cyan   { background: var(--cyan); }

/* ── Micro Row ── */
.micro-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.micro-card {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 10px; text-align: center;
  transition: background .2s, border-color .2s;
}
.micro-card:hover { background: var(--bg2); border-color: var(--border2); }
.micro-icon { font-size: 18px; margin-bottom: 3px; }
.micro-lbl  { font-size: 9px;  font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 3px; }
.micro-val  { font-size: 15px; font-weight: 700; }
.micro-unit { font-size: 10px; font-weight: 400; color: var(--muted); }
.micro-goal { font-size: 9px; color: var(--muted); margin-top: 3px; }

/* ── Dashboard food list ── */
#dash-meals { display: flex; flex-direction: column; gap: 8px; }
.dash-food-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 11px 14px;
}
.dfi-left { flex: 1; min-width: 0; }
.dfi-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dfi-meal { font-size: 10px; color: var(--muted); text-transform: capitalize; margin-top: 1px; }
.dfi-cal  { font-size: 13px; font-weight: 600; color: var(--green); margin-left: 10px; white-space: nowrap; }

/* ── Log Tab ── */
.log-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.meal-section { margin-bottom: 18px; }
.meal-section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted);
  padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.meal-section-cal { color: var(--green); font-size: 11px; }
.log-food-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 12px 14px; margin-bottom: 6px;
}
.lfi-info { flex: 1; min-width: 0; }
.lfi-name    { font-size: 14px; font-weight: 500; }
.lfi-macros  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.lfi-cal     { font-size: 14px; font-weight: 700; color: var(--green); white-space: nowrap; }
.lfi-delete  {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 17px; padding: 0 4px;
  transition: color .2s;
}
.lfi-delete:hover { color: var(--red); }

/* ── Water Tab ── */
.water-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.water-total-disp { font-size: 18px; font-weight: 700; color: var(--cyan); }

.bottle-wrap { display: flex; justify-content: center; margin: 8px 0 26px; }
.bottle { display: flex; flex-direction: column; align-items: center; }
.bottle-neck {
  width: 44px; height: 22px;
  background: var(--bg1); border: 1px solid var(--border2);
  border-radius: 8px 8px 0 0; border-bottom: none;
}
.bottle-body {
  width: 120px; height: 200px;
  background: rgba(34,211,238,0.06);
  border: 2px solid rgba(34,211,238,0.25);
  border-radius: 0 0 24px 24px;
  position: relative; overflow: hidden;
}
.water-fill {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 0%;
  background: linear-gradient(180deg, rgba(34,211,238,0.5) 0%, rgba(34,211,238,0.85) 100%);
  transition: height 0.7s cubic-bezier(.4,0,.2,1);
}
.wave {
  position: absolute; top: -12px; left: -50%;
  width: 200%; height: 24px;
  background: rgba(34,211,238,0.3);
  border-radius: 50%;
  animation: waveAnim 2.5s infinite linear;
}
.w2 { animation-duration: 3.4s; animation-direction: reverse; opacity: 0.5; }
@keyframes waveAnim {
  from { transform: translateX(0); }
  to   { transform: translateX(50%); }
}
.bottle-pct {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 20px; font-weight: 800; color: var(--cyan);
  text-shadow: 0 0 12px rgba(34,211,238,.6);
  z-index: 2;
}

.quick-btns { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.qbtn {
  background: var(--bg1); border: 1px solid var(--border);
  color: var(--cyan); border-radius: var(--rs);
  padding: 10px 6px; font-family: var(--font);
  font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all .2s;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.qbtn span { font-size: 9px; font-weight: 400; color: var(--muted); }
.qbtn:hover { background: rgba(34,211,238,0.1); border-color: rgba(34,211,238,0.4); transform: translateY(-1px); }

.custom-water-row { display: flex; gap: 8px; margin-bottom: 12px; }
.custom-water-row .form-control { flex: 1; }

#water-log-list { display: flex; flex-direction: column; gap: 8px; }
.water-log-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 10px 14px;
}
.wli-left { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.wli-amt  { font-weight: 700; color: var(--cyan); }
.wli-time { font-size: 11px; color: var(--muted); }
.wli-del  { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; transition: color .2s; }
.wli-del:hover { color: var(--red); }

/* ── Goals Form ── */
.goals-form { max-width: 100%; }
.goal-group-label { font-size: 13px; font-weight: 600; color: var(--sub); margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit .form-control { flex: 1; }
.unit { font-size: 12px; color: var(--muted); white-space: nowrap; font-weight: 600; }

/* ── Shared Form Styles ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: .5px; }
.form-control {
  background: var(--bg1);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--rs);
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 14px;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-control:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(74,222,128,.12); }
.form-control::placeholder { color: var(--muted); }
select.form-control { cursor: pointer; }
select.form-control option { background: #1a1a24; }

/* ── Buttons ── */
.btn-green {
  background: var(--green); color: #050810;
  border: none; border-radius: 20px;
  padding: 9px 18px; font-family: var(--font);
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: all .2s;
}
.btn-green:hover { background: #6be89a; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(74,222,128,.35); }
.btn-green.btn-full { width: 100%; border-radius: var(--rs); padding: 13px; font-size: 15px; }
.btn-ghost {
  background: var(--bg1); color: var(--sub);
  border: 1px solid var(--border);
  border-radius: var(--rs); padding: 10px 16px;
  font-family: var(--font); font-size: 13px; cursor: pointer;
  transition: all .2s; width: 100%;
}
.btn-ghost:hover { background: var(--bg2); border-color: var(--border2); }
.btn-ghost.btn-full { width: 100%; }

/* ── Bottom Nav ── */
.bottom-nav {
  height: var(--nh);
  display: flex;
  background: rgba(9,9,15,0.9);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  flex-shrink: 0; z-index: 50;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-family: var(--font);
  transition: color .2s; position: relative;
}
.nav-btn.active { color: var(--green); }
.nav-btn.active::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 32px; height: 2px;
  background: var(--green);
  border-radius: 0 0 4px 4px;
}
.nav-icon { font-size: 20px; line-height: 1; }
.nav-lbl  { font-size: 10px; font-weight: 600; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  display: none; align-items: flex-end; justify-content: center;
  padding-bottom: var(--nh);
}
.modal-overlay.open { display: flex; animation: overlayIn .2s ease; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #111118;
  border: 1px solid var(--border2);
  border-radius: 24px 24px 0 0;
  width: 100%; max-width: 500px;
  max-height: 85vh; display: flex; flex-direction: column;
  animation: slideUp .3s cubic-bezier(.4,0,.2,1);
}
@keyframes slideUp {
  from { transform: translateY(80px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0; flex-shrink: 0;
}
.modal-hdr h2 { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border: none;
  background: var(--bg2); color: var(--muted);
  border-radius: 50%; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.modal-close:hover { background: rgba(248,113,113,.2); color: var(--red); }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }

.search-input { font-size: 15px; padding: 12px 15px; }
.search-results { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.search-result-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 10px 14px; cursor: pointer;
  transition: all .15s;
}
.search-result-item:hover { background: var(--bg2); border-color: var(--green); }
.sri-name  { font-size: 13px; font-weight: 500; }
.sri-sub   { font-size: 11px; color: var(--muted); margin-top: 1px; }
.sri-cal   { font-size: 13px; font-weight: 600; color: var(--green); }

.selected-food-preview {
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.2);
  border-radius: var(--rs); padding: 12px 14px;
}
.sfp-name { font-size: 14px; font-weight: 600; color: var(--green); }
.sfp-serving { font-size: 11px; color: var(--muted); margin-top: 2px; }

.nutrition-preview {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: var(--bg1); border-radius: var(--rs); padding: 10px;
}
.np-item { text-align: center; }
.np-val { font-size: 14px; font-weight: 700; }
.np-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; margin-top:16px;}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Suggestion Tab ── */
#suggest-results { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; margin-bottom: 24px;}
.suggest-card {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 16px; position: relative;
  transition: all .2s;
}
.suggest-card.high-match { border-color: var(--green); background: rgba(74,222,128,0.03); }
.suggest-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.suggest-left { flex: 1; min-width: 0; }
.suggest-icon { font-size: 24px; margin-bottom: 4px; display: inline-block; }
.suggest-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.suggest-match { font-size: 11px; font-weight: 700; color: var(--green); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; display: inline-block; background: rgba(74,222,128,0.1); padding: 2px 6px; border-radius: 4px; }
.suggest-match.low { color: var(--orange); background: rgba(251,146,60,0.1); }
.suggest-tags { font-size: 10px; color: var(--muted); margin-bottom: 8px; }

.suggest-right { text-align: right; flex-shrink: 0;}
.s-cal { font-size: 16px; font-weight: 700; color: var(--text); }
.s-btn { background: var(--bg2); border: 1px solid var(--border2); color: var(--text); border-radius: 6px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .2s; margin-top: 8px; }
.s-btn:hover { background: var(--green); border-color: var(--green); color: #000; }

.suggest-macros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.sm-item { text-align: center; }
.sm-val { font-size: 13px; font-weight: 700; }
.sm-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; }

.suggest-expand-btn {
  width: 100%; border: none; background: none; color: var(--blue);
  font-size: 12px; font-weight: 600; cursor: pointer; padding: 8px 0 0; margin-top: 8px; text-align: center;
}
.suggest-expand-btn:hover { text-decoration: underline; }
.suggest-details { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.suggest-details.open { display: block; animation: slideDown 0.3s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.sd-sec { margin-bottom: 12px; }
.sd-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; letter-spacing: 0.5px; }
.sd-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; color: var(--text); }
.sd-list li { margin-bottom: 4px; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty-state span { display: block; font-size: 34px; margin-bottom: 10px; }
.empty-state p { font-size: 13px; line-height: 1.6; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(var(--nh) + 12px); left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1f2937; border: 1px solid var(--border2);
  color: var(--text); border-radius: 20px;
  padding: 9px 18px; font-size: 13px; font-weight: 500;
  z-index: 999; opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
  pointer-events: none; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── Overrides for water / misc ── */
#reset-water { margin-top: 4px; }

/* ── Header right cluster ── */
.header-right { display: flex; align-items: center; gap: 10px; }
.logout-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border2); border-radius: 8px;
  background: var(--bg1); color: var(--muted);
  font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .2s, border-color .2s;
}
.logout-btn:hover { color: var(--red); border-color: var(--red); }

/* ── Auth Overlay ── */
.auth-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(9,9,15,0.97);
  z-index: 9999;
  align-items: center; justify-content: center;
  padding: 24px;
}
.auth-overlay.visible { display: flex; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--bg1);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 32px 28px;
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.auth-logo-img { width: 38px; height: 38px; object-fit: contain; }
.auth-logo-text {
  font-size: 15px; font-weight: 800;
  background: linear-gradient(120deg, var(--green) 0%, var(--red) 50%, var(--blue) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.auth-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.auth-error {
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--red);
  border-radius: 8px; padding: 10px 14px;
  font-size: 13px; margin-bottom: 16px;
}
.auth-submit { margin-top: 18px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-switch a { color: var(--green); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0 0;
  color: var(--muted); font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: ''; flex: 1;
  height: 1px; background: var(--border);
}

.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 16px;
  margin-top: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border2);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-google:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.22); }
.btn-google:active { background: rgba(255,255,255,0.07); }

/* ── Chipper FAB ── */
.chipper-fab {
  position: fixed;
  bottom: calc(var(--nh) + 14px);
  right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--green) 0%, #22c55e 100%);
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(74,222,128,0.35);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.chipper-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(74,222,128,0.5); }
.chipper-fab.hidden { opacity: 0; pointer-events: none; transform: scale(0.7); }

/* ── Chipper Panel ── */
.chipper-panel {
  position: fixed;
  bottom: var(--nh);
  left: 50%;
  transform: translateX(-50%) translateY(110%);
  width: min(100vw, 500px);
  height: 68vh;
  max-height: 600px;
  background: rgba(13, 15, 20, 0.97);
  border: 1px solid var(--border2);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column;
  z-index: 300;
  transition: transform .35s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
}
.chipper-panel.open {
  transform: translateX(-50%) translateY(0);
}

/* Dock button */
.chipper-dock {
  width: 28px; height: 28px;
  border: 1px solid var(--border2); border-radius: 6px;
  background: none; color: var(--muted);
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
  flex-shrink: 0;
}
.chipper-dock:hover { color: var(--green); border-color: var(--green); }

/* Drag handle cursor on header (not on buttons) */
.chipper-hdr { cursor: grab; }
.chipper-hdr:active { cursor: grabbing; }
.chipper-hdr button { cursor: pointer; }

/* After dragging: opacity-based show/hide (transform is locked by inline style) */
.chipper-panel[data-dragged]:not(.open) {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.chipper-panel[data-dragged].open {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.2s ease;
}

/* Docked to right side */
.chipper-panel.docked {
  right: 0 !important;
  top: var(--hh) !important;
  bottom: 0 !important;
  left: auto !important;
  width: 360px !important;
  height: auto !important;
  max-height: none !important;
  border-radius: 0 !important;
  border-right: none !important;
  border-bottom: none !important;
  border-top: 1px solid var(--border2) !important;
  border-left: 1px solid var(--border2) !important;
  transform: none !important;
  transition: none !important;
}

/* Header */
.chipper-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(255,255,255,0.03);
}
.chipper-hdr-left { display: flex; align-items: center; gap: 10px; }
.chipper-hdr-icon { font-size: 26px; line-height: 1; }
.chipper-hdr-name { font-size: 15px; font-weight: 700; color: var(--text); }
.chipper-hdr-sub  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.chipper-close {
  width: 30px; height: 30px;
  border: 1px solid var(--border2); border-radius: 50%;
  background: none; color: var(--muted);
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
}
.chipper-close:hover { color: var(--text); border-color: var(--border2); }

/* Messages */
.chipper-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.chipper-msg { display: flex; }
.chipper-msg-user  { justify-content: flex-end; }
.chipper-msg-bot   { justify-content: flex-start; }

.chipper-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
}
.chipper-msg-user .chipper-bubble {
  background: var(--green);
  color: #061a0e;
  border-bottom-right-radius: 4px;
}
.chipper-msg-bot .chipper-bubble {
  background: var(--bg2);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

/* Markdown inside bot bubbles */
.chipper-msg-bot .chipper-bubble p   { margin: 0 0 6px; }
.chipper-msg-bot .chipper-bubble p:last-child { margin-bottom: 0; }
.chipper-msg-bot .chipper-bubble h3,
.chipper-msg-bot .chipper-bubble h4  { font-size: 13px; font-weight: 700; margin: 8px 0 4px; color: var(--green); }
.chipper-msg-bot .chipper-bubble ul,
.chipper-msg-bot .chipper-bubble ol  { margin: 4px 0 6px 18px; }
.chipper-msg-bot .chipper-bubble li  { margin-bottom: 2px; }
.chipper-msg-bot .chipper-bubble strong { color: var(--text); }
.chipper-msg-bot .chipper-bubble code {
  background: rgba(255,255,255,0.08); border-radius: 4px;
  padding: 1px 5px; font-size: 12px; font-family: monospace;
}
.chipper-msg-bot .chipper-bubble pre {
  background: rgba(0,0,0,0.3); border-radius: 8px;
  padding: 10px; overflow-x: auto; font-size: 12px;
  margin: 6px 0;
}
.chipper-msg-bot .chipper-bubble em { color: var(--sub); }

/* Typing indicator */
.chipper-typing { display: flex; align-items: center; gap: 4px; padding: 12px 14px !important; }
.chipper-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  animation: chipper-bounce 1.2s ease-in-out infinite;
}
.chipper-typing span:nth-child(2) { animation-delay: .2s; }
.chipper-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chipper-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* Input row */
.chipper-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(255,255,255,0.02);
}
.chipper-input {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font);
  line-height: 1.45;
  padding: 9px 14px;
  outline: none;
  transition: border-color .15s;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  overflow-y: auto;
}
.chipper-input:focus { border-color: var(--green); }
.chipper-input::placeholder { color: var(--muted); }
.chipper-send {
  width: 36px; height: 36px;
  border-radius: 50%; border: none;
  background: var(--green);
  color: #061a0e;
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.chipper-send:hover:not(:disabled) { background: #4ade80; transform: scale(1.05); }
.chipper-send:disabled { background: var(--bg2); color: var(--muted); cursor: not-allowed; }

/* ============================================================
   Responsive — Desktop (≥ 768px)
   ============================================================ */
@media (min-width: 768px) {

  /* ── Core grid layout ── */
  #app {
    display: grid;
    grid-template-areas:
      "header header"
      "nav    main";
    grid-template-columns: 220px 1fr;
    grid-template-rows: var(--hh) 1fr;
    max-width: none;
    margin: 0;
  }

  /* Shift ambient glow to center of main content area */
  #app::before {
    left: calc(110px + 50%);
    transform: translateX(-50%);
  }

  .app-header { grid-area: header; }

  /* ── Sidebar nav ── */
  .bottom-nav {
    grid-area: nav;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 16px 8px;
    overflow-y: auto;
  }

  .nav-btn {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 16px;
    gap: 12px;
    border-radius: 10px;
    height: auto;
  }

  .nav-btn.active::before {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    border-radius: 0 3px 3px 0;
  }

  .nav-icon { font-size: 20px; }
  .nav-lbl  { font-size: 13px; }

  /* ── Main content ── */
  .main-content {
    grid-area: main;
    padding-bottom: 16px;
  }

  /* ── Dashboard: 4-column macro grid ── */
  .macro-grid { grid-template-columns: repeat(4, 1fr); }

  /* ── Suggest: 2-column card grid ── */
  #suggest-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  #suggest-results > .empty-state { grid-column: 1 / -1; }

  /* ── Modal: centered (not bottom-sheet) ── */
  .modal-overlay {
    align-items: center;
    padding-bottom: 0;
  }

  .modal {
    border-radius: 20px;
    max-height: 80vh;
  }

  /* ── Toast: no bottom nav offset ── */
  .toast { bottom: 24px; }

  /* ── Chipper FAB: viewport-relative ── */
  .chipper-fab {
    bottom: 24px;
    right: 24px;
  }

  /* ── Chipper panel: float from bottom-right ── */
  .chipper-panel {
    bottom: 24px;
    right: 24px;
    left: auto;
    width: 420px;
    height: 580px;
    max-height: calc(100vh - 120px);
    border-radius: 18px;
    border-bottom: 1px solid var(--border2);
    transform: translateY(calc(100% + 48px));
  }

  .chipper-panel.open {
    transform: translateY(0);
  }
}
