* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* как у личного бота, только зелёная гамма */
  --bg: #0b110e;
  --bg-card: #121a16;
  --bg-elevated: #19241f;
  --border: rgba(120, 230, 170, 0.11);
  --text: #ecf5ef;
  --text-muted: #8fa69a;
  --accent: #34c785;
  --accent-dark: #29a66e;
  --accent-soft: rgba(52, 199, 133, 0.15);
  --head: #8fe3b8;
  --red: #f07a7a;
  --red-soft: rgba(240, 122, 122, 0.14);
  --amber: #e8c46b;
}

html { height: 100%; }
body {
  min-height: 100%; background: var(--bg); color: var(--text);
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, sans-serif; font-size: 15px;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
button { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 0.76rem; }
.center { text-align: center; }
.warn { color: var(--amber); }
.tap { cursor: pointer; }

.screen { display: none; padding: 12px 12px 20px; }
.screen.active { display: block; }

h3 { font-size: 0.76rem; color: var(--head); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.widget-row h3 { margin-bottom: 0; }

.widget { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.widget-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.row-tools { display: flex; align-items: center; gap: 10px; }
.chevron { color: var(--text-muted); font-size: 1.2rem; transition: transform .2s; }
.open > .chevron, .open .row-tools .chevron { transform: rotate(90deg); }
.empty { color: var(--text-muted); font-size: 0.82rem; padding: 6px 0; line-height: 1.4; }
.hint { color: var(--text-muted); font-size: 0.74rem; margin: 6px 0; line-height: 1.35; }

/* приветствие */
.hello { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px 12px; }
.hello-name { font-family: "Bebas Neue", "Montserrat", sans-serif; font-size: 1.7rem; letter-spacing: .5px; }
.hello-sub { color: var(--text-muted); font-size: 0.8rem; }
.badge { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 10px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }

/* калории */
.kcal-line { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.kcal-big { font-family: "Bebas Neue", sans-serif; font-size: 2.2rem; line-height: 1; }
.bar { height: 8px; background: rgba(255,255,255,0.06); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s; }
.bar-fill.over { background: var(--amber); }
.macro-row { display: flex; justify-content: space-between; margin-top: 10px; font-size: 0.78rem; color: var(--text-muted); }
.macro-row b { color: var(--text); font-weight: 600; }

/* трио вес-сон-шаги */
.trio { display: flex; text-align: center; gap: 8px; }
.trio > div { flex: 1; }
.trio-num { display: block; font-family: "Bebas Neue", sans-serif; font-size: 1.8rem; color: var(--head); }
.trio-label { font-size: 0.72rem; color: var(--text-muted); }

/* занятия */
.session { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.session:last-child { border-bottom: none; }
.session-time { width: 58px; flex-shrink: 0; display: flex; flex-direction: column; }
.session-time b { font-size: 1.05rem; }
.session-time span { font-size: 0.72rem; color: var(--text-muted); }
.session-info { flex: 1; min-width: 0; font-size: 0.9rem; }
.session.cancelled .session-time b, .session.cancelled .session-info > div:first-child { text-decoration: line-through; color: var(--text-muted); }
.mark-btns { display: flex; gap: 6px; margin-top: 8px; }

/* метки и кнопки-чипы */
.tag { display: inline-block; font-size: 0.68rem; padding: 2px 7px; border-radius: 999px; background: var(--bg-elevated); color: var(--text-muted); white-space: nowrap; margin-left: 4px; vertical-align: middle; }
.tag-green { background: var(--accent-soft); color: var(--accent); }
.tag-red { background: var(--red-soft); color: var(--red); margin: 4px 0 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text); border-radius: 10px;
  padding: 8px 12px; font-size: 0.82rem; cursor: pointer; display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
}
.chip small { color: var(--text-muted); font-size: 0.68rem; }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.active small { color: var(--accent); opacity: .8; }

/* цели */
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.check-row:last-child { border-bottom: none; }
.check-title { flex: 1; font-size: 0.92rem; }
.check-row.done .check-title { color: var(--text-muted); text-decoration: line-through; }
.checkbox { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--text-muted); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.checkbox.checked { background: var(--accent); border-color: var(--accent); }
.checkbox.checked::after { content: ''; width: 10px; height: 5px; border: solid #0b110e; border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); }
.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.inline-form input { margin: 0; }
.switch-row { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }
.switch-row input { accent-color: var(--accent); width: 16px; height: 16px; }

/* поля */
input[type="text"], input[type="number"], input[type="time"], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-family: inherit; font-size: 0.9rem; margin-bottom: 8px; min-width: 0;
}
select { -webkit-appearance: none; appearance: none; }
input[type="time"] { color-scheme: dark; min-height: 42px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.72rem; color: var(--text-muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

.btn { display: block; width: 100%; padding: 12px; border-radius: 10px; border: none; font-size: 0.9rem; font-weight: 600; cursor: pointer; margin-top: 4px; }
.btn-accent { background: var(--accent); color: #06130c; }
.btn-accent:active { background: var(--accent-dark); }
.btn-ghost { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--red-soft); color: var(--red); margin-top: 14px; }
.btn-small { border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text); border-radius: 9px; padding: 6px 10px; font-size: 0.78rem; cursor: pointer; white-space: nowrap; }
.btn-small.accent { background: var(--accent); color: #06130c; border-color: var(--accent); font-weight: 600; }
.btn-plus {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); flex-shrink: 0;
  background: var(--bg-elevated); color: var(--accent); font-size: 1.2rem; line-height: 1; cursor: pointer;
}

/* иконки действий */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; padding: 0; border-radius: 9px; background: transparent;
  border: 1px solid transparent; color: var(--text-muted); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn svg { display: block; }
.icon-btn:active { background: var(--bg-elevated); border-color: var(--border); color: var(--text); }
.icon-btn.danger:active { color: var(--red); }
.icon-btn.done { color: var(--accent); }
.icon-btn:disabled { opacity: .3; }

/* еда */
.food-item, .meal { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; cursor: pointer; }
.food-item:last-child, .meal:last-child { border-bottom: none; }
.food-item.compact { cursor: default; }
.meal-main { flex: 1; min-width: 0; }
.grams-btn { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 5px 9px; font-size: 0.8rem; cursor: pointer; white-space: nowrap; }
.grams-box { display: flex; align-items: center; gap: 8px; padding: 8px 0 10px; }
.grams-box input { margin: 0; width: 100px; }
.base-form { margin-bottom: 10px; }

/* графики */
.week-nav { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 10px; font-weight: 600; }
.bars { display: flex; gap: 6px; height: 120px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; color: var(--text); cursor: pointer; border-radius: 8px; padding: 2px 0; min-width: 0; }
.bar-col.locked { cursor: default; opacity: .75; }
.bar-col.selected { background: var(--accent-soft); }
.bar-val { font-size: 0.66rem; height: 14px; color: var(--text); white-space: nowrap; }
.bar-track { flex: 1; width: 60%; max-width: 22px; background: rgba(255,255,255,0.05); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.bar-in { width: 100%; background: var(--accent); border-radius: 6px; }
.bar-in.low { background: var(--amber); }
.bar-day { font-size: 0.68rem; color: var(--text-muted); }
.bar-col.today .bar-day { color: var(--accent); font-weight: 700; }

/* клуб */
.group-card { padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.group-name { font-weight: 600; font-size: 0.92rem; margin-bottom: 2px; }
.group-detail { padding: 4px 2px 14px; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.history-row.cancelled { opacity: .55; }
.history-main { flex: 1; min-width: 0; }
.history-edit { padding: 8px 0 12px; display: flex; flex-direction: column; gap: 8px; }
.history-edit input { margin: 0; }
.history-edit .btn-small { align-self: flex-start; }
.session-mini { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 0.84rem; }
.session-mini.cancelled span { color: var(--text-muted); text-decoration: line-through; }
.day-picker { display: flex; gap: 5px; margin-bottom: 8px; }
.day { flex: 1; aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); color: var(--text-muted); font-size: 0.72rem; font-weight: 600; cursor: pointer; }
.day.active { background: var(--accent); color: #06130c; border-color: var(--accent); }
.loc-row { padding: 6px 0; font-size: 0.86rem; border-bottom: 1px solid var(--border); margin-bottom: 6px; }

/* тренер */
.link-row { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 6px 6px 6px 12px; margin-top: 6px; }
.link-text { flex: 1; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); }
.athlete-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.athlete-row:last-child { border-bottom: none; }
.athlete-main { flex: 1; min-width: 0; font-size: 0.9rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }

/* выезжающая карточка */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: flex-end; }
.sheet-box { background: var(--bg-card); border-top: 1px solid var(--border); border-radius: 18px 18px 0 0; width: 100%; max-height: 92vh; overflow-y: auto; padding: 14px 14px calc(24px + env(safe-area-inset-bottom, 0px)); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.sheet-title { font-family: "Bebas Neue", sans-serif; font-size: 1.6rem; }
.sheet-section { margin-bottom: 18px; }
.chips.wrap .chip { flex: 1 1 calc(50% - 6px); }

/* чат */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 76px - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px) - 24px); height: calc(var(--tg-viewport-stable-height, 100vh) - 100px); position: relative; }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 10px; }
.msg-wrap { display: flex; flex-direction: column; max-width: 100%; }
.msg-wrap.user { align-items: flex-end; }
.msg-wrap.assistant { align-items: flex-start; }
.msg { max-width: 86%; padding: 9px 13px; border-radius: 14px; font-size: 0.9rem; line-height: 1.42; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user { background: var(--accent); color: #06130c; border-bottom-right-radius: 5px; }
.msg.assistant { background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg.assistant b { color: var(--head); }
.typing .msg { color: var(--text-muted); }
.typing .msg-tools { display: none; }
.msg-tools { display: flex; gap: 2px; margin-top: 2px; opacity: .7; }
.msg-tools .icon-btn { width: 28px; height: 28px; }
.msg-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; max-width: 86%; }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; padding-top: 6px; }
.chat-input-row textarea { margin: 0; min-height: 44px; max-height: 120px; resize: none; line-height: 1.35; }
.send-btn { width: 44px; height: 44px; border-radius: 12px; border: none; background: var(--accent); color: #06130c; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; }
.send-btn:disabled { opacity: .5; }
.scroll-down { position: absolute; right: 8px; bottom: 64px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* нижнее меню */
#bottomNav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: rgba(11,17,14,.96);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 40; backdrop-filter: blur(8px);
}
.nav-btn { flex: 1; background: none; border: none; color: var(--text-muted); padding: 8px 0 10px; font-size: 0.66rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.nav-btn.active { color: var(--accent); font-weight: 600; }
.nav-ico svg { display: block; }

/* вход по приглашению */
.gate { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-box { text-align: center; max-width: 320px; }
.gate-logo { font-family: "Bebas Neue", sans-serif; font-size: 2.4rem; color: var(--accent); letter-spacing: 2px; margin-bottom: 12px; }
.gate-box p { color: var(--text-muted); line-height: 1.5; font-size: 0.92rem; }

/* подтверждение и уведомления */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.confirm-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 18px; width: 100%; max-width: 340px; }
.confirm-box p { margin-bottom: 14px; line-height: 1.45; font-size: 0.92rem; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions .btn { margin: 0; }
#toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -150%);
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text); padding: 10px 16px; border-radius: 12px;
  font-size: 0.84rem; z-index: 300; transition: transform .25s; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { transform: translate(-50%, 0); }
