/* NutriCoach — svijetla verzija.
   Ideja: desna strana je "deklaracija tvog dana" (crne debele crte kao na nutritivnoj tablici),
   chat je čisti papir. Jedan naglasak: žuti marker za ono što je aplikacija upisala. */
:root {
  --paper: #FFFFFF;
  --desk: #EEF0ED;
  --ink: #000000;
  --text: #1C1C1C;
  --grey: #6B6E6A;
  --hair: #D9DCD7;
  --marker: #FFE14D;
  --red: #D3261C;
  --font: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--desk); color: var(--text);
  font: 400 16px/1.5 var(--font); font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
}
button, textarea, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.app {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 0;
  height: 100dvh; max-width: 1240px; margin: 0 auto;
}

/* ---------- chat: papir ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--paper); }
.chat-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 18px 28px 12px; border-bottom: 1px solid var(--hair);
}
.chat-head h1 { margin: 0; font-size: 22px; font-weight: 900; font-stretch: 75%; letter-spacing: -0.01em; color: var(--ink); }
.today-mini { margin: 0; color: var(--grey); font-size: 14px; font-variant-numeric: tabular-nums; }

.log { flex: 1; overflow-y: auto; padding: 20px 28px 28px; display: flex; flex-direction: column; gap: 18px; }
.msg { max-width: 640px; }
.msg.user { align-self: flex-end; max-width: min(520px, 85%); }
.msg.user .bubble { background: var(--desk); padding: 9px 13px; border-radius: 4px; }
.msg.assistant .bubble { padding: 0; }
.msg.assistant.proactive .bubble { border-left: 3px solid var(--ink); padding-left: 12px; }
.msg .bubble { overflow-wrap: anywhere; }
.msg .bubble p { margin: 0 0 .55em; } .msg .bubble p:last-child { margin: 0; }
.msg .bubble ul, .msg .bubble ol { margin: .3em 0 .6em; padding-left: 1.2em; }
.msg .bubble strong { font-weight: 700; color: var(--ink); }
.msg img.shot { display: block; max-width: 220px; max-height: 240px; border-radius: 4px; margin: 0 0 6px auto; }
.meta { font-size: 12px; color: var(--grey); margin-bottom: 4px; }

.acts { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; margin-top: 8px; }
.act { font-size: 14px; padding: 0 4px; background: linear-gradient(transparent 12%, var(--marker) 12%, var(--marker) 88%, transparent 88%); }

.typing .bubble { color: var(--grey); }
.typing .dots::after { content: '...'; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.1em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0 } to { width: 1.1em } }
.error .bubble { color: var(--red); }

/* tablice u chatu: kao deklaracija */
.tbl { overflow-x: auto; margin: .5em 0 .8em; }
.tbl table { border-collapse: collapse; font-size: 14px; min-width: 100%; font-variant-numeric: tabular-nums; }
.tbl thead th { border-top: 3px solid var(--ink); border-bottom: 1px solid var(--ink); font-weight: 700; color: var(--ink); text-align: left; }
.tbl th, .tbl td { padding: 5px 10px 5px 0; white-space: nowrap; }
.tbl td { border-bottom: 1px solid var(--hair); }
.tbl td:not(:first-child), .tbl th:not(:first-child) { text-align: right; }
.tbl tbody tr:last-child td { border-bottom: 3px solid var(--ink); }

.empty-chat { margin: auto 0; max-width: 520px; }
.empty-chat h2 { font-size: 30px; line-height: 1.1; font-weight: 900; font-stretch: 75%; color: var(--ink); margin: 0 0 10px; }
.empty-chat p { color: var(--grey); margin: 0; }
.starters { display: flex; flex-direction: column; gap: 0; margin-top: 18px; border-top: 1px solid var(--hair); }
.starters button {
  text-align: left; padding: 11px 0; border: 0; border-bottom: 1px solid var(--hair);
  background: none; cursor: pointer; color: var(--text);
}
.starters button:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- unos ---------- */
.composer { padding: 12px 28px 18px; border-top: 1px solid var(--hair); background: var(--paper); }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.attach {
  flex: none; width: 44px; height: 44px; border-radius: 4px; display: grid; place-items: center;
  border: 1.5px solid var(--ink); cursor: pointer; background: var(--paper);
}
.attach:hover { background: var(--desk); }
.attach:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.attach svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linejoin: round; }
#text {
  flex: 1; resize: none; max-height: 160px; min-height: 44px; padding: 10px 12px; border-radius: 4px;
  border: 1.5px solid var(--ink); background: var(--paper); line-height: 1.4;
}
#text::placeholder { color: var(--grey); }
#text:focus { outline: none; box-shadow: 0 0 0 3px var(--marker); }
.send {
  flex: none; height: 44px; padding: 0 18px; border-radius: 4px; border: 0; cursor: pointer;
  background: var(--ink); color: #fff; font-weight: 700;
}
.send:disabled { opacity: .4; cursor: default; }
.preview { position: relative; display: inline-block; margin: 0 0 10px 52px; }
.preview img { height: 80px; border-radius: 4px; display: block; border: 1px solid var(--hair); }
.preview-x {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff; cursor: pointer; line-height: 1; font-size: 15px;
}

/* ---------- desno: deklaracija dana ---------- */
.board { overflow-y: auto; padding: 22px 22px 32px; display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--paper); border: 2px solid var(--ink); padding: 10px 14px 12px; }
.card h2 {
  margin: 0; padding-bottom: 4px; font-size: 26px; line-height: 1; font-weight: 900; font-stretch: 70%;
  color: var(--ink); border-bottom: 8px solid var(--ink);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.card h2 small { font-size: 13px; font-weight: 400; font-stretch: 100%; color: var(--grey); }
.card .hint { color: var(--grey); font-size: 14px; margin: 8px 0 0; }

.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--ink); font-variant-numeric: tabular-nums; }
.row.thick { border-bottom-width: 4px; }
.row b { font-weight: 700; color: var(--ink); }
.row small { color: var(--grey); font-size: 12px; }
.row .v { text-align: right; }

.left-big { padding: 8px 0 6px; border-bottom: 1px solid var(--ink); display: flex; justify-content: space-between; align-items: flex-end; }
.left-big .lbl { font-weight: 700; color: var(--ink); }
.left-big .lbl small { display: block; font-weight: 400; color: var(--grey); font-size: 13px; }
.left-big .num { font-size: 44px; line-height: .9; font-weight: 900; font-stretch: 70%; color: var(--ink); font-variant-numeric: tabular-nums; }
.left-big.over .num { color: var(--red); }

.strip-wrap { position: relative; margin: 10px 0 4px; }
.strip { height: 18px; background: var(--desk); display: flex; overflow: hidden; }
.strip .seg { height: 100%; border-right: 2px solid var(--paper); min-width: 3px; }
.strip .seg:last-child { border-right: 0; }
.strip-target { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--red); }
.strip-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--grey); padding-bottom: 6px; border-bottom: 4px solid var(--ink); }
.m-dorucak { background: #9A9D98; } .m-rucak { background: #4A4C49; }
.m-vecera { background: #000; } .m-uzina { background: #C9CCC7; } .m-none { background: #7A7D78; }

.pbar { height: 4px; background: var(--desk); margin: 2px 0 4px; }
.pbar i { display: block; height: 100%; background: var(--ink); }

.warn { list-style: none; margin: 8px 0 0; padding: 0; }
.warn li { font-size: 14px; color: var(--red); font-weight: 700; padding: 2px 0; }

.entries { list-style: none; margin: 0; padding: 0; }
.entries li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--hair); font-size: 14px; }
.entries li:last-child { border-bottom: 0; }
.entries .dot { width: 9px; height: 9px; flex: none; }
.entries .nm { flex: 1; min-width: 0; }
.entries .nm small { color: var(--grey); }
.entries .kc { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.entries .del { border: 0; background: none; color: var(--grey); cursor: pointer; padding: 0 4px; font-size: 18px; line-height: 1; }
.entries .del:hover { color: var(--red); }
.sect { font-weight: 700; color: var(--ink); padding: 6px 0 2px; font-size: 14px; }

.wchart { width: 100%; height: auto; display: block; margin-top: 8px; }
.wchart .ln { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.wchart .pt { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.wchart .goal { stroke: var(--red); stroke-dasharray: 4 3; stroke-width: 1; }
.wchart text { fill: var(--grey); font: 11px var(--font); }

.chips { display: flex; flex-wrap: wrap; gap: 4px 12px; padding-top: 8px; font-size: 14px; }
.chip small { color: var(--grey); }

.foodlist { list-style: none; padding: 0; margin: 0; }
.foodlist li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--hair); font-size: 14px; }
.foodlist li:last-child { border-bottom: 0; }
.foodlist small { color: var(--grey); }
.foodlist .k { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- mobitel ---------- */
.tabs { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; height: calc(100dvh - 52px); }
  .app[data-view="chat"] .board, .app[data-view="board"] .chat { display: none; }
  .board { padding: 16px; }
  .chat-head { padding: 14px 16px 10px; }
  .log { padding: 16px; }
  .composer { padding: 10px 12px 12px; }
  .send { padding: 0 14px; }
  .tabs {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 52px;
    background: var(--paper); border-top: 2px solid var(--ink); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs button { flex: 1; border: 0; background: none; font-weight: 700; color: var(--grey); cursor: pointer; }
  .tabs button[aria-pressed="true"] { color: var(--ink); background: var(--marker); }
}
@media (prefers-reduced-motion: reduce) { .typing .dots::after { animation: none; width: auto; } }

/* pep talk */
.head-right { display: flex; align-items: center; gap: 14px; }
.pep {
  border: 1.5px solid var(--ink); background: var(--paper); border-radius: 4px; padding: 5px 12px;
  font-weight: 700; font-size: 14px; cursor: pointer;
}
.pep:hover { background: var(--marker); }
.pep:disabled { opacity: .4; cursor: default; }
audio.voice { display: block; width: min(100%, 420px); height: 40px; margin: 2px 0 10px; }

/* prijava */
.login { position: fixed; inset: 0; z-index: 20; background: var(--desk); display: grid; place-items: center; padding: 16px; }
.login-box { width: min(360px, 100%); background: var(--paper); border: 2px solid var(--ink); padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.login-box h1 { margin: 0 0 8px; font-size: 30px; font-weight: 900; font-stretch: 70%; color: var(--ink); border-bottom: 8px solid var(--ink); padding-bottom: 4px; }
.login-box label { font-weight: 700; }
.login-box input { height: 44px; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: 4px; }
.login-box input:focus { outline: none; box-shadow: 0 0 0 3px var(--marker); }
.login-err { color: var(--red); min-height: 1.2em; margin: 0; font-size: 14px; }
.ios-hint { background: var(--marker); color: var(--ink); font-size: 14px; padding: 8px 16px; text-align: center; }

/* instalirana aplikacija: notch i home indikator */
.chat-head { padding-top: max(18px, env(safe-area-inset-top)); }
@media (max-width: 860px) { .chat-head { padding-top: max(14px, env(safe-area-inset-top)); } }
.board { padding-top: max(16px, env(safe-area-inset-top)); }
.ios-hint { position: fixed; top: 0; left: 0; right: 0; z-index: 10; padding-top: max(8px, env(safe-area-inset-top)); cursor: pointer; }
