:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --link: var(--tg-theme-link-color, #2a7de1);
  --accent: var(--tg-theme-button-color, #2a7de1);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --header: var(--tg-theme-section-header-text-color, var(--hint));
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --ok: #2fa84f;
  --warn: #d98e04;
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --soft: color-mix(in srgb, var(--accent) 10%, var(--card));
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--link); text-decoration: none; }

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.tabs button {
  position: relative;
  border: 0;
  border-radius: 10px;
  padding: 8px 4px;
  background: transparent;
  color: var(--hint);
  font-weight: 600;
  font-size: 14px;
}

.tabs button[aria-current="page"] { background: var(--card); color: var(--text); }

.badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
}

main { padding: 12px; display: grid; gap: 12px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

h2 { margin: 0; font-size: 17px; }

h3 {
  margin: 4px 4px 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--header);
}

.hint { color: var(--hint); font-size: 13px; }
.danger { color: var(--danger); }
.empty { color: var(--hint); text-align: center; padding: 20px 8px; }

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 3px;
  border-radius: 11px;
  background: var(--line);
}

.seg button {
  border: 0;
  border-radius: 9px;
  padding: 7px 4px;
  background: transparent;
  font-weight: 600;
  font-size: 14px;
}

.seg button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

/* Сводка */
.total { display: flex; align-items: baseline; gap: 8px; }
.total b { font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }

.bar {
  display: flex;
  height: 10px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--line);
}

.bar span { display: block; height: 100%; }

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

.stat {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
}

.stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--hint); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.list { display: grid; }
.row {
  display: grid;
  gap: 2px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; padding-top: 0; }
.row-title { font-weight: 600; }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

/* Кнопки */
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--card)); }
.btn:disabled { opacity: .5; }
.btn.grow { flex: 1; }

/* Разбор */
.reason {
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 9%, var(--card));
  color: var(--danger);
  font-size: 14px;
}

.shot { width: 100%; border-radius: 10px; border: 1px solid var(--line); }

details { border-top: 1px solid var(--line); padding-top: 8px; }
summary { cursor: pointer; color: var(--link); font-weight: 600; font-size: 14px; }
.pre { white-space: pre-wrap; word-break: break-word; font-size: 13px; margin: 8px 0 0; }
.qa { margin-top: 8px; }
.qa b { display: block; font-size: 13px; }

.links { display: grid; gap: 4px; font-size: 14px; word-break: break-all; }

/* Ветки */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: var(--line);
  transition: background .2s;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgb(0 0 0 / .2);
  transition: transform .2s;
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }

.cv-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 4px 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.cv-row .lang { font-weight: 700; color: var(--hint); }
.cv-row .btns { grid-column: 2; }

.job { padding: 10px 12px; border-radius: 12px; background: var(--bg); display: grid; gap: 8px; }

/* Обо мне */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 14px; background: var(--bg); font-size: 13px; }
.chip b { font-variant-numeric: tabular-nums; }

.stage { display: grid; gap: 8px; padding: 14px; border-radius: var(--radius); background: var(--card); }
.stage .push { margin-left: auto; }
.stage.moved { animation: moved 1.2s ease-out; }
@keyframes moved { from { box-shadow: 0 0 0 2px var(--accent); } to { box-shadow: 0 0 0 2px transparent; } }
.stage input[type="text"] { background: var(--bg); }

.field { display: grid; gap: 4px; }
.field > span { color: var(--hint); font-size: 12px; }

input[type="text"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--card);
}

textarea { min-height: 120px; resize: vertical; font-size: 14px; line-height: 1.45; }

.range { display: grid; gap: 2px; }
.range-head { display: flex; justify-content: space-between; font-size: 13px; }
.range-head b { font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 6px 0; }
input[type="range"]:disabled { opacity: .35; }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.sticky-save {
  position: sticky;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 4;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgb(0 0 0 / .82);
  color: #fff;
  font-size: 14px;
  z-index: 10;
}

.spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
