:root {
  --bg: #0f1115;
  --surface: #191d24;
  --surface-2: #232833;
  --text: #f5f7fa;
  --muted: #9aa4b2;
  --accent: #7c5cff;
  --accent-2: #a78bfa;
  --cal: #ff7a59;
  --pro: #38d9a9;
  --burn: #ffb347;
  --danger: #ff6b6b;
  --ok: #38d9a9;
  --radius: 20px;
}

* { 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, "Segoe UI", Roboto, sans-serif; overscroll-behavior-y: none; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column;
  padding: 0 16px; padding-bottom: calc(150px + env(safe-area-inset-bottom)); }

.screen { flex: 1; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 2px 10px; }
.topbar h1 { font-size: 26px; margin: 0; letter-spacing: -0.5px; font-weight: 800; }
.topbar h1 span { color: var(--accent-2); }
.screen-tag { color: var(--muted); font-size: 14px; font-weight: 600; }

.icon-btn { background: var(--surface); border: none; color: var(--text); width: 46px; height: 46px;
  border-radius: 14px; font-size: 20px; }

/* Banner */
.banner { background: var(--surface); border-radius: 16px; padding: 14px 16px; font-size: 15px;
  margin-bottom: 14px; line-height: 1.35; border-left: 4px solid var(--accent); }

/* Rings */
.rings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.ring-card { background: var(--surface); border-radius: var(--radius); padding: 18px 12px; text-align: center; }
.ring { --pct: 0; width: 128px; height: 128px; border-radius: 50%; margin: 0 auto;
  background: conic-gradient(var(--cal) calc(var(--pct) * 1%), var(--surface-2) 0);
  display: flex; align-items: center; justify-content: center; transition: background 0.5s ease; }
.ring.pro { background: conic-gradient(var(--pro) calc(var(--pct) * 1%), var(--surface-2) 0); }
.ring-inner { width: 100px; height: 100px; border-radius: 50%; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-val { font-size: 28px; font-weight: 800; line-height: 1; }
.ring-goal { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ring-tag { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.ring-note { font-size: 12px; color: var(--burn); margin: 10px 0 0; min-height: 14px; }

/* Stat strip */
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 20px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px 4px; text-align: center; }
.stat-val { display: block; font-size: 20px; font-weight: 800; }
.stat-lbl { font-size: 10px; color: var(--muted); }

.section-title { font-size: 15px; color: var(--muted); margin: 0 0 10px 2px; font-weight: 600; }

/* Lists / cards */
.recent, .log-list { display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; line-height: 1.5; }
.coach { background: var(--surface); border: 1px dashed var(--surface-2); border-radius: var(--radius); padding: 22px 16px; }
.coach-title { font-size: 18px; font-weight: 800; color: var(--text); margin: 0 0 4px; }
.coach-sub { font-size: 14px; color: var(--muted); margin: 0 0 16px; }
.chips { display: flex; flex-direction: column; gap: 8px; }
.chip { background: var(--surface-2); border: none; color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 15px; text-align: left; }
.chip:active { background: var(--accent); color: #fff; }

.share-cta { width: 100%; margin-bottom: 20px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.entry { background: var(--surface); border-radius: var(--radius); padding: 14px; animation: pop 0.2s ease; }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.entry-said { font-size: 13px; color: var(--muted); font-style: italic; flex: 1; }
.entry-total { font-weight: 800; color: var(--cal); white-space: nowrap; }
.entry.move .entry-total { color: var(--burn); }
.entry-items { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.entry-items li { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.it-emoji { font-size: 18px; }
.it-name { flex: 1; }
.it-macro { font-size: 12px; color: var(--muted); white-space: nowrap; }
.entry-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.entry-src { font-size: 11px; color: var(--muted); }
.entry-src .approx { color: var(--burn); }
.del-btn { background: none; border: none; color: var(--muted); font-size: 13px; padding: 6px; }

.day-total { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.burn-summary { background: linear-gradient(135deg, rgba(255,179,71,0.18), rgba(124,92,255,0.12));
  border-radius: 16px; padding: 14px 16px; font-size: 15px; margin-bottom: 14px; }
.burn-summary b { color: var(--burn); }

/* Dock */
.dock { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; padding: 10px 16px; background: linear-gradient(to top, var(--bg) 78%, transparent); }
.transcript-wrap { margin-bottom: 10px; }
.transcript { width: 100%; background: var(--surface-2); border: 1px solid var(--accent); border-radius: 14px;
  padding: 12px; color: var(--text); font-size: 15px; resize: none; font-family: inherit; }
.dock-controls { display: flex; gap: 10px; align-items: center; }
.mic-btn { width: 56px; height: 56px; flex: none; border-radius: 50%; border: none; font-size: 24px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 18px rgba(124,92,255,0.4); }
.mic-btn.listening { animation: pulse 1.2s infinite; background: linear-gradient(135deg, var(--danger), var(--cal)); }
.mic-btn.requesting, .mic-btn.processing { opacity: 0.7; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,107,107,0.5); } 70% { box-shadow: 0 0 0 16px rgba(255,107,107,0); } 100% { box-shadow: 0 0 0 0 rgba(255,107,107,0); } }
.text-input { flex: 1; background: var(--surface); border: none; border-radius: 14px; padding: 14px; color: var(--text); font-size: 16px; }
.dock-hint { font-size: 12px; color: var(--muted); margin: 8px 2px 0; min-height: 14px; }

/* Buttons */
.btn-primary { background: var(--accent); border: none; color: #fff; font-weight: 700; border-radius: 14px;
  padding: 0 18px; height: 52px; font-size: 16px; }
.btn-primary.add { height: 52px; }
.btn-primary:disabled { opacity: 0.45; }
.btn-primary.full, .btn-ghost.full { width: 100%; margin-top: 10px; }
.btn-ghost { background: var(--surface-2); border: none; color: var(--text); border-radius: 14px; height: 48px; font-size: 15px; width: 100%; }
.btn-danger { background: none; border: 1px solid var(--danger); color: var(--danger); border-radius: 14px; height: 48px; width: 100%; margin-top: 8px; }

/* Bottom nav */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface);
  border-top: 1px solid var(--surface-2); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.nav-btn { background: none; border: none; color: var(--muted); font-size: 20px; padding: 10px 0 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
.nav-btn span { font-size: 10px; }
.nav-btn.active { color: var(--accent-2); }

/* Fields */
.field { display: block; font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.field input, .field select { display: block; width: 100%; margin-top: 6px; background: var(--surface-2);
  border: none; border-radius: 12px; padding: 13px; color: var(--text); font-size: 16px; -webkit-appearance: none; appearance: none; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.weight-row { display: flex; gap: 10px; margin-top: 6px; }
.weight-row input { flex: 1; margin-top: 0; }
.unit-toggle { display: flex; background: var(--surface-2); border-radius: 12px; overflow: hidden; }
.unit-toggle button { background: none; border: none; color: var(--muted); padding: 0 16px; font-weight: 600; font-size: 15px; }
.unit-toggle button.active { background: var(--accent); color: #fff; }
.err { color: var(--danger); font-size: 12px; margin-top: 4px; display: block; }

.settings { padding-bottom: 20px; }
.ai-status { background: var(--surface); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted); margin: 18px 0 12px; }
.disclaimer { font-size: 12px; color: var(--muted); line-height: 1.5; }
.version { font-size: 11px; color: var(--muted); text-align: center; margin-top: 16px; }

.generated { background: var(--surface-2); border-radius: 16px; padding: 14px; margin-bottom: 16px; }
.gen-head { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.gen-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* Sheets / modals */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: flex-end;
  justify-content: center; z-index: 60; }
.sheet-overlay[hidden] { display: none; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; animation: slideUp 0.25s ease; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet h2 { margin: 0 0 6px; }
.sheet-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; line-height: 1.5; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: 12px 0; }
.share-canvas { width: 100%; border-radius: 16px; background: var(--bg); }

/* Toast */
.toast { position: fixed; bottom: calc(140px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text); padding: 12px 16px; border-radius: 14px; display: flex; gap: 14px;
  align-items: center; z-index: 80; box-shadow: 0 8px 24px rgba(0,0,0,0.4); max-width: 90%; }
.toast[hidden] { display: none; }
.toast button { background: none; border: none; color: var(--accent-2); font-weight: 700; font-size: 14px; }

.offline-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--burn); margin-right: 6px; }
