/* ============================================================
   TATA FIT — Running Coach
   Design system: dark athletic, glassmorphism, mobile-first
   ============================================================ */

:root {
  /* base */
  --bg: #0a0a0f;
  --bg-soft: #101018;
  --card: #16161f;
  --card-2: #1c1c28;
  --glass: rgba(255, 255, 255, 0.04);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);

  /* text */
  --text: #f5f5f7;
  --text-dim: #a0a0b0;
  --text-faint: #6b6b7b;

  /* accent */
  --accent: #ff6b35;
  --accent-2: #ff2d78;
  --grad: linear-gradient(135deg, #ff6b35 0%, #ff2d78 100%);
  --grad-soft: linear-gradient(135deg, rgba(255,107,53,.16), rgba(255,45,120,.16));

  /* hr zones */
  --z1: #3b82f6;
  --z2: #22c55e;
  --z3: #eab308;
  --z4: #f97316;
  --z5: #ef4444;

  /* semantic */
  --good: #22c55e;
  --warn: #eab308;
  --bad: #ef4444;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,.45);
  --font: "Plus Jakarta Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 92px; /* space for bottom nav */
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(255,45,120,.08), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(255,107,53,.06), transparent 55%);
  background-attachment: fixed;
}

/* ---------- typography ---------- */
h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: .95rem; font-weight: 700; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- layout ---------- */
.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px;
}

.view { display: none; animation: fadeIn .35s ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--grad);
  display: grid; place-items: center;
  font-size: 19px; font-weight: 900; color: #fff;
  box-shadow: 0 4px 16px rgba(255,80,70,.4);
}
.brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -.02em; }
.brand-sub { font-size: .7rem; color: var(--text-faint); font-weight: 600; }
.chip {
  font-size: .68rem; font-weight: 700; padding: 5px 11px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  color: var(--text-dim); background: var(--glass);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.glass { background: var(--glass); backdrop-filter: blur(8px); border-color: var(--line); }
.card.accent-border { border-color: rgba(255,107,53,.35); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-weight: 700; font-size: .92rem; }
.card-link { font-size: .78rem; color: var(--accent); font-weight: 700; text-decoration: none; }
.section-label {
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-faint); margin: 26px 4px 12px;
}
.section-label:first-of-type { margin-top: 0; }

/* ---------- hero metric ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(400px 200px at 90% 0%, rgba(255,45,120,.18), transparent 60%),
    linear-gradient(180deg, #1d1d2b, #14141f);
  border: 1px solid var(--line-strong);
  border-radius: 24px; padding: 22px;
  margin-bottom: 16px;
}
.hero .session-tag {
  font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em;
  color: var(--accent); margin-bottom: 10px;
}
.hero .session-title { font-size: 1.35rem; font-weight: 800; margin-bottom: 4px; }
.hero .session-desc { font-size: .85rem; color: var(--text-dim); margin-bottom: 18px; }

.metric-row { display: flex; gap: 10px; }
.metric {
  flex: 1; background: var(--glass); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px;
}
.metric .val { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; }
.metric .val small { font-size: .7rem; font-weight: 600; color: var(--text-faint); }
.metric .lbl { font-size: .68rem; color: var(--text-faint); font-weight: 600; margin-top: 3px; }

/* ---------- progress ring ---------- */
.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring {
  --p: 0; --sz: 96px;
  width: var(--sz); height: var(--sz); border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255,255,255,.07) 0);
  display: grid; place-items: center; flex-shrink: 0;
}
.ring::before {
  content: ""; width: calc(var(--sz) - 14px); height: calc(var(--sz) - 14px);
  border-radius: 50%; background: var(--card);
}
.ring .inner { position: absolute; text-align: center; }
.ring .pct { font-size: 1.15rem; font-weight: 800; }
.ring .pct small { font-size: .65rem; color: var(--text-faint); }
.ring-info .big { font-size: 1.05rem; font-weight: 800; }
.ring-info .small { font-size: .78rem; color: var(--text-dim); margin-top: 3px; line-height: 1.35; }

/* ---------- readiness gauge ---------- */
.gauge-track { height: 12px; background: rgba(255,255,255,.06); border-radius: 999px; position: relative; overflow: hidden; }
.gauge-fill {
  height: 100%; border-radius: 999px; background: var(--grad);
  transition: width 1s cubic-bezier(.22,1,.36,1);
}
.gauge-labels { display: flex; justify-content: space-between; margin-top: 8px; font-size: .66rem; color: var(--text-faint); font-weight: 600; }
.readiness-state { margin-top: 12px; display: flex; align-items: center; gap: 10px; }
.readiness-state .state-pill {
  font-size: .78rem; font-weight: 800; padding: 6px 14px; border-radius: 999px;
}
.state-pill.ready { background: rgba(34,197,94,.15); color: var(--good); }
.state-pill.caution { background: rgba(234,179,8,.15); color: var(--warn); }
.state-pill.red { background: rgba(239,68,68,.15); color: var(--bad); }

/* ---------- coach bubble ---------- */
.coach {
  background: linear-gradient(180deg, rgba(255,107,53,.08), rgba(255,45,120,.05));
  border: 1px solid rgba(255,107,53,.25);
  border-radius: var(--radius); padding: 18px;
}
.coach-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.coach-avatar {
  width: 42px; height: 42px; border-radius: 14px; background: var(--grad);
  display: grid; place-items: center; font-size: 20px;
  box-shadow: 0 4px 14px rgba(255,80,70,.35);
}
.coach-name { font-weight: 800; font-size: .9rem; }
.coach-role { font-size: .68rem; color: var(--text-dim); }
.coach-quote { position: relative; font-size: .92rem; line-height: 1.6; color: var(--text); }
.coach-quote::before {
  content: ""; position: absolute; left: 0; top: -6px; width: 3px; height: 100%;
  background: var(--grad); border-radius: 3px;
}
.coach-quote { padding-left: 14px; }
.coach-tips { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.tip {
  display: flex; gap: 10px; align-items: flex-start; font-size: .82rem; color: var(--text-dim);
  background: var(--glass); border-radius: 12px; padding: 10px 12px;
}
.tip .n {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--grad-soft); color: var(--accent);
  display: grid; place-items: center; font-size: .68rem; font-weight: 800;
}

/* ---------- charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 7px; height: 110px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; border-radius: 6px 6px 3px 3px;
  background: var(--grad-soft); border: 1px solid rgba(255,107,53,.3);
  transition: height .8s cubic-bezier(.22,1,.36,1);
  min-height: 4px;
}
.bar.z1 { background: var(--z1); border-color: transparent; opacity: .85; }
.bar.z2 { background: var(--z2); border-color: transparent; opacity: .85; }
.bar.z3 { background: var(--z3); border-color: transparent; opacity: .85; }
.bar.z4 { background: var(--z4); border-color: transparent; opacity: .85; }
.bar.z5 { background: var(--z5); border-color: transparent; opacity: .85; }
.bar-lbl { font-size: .62rem; color: var(--text-faint); font-weight: 600; }
.bar-val { font-size: .62rem; color: var(--text-dim); font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.legend span { font-size: .68rem; color: var(--text-dim); display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* heatmap */
.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.hm-day { aspect-ratio: 1; border-radius: 5px; background: rgba(255,255,255,.04); position: relative; }
.hm-day.lvl1 { background: rgba(255,107,53,.25); }
.hm-day.lvl2 { background: rgba(255,107,53,.45); }
.hm-day.lvl3 { background: rgba(255,107,53,.7); }
.hm-day.lvl4 { background: var(--accent); }
.hm-day.today { outline: 2px solid #fff; outline-offset: 1px; }

/* two-line trend */
.trend-legend { display: flex; gap: 14px; margin-bottom: 10px; font-size: .7rem; color: var(--text-dim); }
.trend-legend b { display: inline-flex; align-items: center; gap: 6px; }
.trend-legend .l1 { color: var(--accent); } .trend-legend .l2 { color: #38bdf8; }

/* ---------- target page ---------- */
.target-hero {
  background: linear-gradient(180deg, #1d1d2b, #14141f);
  border: 1px solid var(--line-strong); border-radius: 24px; padding: 24px;
  text-align: center; margin-bottom: 16px;
}
.target-hero .race-type { font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.target-hero .race-name { font-size: 1.5rem; font-weight: 800; margin: 8px 0 2px; }
.target-hero .race-date { color: var(--text-dim); font-size: .85rem; margin-bottom: 20px; }
.countdown { display: flex; justify-content: center; gap: 14px; margin-bottom: 6px; }
.cd-cell { text-align: center; }
.cd-cell .v { font-size: 1.7rem; font-weight: 800; }
.cd-cell .l { font-size: .64rem; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-weight: 700; font-size: .9rem;
  border: none; border-radius: 14px; padding: 14px 22px; cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 20px rgba(255,80,70,.35); width: 100%; }
.btn-ghost { background: var(--glass); color: var(--text); border: 1px solid var(--line-strong); }
.btn-sm { padding: 9px 16px; font-size: .8rem; border-radius: 11px; }

/* ---------- plan / calendar ---------- */
.day-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px; margin-bottom: 9px;
}
.day-row.today { border-color: rgba(255,107,53,.5); background: var(--grad-soft); }
.day-date { text-align: center; flex-shrink: 0; width: 44px; }
.day-date .d { font-size: 1.25rem; font-weight: 800; }
.day-date .m { font-size: .62rem; color: var(--text-faint); font-weight: 700; text-transform: uppercase; }
.day-body { flex: 1; }
.day-body .sess { font-weight: 700; font-size: .9rem; }
.day-body .meta { font-size: .72rem; color: var(--text-dim); margin-top: 2px; }
.session-badge {
  font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 6px; display: inline-block; margin-bottom: 5px;
}
.badge-easy { background: rgba(59,130,246,.15); color: var(--z1); }
.badge-tempo { background: rgba(234,179,8,.15); color: var(--z3); }
.badge-interval { background: rgba(249,115,22,.15); color: var(--z4); }
.badge-long { background: rgba(34,197,94,.15); color: var(--z2); }
.badge-strength { background: rgba(168,85,247,.15); color: #a855f7; }
.badge-rest { background: rgba(255,255,255,.08); color: var(--text-dim); }
.check {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-strong);
  display: grid; place-items: center; flex-shrink: 0; cursor: pointer;
  transition: all .15s ease; color: transparent; font-size: .8rem;
}
.check.done { background: var(--good); border-color: var(--good); color: #fff; }

/* ---------- activity list ---------- */
.activity {
  display: flex; align-items: center; gap: 14px;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px; margin-bottom: 10px;
}
.act-icon {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  background: var(--grad-soft); display: grid; place-items: center; font-size: 19px;
}
.act-body { flex: 1; }
.act-title { font-weight: 700; font-size: .9rem; }
.act-meta { font-size: .72rem; color: var(--text-faint); margin-top: 3px; }
.act-stats { text-align: right; flex-shrink: 0; }
.act-stats .v { font-weight: 800; font-size: .95rem; }
.act-stats .l { font-size: .64rem; color: var(--text-faint); }

/* ---------- zone bar ---------- */
.zone-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; gap: 2px; margin-top: 12px; }
.zone-bar span { height: 100%; }
.zone-bar .z1 { background: var(--z1); } .zone-bar .z2 { background: var(--z2); }
.zone-bar .z3 { background: var(--z3); } .zone-bar .z4 { background: var(--z4); }
.zone-bar .z5 { background: var(--z5); }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .78rem; font-weight: 700; color: var(--text-dim); margin-bottom: 7px; }
.input, .select {
  width: 100%; font-family: var(--font); font-size: .95rem; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--line-strong);
  border-radius: 13px; padding: 13px 15px; outline: none;
  transition: border .15s ease;
}
.input:focus, .select:focus { border-color: var(--accent); }
.select { appearance: none; }
.input::placeholder { color: var(--text-faint); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- checklist ---------- */
.ex-item {
  display: flex; align-items: center; gap: 12px; padding: 13px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 9px;
}
.ex-item .ex-name { flex: 1; font-weight: 600; font-size: .88rem; }
.ex-item .ex-spec { font-size: .7rem; color: var(--text-faint); margin-top: 2px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 13px; padding: 4px; margin-bottom: 16px; }
.tab { flex: 1; text-align: center; font-size: .8rem; font-weight: 700; color: var(--text-dim); padding: 10px 4px; border-radius: 10px; cursor: pointer; transition: all .15s ease; }
.tab.active { background: var(--grad); color: #fff; box-shadow: 0 3px 12px rgba(255,80,70,.3); }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(14,14,20,.85); backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: .62rem; color: var(--text-faint); font-weight: 600;
  padding: 6px 12px; border-radius: 12px; cursor: pointer; transition: all .15s ease;
  background: none; border: none; font-family: var(--font);
}
.nav-item .ico { font-size: 1.25rem; line-height: 1; }
.nav-item.active { color: var(--accent); }
.nav-item.active .ico { filter: drop-shadow(0 2px 6px rgba(255,107,53,.5)); }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--grad); color: #fff; border: none;
  font-size: 30px; font-weight: 300; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 8px 24px rgba(255,80,70,.45); z-index: 60;
  transition: transform .12s ease;
}
.fab:active { transform: scale(.92); }

/* ---------- split rows ---------- */
.split-row {
  display: grid; grid-template-columns: 40px 1fr 1fr;
  gap: 8px; align-items: center; margin-bottom: 8px;
}
.split-row .km-lbl { font-weight: 800; font-size: .82rem; color: var(--text-dim); text-align: center; }
.split-row .input { padding: 11px 12px; font-size: .9rem; }
.split-add {
  width: 100%; padding: 12px; border-radius: 13px; border: 1px dashed var(--line-strong);
  background: none; color: var(--text-dim); font-family: var(--font);
  font-weight: 700; font-size: .82rem; cursor: pointer; margin-top: 4px;
}
.split-add:active { border-color: var(--accent); color: var(--accent); }

/* ---------- chat ---------- */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 160px); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 4px 2px 12px; -webkit-overflow-scrolling: touch; }
.chat-msg { display: flex; gap: 10px; margin-bottom: 14px; }
.chat-msg.user { flex-direction: row-reverse; }
.chat-bubble {
  max-width: 80%; padding: 12px 15px; border-radius: 18px;
  font-size: .88rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.chat-msg.coach .chat-bubble {
  background: var(--card-2); border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.chat-msg.user .chat-bubble {
  background: var(--grad); color: #fff; border-bottom-right-radius: 6px;
}
.chat-avatar {
  width: 34px; height: 34px; border-radius: 12px; background: var(--grad);
  display: grid; place-items: center; font-size: 16px; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(255,80,70,.3);
}
.chat-typing { display: flex; gap: 4px; padding: 14px 16px; }
.chat-typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim);
  animation: blink 1.2s infinite;
}
.chat-typing i:nth-child(2) { animation-delay: .2s; }
.chat-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity:.2; transform: scale(.8);} 40% { opacity:1; transform: scale(1);} }

.chat-input-bar {
  display: flex; gap: 8px; padding: 10px 0; position: sticky; bottom: 0;
  background: var(--bg); padding-top: 8px;
}
.chat-input-bar .input { flex: 1; border-radius: 999px; padding: 13px 18px; }
.chat-send {
  width: 48px; height: 48px; border-radius: 50%; border: none; background: var(--grad);
  color: #fff; font-size: 18px; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(255,80,70,.35);
}
.chat-send:active { transform: scale(.92); }
.chat-send:disabled { opacity: .4; }

/* markdown-ish minimal */
.chat-bubble b, .chat-bubble strong { color: inherit; }
.chat-msg.coach .chat-bubble b { color: var(--accent); }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1d1d2b; border: 1px solid var(--line-strong); color: var(--text);
  padding: 12px 20px; border-radius: 999px; font-size: .82rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .3s ease; z-index: 99;
  box-shadow: var(--shadow); white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-faint); }
.empty .e { font-size: 40px; margin-bottom: 12px; }
.empty p { font-size: .85rem; line-height: 1.5; }

@media (max-width: 380px) {
  .countdown { gap: 10px; }
  .cd-cell .v { font-size: 1.4rem; }
}
