:root {
  color-scheme: dark;
  --bg: #0e1014; --surface: #171a21; --surface2: #1f232c; --line: #2b303b;
  --text: #e9ebf0; --muted: #949cab;
  --accent: #ff7a3d; --accent-ink: #1c0d04;
  --good: #3ecf8e; --bad: #ff7272; --warn: #ffb84d; --blue: #6aaeff; --water: #4db8ff;
  --r: 14px; --nav-h: 62px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f4f7; --surface: #ffffff; --surface2: #eceef2; --line: #dcdfe6;
    --text: #15181e; --muted: #5a6373;
    --accent: #c74608; --accent-ink: #ffffff;
    --good: #0f8a55; --bad: #c9302c; --warn: #9a6200; --blue: #1f6fd6; --water: #1583cc;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.4; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; }
h2 small { font-weight: 400; color: var(--muted); font-size: 0.9rem; }
h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin-top: 4px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[disabled] { opacity: 0.35; pointer-events: none; }

/* каркас */
#app { min-height: 100%; }
#view { padding: 16px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.tabs { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--line); }
.tabs a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); }
.tabs a span { display: flex; }
.tabs a b { font-size: 0.66rem; font-weight: 500; white-space: nowrap; }
.tabs a.on { color: var(--accent); }
.tabs .brand, .tabs .tab-set { display: none; }
@media (min-width: 900px) {
  .tabs { top: 0; right: auto; bottom: 0; width: 208px; height: auto; flex-direction: column; gap: 2px; padding: 18px 12px; border-top: 0; border-right: 1px solid var(--line); }
  .tabs a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; }
  .tabs a b { font-size: 0.95rem; }
  .tabs a.on { background: var(--surface2); }
  .tabs .brand { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: 1.25rem; padding: 4px 12px 16px; }
  .tabs .brand small { font-weight: 400; font-size: 0.75rem; color: var(--muted); }
  .tabs .tab-set { display: flex; margin-top: auto; }
  #app { padding-left: 208px; }
  #view { padding: 28px 32px 40px; }
  .only-mobile { display: none !important; }
  .toast { bottom: 24px; left: calc(50% + 104px); }
}

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; gap: 0; }
.card.note { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.grid, .cols { display: grid; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (min-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid .span2 { grid-column: span 2; }
  .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

/* строки и текст */
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.bottom { align-items: flex-end; }
.row > .field { flex: 1; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mono { font-variant-numeric: tabular-nums; }
.bad-text { color: var(--bad); } .good-text { color: var(--good); } .warn-text { color: var(--warn); }
.eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.big { font-size: 1.3rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.now-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.now-line strong { font-size: 1.25rem; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.empty { text-align: center; padding: 28px 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.link { background: none; border: 0; padding: 6px 0; color: var(--blue); font-size: 0.9rem; text-align: left; }
.link.strong { color: var(--text); font-weight: 600; font-size: 1rem; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); font-weight: 550; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.on { border-color: var(--accent); color: var(--accent); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.88rem; border-radius: 10px; }
.btn svg { width: 16px; height: 16px; }
.btn span { display: flex; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn.small { width: 36px; height: 36px; font-size: 1.2rem; }
.icon-btn.small svg { width: 16px; height: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { border-color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.add { background: transparent; border-style: dashed; color: var(--muted); }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; flex: none; }
.seg button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); white-space: nowrap; font-size: 0.9rem; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
#view > .seg { align-self: flex-start; }

/* формы */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 0.82rem; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); min-width: 0; }
textarea { resize: vertical; }
select { appearance: auto; width: auto; }
.row > input[type=text] { flex: 1; }
.big-input { font-size: 1.6rem !important; font-weight: 650; }
.checkline { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.checkline input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.code { display: block; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); overflow-wrap: anywhere; user-select: all; }

/* списки */
.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--line); }
.line, .total { display: flex; align-items: center; gap: 10px; padding: 10px 0; min-height: 44px; }
.tag { font-size: 0.72rem; padding: 3px 8px; border-radius: 6px; background: var(--surface2); color: var(--muted); font-weight: 600; white-space: nowrap; flex: none; }
.tag.work { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.tag.gym { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.tag.good { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.tag.bad { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.tag.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.seg-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 0; min-height: 48px; background: none; border: 0; text-align: left; }
.seg-row:hover { background: color-mix(in srgb, var(--surface2) 60%, transparent); }
.seg-row .date { width: 118px; flex: none; font-size: 0.88rem; white-space: nowrap; }
.workout.today { box-shadow: inset 3px 0 0 var(--accent); padding-left: 10px; }
.task { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 0; }
.task-main { flex: 1; min-width: 0; background: none; border: 0; padding: 6px 0; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.task-title { overflow-wrap: anywhere; display: block; }
.task-meta { font-size: 0.8rem; color: var(--muted); display: block; }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.task.overdue .task-meta { color: var(--bad); }
.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted); background: transparent; color: transparent; display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; margin: 9px; }
.check svg { width: 16px; height: 16px; stroke-width: 3; }
.check.on { background: var(--good); border-color: var(--good); color: var(--bg); }
.task .check { margin-left: 0; }
.task.ex .fact { width: 108px; flex: none; min-height: 40px; }
.subs:empty { display: none; }

/* показатели */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stats b { font-size: 1.1rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stats span { font-size: 0.78rem; color: var(--muted); }
.meter { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
.meter.big { padding: 2px 0; }
.bar { height: 10px; border-radius: 6px; background: var(--surface2); overflow: hidden; }
.meter.big .bar { height: 14px; border-radius: 8px; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.3s; }
.bar.water i { background: var(--water); }
.bar.good i { background: var(--good); }
.bar.over i { background: var(--bad); }
.timeline { display: flex; height: 22px; border-radius: 8px; overflow: hidden; gap: 2px; background: var(--surface2); }
.timeline i { min-width: 2px; }

/* календарь */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month.head span { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 2px 0; }
.day { position: relative; min-height: 50px; border-radius: 10px; border: 1px solid transparent; background: var(--surface2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 2px; }
.day b { font-weight: 500; font-variant-numeric: tabular-nums; }
.day.work { background: color-mix(in srgb, var(--accent) 20%, var(--surface2)); }
.day.work b { color: var(--accent); font-weight: 700; }
.day.today { border-color: var(--muted); }
.day.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dots { display: flex; gap: 3px; height: 6px; }
.lg { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.lg.me { background: var(--text); } .lg.yg { background: var(--blue); } .lg.gym { background: var(--good); } .lg.work { background: var(--accent); border-radius: 2px; }
.legend { font-size: 0.78rem; color: var(--muted); }
.legend > span { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.legend .lg { margin-left: 8px; } .legend .lg:first-child { margin-left: 0; }

/* деньги: картинка-путь */
.journey { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; }
.caption { padding: 10px 16px 12px; font-size: 0.9rem; }

/* еда */
.foods { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.food { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; background: var(--surface2); min-width: 0; }
.food:hover { border-color: var(--muted); }
.food-main { flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: 10px 4px 10px 12px; display: flex; flex-direction: column; gap: 2px; min-height: 56px; }
.food-main b { overflow-wrap: anywhere; font-weight: 600; }
.food-main span { font-size: 0.8rem; }
.food .icon-btn { align-self: center; }

/* окна */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; }
.sheet { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 760px) {
  .sheet-wrap { background: rgba(0, 0, 0, 0.55); align-items: center; justify-content: center; padding: 24px; }
  .sheet { flex: none; width: 100%; max-width: 560px; max-height: 88vh; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
}
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 0.92rem; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); transition: opacity 0.3s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; }

/* вход */
.auth { max-width: 380px; margin: 0 auto; padding: 18vh 20px 40px; display: flex; flex-direction: column; gap: 16px; }
.auth h1 { font-size: 2rem; }

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