/* Pulse — dark, ring-forward aesthetic. Always dark for the premium look. */
:root {
  --bg: #0a0a0c;
  --bg-elev: #161619;
  --card: #161619;
  --card-2: #1f1f24;
  --text: #f5f5f7;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --hair: rgba(255, 255, 255, 0.07);
  --sep: rgba(255, 255, 255, 0.07);

  --accent: #8b5cf6;
  --accent-2: #a855f7;

  --ring-track: rgba(255, 255, 255, 0.08);
  --green: #30d158;
  --blue: #0a84ff;
  --purple: #a855f7;
  --amber: #ffb340;
  --red: #ff453a;
  --cyan: #32d8e6;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 30px rgba(0, 0, 0, 0.4);
  --glow: 0 8px 24px rgba(139, 92, 246, 0.45);
  --r: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body {
  min-height: 100vh;
  padding-bottom: calc(78px + var(--safe-bottom));
  background-image: radial-gradient(900px 480px at 50% -8%, rgba(139, 92, 246, 0.14), transparent 70%);
  background-attachment: fixed;
}
button { font-family: inherit; cursor: pointer; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--safe-top) + 12px) 20px 10px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
}
.header-row { display: flex; align-items: center; justify-content: space-between; }
.app-header h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.6px; margin: 0; }
.header-date { margin: 2px 0 0; color: var(--text-3); font-size: 13px; font-weight: 600; }
.icon-btn {
  border: none; background: var(--card-2); color: var(--text);
  font-size: 18px; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; border: 1px solid var(--hair);
}
.icon-btn:active { background: var(--accent); }

/* ---------- View ---------- */
.view { padding: 8px 16px 24px; max-width: 720px; margin: 0 auto; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-3); margin: 24px 6px 10px; }
.muted { color: var(--text-2); }
.tiny { font-size: 12px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: var(--r);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 4px; font-size: 17px; font-weight: 700; }
.card h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }

.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* metric tile */
.metric { background: var(--card); border: 1px solid var(--hair); border-radius: 18px; padding: 15px; }
.metric .label { font-size: 11px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.metric .value { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin-top: 3px; }
.metric .value small { font-size: 13px; font-weight: 600; color: var(--text-3); }
.metric .delta { font-size: 12px; font-weight: 700; margin-top: 3px; }
.delta.up { color: var(--green); } .delta.down { color: var(--red); } .delta.flat { color: var(--text-3); }

/* ---------- Hero: trio of rings ---------- */
.hero { background: linear-gradient(160deg, #1b1b22, #131317); }
.rings3 { display: flex; justify-content: space-around; align-items: flex-start; gap: 6px; }
.ringcol { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: 1; }
.ringcol-label { font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.7px; }
.hero-blurb { margin-top: 16px; font-size: 14px; line-height: 1.45; color: var(--text-2); text-align: center; }
.hero-state { font-weight: 800; }

.ring { position: relative; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .score { font-weight: 800; line-height: 1; letter-spacing: -1px; font-size: 38px; }
.ring.sm .score { font-size: 28px; }
.ring .score-sub { font-size: 10px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 3px; }

/* ---------- Forms ---------- */
label.fld { display: block; margin-bottom: 13px; }
label.fld .lab { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
input, select, textarea {
  width: 100%; font-size: 16px; font-family: inherit;
  padding: 13px 14px; border-radius: 13px; border: 1px solid var(--hair);
  background: var(--card-2); color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px); background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
textarea { resize: vertical; min-height: 64px; }

.seg { display: flex; background: var(--card-2); border-radius: 12px; padding: 4px; gap: 4px; border: 1px solid var(--hair); }
.seg button { flex: 1; border: none; background: transparent; color: var(--text-2); padding: 10px 6px; border-radius: 9px; font-size: 14px; font-weight: 600; }
.seg button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: none; border-radius: 14px; padding: 15px;
  font-size: 16px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.btn:active { filter: brightness(0.92); }
.btn.secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--hair); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: 0.5; }
.btn-sm { width: auto; padding: 10px 15px; font-size: 14px; border-radius: 11px; }

/* list rows */
.list { background: var(--card); border: 1px solid var(--hair); border-radius: var(--r); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--sep); }
.li:last-child { border-bottom: none; }
.li.accent { border-left: 3px solid var(--accent); }
.li .li-main { flex: 1; min-width: 0; }
.li .li-title { font-weight: 600; font-size: 15px; }
.li .li-sub { font-size: 13px; color: var(--text-3); }
.li .li-val { font-weight: 800; }
.del { color: var(--red); background: transparent; border: none; font-size: 20px; padding: 4px 8px; }

.pill { display: inline-block; padding: 5px 11px; border-radius: 100px; font-size: 12px; font-weight: 700; }
.pill.green { background: rgba(48,209,88,0.18); color: var(--green); }
.pill.amber { background: rgba(255,179,64,0.18); color: var(--amber); }
.pill.red { background: rgba(255,69,58,0.18); color: var(--red); }
.pill.blue { background: rgba(10,132,255,0.18); color: var(--blue); }

/* nutrition chips */
.nchips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.nchip { display: flex; align-items: center; gap: 11px; background: var(--card-2); border: 1px solid var(--hair); border-radius: 15px; padding: 12px 13px; }
.nchip .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.nchip-l { font-size: 11px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.nchip-v { font-size: 18px; font-weight: 800; margin-top: 1px; }
.nchip-v span { font-size: 12px; color: var(--text-3); font-weight: 600; }

/* macro bars */
.macro { margin-bottom: 13px; }
.macro .macro-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.bar { height: 9px; border-radius: 6px; background: var(--ring-track); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; }

/* coach chat */
.chat { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 14px; }
.bubble { max-width: 86%; padding: 12px 15px; border-radius: 19px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; }
.bubble.coach { align-self: flex-start; background: var(--card-2); border: 1px solid var(--hair); border-bottom-left-radius: 6px; }
.bubble.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 6px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { min-height: 46px; max-height: 120px; }
.chat-input .btn { width: auto; padding: 13px 17px; }

.insight { display: flex; gap: 13px; align-items: flex-start; padding: 13px 0; border-bottom: 1px solid var(--sep); }
.insight:last-child { border-bottom: none; }
.insight .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; box-shadow: 0 0 10px currentColor; }
.insight .it { font-size: 15px; line-height: 1.45; }
.insight .it b { font-weight: 700; }

.spark { width: 100%; height: 56px; display: block; }

/* ---------- Tab bar (with raised center button) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: flex-end;
  padding: 10px 8px calc(8px + var(--safe-bottom));
  background: rgba(12, 12, 14, 0.82);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--hair);
}
.tab {
  border: none; background: transparent; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; flex: 1; padding: 4px 2px;
}
.tab .tab-ico { font-size: 21px; line-height: 1; }
.tab.active { color: var(--accent); }
.tab.center {
  position: relative;
}
.tab.center .tab-ico {
  width: 56px; height: 56px; margin-top: -26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; display: grid; place-items: center; font-size: 24px;
  box-shadow: var(--glow); border: 3px solid var(--bg);
}
.tab.center.active { color: var(--accent); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.6); display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 560px; background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--hair); border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  max-height: 88vh; overflow-y: auto; animation: slideUp 0.26s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal h2 { margin: 0 0 14px; font-size: 21px; font-weight: 800; }
.modal-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--text-3); opacity: 0.5; margin: -4px auto 14px; }

.empty { text-align: center; color: var(--text-3); padding: 26px 10px; font-size: 14px; }

.banner {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  border-radius: var(--r); padding: 15px 17px; margin-bottom: 14px; font-size: 14px; line-height: 1.5;
}
.banner b { font-weight: 800; }
.banner .x { float: right; background: rgba(255,255,255,0.25); border: none; color: #fff; border-radius: 50%; width: 24px; height: 24px; font-size: 14px; }

.fade-in { animation: fade 0.26s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
