:root {
  --bg: #07070b; --card: #14141f; --card-2: #181824; --stroke: rgba(255,255,255,0.08);
  --stroke-2: rgba(255,255,255,0.14); --text: #f5f5f9; --dim: #a9a9bb; --faint: #6c6c7e;
  --purple: #8d73f2; --purple-2: #a78bff; --blue: #4d9ef2; --cyan: #38d6e0;
  --green: #4dd58a; --yellow: #fbbf3b; --red: #f2575c;
  --grad: linear-gradient(105deg, #a78bff, #5ab0ff);
  --tabbar: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 40% at 20% 0%, rgba(141,115,242,0.16), transparent 70%),
    radial-gradient(50% 40% at 95% 5%, rgba(77,158,242,0.14), transparent 70%), var(--bg);
}
a { color: var(--blue); text-decoration: none; }
.hidden { display: none !important; }

/* Header */
header.app {
  position: sticky; top: 0; z-index: 10; padding: calc(env(safe-area-inset-top) + 14px) 18px 12px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(7,7,11,0.7); backdrop-filter: blur(16px); border-bottom: 1px solid var(--stroke);
}
header.app .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.15rem; }
header.app .brand img { width: 26px; height: 26px; border-radius: 7px; }
header.app .sync { font-size: 0.72rem; color: var(--faint); display: flex; align-items: center; gap: 5px; }
header.app .sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
header.app .hright { display: flex; align-items: center; gap: 10px; }
.support-btn {
  display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; font-weight: 700;
  padding: 7px 13px; border-radius: 999px; background: linear-gradient(105deg,#a78bff,#5ab0ff);
  color: #fff !important; text-decoration: none; white-space: nowrap;
}
.support-btn:hover { filter: brightness(1.07); }

/* Clickable + chevrons */
.tappable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tile.tappable:active, .card.tappable:active { transform: scale(0.98); }
.rowlink { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 4px; border-bottom: 1px solid var(--stroke); cursor: pointer; }
.rowlink:last-child { border-bottom: 0; }
.rowlink .lv { display: flex; align-items: center; gap: 12px; }
.rowlink .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(141,115,242,.14); color: var(--purple-2); }
.rowlink .rv { display: flex; align-items: center; gap: 8px; color: var(--dim); }
.chev { color: var(--faint); }
.backbtn { background: none; border: 0; color: var(--dim); font-size: .95rem; padding: 4px 0 10px; cursor: pointer; font-family: inherit; }

/* Detail modal */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); }
.modal.hidden { display: none; }
.modal-card { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--card-2); border: 1px solid var(--stroke-2); border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(env(safe-area-inset-bottom) + 24px); animation: slideup .25s ease; }
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-card .mh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-card .mh h3 { margin: 0; font-size: 1.15rem; }
.modal-card .close { background: none; border: 0; color: var(--dim); font-size: 1.4rem; cursor: pointer; }
.modal-card .bigval { font-family: "Inter"; font-weight: 800; font-size: 2.6rem; line-height: 1; margin: 6px 0; }
.modal-card .how { color: var(--dim); font-size: .92rem; line-height: 1.6; margin: 12px 0; }
.detrow { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--stroke); font-size: .9rem; }
.detrow:last-child { border-bottom: 0; }
.detrow .k { color: var(--dim); }

/* Trend sparkline */
.trend { background: var(--card); border: 1px solid var(--stroke); border-radius: 16px; padding: 14px; margin-bottom: 10px; cursor: pointer; }
.trend .th { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 6px; }
.trend .th b { font-weight: 700; }

/* Layout */
main { padding: 18px 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px); max-width: 560px; margin: 0 auto; }
h2.section { font-size: 1.05rem; margin: 22px 4px 12px; }
.muted { color: var(--dim); }
.center { text-align: center; }

/* Cards & tiles */
.card { background: var(--card); border: 1px solid var(--stroke); border-radius: 20px; padding: 18px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 1rem; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--card-2); border: 1px solid var(--stroke); border-radius: 16px; padding: 12px 8px; text-align: center; }
.tile .v { font-weight: 700; font-size: 1.15rem; }
.tile .l { font-size: 0.7rem; color: var(--faint); margin-top: 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Rings */
.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .track { fill: none; stroke: rgba(255,255,255,0.07); }
.ring .bar { fill: none; stroke-linecap: round; transition: stroke-dashoffset 1.3s cubic-bezier(.2,.85,.25,1); }
.ring .lab { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .lab .val { font-weight: 700; }
.ring .lab .cap { font-size: 0.7rem; color: var(--faint); margin-top: 2px; }
.bigring { display: grid; place-items: center; margin: 6px 0 14px; }

.pill { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 5px 12px; border-radius: 999px; }
.pill.green { background: rgba(77,213,138,.16); color: var(--green); }
.pill.yellow { background: rgba(251,191,59,.16); color: var(--yellow); }
.pill.red { background: rgba(242,87,92,.16); color: var(--red); }
.pill.blue { background: rgba(77,158,242,.16); color: var(--blue); }
.pill.cyan { background: rgba(56,214,224,.16); color: var(--cyan); }
.pill.purple { background: rgba(141,115,242,.16); color: var(--purple-2); }

.guidance { color: var(--dim); font-size: 0.92rem; margin-top: 10px; }
.legend { display: flex; gap: 16px; font-size: 0.72rem; color: var(--faint); margin-top: 8px; }
.legend i { display: inline-block; width: 16px; height: 4px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* Bars */
.bars .barrow { margin-bottom: 10px; }
.bars .bh { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 4px; }
.bars .track { height: 8px; background: rgba(255,255,255,.08); border-radius: 6px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 6px; background: var(--grad); }

/* Forms */
label.f { display: block; font-size: 0.85rem; color: var(--dim); margin: 12px 0 4px; }
input.f, select.f, textarea.f {
  width: 100%; background: var(--card-2); border: 1px solid var(--stroke-2); color: var(--text);
  border-radius: 12px; padding: 11px 12px; font-size: 1rem; font-family: inherit;
}
textarea.f { min-height: 90px; resize: vertical; }
button.btn {
  width: 100%; border: 0; border-radius: 999px; padding: 14px; font-size: 1rem; font-weight: 600;
  background: var(--grad); color: #fff; margin-top: 14px; cursor: pointer; font-family: inherit;
}
button.btn.ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--stroke-2); }
button.btn.coffee { background: #ffdd00; color: #3a2f00; }

/* Bottom tab bar */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: rgba(12,12,19,0.92); backdrop-filter: blur(16px);
  border-top: 1px solid var(--stroke);
}
nav.tabs button {
  flex: 1; background: none; border: 0; color: var(--faint); font-size: 0.66rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 9px; font-family: inherit;
}
nav.tabs button svg { width: 22px; height: 22px; }
nav.tabs button.active { color: var(--purple-2); }

/* Install banner */
.install { background: var(--card); border: 1px solid var(--stroke-2); border-radius: 16px; padding: 14px; margin-bottom: 14px; font-size: 0.9rem; }
.install b { color: var(--text); }
