:root {
  --bg1: #2C0F12;
  --bg-mid: #4a1519;
  --panel: #3a1216;
  --overlay: rgba(20,5,7,.78);
  --bg2: #6B1E23;
  --ink: #F6E9E6;
  --ink-2: rgba(246, 233, 230, .66);
  --ink-3: rgba(246, 233, 230, .42);
  --line: rgba(255, 255, 255, .16);
  --glass: rgba(255, 255, 255, .06);
  --glass-2: rgba(255, 255, 255, .1);
  --p: #F4A6A0;
  --f: #F2D08B;
  --c: #A8C8F0;
  --accent: #F6E9E6;
  --danger: #ff9b9b;
  --rail-w: 88px;
  --radius: 28px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg1) 0%, var(--bg-mid) 55%, var(--bg2) 100%) fixed;
  line-height: 1.4;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 3px 3px;
}
button, input, select { font: inherit; color: inherit; }
b { font-weight: 600; }

.app { position: relative; min-height: 100vh; padding-left: var(--rail-w); }
.content { max-width: 980px; margin: 0 auto; padding: 36px 28px 60px; }
.page { display: none; animation: fade .25s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.glass {
  background: linear-gradient(145deg, rgba(255,255,255,.09), rgba(255,255,255,.03));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.eyebrow { font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
h1 { margin: 0; font-size: 32px; font-weight: 500; letter-spacing: .02em; }
h2 { margin: 0 0 6px; font-weight: 500; font-size: 24px; letter-spacing: .02em; }
.muted { color: var(--ink-2); font-size: 14px; }

/* кнопки */
.btn {
  border: 1px solid var(--line); border-radius: 999px; padding: 12px 22px; cursor: pointer;
  background: var(--glass-2); transition: transform .12s, background .2s;
}
.btn:hover { background: rgba(255,255,255,.16); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--bg1); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 8px; padding: 14px; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass-2);
  cursor: pointer; padding: 0; display: grid; place-items: center; color: var(--ink);
}
.icon-btn svg { width: 22px; height: 22px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: rgba(255,255,255,.16); }
.date-switch { display: flex; gap: 10px; align-items: center; }
.pill {
  position: relative; border: 1px solid var(--line); border-radius: 999px; padding: 11px 20px;
  background: var(--glass-2); min-width: 170px; text-align: center; cursor: pointer; display: block;
  color: inherit; font: inherit;
}
.pill:hover { background: rgba(255,255,255,.14); }

/* сводка */
.summary { display: grid; grid-template-columns: 190px 1fr; gap: 28px; padding: 26px 30px; align-items: center; margin-bottom: 18px; }
.ring-wrap { position: relative; width: 170px; height: 170px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring-bg { stroke: rgba(255,255,255,.1); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .6s ease, stroke .3s; }
.ring-fg.over { stroke: var(--danger); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text b { font-size: 34px; font-weight: 500; }
.ring-text span { font-size: 12px; color: var(--ink-2); letter-spacing: .08em; text-align: center; max-width: 110px; }
.bars { display: grid; gap: 16px; }
.bar-top { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.bar-top b { color: var(--ink); }
.bar { height: 10px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .5s ease; }
.c-p { color: var(--p); } .c-f { color: var(--f); } .c-c { color: var(--c); }
i.c-p { background: var(--p); } i.c-f { background: var(--f); } i.c-c { background: var(--c); }

/* ввод */
.add-row { display: grid; grid-template-columns: 1fr 140px auto; gap: 10px; padding: 12px; border-radius: 999px; margin-bottom: 18px; position: relative; z-index: 5; }
.add-row input { background: rgba(0,0,0,.22); border: 1px solid transparent; border-radius: 999px; padding: 13px 20px; outline: none; width: 100%; }
.add-row input:focus { border-color: var(--line); }
input::placeholder { color: var(--ink-3); }
.add-row .btn { padding: 13px 28px; }
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: var(--panel); border: 1px solid var(--line);
  border-radius: 22px; max-height: 320px; overflow: auto; box-shadow: 0 18px 40px rgba(0,0,0,.5); z-index: 20; padding: 6px;
}
.ac-item { padding: 10px 14px; border-radius: 16px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.ac-item:hover, .ac-item.sel { background: rgba(255,255,255,.1); }
.ac-item small { color: var(--ink-3); white-space: nowrap; font-size: 12px; }
.ac-item.new { color: var(--f); }

/* таблица */
.table-card { padding: 10px 14px 14px; margin-bottom: 18px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { padding: 12px 10px; text-align: center; white-space: nowrap; }
th { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; border-bottom: 1px solid var(--line); }
td { border-bottom: 1px solid rgba(255,255,255,.07); }
th.left, td.left { text-align: left; white-space: normal; }
tbody tr:hover { background: rgba(255,255,255,.04); }
tfoot td { font-weight: 600; border-bottom: none; border-top: 1px solid var(--line); padding-top: 16px; }
td .g-input { width: 78px; text-align: center; background: transparent; border: 1px solid transparent; border-radius: 99px; padding: 5px 6px; outline: none; }
td .g-input:hover, td .g-input:focus { border-color: var(--line); background: rgba(0,0,0,.2); }
.del { background: none; border: none; cursor: pointer; color: var(--ink-3); font-size: 18px; padding: 4px 8px; border-radius: 50%; }
.del:hover { color: var(--danger); }
.empty { text-align: center; color: var(--ink-3); padding: 28px 10px 18px; }

/* доли калорий */
.share { padding: 20px 26px 24px; }
.share-head { font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 14px; }
.share-head.pad { padding: 14px 10px 0; }
.share-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.1); }
.share-bar i { display: block; height: 100%; transition: width .5s; }
.share-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.leg b { font-size: 26px; font-weight: 500; display: block; }
.leg span { font-size: 13px; color: var(--ink-2); }
.leg .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* сегменты */
.seg { display: inline-flex; padding: 4px; border-radius: 999px; background: rgba(0,0,0,.22); border: 1px solid var(--line); gap: 2px; margin-bottom: 18px; }
.seg button { border: none; background: transparent; padding: 10px 22px; border-radius: 999px; cursor: pointer; color: var(--ink-2); transition: .2s; }
.seg button.on { background: var(--accent); color: var(--bg1); font-weight: 600; }
.seg.small { margin-bottom: 0; }
.seg.small button { padding: 9px 16px; font-size: 14px; }
.seg.wrap { flex-wrap: wrap; border-radius: 24px; }

/* статистика */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { padding: 18px 20px; border-radius: 24px; }
.stat span { display: block; font-size: 12px; color: var(--ink-3); letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px; }
.stat b { font-size: 26px; font-weight: 500; }
.stat small { color: var(--ink-2); font-size: 13px; margin-left: 4px; }
.chart-card { padding: 20px 24px 14px; margin-bottom: 18px; }
#chart svg { width: 100%; height: auto; display: block; overflow: visible; }
#chart text { fill: var(--ink-3); font-size: 11px; }
.chart-empty { text-align: center; color: var(--ink-3); padding: 40px 0; }

/* план */
.plan-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
.plan-form, .plan-result { padding: 26px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12px; color: var(--ink-3); letter-spacing: .16em; text-transform: uppercase; margin-bottom: 8px; }
.field input, .field select {
  width: 100%; background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 999px; padding: 12px 18px; outline: none;
}
.field select option { background: var(--panel); }
.field input:focus, .field select:focus { border-color: rgba(255,255,255,.4); }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.big { font-size: 56px; font-weight: 500; margin: 8px 0 4px; letter-spacing: .01em; }
.plan-macros { display: grid; gap: 12px; margin: 22px 0; }
.pm { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-radius: 999px; border: 1px solid var(--line); background: rgba(0,0,0,.18); }
.pm b { font-size: 18px; font-weight: 500; }
.plan-facts { font-size: 14px; color: var(--ink-2); display: grid; gap: 6px; }

/* меню справа */
.rail {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--rail-w); display: flex; flex-direction: column; justify-content: center; gap: 14px;
  align-items: center; padding: 20px 0; z-index: 30;
}
.rail::before { content: ""; position: absolute; inset: 20px 12px; border-radius: 40px; background: linear-gradient(160deg, rgba(255,255,255,.1), rgba(255,255,255,.03)); border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(0,0,0,.35); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: -1; }
.rail-btn { width: 56px; height: 56px; border-radius: 50%; border: 1px solid transparent; background: transparent; cursor: pointer; display: grid; place-items: center; position: relative; transition: .2s; color: var(--ink-2); }
.rail-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn span { display: none; font-size: 11px; }
.rail-btn:hover { background: rgba(255,255,255,.1); color: var(--ink); }
.rail-btn.active { background: var(--accent); color: var(--bg1); }

/* модалки */
.modal { position: fixed; inset: 0; background: rgba(15, 4, 6, .7); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal[hidden] { display: none; }
.modal-box { width: 100%; max-width: 480px; padding: 30px; background: var(--panel); }
.modal-box.center { text-align: center; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-actions.center { justify-content: center; }
.form-err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 8px; }
.soon-icon { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--glass-2); }
.soon-icon svg { width: 34px; height: 34px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--accent); color: var(--bg1); padding: 12px 22px; border-radius: 999px; z-index: 60; font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast[hidden] { display: none; }

/* выпадающий список: своя стрелка, отступ от края */
.field select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 54px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F6E9E6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 22px center; background-size: 20px;
}

/* числовые поля: без нативных спиннеров, свои прозрачные стрелки */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num { position: relative; display: block; }
.num > input { padding-right: 46px; }
.num-btns { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; }
.num-btn { width: 24px; height: 15px; padding: 0; border: none; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--ink-3); transition: color .15s; }
.num-btn:hover { color: var(--ink); }
.num-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
td .num { width: 108px; margin: 0 auto; }
td .num .g-input { width: 100%; padding: 6px 28px 6px 12px; }
td .num .num-btns { right: 8px; }

/* календарь */
.cal { position: absolute; z-index: 70; width: 316px; max-width: calc(100vw - 24px); padding: 18px 18px 12px; background: var(--panel); border-radius: 28px; animation: fade .18s ease; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { font-size: 17px; font-weight: 500; letter-spacing: .02em; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button { width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--glass-2); cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.cal-nav button:hover { background: rgba(255,255,255,.16); }
.cal-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-wd { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 8px 0 6px; }
.cal-day { aspect-ratio: 1; padding: 0; border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; font-size: 14px; }
.cal-day:hover { background: rgba(255,255,255,.12); }
.cal-day.other { color: var(--ink-3); }
.cal-day.today { border-color: var(--ink-3); }
.cal-day.sel { background: var(--accent); color: var(--bg1); font-weight: 600; border-color: transparent; }
.cal-foot { display: flex; justify-content: center; margin-top: 8px; }
.cal-foot button { background: none; border: none; color: var(--ink-2); cursor: pointer; padding: 8px 16px; border-radius: 99px; }
.cal-foot button:hover { color: var(--ink); background: rgba(255,255,255,.08); }

/* удаление с возможностью вернуть */
.undo { position: relative; width: 38px; height: 38px; padding: 0; border: none; border-radius: 50%; background: transparent; cursor: pointer; color: var(--ink); display: inline-grid; place-items: center; }
.undo > svg { grid-area: 1 / 1; }
.undo:hover { background: rgba(255,255,255,.1); }
.undo-ring { width: 38px; height: 38px; transform: rotate(-90deg); }
.undo-ring circle { fill: none; stroke-width: 2.5; }
.u-bg { stroke: rgba(255,255,255,.18); }
.u-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100.53; stroke-dashoffset: 0; animation: countdown 3s linear forwards; }
@keyframes countdown { to { stroke-dashoffset: 100.53; } }
.undo-arrow { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
tr.removed td:not(:last-child) { opacity: .38; }
tr.removed td.left { text-decoration: line-through; }
tr.removed:hover { background: none; }

/* телефон */
@media (max-width: 760px) {
  .app { padding-left: 0; padding-bottom: 92px; }
  .content { padding: 22px 14px 40px; }
  h1 { font-size: 26px; }
  .summary { grid-template-columns: 1fr; justify-items: center; padding: 22px 18px; gap: 20px; }
  .bars { width: 100%; }
  .add-row { grid-template-columns: 1fr 1fr; border-radius: 28px; }
  .add-row .ac-wrap { grid-column: 1 / -1; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .plan-grid { grid-template-columns: 1fr; }
  .big { font-size: 44px; }
  .share-legend .leg b { font-size: 22px; }
  .page-head { align-items: flex-start; }
  .pill { min-width: 140px; }
  .rail { top: auto; left: 0; width: 100%; height: 80px; flex-direction: row; justify-content: space-around; padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); gap: 4px; }
  .rail::before { inset: 6px 10px; border-radius: 32px; }
  .rail-btn { width: 64px; height: 56px; border-radius: 22px; }
}

/* Профиль и привычки */
.profile-summary, .habits-card { padding: 26px 30px; margin-bottom: 18px; }
.profile-user { display:flex; align-items:center; gap:16px; margin-bottom:22px; }
.profile-user h2, .section-heading h2 { margin:0 0 4px; }
.profile-avatar { width:64px; height:64px; border:1px solid var(--line); border-radius:50%; background:rgba(0,0,0,.18); display:grid; place-items:center; flex:none; }
.profile-avatar svg { width:32px; height:32px; fill:none; stroke:var(--ink); stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }
.profile-params { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin-bottom:20px; }
.profile-param { padding:13px 16px; border:1px solid var(--line); border-radius:18px; background:rgba(0,0,0,.14); }
.profile-param span { display:block; color:var(--ink-3); font-size:11px; letter-spacing:.13em; text-transform:uppercase; margin-bottom:5px; }
.profile-param b { font-size:17px; font-weight:500; }
.profile-empty { color:var(--ink-2); padding:14px 0; font-size:14px; }
.profile-plan-result { border-top:1px solid var(--line); padding-top:22px; }
.profile-plan-result .big { font-size:58px; }
.profile-plan-result .plan-macros { grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; }
.profile-plan-result .pm { border-radius:18px; padding:13px 15px; gap:8px; }
.profile-actions { display:flex; justify-content:flex-end; margin-top:20px; }
.section-heading { margin-bottom:18px; }
.section-heading p { margin:6px 0 0; max-width:650px; }
.profile-habits { display:grid; gap:9px; margin-bottom:18px; }
.profile-habit { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:13px 16px; border:1px solid var(--line); border-radius:18px; background:rgba(0,0,0,.14); }
.profile-habit-main { min-width:0; }
.profile-habit-main b { display:block; font-weight:550; }
.profile-habit-main small { color:var(--ink-2); }
.habit-actions { display:flex; gap:7px; flex:none; }
.habit-actions button { border:1px solid var(--line); background:rgba(255,255,255,.05); color:var(--ink-2); border-radius:999px; padding:7px 11px; cursor:pointer; }
.habit-actions button:hover { color:var(--ink); background:var(--glass-2); }
.diary-habits { padding:20px 26px; margin-bottom:18px; }
.diary-habit-row { display:flex; justify-content:space-between; align-items:center; gap:14px; padding:14px 0; border-bottom:1px solid rgba(255,255,255,.07); cursor:pointer; }
.diary-habit-row:last-child { border-bottom:0; }
.diary-habit-info b { display:block; font-weight:550; }
.diary-habit-info small { color:var(--ink-2); }
.habit-progress { color:var(--ink-3); font-size:12px; margin-top:9px; }
.modal-title-row { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:12px; }
.modal-title-row h2 { margin:0; }
.modal-x { width:36px; height:36px; font-size:23px; line-height:1; }
.plan-modal { width:min(650px, calc(100vw - 28px)); max-height:90vh; overflow:auto; }
.plan-modal .plan-form { padding:8px 0 0; }
.plan-modal .field { margin-bottom:15px; }
.plan-modal .row3 { gap:9px; }
.habit-amount-row { grid-template-columns:1fr 1fr; }
@media (max-width:700px) {
  .profile-summary, .habits-card { padding:20px; }
  .profile-params { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .profile-plan-result .plan-macros { grid-template-columns:1fr; }
  .profile-actions .btn { width:100%; }
  .diary-habits { padding:18px; }
}
@media (max-width:440px) {
  .plan-modal .row3 { grid-template-columns:1fr 1fr 1fr; gap:6px; }
  .plan-modal .field input, .plan-modal .field select { padding:11px 10px; }
  .plan-modal .seg.small button { padding:8px 10px; }
}

/* Чекбокс привычки */
.habit-check { position:relative; flex:none; display:grid; place-items:center; width:44px; height:44px; }
.habit-check input { position:absolute; inset:0; width:100%; height:100%; margin:0; opacity:0; cursor:pointer; z-index:1; }
.habit-check .box { width:36px; height:36px; border-radius:12px; border:1.5px solid rgba(246,233,230,.38); background:rgba(0,0,0,.2); display:grid; place-items:center; transition:background .2s, border-color .2s, box-shadow .2s, transform .12s; box-shadow:inset 0 1px 0 rgba(255,255,255,.05); }
.habit-check .box svg { width:22px; height:22px; fill:none; stroke:var(--bg1); stroke-width:3; stroke-linecap:round; stroke-linejoin:round; stroke-dasharray:24; stroke-dashoffset:24; transition:stroke-dashoffset .25s ease .05s; }
.diary-habit-row:hover .habit-check .box { border-color:rgba(246,233,230,.7); background:rgba(255,255,255,.08); }
.habit-check input:focus-visible + .box { box-shadow:0 0 0 3px rgba(246,233,230,.35); }
.habit-check input:active + .box { transform:scale(.92); }
.habit-check input:checked + .box { background:var(--accent); border-color:var(--accent); box-shadow:0 6px 18px rgba(0,0,0,.35); }
.habit-check input:checked + .box svg { stroke-dashoffset:0; }
.diary-habit-row.done .diary-habit-info b { opacity:.6; }

/* Ник под заголовком, аватар */
.nick-line { display:flex; align-items:center; gap:10px; margin-top:6px; flex-wrap:wrap; }
.nick { color:var(--ink-2); font-size:17px; letter-spacing:.02em; }
.nick-name { color:var(--ink-3); font-size:14px; }
.link-btn { background:none; border:none; padding:2px 4px; color:var(--ink-2); cursor:pointer; font-size:13px; text-decoration:underline; text-underline-offset:3px; }
.link-btn:hover { color:var(--ink); }
.link-btn.back { display:block; margin:0 0 10px -4px; text-decoration:none; font-size:14px; }
.profile-avatar { position:relative; overflow:hidden; padding:0; color:inherit; }
.profile-avatar img { width:100%; height:100%; object-fit:cover; display:block; }
.profile-avatar img[hidden] { display:none; }
.profile-avatar.editable { cursor:pointer; width:84px; height:84px; }
.profile-avatar.editable svg.ph { width:38px; height:38px; }
.avatar-over { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; background:var(--overlay); opacity:0; transition:opacity .18s; text-align:center; padding:4px; }
.avatar-over svg { width:20px; height:20px; fill:none; stroke:var(--ink); stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
.avatar-over em { font-style:normal; font-size:10px; line-height:1.15; color:var(--ink); }
@media (hover:hover) and (pointer:fine) { .profile-avatar.editable:hover .avatar-over, .profile-avatar.editable:focus-visible .avatar-over { opacity:1; } }
@media (hover:none), (pointer:coarse) { .avatar-over { display:none !important; } .profile-avatar.editable:hover svg.ph { opacity:1 !important; } }

/* Поля с @ */
.at-input { display:flex; align-items:center; background:rgba(0,0,0,.22); border:1px solid var(--line); border-radius:999px; padding-left:18px; }
.at-input span { color:var(--ink-3); }
.at-input input { border:none !important; background:transparent !important; padding-left:6px !important; }
.at-input:focus-within { border-color:rgba(255,255,255,.4); }
.hint { font-size:12px; color:var(--ink-3); margin-top:6px; }

/* Друзья */
.friend-search { display:flex; align-items:center; gap:4px; padding:6px 8px 6px 22px; border-radius:999px; margin-bottom:18px; }
.friend-search .at { color:var(--ink-3); font-size:18px; }
.friend-search input { flex:1; min-width:0; background:transparent; border:none; outline:none; padding:13px 10px; font-size:16px; }
.friends-card { padding:20px 24px; margin-bottom:18px; }
.share-head.sub { margin-top:22px; }
.person { display:flex; align-items:center; gap:14px; padding:12px 10px; border-radius:20px; }
.person + .person { border-top:1px solid rgba(255,255,255,.07); }
.person.click { cursor:pointer; }
.person.click:hover { background:rgba(255,255,255,.06); }
.person-main { flex:1; min-width:0; }
.person-main b { display:block; font-weight:550; overflow:hidden; text-overflow:ellipsis; }
.person-main small { color:var(--ink-2); }
.person-actions { display:flex; gap:8px; align-items:center; flex:none; }
.person .chev { width:20px; height:20px; fill:none; stroke:var(--ink-3); stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.rel-note { color:var(--ink-3); font-size:13px; }
.btn.sm { padding:8px 16px; font-size:14px; }
.mini-avatar { width:48px; height:48px; border-radius:50%; border:1px solid var(--line); background:rgba(0,0,0,.2); display:grid; place-items:center; overflow:hidden; flex:none; }
.mini-avatar img { width:100%; height:100%; object-fit:cover; display:block; }
.mini-avatar svg { width:24px; height:24px; fill:none; stroke:var(--ink); stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }
.rail-badge { position:absolute; top:6px; right:6px; min-width:18px; height:18px; padding:0 5px; border-radius:99px; background:var(--f); color:var(--bg1); font-style:normal; font-size:11px; font-weight:700; display:grid; place-items:center; }
.rail-badge[hidden] { display:none; }
#fv-plan { margin-top:4px; }
#fv-plan .big { font-size:48px; }
#fv-plan .plan-macros { grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; margin-bottom:0; }
#fv-plan[hidden] { display:none; }
@media (max-width:700px) { #fv-plan .plan-macros { grid-template-columns:1fr; } .person-actions .btn.ghost { padding:8px 12px; } }

/* Вход и регистрация */
body.locked .app { filter:blur(6px); pointer-events:none; }
.auth { position:fixed; inset:0; z-index:80; display:grid; place-items:center; padding:16px; overflow:auto; background:linear-gradient(135deg, var(--bg1) 0%, var(--bg-mid) 55%, var(--bg2) 100%); }
.auth[hidden] { display:none; }
.auth-box { width:100%; max-width:440px; padding:34px 32px; }
.auth-box h1 { margin-bottom:18px; }
.auth-box .seg { display:flex; margin-bottom:22px; }
.auth-box .seg button { flex:1; }
.auth-box .link-btn { margin:2px 12px 8px 0; }
.code-input { text-align:center; font-size:26px; letter-spacing:.5em; padding-left:calc(18px + .5em) !important; }

/* правки аватара и пустых состояний */
.profile-avatar.editable { width:104px; height:104px; }
.profile-avatar.editable svg.ph { width:46px; height:46px; }
.profile-avatar.editable:hover svg.ph { opacity:0; }
.avatar-over { background:var(--overlay); gap:5px; padding:10px; }
.avatar-over svg { width:24px; height:24px; }
.avatar-over em { font-size:12px; line-height:1.2; }
.profile-params .profile-empty { grid-column:1 / -1; padding-top:0; }
.profile-user { gap:20px; }

/* Авторизация: по центру */
.auth-box { text-align:center; }
.auth-box h1 { text-align:center; margin-bottom:20px; }
.auth-box .auth-brand { font-size:14px; letter-spacing:.34em; color:var(--ink-2); margin-bottom:10px; }
.auth-box .field, .auth-box .hint, .auth-box .form-err, .auth-box .muted { text-align:left; }
.auth-box .link-btn { display:block; margin:2px auto 10px; }
.auth-box [data-view] .link-btn + .link-btn { margin-top:-4px; }
.hint.bad { color:var(--danger); }
.hint.good { color:#a8e0b4; }
.at-input.locked { opacity:.6; }
.at-input.locked input { cursor:not-allowed; }
.auth-box .seg[hidden] { display:none; }

/* автозаполнение браузера не должно менять фон полей */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, select:-webkit-autofill {
  -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
  transition: background-color 600000s 0s, color 600000s 0s;
}

/* скроллбары: без «ползунка» в окнах, тонкий и тёмный на страницах */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.22) transparent; }
.modal, .modal-box, .plan-modal, .auth { scrollbar-width: none; }
.modal::-webkit-scrollbar, .modal-box::-webkit-scrollbar, .plan-modal::-webkit-scrollbar, .auth::-webkit-scrollbar { display: none; width: 0; }
.modal { overflow-y: auto; }
.modal-box { max-height: calc(100vh - 32px); overflow-y: auto; }

/* слипшиеся блоки */
.share, .chart-card, .table-card { margin-bottom: 18px; }
.page > .glass:last-child { margin-bottom: 0; }

/* рекорды, ячейка «+» */
.records-block { margin: 4px 0 20px; }
.records-block .eyebrow { margin-bottom: 10px; }
.records-block .profile-params { margin-bottom: 0; }
button.profile-param { text-align: left; cursor: pointer; font: inherit; color: inherit; transition: .2s; }
button.profile-param:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.3); }
.profile-param.add-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; border-style: dashed; color: var(--ink-2); min-height: 74px; }
.profile-param.add-cell i { font-style: normal; font-size: 26px; line-height: 1; color: var(--ink); }
.profile-param.add-cell em { font-style: normal; font-size: 11px; letter-spacing: .06em; line-height: 1.2; }

/* выбор плана */
.choice-list { display: grid; gap: 12px; margin-top: 16px; }
.choice { text-align: left; padding: 18px 22px; border-radius: 22px; border: 1px solid var(--line); background: rgba(0,0,0,.18); cursor: pointer; transition: .2s; display: block; width: 100%; }
.choice:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.3); }
.choice b { display: block; font-size: 17px; font-weight: 550; margin-bottom: 4px; }
.choice small { color: var(--ink-2); font-size: 13px; line-height: 1.35; display: block; }

/* переключатели */
.switch { position: relative; width: 50px; height: 30px; flex: none; display: inline-block; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: rgba(0,0,0,.28); border: 1px solid var(--line); transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink-2); transition: .2s; }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); background: var(--bg1); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + i { opacity: .45; }
.switch input:focus-visible + i { outline: 2px solid var(--ink-2); outline-offset: 2px; }
.set-list { display: grid; gap: 4px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 4px; border-bottom: 1px solid rgba(255,255,255,.07); cursor: pointer; }
.set-row:last-child { border-bottom: 0; }
.set-sub { margin-left: 4px; padding-left: 0; }
.set-sub.off { opacity: .6; }

/* расписание */
.schedule-view { display: grid; gap: 8px; margin-bottom: 18px; }
.schedule-view .profile-empty { padding: 4px 0 8px; }
.sched-item { display: flex; justify-content: space-between; gap: 12px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(0,0,0,.14); }
.sched-item b { font-weight: 550; }
.sched-rows { display: grid; gap: 8px; margin-top: 8px; }
.sched-row { display: grid; grid-template-columns: 50px 1fr 100px 12px 100px; align-items: center; gap: 8px; padding: 6px 0; }
.sched-day .short { display: none; }
.sched-row input.time-in, #invite-time { color-scheme: dark; width: 100%; background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 999px; padding: 9px 10px; outline: none; text-align: center; min-width: 0; }
#invite-time { padding: 12px 18px; }
.sched-row .dash { text-align: center; color: var(--ink-3); }
@media (max-width: 480px) { .sched-row { grid-template-columns: 50px 34px 1fr 10px 1fr; gap: 6px; } .sched-day .full { display: none; } .sched-day .short { display: inline; } }
.invite-row { grid-template-columns: 1.4fr 1fr; align-items: start; }
.invite-row .pill { width: 100%; min-width: 0; padding: 12px 14px; }

/* совместные тренировки */
.workout-list { display: grid; gap: 9px; }
.workout-list:empty { display: none; }
.workout { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-radius: 18px; border: 1px solid rgba(242,208,139,.4); background: rgba(242,208,139,.08); }
.workout-main small { display: block; color: var(--ink-2); margin-top: 2px; }
.workout-act { display: flex; gap: 8px; }
.fv-workouts { margin-bottom: 18px; }

/* профиль друга */
.fv-card { position: relative; }
.chat-go { position: absolute; top: 22px; right: 24px; width: 44px; height: 44px; }
.chat-go svg, .icon-btn.sm svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.sm { width: 38px; height: 38px; }
.profile-actions.two { gap: 10px; flex-wrap: wrap; }
.section-heading.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.eaten-kcal { display: flex; align-items: baseline; gap: 10px; }
.eaten-kcal b { font-size: 44px; font-weight: 500; }
.eaten-kcal span { color: var(--ink-2); }
.eaten .plan-macros { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; margin: 12px 0 0; }
.eaten .pm { border-radius: 18px; padding: 13px 15px; }
.habit-state { color: var(--ink-3); font-size: 13px; flex: none; }
.habit-state.yes { color: #a8e0b4; }
@media (max-width: 700px) { .eaten .plan-macros { grid-template-columns: 1fr; } .chat-go { top: 16px; right: 16px; } }

/* чат */
.unread { font-style: normal; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--f); color: var(--bg1); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.chat-time { color: var(--ink-3); font-size: 12px; }
.chat-box { display: flex; flex-direction: column; height: calc(100vh - 72px); min-height: 420px; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.chat-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-who small { color: var(--ink-2); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.chat-hint { text-align: center; margin: auto; }
.day-sep { text-align: center; margin: 10px 0 4px; }
.day-sep span { font-size: 12px; color: var(--ink-3); letter-spacing: .08em; padding: 4px 12px; border-radius: 99px; background: rgba(0,0,0,.2); }
.sys-msg { text-align: center; color: var(--ink-3); font-size: 12.5px; margin: 6px 0; }
.msg { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.msg.mine { justify-content: flex-end; }
.bubble { max-width: min(76%, 520px); padding: 10px 14px 7px; border-radius: 20px; background: rgba(255,255,255,.1); border: 1px solid var(--line); word-break: break-word; line-height: 1.35; }
.msg.mine .bubble { background: rgba(246,233,230,.18); border-color: rgba(246,233,230,.3); border-bottom-right-radius: 7px; }
.msg.theirs .bubble { border-bottom-left-radius: 7px; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 3px; font-size: 11px; color: var(--ink-3); }
.tick { width: 16px; height: 16px; fill: none; stroke: var(--ink-3); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tick.read { stroke: #8fd3ff; }
.msg-edit { order: -1; width: 28px; height: 28px; border-radius: 50%; border: none; background: transparent; color: var(--ink-3); cursor: pointer; display: grid; place-items: center; opacity: 0; transition: .15s; flex: none; padding: 0; }
.msg-edit svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.msg:hover .msg-edit, .msg-edit:focus-visible { opacity: 1; }
.msg-edit:hover { color: var(--ink); background: rgba(255,255,255,.1); }
@media (hover:none) { .msg-edit { opacity: .7; } }
.bubble.invite { min-width: 220px; border-color: rgba(242,208,139,.5); background: rgba(242,208,139,.1); }
.bubble.invite .eyebrow { margin-bottom: 4px; }
.inv-when { color: var(--ink-2); margin: 3px 0 8px; }
.inv-act { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.inv-status { font-size: 13px; color: var(--ink-2); }
.inv-status.accepted { color: #a8e0b4; }
.inv-status.declined, .inv-status.cancelled { color: var(--danger); }
.chat-edit-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 18px; font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--line); background: rgba(0,0,0,.18); }
.chat-edit-bar button { background: none; border: none; color: var(--ink-2); font-size: 20px; cursor: pointer; }
.chat-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 999px; padding: 13px 20px; outline: none; font-size: 16px; }
.chat-form input:focus { border-color: rgba(255,255,255,.4); }
.chat-send { width: 50px; height: 50px; border-radius: 50%; border: none; background: var(--accent); color: var(--bg1); cursor: pointer; display: grid; place-items: center; flex: none; }
.chat-send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* меню: настройки внизу */
.rail { justify-content: center; }
.rail-settings { margin-top: 18px; }
@media (min-width: 761px) { .rail { padding-bottom: 36px; } .rail-settings { position: absolute; bottom: 38px; left: 16px; margin-top: 0; } }
@media (max-width: 760px) {
  .rail { gap: 0; }
  .rail-btn { width: 52px; height: 52px; border-radius: 20px; }
  .rail-settings { margin-top: 0; }
  .chat-box { height: calc(100dvh - 190px); }
  .bubble { max-width: 84%; }
}
[hidden] { display: none !important; }

/* ---------- темы оформления ---------- */
[data-theme="green"] { --bg1:#051F20; --bg-mid:#0B2B26; --bg2:#163832; --panel:#0B2B26; --overlay:rgba(5,31,32,.82); --ink:#DAF1DE; --ink-2:rgba(218,241,222,.68); --ink-3:rgba(218,241,222,.44); --accent:#8EB69B; --line:rgba(142,182,155,.26); }
[data-theme="blue"] { --bg1:#06141B; --bg-mid:#11212D; --bg2:#253745; --panel:#11212D; --overlay:rgba(6,20,27,.82); --ink:#CCD0CF; --ink-2:rgba(204,208,207,.68); --ink-3:rgba(204,208,207,.44); --accent:#9BA8AB; --line:rgba(155,168,171,.26); }
[data-theme="pink"], [data-theme="purple"] { --bg1:#3A0B19; --bg-mid:#6D1D32; --bg2:#8E2B44; --panel:#4B0F1E; --overlay:rgba(58,11,25,.82); --ink:#F7D6DC; --ink-2:rgba(247,214,220,.7); --ink-3:rgba(247,214,220,.46); --accent:#E07A94; --line:rgba(224,122,148,.28); }
.theme-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; padding:6px 0 4px; }
.theme-opt { border:1.5px solid var(--line); background:var(--glass); border-radius:18px; padding:8px; cursor:pointer; text-align:center; font-size:13px; color:var(--ink); }
.theme-opt i { display:block; height:44px; border-radius:12px; margin-bottom:6px; }
.theme-opt.on { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
@media (max-width:560px){ .theme-grid{grid-template-columns:repeat(2,1fr);} }
.set-acc > .set-acc-head { display:flex; justify-content:space-between; align-items:center; width:100%; background:none; border:0; padding:6px 0; cursor:pointer; font-weight:600; font-size:inherit; text-align:left; }
.set-acc .chev { transition:transform .2s; }
.set-acc.open .chev { transform:rotate(180deg); }
.set-acc-body { display:none; padding-top:8px; }
.set-acc.open .set-acc-body { display:block; }
.chat-head-user { display:flex; align-items:center; gap:12px; background:none; border:0; padding:0; cursor:pointer; color:inherit; text-align:left; }
.bio-line { color:var(--ink-2); font-size:14px; margin:4px 0 0; min-height:20px; }
.bio-line button { background:none; border:0; color:var(--ink-2); cursor:pointer; padding:0; text-decoration:underline dotted; font:inherit; }
.bio-line input { background:rgba(0,0,0,.22); border:1px solid var(--line); border-radius:999px; padding:6px 14px; color:var(--ink); width:100%; max-width:420px; outline:none; }
.adm-row { display:grid; grid-template-columns:1fr repeat(3,64px) auto; gap:6px; align-items:center; margin:6px 0; }
.adm-row input { background:rgba(0,0,0,.22); border:1px solid transparent; border-radius:12px; padding:8px 10px; width:100%; color:var(--ink); min-width:0; }
@media (max-width:560px){ .adm-row{grid-template-columns:1fr 1fr 1fr 1fr;} .adm-row input:first-child{grid-column:1/-1;} }
.meal-open { display:block; margin:-6px 0 16px 18px; }
.unit-tag { color:var(--ink-3); font-size:12px; margin-left:4px; }
.pcs-tag { font-style:normal; color:var(--ink-3); font-size:12px; margin-left:6px; }
.set-group { margin-top:12px; }
td.pcs { white-space:nowrap; }
td.pcs .num { display:inline-block; width:92px; vertical-align:middle; margin:0; }
td.pcs .unit-tag { display:inline-block; width:0; overflow:visible; position:relative; left:6px; }
.add-row .btn.primary:hover { filter:none; }
.diary-habits, .add-row { isolation:isolate; }
.habit-check input:checked + .box { box-shadow:none; }

.bio-line button.has { text-decoration:none; cursor:pointer; color:var(--ink-2); }
.bio-line button.has::after { content:" ✎"; opacity:.45; font-size:12px; }
.bio-line button.empty { text-decoration:underline; text-decoration-style:solid; text-underline-offset:3px; text-decoration-color:var(--ink-3); color:var(--ink-2); }
.profile-user > div:not(.profile-avatar) { flex:1; min-width:0; }
.bio-line input { max-width:none; width:100%; font-size:14px; }
.fv-top { display:flex; justify-content:flex-end; align-items:center; gap:10px; margin-bottom:14px; flex-wrap:wrap; }
.fv-top .chat-go { position:static; }
.btn.sm { padding:9px 16px; font-size:14px; }
.icon-btn.trash:hover { color:var(--danger); }
.person.removed { opacity:.55; }
.set-logout { display:flex; justify-content:center; margin:26px 0 8px; }
.set-acc:not(.open) { background:transparent; box-shadow:none; backdrop-filter:none; -webkit-backdrop-filter:none; padding-top:16px; padding-bottom:16px; border-radius:22px; }
.set-acc:not(.open) .set-acc-head { padding:0; }

[data-theme="sand"] { --bg1:#2A211D; --bg-mid:#4A3A34; --bg2:#77574A; --panel:#3B2E29; --overlay:rgba(42,33,29,.84); --ink:#F9F2E4; --ink-2:rgba(249,242,228,.7); --ink-3:rgba(249,242,228,.46); --accent:#D0AE92; --line:rgba(208,174,146,.28); }
[data-theme="truffle"] { --bg1:#1F1915; --bg-mid:#302924; --bg2:#453C36; --panel:#302924; --overlay:rgba(31,25,21,.84); --ink:#F5EDE6; --ink-2:rgba(245,237,230,.68); --ink-3:rgba(245,237,230,.44); --accent:#C7BBB1; --line:rgba(199,187,177,.26); }
.sched-row input.time-in, #invite-time { text-align:center; letter-spacing:.04em; }
/* автозаполнение браузера: без белого фона */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active,
textarea:-webkit-autofill, select:-webkit-autofill {
  -webkit-text-fill-color: var(--ink) !important;
  caret-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--panel) inset !important;
  box-shadow: 0 0 0 1000px var(--panel) inset !important;
  transition: background-color 9999s ease-in-out 0s;
  border-radius: inherit;
}
input:autofill { background-color: var(--panel) !important; color: var(--ink) !important; -webkit-text-fill-color: var(--ink) !important; }
.at-input { overflow:hidden; }
.at-input input:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px var(--panel) inset !important; box-shadow: 0 0 0 1000px var(--panel) inset !important; border-radius:0; }

/* вход: скруглённые поля и автозаполнение только на экране авторизации */
.auth .field input { border-radius: 999px; }
.auth input:-webkit-autofill, .auth input:-webkit-autofill:hover, .auth input:-webkit-autofill:focus, .auth input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--ink) !important; caret-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px color-mix(in srgb, var(--bg-mid) 80%, #000) inset !important; box-shadow: 0 0 0 1000px color-mix(in srgb, var(--bg-mid) 80%, #000) inset !important;
  border-radius: 999px; transition: background-color 600000s 0s;
}
/* меню: кнопка настроек вплотную к рамке */
@media (min-width: 761px) {
  .rail::before { border-radius: calc((var(--rail-w) - 26px) / 2); }
  .rail-settings { width: calc(var(--rail-w) - 26px); height: calc(var(--rail-w) - 26px); left: 13px; bottom: 21px; }
}

/* вложения и голосовые в чате */
.chat-form { align-items: center; }
.chat-ico { width: 44px; height: 44px; border-radius: 50%; border: none; background: transparent; color: var(--ink-2); cursor: pointer; display: grid; place-items: center; flex: none; }
.chat-ico:hover { background: rgba(255,255,255,.1); color: var(--ink); }
.chat-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-send[hidden], .chat-form input[hidden], .chat-rec[hidden] { display: none; }
.chat-rec { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 999px; padding: 6px 8px 6px 18px; height: 50px; }
.chat-rec b { font-variant-numeric: tabular-nums; }
.chat-rec .rec-hint { color: var(--ink-3); font-size: 13px; flex: 1; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff5c5c; animation: recblink 1s infinite; flex: none; }
@keyframes recblink { 50% { opacity: .25; } }
.chat-form.recording #chat-attach { visibility: hidden; }
.chat-form.recording #chat-mic { background: #ff5c5c; color: #fff; }
.bubble.media { padding: 4px 4px 6px; }
.bubble.media .meta { padding: 0 8px; }
.bubble.media img, .bubble.media video { display: block; max-width: min(100%, 320px); max-height: 360px; border-radius: 16px; cursor: pointer; background: rgba(0,0,0,.25); }
.bubble.media video { cursor: default; }
.bubble.voice { min-width: 230px; padding: 8px 12px 6px; }
.bubble.voice audio { display: block; width: 100%; height: 38px; }
.bubble.media.uploading { opacity: .6; }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.88); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }
.lightbox button { position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(255,255,255,.16); color: #fff; font-size: 26px; cursor: pointer; }

/* друзья: компактные строки, имя сверху, ник снизу */
.fr-card { padding: 8px 12px; }
.fr-card .person { padding: 9px 8px; }
.person-main b { line-height: 1.25; }
.person-main small { display: block; line-height: 1.25; font-size: 13.5px; }
.swipe { position: relative; overflow: hidden; border-radius: 20px; }
.swipe + .swipe { border-top: 1px solid rgba(255,255,255,.07); border-radius: 0; }
.swipe .person + .person { border-top: 0; }
.sw-trash { display: none; }

/* телефон: только мобильная адаптация */
html { background: var(--bg1); }
@media (max-width: 760px) {
  .app { min-height: 100dvh; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .content { padding-top: calc(22px + env(safe-area-inset-top)); }
  .rail { height: calc(80px + env(safe-area-inset-bottom)); padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: center; }
  .rail::before { inset: 6px 10px calc(6px + env(safe-area-inset-bottom)) 10px; }
  .chat-box { height: calc(100dvh - env(safe-area-inset-top) - 22px - 80px - env(safe-area-inset-bottom) - 12px); min-height: 0; }
  .fr-card { padding: 4px 6px; }
  .fr-card .person { padding: 8px 8px; background: transparent; }
  .swipe .person { position: relative; z-index: 1; will-change: transform; }
  .swipe .person-actions .trash { display: none; }
  .sw-trash { display: grid; place-items: center; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.1); color: var(--ink); cursor: pointer; z-index: 0; opacity: 0; pointer-events: none; }
  .swipe.open .sw-trash { pointer-events: auto; }
  .sw-trash svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
}

/* ===== профиль: имя с карандашом, режим редактирования ===== */
.pu-main { flex: 1; min-width: 0; }
.pu-title { display: flex; align-items: center; gap: 8px; }
.pu-title h2 { margin: 0; font-size: 26px; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.icon-btn.pu-pencil { width: 34px; height: 34px; flex: none; background: transparent; color: var(--ink-2); }
.pu-pencil svg { width: 18px; height: 18px; }
.pu-pencil .i-ok { display: none; }
.profile-summary.editing .pu-pencil { background: var(--accent); color: var(--bg1); border-color: transparent; }
.profile-summary.editing .pu-pencil .i-ok { display: block; }
.profile-summary.editing .pu-pencil .i-pen { display: none; }
.pu-nick { color: var(--ink-2); font-size: 15px; margin-top: 2px; }
.pu-bd { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.pu-edit-name { display: none; margin-top: 6px; }
.profile-summary.editing .pu-edit-name { display: inline-block; }
.profile-summary:not(.editing) .profile-avatar.editable { cursor: default; }
.profile-summary:not(.editing) .avatar-over { display: none !important; }
.profile-summary:not(.editing) .profile-avatar.editable:hover svg.ph { opacity: 1 !important; }
.bio-line[hidden], .pu-bd[hidden] { display: none; }
.kcal-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kcal-row .big { margin: 8px 0 4px; }
.stat-link { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--glass-2); color: var(--ink); border-radius: 999px; padding: 10px 16px; cursor: pointer; font: inherit; font-size: 14px; flex: none; transition: .2s; }
.stat-link:hover { background: rgba(255,255,255,.16); }
.stat-link svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rec-empty { grid-column: 1 / -1; padding: 4px 0; }
#fv-records-wrap .profile-params { display: block; }
#fv-records-wrap .profile-params:has(.profile-param) { display: grid; }

/* ===== настройки в стиле списка ===== */
.set-card { background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.03)); border-radius: 22px; overflow: hidden; margin-bottom: 18px; box-shadow: 0 10px 28px rgba(0,0,0,.22); }
.set-card.pad { padding: 8px 18px 12px; }
.set-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 11px 16px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; position: relative; }
.set-item + .set-item::before { content: ""; position: absolute; top: 0; left: 70px; right: 0; height: 1px; background: rgba(255,255,255,.08); }
.set-item:hover { background: rgba(255,255,255,.05); }
.set-item[hidden] { display: none; }
.set-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; font-style: normal; color: #fff; }
.set-ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic-blue { background: #3b82f6; } .ic-slate { background: #64748b; } .ic-orange { background: #f59e0b; } .ic-red { background: #ef4444; } .ic-green { background: #22a45d; } .ic-purple { background: #8b5cf6; }
.set-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.set-txt b { font-weight: 500; font-size: 15.5px; }
.set-txt small { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-go { width: 18px; height: 18px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.set-sub-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.set-sub-head h1 { margin: 0; font-size: 28px; }
.set-pane[hidden], #set-main[hidden], #set-sub[hidden] { display: none; }
.set-pane .set-row { font-size: 14.5px; padding: 11px 0; }
.set-pane .share-head.sub { font-size: 12px; margin-top: 8px; }
.set-pane .theme-opt { border-width: 1px; border-color: transparent; background: rgba(255,255,255,.05); }
.set-pane .theme-opt.on { border-color: var(--accent); }
.acc-avatar { display: grid; place-items: center; margin: 4px 0 18px; }
.acc-avatar .profile-avatar.editable { width: 104px; height: 104px; }
.acc-avatar .profile-avatar.editable:hover svg.ph { opacity: 1; }
.acc-cam { position: absolute; right: 0; bottom: 0; left: 0; height: 32px; display: grid; place-items: center; background: rgba(0,0,0,.45); }
.acc-cam svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.acc-card { background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.03)); border-radius: 18px; padding: 6px 14px; }
.fl { position: relative; display: block; padding: 8px 0; }
.fl + .fl { border-top: 1px solid rgba(255,255,255,.08); }
.fl span { display: block; font-size: 12px; color: var(--ink-3); }
.fl input { width: 100%; background: transparent; border: 0; outline: none; color: var(--ink); font: inherit; font-size: 16px; padding: 3px 0 0; border-radius: 0; box-shadow: none; }
.fl input:disabled { opacity: .6; }
.fl em { position: absolute; right: 0; top: 10px; font-style: normal; font-size: 12px; color: var(--ink-3); }
.acc-hint { color: var(--ink-3); font-size: 12.5px; margin: 8px 6px 16px; line-height: 1.4; }
.acc-hint.first { margin-top: 0; }
.acc-bd { display: flex; align-items: center; gap: 12px; background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.03)); border-radius: 18px; padding: 8px 14px 8px 10px; }
.acc-bd .set-ic { width: 32px; height: 32px; border-radius: 9px; }
.acc-bd .set-ic svg { width: 19px; height: 19px; }
.acc-bd-t { flex: 1; font-size: 15.5px; }
.acc-bd input { width: 128px; background: transparent; border: 0; outline: none; color: var(--ink-2); font: inherit; font-size: 15px; text-align: right; padding: 8px 0; border-radius: 0; box-shadow: none; }
.acc-sect { font-size: 12px; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3); margin: 8px 6px 8px; }
.set-pane .profile-params { margin-bottom: 16px; }

/* ===== цель: 2 на 2 ===== */
.seg.wrap[data-name="goal"] { display: grid; grid-template-columns: 1fr 1fr; width: 100%; border-radius: 24px; }
.seg.wrap[data-name="goal"] button { text-align: center; }
.opt-hint { color: var(--ink-3); text-transform: none; letter-spacing: 0; font-size: 11px; margin-left: 4px; }

/* ===== телефон ===== */
@media (max-width: 760px) {
  .pu-title h2 { font-size: 22px; }
  .profile-user { align-items: flex-start; }
  .profile-avatar.editable { width: 76px; height: 76px; }
  .kcal-row .big { font-size: 38px; }
  .profile-plan-result .big { font-size: 40px; }
  .stat-link { padding: 8px 12px; font-size: 13px; }
  .stat-link svg { width: 18px; height: 18px; }
  .set-sub-head h1 { font-size: 24px; }
  .set-card.pad { padding: 6px 14px 10px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 0; min-width: 0; padding: 12px 10px; font-size: 14px; }
  .modal-actions #record-delete { flex-basis: 100%; order: 3; }
  #m-plan-manual .row3 { align-items: end; gap: 8px; }
  #m-plan-manual .row3 .field label { white-space: nowrap; font-size: 10px; letter-spacing: .04em; }
  #m-plan-manual .row3 .field input { padding-left: 10px; padding-right: 10px; }
  /* чат на весь экран */
  .content:has(#chat-conv-view:not([hidden])) { padding: calc(6px + env(safe-area-inset-top)) 6px 0; }
  .chat-box { height: calc(100dvh - env(safe-area-inset-top) - 6px - 80px - env(safe-area-inset-bottom) - 8px); border-radius: 20px; }
  .chat-head { padding: 6px 10px; gap: 8px; }
  .chat-head .icon-btn { width: 36px; height: 36px; }
  .chat-head .icon-btn svg { width: 20px; height: 20px; }
  .chat-head-user { gap: 9px; }
  .chat-head .mini-avatar { width: 34px; height: 34px; }
  .chat-who b { font-size: 15px; line-height: 1.2; }
  .chat-who small { font-size: 12px; line-height: 1.2; }
  .chat-msgs { padding: 10px 10px; }
  .chat-form { padding: 6px 8px; gap: 4px; }
  .chat-form input { padding: 9px 16px; }
  .chat-ico { width: 38px; height: 38px; }
  .chat-ico svg { width: 22px; height: 22px; }
  .chat-form .chat-send { width: 38px; height: 38px; }
  .chat-rec { height: 40px; }
}
#set-main, #set-sub { max-width: 680px; }
