/* Project Ibiza - premium black + gold, athletic, mobile first. */

:root {
  --bg: #0a0908;
  --bg-2: #131110;
  --card: #16140f;
  --card-2: #1d1a13;
  --line: #2a261c;
  --gold: #d4af37;
  --gold-hi: #f1d98a;
  --gold-dim: #9c8336;
  --amber: #b8862b;
  --text: #ece7da;
  --muted: #8c8676;
  --bad: #d96b5a;
  --good: #6fbf73;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  --maxw: 480px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(212, 175, 55, 0.10), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

h1, h2, h3, .ttl { font-family: 'Oswald', sans-serif; font-weight: 600; letter-spacing: 0.04em; margin: 0; }
.display { font-family: 'Anton', sans-serif; letter-spacing: 0.02em; line-height: 0.92; }

#app { max-width: var(--maxw); margin: 0 auto; padding: 0 16px calc(86px + env(safe-area-inset-bottom)); }

/* Header ------------------------------------------------------------------ */
.app-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 2px 10px;
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; }
.brand .name { font-family: 'Oswald'; text-transform: uppercase; letter-spacing: 0.22em; font-size: 13px; color: var(--gold); }
.icon-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--gold);
  width: 38px; height: 38px; border-radius: 10px; font-size: 17px; display: grid; place-items: center;
}

/* Countdown hero ---------------------------------------------------------- */
.hero {
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: 22px; padding: 22px 20px; text-align: center;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(80% 50% at 50% 0%, rgba(212,175,55,0.14), transparent 70%);
  pointer-events: none;
}
.hero .label { text-transform: uppercase; letter-spacing: 0.34em; font-size: 11px; color: var(--muted); }
.hero .count { font-size: clamp(72px, 26vw, 128px); color: var(--gold); margin: 4px 0 0; text-shadow: 0 0 26px rgba(212,175,55,0.25); }
.hero .count small { font-family: 'Oswald'; font-size: 18px; color: var(--muted); letter-spacing: 0.2em; display: block; margin-top: -6px; }
.hero .sub { color: var(--gold-hi); font-size: 13px; letter-spacing: 0.08em; margin-top: 8px; }

/* Cards ------------------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.card h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--gold); margin-bottom: 12px; }
.card.coach { border-color: var(--gold-dim); }
.section-gap { margin-top: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.stat .v { font-family: 'Oswald'; font-size: 26px; color: var(--text); margin-top: 2px; }
.stat .v small { font-size: 13px; color: var(--muted); }
.stat.accent .v { color: var(--gold); }

/* Coach pill */
.call-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  font-family: 'Oswald'; text-transform: uppercase; letter-spacing: 0.12em; font-size: 13px;
  border: 1px solid var(--line);
}
.call-hold { color: var(--good); border-color: rgba(111,191,115,0.4); background: rgba(111,191,115,0.08); }
.call-drop { color: var(--gold); border-color: var(--gold-dim); background: rgba(212,175,55,0.08); }
.call-refeed { color: var(--bad); border-color: rgba(217,107,90,0.4); background: rgba(217,107,90,0.08); }
.call-log, .call-aggressive { color: var(--muted); }
.coach-reason { margin-top: 10px; line-height: 1.5; font-size: 14px; }
.coach-note { margin-top: 10px; font-size: 13px; color: var(--gold-hi); background: rgba(212,175,55,0.06); border-left: 2px solid var(--gold-dim); padding: 8px 10px; border-radius: 0 8px 8px 0; }
.coach-meta { color: var(--muted); font-size: 12px; margin-top: 10px; }

/* Chart ------------------------------------------------------------------- */
.trend { width: 100%; height: auto; display: block; }
.trend .grid { stroke: var(--line); stroke-width: 1; }
.trend .ylab, .trend .xlab { fill: var(--muted); font-size: 9px; font-family: 'Manrope'; }
.trend .goal { stroke: var(--good); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.7; }
.trend .goal-lab { fill: var(--good); font-size: 9px; font-family: 'Oswald'; }
.trend .line { fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.trend .dot { fill: var(--gold-hi); stroke: var(--bg); stroke-width: 1; }
.trend .proj { stroke: var(--amber); stroke-width: 2; stroke-dasharray: 4 4; opacity: 0.9; }
.trend .proj-dot { fill: var(--amber); }
.trend .proj-lab { fill: var(--amber); font-size: 10px; font-family: 'Oswald'; }
.trend .ibiza { stroke: var(--gold-dim); stroke-width: 1; stroke-dasharray: 1 4; opacity: 0.6; }
.chart-empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 14px; }

/* Forms ------------------------------------------------------------------- */
label.field { display: block; margin-top: 12px; }
label.field .lab { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 6px; display: block; }
input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px; font-size: 16px; font-family: 'Manrope';
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-dim); }
textarea { min-height: 220px; line-height: 1.5; resize: vertical; font-size: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #1a1505;
  border: none; border-radius: 12px; padding: 14px 18px; font-family: 'Oswald';
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 15px; font-weight: 600; width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--gold-dim); }
.btn.sm { width: auto; padding: 9px 14px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid rgba(217,107,90,0.5); }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }

/* Lists ------------------------------------------------------------------- */
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.li { display: flex; align-items: center; justify-content: space-between; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.li .d { font-family: 'Oswald'; color: var(--text); }
.li .m { color: var(--muted); font-size: 13px; }
.li .v { font-family: 'Oswald'; font-size: 20px; color: var(--gold); }
.del { background: none; border: none; color: var(--muted); font-size: 18px; padding: 4px 8px; }

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

/* Workout log */
.exercise { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; }
.ex-head { display: grid; grid-template-columns: 1fr auto 32px; gap: 8px; align-items: center; }
.ex-head .ex-pick { min-width: 0; }
.ex-new { margin-top: 8px; }
.ex-muscle { width: auto; }
.rm-ex { background: transparent; border: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.set-row { display: grid; grid-template-columns: 28px 1fr 1fr 32px; gap: 8px; align-items: center; margin-top: 8px; }
.set-row .n { color: var(--muted); font-family: 'Oswald'; text-align: center; }
.workout-card .head { display: flex; justify-content: space-between; align-items: baseline; }
.workout-card .ex { margin-top: 8px; font-size: 14px; }
.workout-card .ex b { font-family: 'Oswald'; font-weight: 600; color: var(--gold-hi); }
.mtag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold-dim); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }

/* Weekly muscle balance --------------------------------------------------- */
.card.balance { border-color: var(--gold-dim); }
.bal-list { margin-top: 6px; }
.bal-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.bal-row:last-child { border-bottom: none; }
.bal-name { font-family: 'Oswald'; font-size: 15px; letter-spacing: 0.04em; }
.bal-meta { color: var(--muted); font-size: 13px; }
.bal-flag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); }
.bal-row.ok .bal-flag { color: var(--gold-hi); border-color: var(--gold-dim); background: rgba(212,175,55,0.08); }
.bal-row.under .bal-name { color: var(--gold); }
.bal-row.under .bal-flag { color: #f0c000; border-color: #6a5a16; background: rgba(240,192,0,0.12); }
.bal-subs { font-size: 12px; color: var(--muted); padding: 0 0 9px; border-bottom: 1px solid var(--line); margin-top: -4px; }
.bal-subs.ok { color: var(--gold-dim); }
.sub-gap { display: inline-block; color: #f0c000; border: 1px solid #6a5a16; background: rgba(240,192,0,0.12); border-radius: 999px; padding: 1px 8px; margin: 2px 4px 0 0; font-size: 11px; }

/* Photos ------------------------------------------------------------------ */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.photo-cell { position: relative; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.photo-cell .date { position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; background: linear-gradient(transparent, rgba(0,0,0,0.8)); color: var(--gold-hi); padding: 10px 6px 4px; font-family: 'Oswald'; letter-spacing: 0.06em; }
.photo-cell.sel { outline: 2px solid var(--gold); }
.photo-cell .pin { position: absolute; top: 4px; right: 4px; background: var(--gold); color: #1a1505; font-family: 'Oswald'; font-size: 11px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.compare figure { margin: 0; }
.compare img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.compare figcaption { text-align: center; font-family: 'Oswald'; color: var(--gold); margin-top: 6px; font-size: 13px; }

/* Tab bar ----------------------------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: rgba(12, 11, 9, 0.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  max-width: var(--maxw); margin: 0 auto;
}
.tab { background: none; border: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 9.5px; font-family: 'Oswald'; letter-spacing: 0.04em; text-transform: uppercase; padding: 4px 2px; flex: 1; min-width: 0; }
.tab svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tab.active { color: var(--gold); }

/* Chat (elite AI coach) --------------------------------------------------- */
.chat-card { display: flex; flex-direction: column; }
.chat-thread { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; padding: 4px 2px 8px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; font-size: 14px; line-height: 1.45; word-wrap: break-word; }
.msg-user { align-self: flex-end; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #1a1505; border-bottom-right-radius: 5px; }
.msg-coach { align-self: flex-start; background: var(--bg-2); border: 1px solid var(--line); color: var(--text); border-bottom-left-radius: 5px; }
.msg.typing { display: flex; gap: 4px; align-items: center; }
.msg.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); opacity: 0.5; animation: blink 1.2s infinite both; }
.msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.quick-row { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 4px; -webkit-overflow-scrolling: touch; }
.chip { white-space: nowrap; background: var(--bg-2); border: 1px solid var(--gold-dim); color: var(--gold-hi); border-radius: 999px; padding: 8px 12px; font-size: 12px; font-family: 'Manrope'; flex: 0 0 auto; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; margin-top: 6px; }
.chat-input textarea { min-height: 44px; resize: none; line-height: 1.4; }
.chat-input .btn { width: auto; flex: 0 0 auto; padding: 12px 16px; }
.chat-input .attach-btn { padding: 12px 12px; }
.msg-img { display: block; width: 100%; max-width: 220px; border-radius: 10px; margin-bottom: 6px; border: 1px solid rgba(0,0,0,0.25); }
.chat-attach { padding: 4px 2px 0; }
.attach-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--gold-dim); color: var(--gold-hi); border-radius: 10px; padding: 5px 8px; font-size: 12px; }
.attach-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
.attach-chip button { background: none; border: none; color: var(--gold); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.assess-card { border-color: var(--gold-dim); margin-top: 12px; }
.assess-text { line-height: 1.55; font-size: 14px; }
.tap { font-size: 10px; color: var(--gold-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-left: 6px; }
.edit-weigh { cursor: pointer; }

/* Onboarding overlay ------------------------------------------------------ */
.onboard { position: fixed; inset: 0; z-index: 60; background: var(--bg); overflow-y: auto; }
.onboard .inner { max-width: var(--maxw); margin: 0 auto; padding: calc(24px + env(safe-area-inset-top)) 18px 40px; }
.onboard .lead { font-family: 'Anton'; font-size: 40px; color: var(--gold); line-height: 0.95; margin: 30px 0 6px; }
.onboard .lead-sub { color: var(--muted); margin-bottom: 8px; line-height: 1.5; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--gold-dim); color: var(--gold-hi);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; z-index: 80; box-shadow: var(--shadow);
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.target-editor .row2 { margin-top: 10px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: none; }
.pace { font-size: 13px; color: var(--muted); margin-top: 6px; }
.pace b { color: var(--gold-hi); font-family: 'Oswald'; }
a.link { color: var(--gold); }
