/* Здоровье — кабинет. Тёмная типографская тема под стиль протокола.
   Никаких эмодзи: иконки — inline SVG, статусы — типографские глифы. */

:root {
  --bg: #0f1113;
  --panel: #16191c;
  --panel-2: #1b1f23;
  --line: #262c32;
  --text: #e7e4de;
  --muted: #8e959d;
  --dim: #626a72;

  --red: #c8483c;
  --ochre: #b8863a;
  --green: #5f8f4e;
  --blue: #4a86cc;
  --violet: #8a6bbf;

  --accent: var(--red);

  --r: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ каркас */
.app { display: none; min-height: 100vh; flex-direction: column; }
.app.on { display: flex; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 56px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 19, .92);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--serif); font-size: 17px; letter-spacing: .02em;
}
.brand svg { width: 22px; height: 22px; color: var(--accent); }

.tabs { display: flex; gap: 2px; margin-left: 8px; overflow-x: auto; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: 0; cursor: pointer;
  padding: 8px 12px; border-radius: 8px;
  color: var(--muted); font-size: 13px; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .08em;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.on { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }

.who { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #12141600; /* заливка через ::after */
  font-weight: 700; font-size: 13px;
  color: #14171a;
}

main { flex: 1; padding: 22px 20px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }
.view { display: none; }
.view.on { display: block; }

h1 { font-family: var(--serif); font-size: 26px; font-weight: 500; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 26px 0 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }
.lead { color: var(--muted); margin: 0 0 20px; max-width: 70ch; }

/* ------------------------------------------------------------------ карточки */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px;
}
.card.wide { grid-column: 1 / -1; }
.card h3 { color: var(--muted); font-size: 12px; letter-spacing: .09em; text-transform: uppercase; }

.big { font-size: 30px; font-family: var(--mono); line-height: 1.1; }
.big small { font-size: 14px; color: var(--dim); font-family: inherit; }
.sub { color: var(--dim); font-size: 12.5px; margin-top: 6px; }

.bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.bar.green > i { background: var(--green); }
.bar.blue > i { background: var(--blue); }

.flag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); }
.flag.ok { color: var(--green); border-color: #2c4429; }
.flag.warn { color: var(--ochre); border-color: #4a3a1c; }
.flag.bad { color: var(--red); border-color: #4d2622; }

/* ------------------------------------------------------------------ таблицы */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--mono); }

/* ------------------------------------------------------------------ формы */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; letter-spacing: .04em; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 120px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--dim); background: #20252a; }
.btn.primary { background: var(--accent); border-color: transparent; color: #14171a; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: none; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn svg { width: 15px; height: 15px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--panel); border: 0; padding: 6px 12px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--panel-2); color: var(--text); }
.seg button + button { border-left: 1px solid var(--line); }

/* ------------------------------------------------------------------ вход */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
}
.login .box { width: 100%; max-width: 380px; }
.login h1 { text-align: center; margin-bottom: 6px; }
.login .lead { text-align: center; }
.profiles { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
.profile {
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--r);
  padding: 14px; cursor: pointer; text-align: center;
}
.profile.on { border-color: var(--accent); background: var(--panel-2); }
.profile .dot { width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 8px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; text-align: center; }

/* ------------------------------------------------------------------ макет тела */
.bodies { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.body-wrap { text-align: center; }
.body-wrap figcaption { font-size: 11.5px; color: var(--dim); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.bodymap { width: 190px; height: auto; max-width: 44vw; }
.bodymap .silhouette { fill: #21262b; stroke: #2e353c; stroke-width: 1; }
.bodymap .muscle {
  fill: #2b3239; stroke: #363e46; stroke-width: .7;
  transition: fill .25s;
  cursor: pointer;
}
.bodymap .muscle.is-secondary { fill: color-mix(in srgb, var(--ochre) calc(var(--heat, 0) * 100%), #2b3239); }
.bodymap .muscle.is-primary  { fill: color-mix(in srgb, var(--red)   calc(var(--heat, 0) * 100%), #2b3239); stroke: #7a2d25; }
.bodymap .muscle.is-sore { fill: color-mix(in srgb, var(--violet) calc(var(--heat, 0) * 100%), #2b3239); stroke: #4c3a6b; }
.bodymap .muscle:hover { stroke: var(--text); stroke-width: 1.2; }

/* сетка восстановления: мышца × день */
.rec { overflow-x: auto; }
.rec table { border-collapse: separate; border-spacing: 2px; width: auto; min-width: 100%; }
.rec th { font-size: 10.5px; color: var(--dim); text-transform: none; letter-spacing: 0; padding: 2px 4px; border: 0; white-space: nowrap; }
.rec td { border: 0; padding: 0; }
.rec td.name { font-size: 12.5px; color: var(--muted); padding-right: 10px; white-space: nowrap; }
.rec i.cell { display: block; width: 18px; height: 18px; border-radius: 4px; background: var(--panel-2); }
.rec i.cell.l1 { background: color-mix(in srgb, var(--violet) 28%, var(--panel-2)); }
.rec i.cell.l2 { background: color-mix(in srgb, var(--violet) 52%, var(--panel-2)); }
.rec i.cell.l3 { background: color-mix(in srgb, var(--violet) 76%, var(--panel-2)); }
.rec i.cell.l4 { background: var(--violet); }
.rec i.cell.load { box-shadow: inset 0 0 0 1.5px var(--red); }

.legend { display: flex; gap: 16px; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .p { background: var(--red); }
.legend .s { background: var(--ochre); }

.muscle-list { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
}
.chip.p { color: #f0a49a; border-color: #5a2b25; }
.chip.s { color: #dcbb84; border-color: #4a3a1c; }

/* ------------------------------------------------------------------ протокол */
.scale { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 22px; }
.scale div { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel); }
.scale b { display: block; font-size: 13px; }
.scale span { font-size: 12px; color: var(--dim); }

.mark { font-family: var(--mono); letter-spacing: -1px; }
.s-solid    { color: var(--green); }
.s-probable { color: var(--blue); }
.s-weak     { color: var(--ochre); }
.s-debunked { color: var(--red); }

.claim { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--panel); margin-bottom: 12px; }
.claim header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.claim header b { font-size: 15px; }
.claim .body { color: #cfccc6; white-space: pre-wrap; font-size: 14.5px; }
.claim .src { margin-top: 10px; font-size: 12px; color: var(--dim); font-style: italic; }
.claim.s-debunked { border-left: 3px solid var(--red); }
.claim.s-solid { border-left: 3px solid var(--green); }
.claim.s-probable { border-left: 3px solid var(--blue); }
.claim.s-weak { border-left: 3px solid var(--ochre); }

.action { border-left: 3px solid var(--accent); padding: 10px 14px; background: var(--panel-2); border-radius: 0 8px 8px 0; white-space: pre-wrap; font-size: 14px; margin: 14px 0 26px; }

details.section { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; background: var(--panel); overflow: hidden; }
details.section > summary { cursor: pointer; padding: 13px 16px; list-style: none; display: flex; align-items: baseline; gap: 12px; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary:hover { background: var(--panel-2); }
details.section .no { font-family: var(--mono); color: var(--dim); font-size: 13px; }
details.section .ttl { font-family: var(--serif); font-size: 17px; }
details.section .inner { padding: 4px 16px 18px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------------ чат */
.chat { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 380px; }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 6px; }
.msg { max-width: 74%; padding: 10px 13px; border-radius: 12px; white-space: pre-wrap; font-size: 14.5px; }
.msg.user { align-self: flex-end; background: var(--panel-2); border: 1px solid var(--line); }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg.pending { color: var(--dim); font-style: italic; }
.composer { display: flex; gap: 8px; margin-top: 12px; }
.composer textarea { min-height: 46px; max-height: 160px; }

/* ------------------------------------------------------------------ прочее */
.empty { color: var(--dim); font-size: 14px; padding: 18px 0; }
.hint { font-size: 12.5px; color: var(--dim); margin-top: 6px; }
.spark { width: 100%; height: 40px; display: block; margin-top: 8px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.spark .area { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.week .d {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 4px; text-align: center;
  background: var(--panel-2); cursor: pointer; font-size: 12px;
}
.week .d.done { border-color: var(--green); color: #a8ce97; }
.week .d.rest { color: var(--dim); }
.week .d.today { box-shadow: inset 0 0 0 1px var(--accent); }
.week .d b { display: block; font-size: 11px; letter-spacing: .05em; color: var(--muted); }

/* ------------------------------------------------------------------ программа */
.progdays { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 16px; }
.progdays::-webkit-scrollbar { height: 4px; }
.progdays::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
.progdays .pd {
  flex: 0 0 auto; min-width: 74px; text-align: center; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; background: var(--panel);
}
.progdays .pd b { display: block; font-size: 11px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.progdays .pd span { font-size: 12px; color: var(--dim); }
.progdays .pd.on { border-color: var(--accent); background: var(--panel-2); }
.progdays .pd.done { border-color: var(--green); }
.progdays .pd.rest span { color: var(--dim); }

.budget { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.budget b { font-family: var(--mono); font-size: 20px; }
.budget.over b { color: var(--red); }

/* Инвентарь: короткая строка над программой — что вообще есть в наличии */
.inv { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; margin: 0 0 18px; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--panel-2); }
.inv b { font-size: 11.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.inv .chip { font-family: var(--mono); font-size: 12.5px; padding: 2px 8px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--text); background: var(--panel); }
.inv .sub { flex: 1 1 100%; font-size: 12.5px; color: var(--dim); }

.pitem { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); margin-bottom: 10px; overflow: hidden; }
.pitem > summary { cursor: pointer; list-style: none; padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.pitem > summary::-webkit-details-marker { display: none; }
.pitem > summary:hover { background: var(--panel-2); }
.pitem .n { font-family: var(--mono); color: var(--dim); font-size: 13px; min-width: 18px; }
.pitem .nm { flex: 1; font-weight: 600; }
.pitem .dose { font-family: var(--mono); font-size: 14px; color: var(--text); white-space: nowrap; }
.pitem .rest { font-size: 12px; color: var(--dim); white-space: nowrap; }
.pitem .inner { padding: 0 14px 14px; border-top: 1px solid var(--line); display: flex; gap: 16px; flex-wrap: wrap; }
.pitem .inner ul { margin: 10px 0 0; padding-left: 18px; color: #cfccc6; font-size: 14px; flex: 1 1 260px; }
.pitem .tg { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--green); }

.demo { width: 128px; height: 128px; flex: 0 0 auto; margin-top: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.demo .fig { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.demo .fig circle { fill: var(--accent); stroke: none; }
.demo .bar { stroke: #4b545d; stroke-width: 4; stroke-linecap: round; }
.demo .pack { fill: var(--ochre); stroke: none; }

.blockhead { font-size: 11.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: 18px 0 8px; }

/* Состав приёма пищи: строки-продукты живут под своим приёмом и не спорят с ним по весу */
tr.meal-head td { border-bottom: 0; padding-top: 12px; }
tr.meal-item td { color: var(--muted); font-size: 13px; padding-top: 2px; padding-bottom: 2px; border-bottom: 0; }
tr.meal-item td:nth-child(2) { padding-left: 22px; }
tr.meal-item:last-of-type td { padding-bottom: 8px; }
tr.meal-total td { border-top: 1px solid var(--line); border-bottom: 0; padding-top: 10px; }
tr.meal-head .chip { font-size: 10.5px; padding: 1px 7px; vertical-align: 2px; }

.ex { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 14px 16px; margin-bottom: 10px; }
.ex .top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ex .meta { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.ex ul { margin: 8px 0 0; padding-left: 18px; color: #cfccc6; font-size: 14px; }
.ex ul li { margin-bottom: 3px; }

.pill { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  main { padding: 16px 12px 50px; }
  .msg { max-width: 88%; }
}
