/* Team Evolve brand: black, white and purple */
:root {
  --bg: #000000;
  --surface: #121214;
  --surface-2: #1b1b1f;
  --ink: #ffffff;
  --muted: #a3a3ad;
  --line: #2a2a30;
  --accent: #8c52ff;      /* Team Evolve purple */
  --accent-soft: rgba(140, 82, 255, .14);
  --accent-ink: #ffffff;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Archivo", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 820px; margin: 0 auto; padding: 24px 16px 96px; }
h1, h2, legend, .display {
  font-stretch: 125%;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.6rem, 5.5vw, 2.4rem); margin: 8px 0 6px; line-height: 1.05; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 0 0 12px; }
.accent { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { display: grid; place-items: center; min-height: 50vh; }
.center-text { text-align: center; }
.notice { background: var(--accent-soft); border: 1px solid rgba(140,82,255,.35); border-radius: 10px; padding: 10px 14px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: #000; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { height: 34px; width: auto; display: block; }
.wordmark { font-stretch: 125%; font-weight: 800; letter-spacing: .12em; font-size: .95rem; }
.wm-team { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--muted); }
@media (max-width: 480px) { #topbar-name { display: none; } }

/* Cards, forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
fieldset { margin: 0; min-width: 0; }
legend { font-size: .95rem; padding: 0 6px; margin-left: -6px; color: var(--accent); }
fieldset.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
fieldset.form-grid > legend { grid-column: 1 / -1; }
fieldset.form-grid > .full, fieldset.form-grid > .hint { grid-column: 1 / -1; }
.hint { margin: -4px 0 0; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .95rem; }
label .req { color: var(--accent); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }
.grid2, .grid3 { display: grid; gap: 12px; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.check { flex-direction: row; align-items: flex-start; gap: 12px; font-weight: 400; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }

/* Buttons */
.btn {
  font: inherit; font-weight: 700; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); padding: 12px 18px;
  text-transform: uppercase; letter-spacing: .04em; font-stretch: 112%;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-big { padding: 16px 20px; font-size: 1rem; }
.btn-ghost {
  font: inherit; font-size: .9rem; background: transparent; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font-weight: 600; }

/* Tabs */
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin: 18px 0; }
.tabs.scroll { overflow-x: auto; scrollbar-width: none; }
.tab { flex: 1; font: inherit; font-weight: 700; font-size: .9rem; white-space: nowrap; border: 0; background: transparent; color: var(--muted); padding: 10px 12px; border-radius: 9px; cursor: pointer; position: relative; }
.tab.active { background: var(--accent); color: #fff; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-left: 4px; vertical-align: middle; }

/* Auth */
.auth { max-width: 440px; margin: 4vh auto 0; }
.auth-logo { display: block; width: 120px; height: auto; margin: 0 auto 18px; }

/* PAR-Q, terms */
.parq { display: flex; flex-direction: column; }
.parq-q { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.parq-q:last-child { border-bottom: 0; }
.parq-q p { margin: 0; font-size: .95rem; }
.yn { display: flex; gap: 6px; flex: none; }
.yn label { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.yn input { width: auto; accent-color: var(--accent); }
.yn-field { gap: 8px; }
@media (max-width: 480px) { .parq-q { flex-direction: column; align-items: flex-start; } }
.terms { margin: 0; padding-left: 20px; color: var(--muted); }
.terms li { margin-bottom: 6px; }

/* Scale slider */
.score { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; }
.score input[type=range] { grid-column: 1 / -1; padding: 0; accent-color: var(--accent); background: transparent; border: 0; }
.score output { font-weight: 900; font-size: 1.15rem; min-width: 2ch; text-align: right; color: var(--accent); }
.score .ends { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); font-weight: 400; }

/* Photo slots */
.photo-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.photo-slot {
  position: relative; aspect-ratio: 3 / 4; border: 1.5px dashed var(--line); border-radius: 12px;
  display: grid; place-items: center; text-align: center; cursor: pointer; overflow: hidden;
  background: var(--surface-2); color: var(--muted); font-size: .85rem; font-weight: 600;
}
.photo-slot:hover { border-color: var(--accent); color: var(--ink); }
.photo-slot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.photo-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot .slot-label { position: relative; z-index: 1; padding: 4px 8px; border-radius: 6px; }
.photo-slot.filled .slot-label { background: rgba(0,0,0,.65); color: #fff; align-self: end; margin-bottom: 8px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.thumbs a { display: block; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); position: relative; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs span { position: absolute; left: 6px; bottom: 6px; font-size: .7rem; background: rgba(0,0,0,.7); padding: 2px 6px; border-radius: 4px; }

/* Stats and targets */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat .v { font-size: 1.5rem; font-weight: 900; font-stretch: 112%; }
.stat .v small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.targets { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .95rem; }
table.targets th { background: var(--accent); color: #fff; font-weight: 700; text-align: center; padding: 9px 8px; }
table.targets th:first-child { border-top-left-radius: 10px; }
table.targets th:last-child { border-top-right-radius: 10px; }
table.targets td { text-align: center; padding: 10px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
table.targets td:first-child { text-align: left; font-weight: 700; }
@media (max-width: 480px) { table.targets { font-size: .82rem; } table.targets th, table.targets td { padding: 8px 3px; } }
.macro-grid { display: grid; grid-template-columns: 110px repeat(5, minmax(64px, 1fr)); gap: 8px; align-items: center; overflow-x: auto; }
.macro-grid > span { font-size: .75rem; color: var(--muted); text-align: center; }
.macro-grid input { padding: 9px 8px; }
@media (max-width: 560px) { .macro-grid { grid-template-columns: 62px minmax(64px, 1.5fr) repeat(4, minmax(40px, 1fr)); gap: 5px; overflow: visible; } .macro-grid input { padding: 8px 4px; font-size: .9rem; } .macro-grid > span { font-size: .68rem; } }

.prewrap { white-space: pre-wrap; margin: 0; }
.plan-text { white-space: pre-wrap; margin: 0; font-size: .95rem; line-height: 1.6; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.client-row { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.client-row:hover { border-color: var(--accent); }
.client-row .sub { color: var(--muted); font-size: .875rem; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: .72rem; font-weight: 700; padding: 4px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.badge.good { color: var(--good); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.badge.accent { color: var(--accent); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Check-ins */
.ci { display: flex; flex-direction: column; gap: 14px; }
.ci-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: minmax(130px, 45%) 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; white-space: pre-wrap; }
.kv .yes { color: var(--bad); font-weight: 700; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: 8px; } }
.feedback { border-left: 3px solid var(--accent); padding: 10px 14px; background: var(--surface-2); border-radius: 0 10px 10px 0; }
.feedback .who { font-weight: 700; font-size: .85rem; color: var(--accent); margin-bottom: 2px; }

/* AI panels */
.ai { border: 1px solid rgba(140,82,255,.45); background: linear-gradient(180deg, rgba(140,82,255,.10), rgba(140,82,255,.03)); }
.ai-tag { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.ai-tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.ai.working .ai-tag::before { animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }
.ai details { border-top: 1px solid var(--line); padding-top: 10px; }
.ai summary { cursor: pointer; font-weight: 700; }
.ai ul { margin: 0; padding-left: 20px; }
.status-on_track { color: var(--good); }
.status-needs_attention { color: var(--warn); }
.status-concern { color: var(--bad); }

/* Messages */
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; font-size: .95rem; }
.bubble.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble .meta { display: block; font-size: .7rem; opacity: .7; margin-top: 4px; }
.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.composer textarea { min-height: 46px; }

/* Charts */
.spark { width: 100%; height: 90px; display: block; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }

/* Welcome */
.welcome-section h2 { color: var(--accent); }
.welcome-section ul { margin: 0; padding-left: 20px; }
.welcome-section li { margin-bottom: 6px; }

.empty { text-align: center; padding: 32px 18px; color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - 32px); background: #fff; color: #000;
  padding: 12px 18px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--bad); color: #000; }

/* Exercise library */
.ex-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ex-row .ex-main { min-width: 0; }
.ex-row h3 { overflow-wrap: anywhere; }
.ex-group { color: var(--muted); font-size: .85rem; }
.ex-link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); font-weight: 700; cursor: pointer; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { font: inherit; font-size: .85rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 99px; padding: 6px 12px; cursor: pointer; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.video { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
.video.tall { aspect-ratio: 9 / 16; max-height: 70vh; margin: 0 auto; width: auto; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.8); display: grid; place-items: center; padding: 16px; }
.modal-card { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

/* Install banner */
.install { display: flex; gap: 12px; align-items: center; }
.install img { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.install .grow { flex: 1; min-width: 0; }

/* Food log */
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.day-nav h2 { margin: 0; text-align: center; flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { font: inherit; font-size: .85rem; font-weight: 700; border: 0; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.seg button.active { background: var(--accent); color: #fff; }
.seg button:disabled { cursor: default; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 72px 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.bar-row .lbl { color: var(--muted); }
.bar-row .val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.over > span { background: var(--warn); }
.meal h3 { display: flex; justify-content: space-between; align-items: baseline; }
.meal h3 small { color: var(--muted); font-weight: 500; }
.food-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
.food-item:first-of-type { border-top: 0; }
.food-item .fi-name { min-width: 0; }
.food-item .fi-name b { display: block; overflow-wrap: anywhere; font-weight: 600; }
.food-item .fi-name span { color: var(--muted); font-size: .8rem; }
.food-item .fi-kcal { white-space: nowrap; font-variant-numeric: tabular-nums; }
.icon-btn { font: inherit; background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; flex: none; }
.icon-btn:hover { color: var(--bad); border-color: var(--bad); }
.result { display: flex; justify-content: space-between; gap: 10px; align-items: center; width: 100%; text-align: left; font: inherit; color: inherit; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.result:hover { border-color: var(--accent); }
.result b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.result span { color: var(--muted); font-size: .8rem; }
.scanner { position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000; border-radius: 12px; overflow: hidden; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner::after { content: ""; position: absolute; left: 12%; right: 12%; top: 40%; height: 20%; border: 2px solid var(--accent); border-radius: 10px; pointer-events: none; }
#html5-reader { width: 100%; }
.macro-preview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.macro-preview div { background: var(--surface-2); border-radius: 10px; padding: 8px 4px; }
.macro-preview b { display: block; font-size: 1.1rem; }
.macro-preview span { font-size: .72rem; color: var(--muted); }
.week-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.week-table th, .week-table td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.week-table th:first-child, .week-table td:first-child { text-align: left; }
.week-table th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }

/* WhatsApp */
.btn-wa { display: inline-flex; align-items: center; gap: 8px; background: #25d366; color: #000; text-decoration: none; font-weight: 800; border-radius: 10px; padding: 10px 16px; font-size: .95rem; }
.btn-wa:hover { filter: brightness(1.05); }
.btn-wa svg { width: 18px; height: 18px; }
