/* Diet Coach — Clinical Health theme (direction C, 2026-09-14). Selectors preserved. */
*{box-sizing:border-box;margin:0;padding:0}

:root{
  --bg:#f4f6f8;
  --surface:#ffffff;
  --surface-2:#eef2f6;
  --line:#e7ecf1;
  --line-strong:#dde3ea;
  --primary:#0a84ff;
  --primary-press:#0060df;
  --ink:#0b1420;
  --text:#243040;
  --muted:#7b8794;
  --shadow:0 2px 6px rgba(20,40,80,.05);
  --shadow-md:0 4px 16px rgba(20,40,80,.08);
  --ok:#1aa251;
  --warn:#e8871e;
  --over:#e5484d;
}

body{
  background:var(--bg);
  color:var(--text);
  height:100dvh;
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Inter,sans-serif;
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
}

.app{flex-direction:column;max-width:640px;height:100dvh;margin:0 auto;display:flex;background:var(--bg)}

header{
  border-bottom:1px solid var(--line);
  background:var(--surface);
  justify-content:space-between;align-items:center;
  padding:14px 18px;display:flex;position:sticky;top:0;z-index:5;
}
.header-btns{gap:8px;display:flex}
header h1{
  font-size:1.15rem;font-weight:650;letter-spacing:-.015em;color:var(--ink);
  display:flex;align-items:center;gap:8px;
}
header h1::before{content:"";width:8px;height:8px;border-radius:50%;background:var(--primary);flex-shrink:0}

.messages{flex-direction:column;flex:1;gap:14px;padding:18px 16px;display:flex;overflow-y:auto;scroll-behavior:smooth}
.empty{color:var(--muted);text-align:center;margin-top:38%;padding:0 24px;line-height:1.7;font-size:.95rem}

.msg{display:flex;animation:rise .22s ease-out both}
@keyframes rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.msg.user{justify-content:flex-end}
.msg.assistant{justify-content:flex-start}

.bubble{white-space:pre-wrap;word-break:break-word;max-width:84%;padding:11px 15px;font-size:.95rem;line-height:1.55}
.msg.user .bubble{
  background:var(--primary);color:#fff;
  border-radius:18px 18px 5px 18px;
}
.msg.assistant .bubble{
  background:var(--surface);color:var(--text);
  border:1px solid var(--line);border-radius:18px 18px 18px 5px;
  box-shadow:var(--shadow);
}

.input-bar{border-top:1px solid var(--line);background:var(--surface);gap:9px;padding:12px 16px;display:flex;align-items:center}
.attach-btn{
  background:var(--surface-2);color:var(--muted);cursor:pointer;border:none;
  border-radius:50%;width:44px;height:44px;padding:0;font-size:1.2rem;
  display:flex;align-items:center;justify-content:center;transition:background .15s,transform .1s;flex-shrink:0;
}
.attach-btn:hover{background:#e3e9ef}
.attach-btn:active{transform:scale(.94)}
.attach-btn:disabled{opacity:.4}

.input-bar input[type=text],.input-bar input:not([type]){
  border:1px solid var(--line-strong);background:var(--surface);color:var(--text);
  border-radius:22px;outline:none;flex:1;padding:12px 17px;font-size:1rem;transition:border-color .15s,box-shadow .15s;
}
.input-bar input::placeholder{color:var(--muted)}
.input-bar input:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(10,132,255,.15)}

.input-bar button[type=submit]{
  background:var(--primary);color:#fff;cursor:pointer;border:none;border-radius:22px;
  padding:12px 20px;font-size:.9rem;font-weight:600;transition:background .15s,transform .1s;flex-shrink:0;
}
.input-bar button[type=submit]:hover:not(:disabled){background:var(--primary-press)}
.input-bar button[type=submit]:active:not(:disabled){transform:translateY(1px)}
.input-bar button[type=submit]:disabled{opacity:.45;cursor:not-allowed}

.image-preview{border-top:1px solid var(--line);gap:10px;padding:10px 16px;display:flex;position:relative;overflow-x:auto;background:var(--surface)}
.preview-item{flex-shrink:0;position:relative}
.image-preview img{border-radius:12px;max-height:82px;box-shadow:var(--shadow)}
.remove-img{color:#fff;cursor:pointer;background:rgba(11,20,32,.72);border:none;border-radius:50%;width:22px;height:22px;font-size:.7rem;position:absolute;top:-6px;right:-6px}
.msg-img{border-radius:12px;max-width:100%;max-height:200px;margin-bottom:8px;display:block;box-shadow:var(--shadow)}

.msg.assistant .bubble h1,.msg.assistant .bubble h2,.msg.assistant .bubble h3{color:var(--ink);margin:12px 0 6px;font-size:1rem;font-weight:700}
.msg.assistant .bubble h2{font-size:.95rem}
.msg.assistant .bubble h3{font-size:.9rem}
.msg.assistant .bubble h1:first-child,.msg.assistant .bubble h2:first-child,.msg.assistant .bubble h3:first-child{margin-top:0}
.msg.assistant .bubble p{margin:6px 0}
.msg.assistant .bubble p:first-child{margin-top:0}
.msg.assistant .bubble p:last-child{margin-bottom:0}
.msg.assistant .bubble ul,.msg.assistant .bubble ol{margin:6px 0;padding-left:20px}
.msg.assistant .bubble li{margin:4px 0}
.msg.assistant .bubble strong{color:var(--ink)}
.msg.assistant .bubble table{border-collapse:collapse;width:100%;margin:8px 0;font-size:.85rem;border-radius:8px;overflow:hidden}
.msg.assistant .bubble th,.msg.assistant .bubble td{text-align:left;border:1px solid var(--line);padding:6px 9px}
.msg.assistant .bubble th{background:var(--surface-2);color:var(--ink);font-weight:600}
.msg.assistant .bubble code{background:var(--surface-2);border:1px solid var(--line);border-radius:5px;padding:1px 5px;font-size:.85em}

.nav-btn{color:var(--primary);cursor:pointer;background:rgba(10,132,255,.08);border:1px solid var(--line);border-radius:9px;padding:.45rem .85rem;font-size:.85rem;transition:background .15s}
.nav-btn:hover{background:rgba(10,132,255,.14)}
.attach-btn.listening{color:var(--over);animation:1s infinite pulse}
@keyframes pulse{0%,to{opacity:1}50%{opacity:.4}}

/* ---- Dashboard / timeline / exercise pages (shared stylesheet) ---- */
.dashboard{color:var(--text);background:var(--bg);flex-direction:column;height:100vh;display:flex}
.dash-header{background:var(--surface);border-bottom:1px solid var(--line);align-items:center;gap:1rem;padding:1rem 1.5rem;display:flex}
.dash-header h1{flex:1;margin:0;font-size:1.25rem;font-weight:700;letter-spacing:-.015em;color:var(--ink)}
.dash-header input[type=date]{color:var(--text);background:var(--surface);border:1px solid var(--line-strong);border-radius:8px;padding:.45rem .85rem;font-size:.9rem}
.back-btn{color:var(--primary);cursor:pointer;background:rgba(10,132,255,.08);border:1px solid var(--line);border-radius:8px;padding:.45rem .85rem;font-size:.85rem;transition:background .15s}
.back-btn:hover{background:rgba(10,132,255,.14)}
.dash-grid{flex:1;grid-template-rows:1fr 1fr;grid-template-columns:1fr 1fr;gap:1.1rem;padding:1.1rem 1.5rem;display:grid;overflow-y:auto}
@media (width<=768px){.dash-grid{grid-template-rows:auto;grid-template-columns:1fr}}
.panel{background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:1.3rem;overflow-y:auto;box-shadow:var(--shadow-md)}
.panel h2{color:var(--ink);margin:0 0 .9rem;font-size:1.1rem;font-weight:700;letter-spacing:-.01em}
.panel h3{color:var(--muted);text-transform:uppercase;letter-spacing:.6px;margin:.7rem 0 .35rem;font-size:.8rem;font-weight:600}
.health-stats{grid-template-columns:repeat(3,1fr);gap:.85rem;display:grid}
.stat{text-align:center;background:var(--surface-2);border:1px solid var(--line);border-radius:12px;padding:.75rem}
.stat-val{color:var(--ink);font-size:1.5rem;font-weight:750;display:block}
.stat-label{color:var(--muted);font-size:.75rem}
.macro-bars{flex-direction:column;gap:.55rem;display:flex}
.macro-row{grid-template-columns:70px 1fr 65px;align-items:center;gap:.5rem;display:grid}
.macro-label{color:var(--muted);font-size:.8rem}
.macro-bar-bg{background:var(--surface-2);border-radius:10px;height:20px;position:relative;overflow:hidden}
.macro-bar-fill{background:var(--primary);border-radius:10px;height:100%;transition:width .4s}
.macro-bar-fill.good{background:var(--ok)}
.macro-bar-fill.over{background:var(--over)}
.macro-target-zone{background:rgba(26,162,81,.14);border-left:1px dashed rgba(26,162,81,.5);border-right:1px dashed rgba(26,162,81,.5);height:100%;position:absolute;top:0}
.macro-value{text-align:right;font-size:.8rem;font-weight:600}
.macro-value.good{color:var(--ok)}
.macro-value.over{color:var(--over)}
.meals-panel{overflow-y:auto}
.exercise-list{flex-direction:column;gap:.45rem;display:flex}
.exercise-item{border-bottom:1px solid var(--line);justify-content:space-between;align-items:center;padding:.45rem 0;font-size:.85rem;display:flex}
.exercise-name{color:var(--text)}
.exercise-details{color:var(--primary);white-space:nowrap;font-weight:600}
.exercise-total{color:var(--ok);justify-content:space-between;padding-top:.5rem;font-size:.85rem;font-weight:700;display:flex}
.meal-group{margin-bottom:.5rem}
.meal-item{border-bottom:1px solid var(--line);grid-template-columns:160px 1fr auto;align-items:baseline;gap:.5rem;padding:.35rem 0;font-size:.82rem;display:grid}
.item-name{color:var(--text);text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}
.item-desc{color:var(--muted);text-overflow:ellipsis;white-space:nowrap;font-size:.75rem;overflow:hidden}
.item-cal{color:var(--primary);white-space:nowrap;text-align:right;font-weight:600}
.suggest-btn{color:var(--primary);cursor:pointer;background:rgba(10,132,255,.08);border:1px solid var(--line);border-radius:10px;width:100%;padding:.65rem 1.2rem;font-size:.9rem;font-weight:600;transition:background .15s}
.suggest-btn:hover:not(:disabled){background:rgba(10,132,255,.16)}
.suggest-btn:disabled{opacity:.5;cursor:not-allowed}
.suggestions-content{margin-top:.85rem;font-size:.85rem;line-height:1.55}
.suggestions-content ul{padding-left:1.2rem}
.suggestions-content li{margin-bottom:.35rem}
.loading{color:var(--muted);font-size:.85rem;font-style:italic}
