:root {
  --bg: #0d1016;
  --surface: #171b24;
  --surface-2: #202633;
  --text: #f5f7fb;
  --muted: #8d97aa;
  --accent: #8e7dff;
  --accent-2: #60d6b2;
  --danger: #ff6b7d;
  --border: rgba(255,255,255,.08);
  --shadow: 0 18px 45px rgba(0,0,0,.24);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top right, rgba(142,125,255,.16), transparent 28rem), var(--bg); color: var(--text); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.app { width: min(100%, 980px); margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 700; }
h1 { margin: 3px 0 0; font-size: 30px; letter-spacing: -.04em; }
h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
p { color: var(--muted); }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); font-size: 23px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border: 1px solid var(--border); background: rgba(23,27,36,.82); border-radius: 16px; position: sticky; top: max(8px, env(safe-area-inset-top)); z-index: 5; backdrop-filter: blur(16px); }
.tab { border: 0; border-radius: 11px; padding: 11px; background: transparent; color: var(--muted); font-weight: 700; }
.tab.active { background: var(--surface-2); color: var(--text); }
.tab-content { display: none; padding-top: 14px; }
.tab-content.active { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.daily-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.daily-stat { min-height: 132px; }
.daily-stat small { display: block; margin-top: 9px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.daily-fact { background: linear-gradient(145deg, rgba(96,214,178,.13), rgba(255,255,255,.015)), var(--surface); }
.goal-panel { background: linear-gradient(145deg, rgba(142,125,255,.08), rgba(255,255,255,.01)), var(--surface); }
.stat { min-height: 100px; border: 1px solid var(--border); border-radius: 20px; padding: 16px; background: linear-gradient(145deg, rgba(255,255,255,.035), rgba(255,255,255,.01)), var(--surface); box-shadow: var(--shadow); }
.stat-primary { background: linear-gradient(145deg, rgba(142,125,255,.28), rgba(96,214,178,.08)), var(--surface); }
.stat span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.stat strong { font-size: 25px; letter-spacing: -.035em; }
.panel { margin-top: 12px; padding: 17px; border: 1px solid var(--border); border-radius: 22px; background: rgba(23,27,36,.92); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-head p { margin: 5px 0 0; font-size: 13px; }
.chart-wrap { width: 100%; min-height: 260px; overflow: hidden; }
#chart { width: 100%; height: 260px; display: block; }
.legend { display: flex; gap: 18px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.actual { background: var(--accent); }
.dot.plan { background: var(--accent-2); }
form { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
input { width: 100%; border: 1px solid var(--border); border-radius: 14px; padding: 13px 14px; background: var(--surface-2); color: var(--text); outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(142,125,255,.15); }
.actions { grid-column: 1 / -1; display: flex; gap: 9px; }
.primary, .secondary, .danger { border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 800; }
.primary { flex: 1; color: white; background: linear-gradient(135deg, var(--accent), #6a9bff); }
.secondary { color: var(--text); background: var(--surface-2); }
.danger { color: var(--danger); background: rgba(255,107,125,.1); }
.history { display: grid; gap: 8px; }
.history-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: 0; }
.history-date { color: var(--muted); font-size: 13px; }
.history-weight { font-weight: 800; font-size: 17px; }
.history-change { font-size: 12px; color: var(--muted); }
.row-actions { display: flex; gap: 5px; }
.row-actions button { border: 0; border-radius: 10px; padding: 8px 10px; background: var(--surface-2); color: var(--text); }
.food-intro p { margin-bottom: 0; line-height: 1.5; }
.food-days { display: grid; gap: 12px; }
.food-day { padding: 16px; border: 1px solid var(--border); border-radius: 22px; background: rgba(23,27,36,.92); box-shadow: var(--shadow); }
.food-day-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.food-day-head span { color: var(--muted); font-size: 12px; }
.food-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.food-card { position: relative; overflow: hidden; border-radius: 15px; background: var(--surface-2); }
.food-card img { width: 100%; aspect-ratio: 1 / 1; display: block; object-fit: cover; }
.food-caption { padding: 10px; color: var(--text); font-size: 13px; line-height: 1.4; white-space: pre-wrap; }
.food-delete { position: absolute; top: 7px; right: 7px; width: 31px; height: 31px; padding: 0; border: 0; border-radius: 10px; background: rgba(10,12,18,.76); color: white; }
.empty { padding: 24px 10px; text-align: center; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; background: #f5f7fb; color: #11141a; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 20; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate-card { text-align: center; }
.logo { width: 68px; height: 68px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 22px; background: linear-gradient(135deg, var(--accent), #6a9bff); font-size: 34px; font-weight: 900; }
@media (min-width: 720px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .food-grid { grid-template-columns: repeat(4, 1fr); }
  #chart { height: 340px; }
  .chart-wrap { min-height: 340px; }
}
@media (max-width: 520px) {
  .daily-stat strong { font-size: 22px; }
  form { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr auto; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* Исправление выхода поля даты за границы на мобильных устройствах */
form,
form label,
form .actions {
  min-width: 0;
  max-width: 100%;
}

form input,
form select,
form textarea {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

input[type="date"] {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

@media (max-width: 520px) {
  .form-panel form,
  .goal-panel form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }
}


/* KOBI_WEIGHT_STATS_START */
.stats-info {
  margin: 2px 2px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stats-grid .stat {
  min-width: 0;
  min-height: 92px;
  background:
    linear-gradient(
      145deg,
      rgba(255,255,255,.035),
      rgba(255,255,255,.01)
    ),
    var(--surface);
}

.stats-grid .stat strong {
  display: block;
  white-space: nowrap;
}

@media (max-width: 390px) {
  .stats-grid .stat {
    min-height: 86px;
    padding: 14px 12px;
  }

  .stats-grid .stat strong {
    font-size: 21px;
  }
}
/* KOBI_WEIGHT_STATS_END */


/* KOBI_DIARY_TITLE_START */
.topbar > div {
  min-width: 0;
}

.topbar h1 {
  font-size: clamp(23px, 7vw, 30px);
  line-height: 1.08;
}

.gate-card h1 {
  font-size: clamp(25px, 8vw, 32px);
  line-height: 1.1;
}
/* KOBI_DIARY_TITLE_END */


/* KOBI_GOAL_ALERT_START */
.stats-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 2px 2px 10px;
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(10px, 2.9vw, 13px);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.stats-info > span {
  min-width: 0;
}

#stats-info-date {
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-goal {
  flex: 0 0 auto;
  text-align: right;
  transition:
    color 160ms ease,
    opacity 160ms ease;
}

.stats-goal.is-warning {
  color: #e8b45f;
}

.stats-goal.is-warning::before {
  content: "⚠";
  display: inline-block;
  margin-right: 4px;
  font-size: 0.92em;
}

.goal-speed-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: -2px 0 10px;
  padding: 9px 10px;
  border: 1px solid rgba(232, 180, 95, 0.28);
  border-radius: 12px;
  background: rgba(232, 180, 95, 0.08);
  color: rgba(245, 229, 198, 0.88);
  font-size: 12px;
  line-height: 1.4;
}

.goal-speed-alert[hidden] {
  display: none !important;
}

.goal-speed-alert-icon {
  display: grid;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  place-items: center;
  margin-top: 1px;
  border: 1px solid rgba(232, 180, 95, 0.55);
  border-radius: 50%;
  color: #e8b45f;
  font-size: 11px;
  font-weight: 900;
}
/* KOBI_GOAL_ALERT_END */


/* KOBI_PUBLIC_LANDING_START */
.gate-card {
  width: min(420px, calc(100vw - 32px));
  padding: 34px 26px;
  text-align: center;
}

.public-logo {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin: 0 auto 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 25px;
  font-weight: 800;
}

.gate-card h1 {
  margin: 0 0 12px;
  font-size: clamp(24px, 7vw, 31px);
}

.gate-card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.gate-card a {
  color: inherit;
  font-weight: 750;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  text-underline-offset: 3px;
}
/* KOBI_PUBLIC_LANDING_END */
