/* Цвета берутся из темы Telegram (--tg-theme-*), запасные — для обычного браузера */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f3f5);
  --text: var(--tg-theme-text-color, #1b1d21);
  --hint: var(--tg-theme-hint-color, #80868f);
  --accent: var(--tg-theme-button-color, #2b7de9);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --border: rgba(128, 128, 128, 0.28);
  --danger: #e8590c;
  --warn: #f59f00;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-bg-color, #17191c);
    --bg2: var(--tg-theme-secondary-bg-color, #22252a);
    --text: var(--tg-theme-text-color, #eceef1);
    --hint: var(--tg-theme-hint-color, #8d939c);
  }
}

* { box-sizing: border-box; }
/* hidden сильнее любых display из классов (.btn.wide, .row…) */
[hidden] { display: none !important; }

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

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

.hint { color: var(--hint); }

/* ---------- Профиль ---------- */

.home { padding: 16px 16px 28px; max-width: 720px; margin: 0 auto; }

.profile { display: flex; align-items: center; gap: 14px; }
.avatar {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 20px;
  font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-text { min-width: 0; }
.profile h1 { margin: 0; font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.profile p { margin: 2px 0 0; font-size: 14px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.tile { background: var(--bg2); border-radius: 12px; padding: 10px 8px; text-align: center; }
.tile b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; }

.card { background: var(--bg2); border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.bar { display: block; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* Плитка и карточка ачивок — кнопки на страницу достижений */
.tile-link, button.card { width: 100%; border: 0; color: inherit; font: inherit; cursor: pointer; }
.tile-link:active, button.card:active, .goal:active, .ach-item:active { transform: scale(0.98); }
button.card { display: block; text-align: left; }
.achievement > span { display: block; }
.achievement .bar { margin-bottom: 2px; }
.achievement > .ach-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 15px; }
.ach-card-row { margin-bottom: 6px; font-size: 14px; }
.chevron { flex: none; color: var(--hint); font-size: 22px; line-height: 1; }

.home h2, .page h2 { margin: 22px 0 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--hint); }

.nav-buttons { display: grid; gap: 8px; }
.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--bg2);
  text-align: left;
  cursor: pointer;
}
.nav:active { opacity: 0.7; }
.nav > span:last-child { display: flex; flex-direction: column; font-weight: 600; }
.nav small { font-weight: 400; font-size: 13px; }
.nav-icon { font-size: 22px; }

.actions { list-style: none; margin: 0; padding: 0; }
.action { padding: 10px 0; border-bottom: 1px solid var(--border); }
.action:last-child { border-bottom: 0; }
.action-head { display: flex; align-items: baseline; gap: 8px; }
.action-head .project { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.action-head time { flex: none; font-size: 13px; font-variant-numeric: tabular-nums; }
.action-move { margin-top: 2px; font-size: 14px; }
.action-move .arrow { margin: 0 6px; color: var(--hint); }
.action-move .to { font-weight: 600; }
.note { margin: 4px 0 0; padding-left: 8px; border-left: 2px solid var(--border); font-size: 13px; color: var(--hint); }

.more {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: none;
  color: var(--accent);
  cursor: pointer;
}
.more:disabled { opacity: 0.5; }

/* ---------- Шапка статистики ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px 0;
}

.top-row { display: flex; gap: 8px; align-items: center; }

.top-row select {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
}

.icon, .ghost {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  cursor: pointer;
  white-space: nowrap;
}
.icon { width: 38px; font-size: 18px; }
.icon.back { font-size: 26px; line-height: 1; }
.ghost { padding: 0 12px; }
.ghost[aria-expanded="true"] { background: var(--accent); color: var(--accent-text); border-color: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; }
.chips[hidden] { display: none; }

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg2);
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
}
.chip b { font-weight: 600; margin-left: 4px; }
.chip.off { opacity: 0.45; text-decoration: line-through; }
.chip.reset { background: transparent; color: var(--accent); border-color: transparent; }

.tabs { display: flex; gap: 4px; margin-top: 10px; }
.tabs button {
  flex: 1;
  padding: 9px 6px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--hint);
  cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 12px 16px 24px; }

.status { padding: 32px 0; text-align: center; color: var(--hint); }
.status.error { color: var(--danger); }
.summary { margin: 0 0 10px; font-size: 13px; }

/* ---------- Таблица по стадиям ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  align-items: start;
}

.stage { background: var(--bg2); border-radius: 12px; padding: 10px 12px 12px; }
.stage header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stage h3 { margin: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.stage .count {
  flex: none;
  min-width: 26px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.stage p { margin: 2px 0 8px; font-size: 13px; }
.stage.none { outline: 1px dashed var(--danger); }
.board-note { grid-column: 1 / -1; margin: 8px 0; }
.link { padding: 0; border: 0; background: none; color: var(--accent); cursor: pointer; }

.nums { display: flex; flex-wrap: wrap; gap: 5px; }
button.num { color: inherit; font: inherit; font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer; }
button.num:active { transform: scale(0.95); }
button.num:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.num {
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Тепловая карта ---------- */

.heat-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
}
.heat-toolbar select {
  margin-left: 6px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg2);
}
.legend { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 16px; height: 16px; border-radius: 3px; box-shadow: inset 0 0 0 2px var(--accent); }

.heat-scroll {
  overflow: auto;
  max-height: calc(100vh - 190px);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.heat { border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.heat th, .heat td {
  min-width: 34px;
  height: 30px;
  padding: 0 4px;
  text-align: center;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background-clip: padding-box;
}
.heat thead th { position: sticky; top: 0; z-index: 2; background: var(--bg2); vertical-align: bottom; font-weight: 500; }
.heat thead th.stage-col span {
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  max-height: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 6px 0;
}
.heat .row-head { position: sticky; left: 0; z-index: 1; background: var(--bg2); text-align: left; padding: 0 10px; font-weight: 500; }
.heat thead .row-head, .heat tfoot .row-head { z-index: 3; }
.heat tfoot th, .heat tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--bg2); font-weight: 600; }
.heat .total { background: var(--bg2); font-weight: 600; }
.heat td.cur { box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- Выгрузка в чат ---------- */

.export {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg2);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--bg2)), var(--bg2) 70%);
}
.export-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  font-size: 20px;
}
.export-text { display: flex; flex-direction: column; flex: 1 1 160px; min-width: 0; line-height: 1.3; }
.export-text small { font-size: 12px; }
.export-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: 1 1 220px; }
.export-buttons .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  white-space: nowrap;
}
.export-buttons .btn.busy { opacity: 1; }
.export-buttons .btn.busy .export-glyph { display: none; }
.export-buttons .btn.busy::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: export-spin 0.7s linear infinite;
}
@keyframes export-spin { to { transform: rotate(360deg); } }

/* ---------- Достижения ---------- */

.ach { padding: 12px 16px 32px; max-width: 720px; margin: 0 auto; }
.ach-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ach-title h1 { margin: 0; font-size: 22px; }

/* Шапка — всегда «игровая» тёмная, в любой теме */
.ach-hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px;
  border-radius: 20px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 10% 15%, rgba(255, 193, 59, 0.32), transparent 45%),
    radial-gradient(circle at 95% 110%, rgba(178, 102, 255, 0.5), transparent 55%),
    linear-gradient(135deg, #1e1b4b, #0e0f24);
  box-shadow: 0 12px 30px -14px rgba(60, 30, 160, 0.7);
}
.ach-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.6px 1.6px at 18% 78%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1.2px 1.2px at 62% 18%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.6px 1.6px at 88% 42%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1.2px 1.2px at 44% 88%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.2px 1.2px at 76% 82%, rgba(255, 255, 255, 0.6), transparent);
}
.ring {
  --p: 0;
  position: relative;
  flex: none;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(#ffc13b calc(var(--p) * 1%), rgba(255, 255, 255, 0.14) 0);
  box-shadow: 0 0 24px -6px rgba(255, 193, 59, 0.7);
}
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #18173d; }
.ring b { position: relative; font-size: 22px; font-variant-numeric: tabular-nums; }
.hero-text { position: relative; z-index: 1; min-width: 0; }
.hero-caption { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255, 255, 255, 0.7); }
.hero-count { margin: 2px 0 10px; font-size: 32px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.hero-count small { font-size: 18px; font-weight: 600; color: rgba(255, 255, 255, 0.6); }
.rarity-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.rarity-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rarity-count i { width: 9px; height: 9px; border-radius: 50%; background: var(--r); box-shadow: 0 0 8px var(--r); }
.hero-last { margin: 10px 0 0; font-size: 13px; color: rgba(255, 255, 255, 0.75); overflow-wrap: anywhere; }
.hero-last b { color: #fff; }

.ach-h2 { margin: 22px 0 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--hint); }

/* Ближайшие цели: листаются пальцем, на широком экране — сеткой */
.goals {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 82%);
  gap: 10px;
  margin: 0 -16px;
  padding: 2px 16px 6px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 16px;
  scrollbar-width: none;
}
.goals::-webkit-scrollbar { display: none; }
.goals[hidden] { display: none; }
@media (min-width: 640px) {
  .goals { grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); margin: 0; padding: 0; overflow: visible; }
}
.goal {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg2);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
}
.goal::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--r); }
.goal-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.goal-text b { font-size: 15px; }
.goal-text .hint { font-size: 13px; }

.ach-progress { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; }
.ach-progress .bar { flex: 1; height: 8px; }
.ach-progress .bar span { background: var(--r); box-shadow: 0 0 10px var(--r); }
.ach-count { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }

.segmented { display: flex; gap: 4px; margin: 22px 0 4px; padding: 4px; border-radius: 12px; background: var(--bg2); }
.segmented button {
  flex: 1;
  padding: 8px 6px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--hint);
  font-weight: 600;
  cursor: pointer;
}
.segmented button[aria-selected="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); }

.ach-section { margin-top: 18px; }
.ach-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ach-section-head h3 { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.ach-section-count { font-size: 13px; font-weight: 700; color: var(--hint); font-variant-numeric: tabular-nums; }
.section-bar { display: block; height: 3px; margin: 6px 0 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.section-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffc13b, #ff7a3b); }

.ach-items { display: grid; gap: 8px; }
.ach-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 10px 10px 12px;
  border: 0;
  border-radius: 14px;
  background: var(--bg2);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ach-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ach-name { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; }
.ach-desc { font-size: 13px; color: var(--hint); }
.ach-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; font-size: 12px; }
.ach-empty { margin: 24px 0; text-align: center; }
.rarity-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--r);
  color: #14141c;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.new {
  padding: 1px 6px;
  border-radius: 6px;
  background: #ff4862;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

/* Значок: кольцо цвета редкости, тёмный диск и emoji — как на карточке в боте */
.badge {
  --size: 52px;
  --r: #8d939c;
  position: relative;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  display: grid;
  place-items: center;
  isolation: isolate;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, 0.28)), var(--r);
}
.badge::before {
  content: "";
  position: absolute;
  inset: calc(var(--size) * 0.08);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #2d2b58, #111126 72%);
}
.badge .emoji, .badge img { position: relative; }
.badge .emoji { font-size: calc(var(--size) * 0.48); line-height: 1; }
.badge.sm { --size: 46px; }
.badge.lg { --size: 112px; margin: 6px auto 16px; }
.badge.earned { box-shadow: 0 0 0 2px var(--bg2), 0 0 18px -3px var(--r); }
.badge.target, .badge.closed, .badge.secret { background: linear-gradient(155deg, rgba(255, 255, 255, 0.4), rgba(0, 0, 0, 0.25)), #80858f; }
.badge.target .emoji, .badge.target img { filter: grayscale(0.6); opacity: 0.8; }
.badge.closed .emoji, .badge.closed img { filter: grayscale(1); opacity: 0.45; }
.badge.secret .emoji { font-weight: 800; opacity: 0.85; }
.badge.closed::after {
  content: "🔒";
  position: absolute;
  right: -3px;
  bottom: -3px;
  font-size: calc(var(--size) * 0.3);
  line-height: 1;
}
/* Своя картинка из пака — готовый значок, без кольца */
.badge.has-image { background: none; box-shadow: none; }
.badge.has-image::before { display: none; }
.badge.has-image img { width: 100%; height: 100%; object-fit: contain; }
.badge.has-image.earned img { filter: drop-shadow(0 0 10px var(--r)); }

/* ---------- Панель ачивки ---------- */

.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); opacity: 0; transition: opacity 0.2s; }
.sheet-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  text-align: center;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-handle { width: 40px; height: 5px; margin: 0 auto 14px; border-radius: 999px; background: var(--border); }
#sheet-body h2 { margin: 0 0 8px; font-size: 22px; }
.sheet-desc { margin: 12px 0 0; font-size: 16px; }
.sheet-flavor { margin: 8px 0 0; color: var(--hint); font-style: italic; }
.sheet-status { margin: 16px 0 0; }
.sheet-status .ach-progress { max-width: 320px; margin: 0 auto; font-size: 14px; }
.sheet-comment { margin: 10px 0 0; padding: 8px 12px; border-left: 3px solid var(--accent); border-radius: 8px; background: var(--bg2); text-align: left; }
.sheet-close {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}

/* Полученная ачивка в панели: вспышка и медленно вращающийся блик */
.sheet.open .badge.lg.earned { animation: badge-pop 0.45s cubic-bezier(0.2, 1.5, 0.4, 1); }
.badge.lg.earned:not(.has-image)::after {
  content: "";
  position: absolute;
  inset: -16px;
  z-index: -1;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--r), transparent 35%, transparent 50%, var(--r), transparent 85%);
  opacity: 0.55;
  filter: blur(12px);
  animation: badge-spin 6s linear infinite;
}
@keyframes badge-pop { from { transform: scale(0.6); } to { transform: scale(1); } }
@keyframes badge-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .sheet-panel, .sheet-backdrop { transition: none; }
  .sheet.open .badge.lg.earned, .badge.lg.earned::after { animation: none; }
}


/* ---------- Админка ---------- */

.page { padding: 12px 16px 32px; max-width: 720px; margin: 0 auto; }
.page-title { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.page-title h1 { margin: 0; font-size: 22px; }
.page-tabs { margin: 0 0 12px; border-bottom: 1px solid var(--border); }
/* Четыре вкладки помещаются на телефоне */
.page-tabs button { flex: 1 1 auto; padding: 9px 4px; font-size: 14px; white-space: nowrap; }
.small { font-size: 13px; }
.attention { color: var(--warn); font-weight: 600; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.counter {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--warn);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  vertical-align: 1px;
}

.search {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text);
  font: inherit;
}
.chip.on { background: var(--accent); color: var(--accent-text); border-color: transparent; }
/* Фильтр ролей — одной строкой, листается пальцем */
#role-filter { flex-wrap: nowrap; margin: 0 -16px; padding: 10px 16px 2px; overflow-x: auto; scrollbar-width: none; }
#role-filter::-webkit-scrollbar { display: none; }
#role-filter .chip { flex: none; white-space: nowrap; }

.btn {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  font-weight: 600;
  cursor: pointer;
}
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.wide { display: block; width: 100%; margin-top: 10px; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { background: none; color: var(--danger); border-color: rgba(232, 89, 12, 0.5); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:not(:disabled):active { transform: scale(0.98); }

.icon-sm {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 15px;
  cursor: pointer;
}
.icon-sm:hover { background: var(--border); }
.icon-sm.muted { opacity: 0.35; }
.icon-sm:disabled { opacity: 0.3; cursor: default; }

.rows { display: grid; gap: 6px; margin-top: 10px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--bg2);
  text-align: left;
  cursor: pointer;
}
.row:active { opacity: 0.7; }
.profile a { color: var(--accent); text-decoration: none; }
.avatar.sm { width: 38px; height: 38px; font-size: 14px; }
.row-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 600; overflow-wrap: anywhere; }
.row-sub { font-size: 13px; }

.role-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.role-tag[data-role="admin"] { background: rgba(124, 92, 255, 0.18); color: #7c5cff; }
.role-tag[data-role="guest"] { background: rgba(245, 159, 0, 0.2); color: #c27c00; }
.role-tag[data-role="deleted"] { background: rgba(232, 89, 12, 0.15); color: var(--danger); }

.pending {
  margin-top: 10px;
  padding: 10px 12px 4px;
  border: 1px solid rgba(245, 159, 0, 0.45);
  border-radius: 12px;
  background: rgba(245, 159, 0, 0.1);
}
.pending h3 { margin: 0 0 4px; font-size: 14px; }
.pending-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.pending h3 + .pending-row { border-top: 0; }
.pending-name {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 600;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.approve { display: flex; gap: 6px; flex: none; }

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(232, 89, 12, 0.12);
}
.banner p { margin: 0; }
.banner.attention { background: rgba(245, 159, 0, 0.14); color: inherit; font-weight: 400; }

.segmented.roles { margin: 0; }
.segmented button[aria-checked="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); }
.segmented button:disabled { cursor: default; }
.segmented.roles + .hint { margin: 6px 0 0; }

.award { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.award-emoji { flex: none; font-size: 26px; }
.award-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.award-comment { font-size: 13px; font-style: italic; color: var(--hint); overflow-wrap: anywhere; }
#user-awards > .hint { margin: 0; }

#user-danger { margin-top: 28px; }
#user-danger .hint { margin: 6px 2px 0; }

.stage-row { display: flex; align-items: flex-start; gap: 8px; padding: 10px 6px 10px 12px; border-radius: 12px; background: var(--bg2); }
.stage-row .row-body b { overflow-wrap: anywhere; }
.stage-facts { font-size: 13px; }
.row-actions { display: flex; flex: none; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
.filters select {
  min-width: 0;
  height: 38px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
}
.history-bar { display: flex; justify-content: space-between; gap: 8px; margin: 10px 0 2px; font-size: 13px; }
.action-head .icon-sm { width: 28px; height: 28px; margin: -4px -6px -4px 0; font-size: 14px; }
.action-who { margin-top: 2px; font-size: 13px; }
.action-who .link { font-size: inherit; }
/* Заголовок раздела со ссылкой справа: «Последние переводы · Мои» */
.h2-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.h2-row .link { font-size: 13px; font-weight: 400; text-transform: none; letter-spacing: 0; }
/* Правка примечания: перевод под заголовком */
.note-form h2 { margin-bottom: 2px; }
.note-form .card-sub { margin-bottom: 4px; }

/* Формы в панели снизу */
.sheet.form .sheet-panel { text-align: left; }
.sheet-form h2 { margin: 0 0 12px; font-size: 20px; overflow-wrap: anywhere; }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: 13px; color: var(--hint); }
.field input, .field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  resize: vertical;
}
.options { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; }
.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--bg2);
  cursor: pointer;
}
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option:has(input:checked) { border-color: var(--accent); }
.option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.option-emoji { flex: none; font-size: 28px; }
.option-body { display: flex; flex-direction: column; font-size: 13px; }
.option-body b { font-size: 15px; }
/* Галочка — для выбора нескольких (подписки) */
.option.multi .check-box {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 700;
}
.option.multi:has(input:checked) .check-box { background: var(--accent); border-color: var(--accent); }
.option.multi:has(input:checked) .check-box::after { content: '✓'; }
.option.multi:has(input:disabled) { opacity: 0.6; }
.sheet-form .btn.wide { margin-top: 16px; }
.sheet.form .sheet-close { margin-top: 8px; background: var(--bg2); color: var(--text); }
/* Свои кнопки длинной формы — всегда видны у нижнего края панели, поверх прокручиваемого списка */
.sheet-footer {
  position: sticky;
  bottom: calc(-20px - env(safe-area-inset-bottom));
  z-index: 2;
  display: grid;
  gap: 8px;
  margin: 12px -20px calc(-20px - env(safe-area-inset-bottom));
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.sheet-form .sheet-footer .btn.wide { margin-top: 0; }
.sheet-footer .error-text { margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 60;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 12px;
  background: #23262b;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* ---------- Перевод изделий ---------- */

/* Главная кнопка профиля */
.cta {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 16px;
  padding: 14px 14px 14px 16px;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, #7950f2));
  color: var(--accent-text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 12px 26px -16px var(--accent);
}
.cta:active { transform: scale(0.98); }
.cta-icon { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: rgba(255, 255, 255, 0.18); font-size: 22px; }
.cta-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.cta-text b { font-size: 17px; }
.cta-text small { font-size: 13px; opacity: 0.85; }
.cta .chevron { color: inherit; opacity: 0.8; }

.move-top .search { margin: 8px 0 10px; }
.move main { padding-bottom: 24px; }
body.has-bar .move main { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.move-hint { margin: 0 0 10px; }
.mv-empty { margin-top: 24px; text-align: center; }

.found {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
  padding: 8px 8px 8px 12px;
  border-radius: 12px;
  background: var(--bg2);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  font-size: 14px;
}

/* Стадия: полоска и точка цвета группы (--c) */
.mv-section {
  position: relative;
  margin-bottom: 10px;
  padding: 10px 12px 12px 16px;
  border-radius: 14px;
  background: var(--bg2);
}
.mv-section::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; border-radius: 14px 0 0 14px; background: var(--c); }
.mv-section-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.mv-head { display: flex; align-items: flex-start; gap: 8px; flex: 1; min-width: 0; }
.mv-dot {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 3px rgba(128, 128, 128, 0.18);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent);
}
.mv-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.mv-title b { font-size: 15px; overflow-wrap: anywhere; }
.mv-title .hint { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv-count {
  flex: none;
  min-width: 28px;
  margin-top: 1px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--border);
  background: color-mix(in srgb, var(--c) 20%, transparent);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.mv-all {
  flex: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.mv-all.on { background: var(--accent); color: var(--accent-text); border-color: transparent; }

.mv-section.collapsed { padding: 0; }
.mv-expand {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px 10px 16px;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.mv-collapse { display: block; margin: 10px auto 0; font-size: 13px; }

/* Изделия: крупные кнопки под палец */
.mv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 6px; }
.mv-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 50px;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.12s, background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.mv-chip b { font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.mv-chip small { font-size: 11px; color: var(--hint); white-space: nowrap; }
.mv-chip:active { transform: scale(0.94); }
.mv-chip.on { background: var(--accent); border-color: transparent; color: var(--accent-text); box-shadow: 0 6px 14px -8px var(--accent); }
.mv-chip.on small { color: inherit; opacity: 0.85; }
.mv-chip.on::after {
  content: "✓";
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
/* Только что переведённые — вспышка цветом новой стадии */
.mv-chip.flash { animation: mv-flash 1.6s ease-out; }
@keyframes mv-flash {
  0%, 35% { border-color: var(--c); box-shadow: 0 0 0 4px var(--c); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Панель снизу: сколько выбрано и «Перевести» */
.move-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 -12px 30px -20px rgba(0, 0, 0, 0.5);
  animation: bar-in 0.2s ease-out;
}
.mv-bar-inner { display: flex; align-items: center; gap: 8px; max-width: 720px; margin: 0 auto; }
.mv-bar-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.mv-bar-text b { font-variant-numeric: tabular-nums; }
.mv-bar-text .hint { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv-go { flex: none; padding: 12px 18px; border-radius: 12px; font-size: 15px; }
@keyframes bar-in { from { transform: translateY(100%); } }
body.has-bar .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

/* Выбор стадии */
.mv-pick-sub { margin: -4px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.pick-h { margin: 18px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--hint); }
.picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.picks.big { grid-template-columns: 1fr; }
.pick {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 10px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--bg2);
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.pick .mv-dot { margin-top: 0; }
.pick-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pick-text b { font-size: 14px; overflow-wrap: break-word; }
.pick-text small { font-size: 12px; }
.pick.big { padding: 11px 14px; }
.pick.big b { font-size: 16px; }
.pick[aria-checked="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--bg2)); }
.pick:active { transform: scale(0.98); }
.pick-tag { align-self: flex-start; margin-top: 3px; padding: 0 6px; border-radius: 6px; background: var(--border); color: var(--hint); font-size: 11px; font-weight: 600; white-space: nowrap; }
.note-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.note-chips .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Кнопка «Перевести» всегда видна, даже если список стадий длинный */
.mv-pick-foot {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin: 14px -20px 0;
  padding: 10px 20px 4px;
  background: var(--bg);
  box-shadow: 0 -10px 16px -14px rgba(0, 0, 0, 0.45);
}
.mv-pick-foot .hint { margin: 0 0 8px; }
.mv-pick-foot .btn.wide { margin-top: 0; padding: 13px; font-size: 16px; }

/* Карточка изделия */
.card-sheet h2 { margin-bottom: 2px; }
.card-sub { margin: 0 0 10px; font-size: 14px; }
.card-now {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg2);
  background: color-mix(in srgb, var(--c) 14%, var(--bg2));
}
.card-now .mv-dot { margin-top: 0; }
.visits { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.visit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg2);
  background: color-mix(in srgb, var(--c) 18%, transparent);
  font-size: 12px;
}
.card-sheet .actions { margin-top: -4px; }

/* Всплывашка с кнопкой «Отменить» */
.toast.with-action { display: flex; align-items: center; gap: 12px; padding-right: 8px; overflow: hidden; }
.toast-text { min-width: 0; }
.toast-action {
  flex: none;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #ffd43b;
  font-weight: 700;
  cursor: pointer;
}
.toast-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.55);
  transform-origin: left;
  animation: toast-timer linear forwards;
}
@keyframes toast-timer { to { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
  .mv-chip, .move-bar, .mv-chip.flash, .toast-timer { animation: none; transition: none; }
}

/* ---------- Админка: проекты ---------- */

.page-title h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.search-gap { margin-top: 10px; }
.list-bar { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 12px 0 0; font-size: 13px; }

/* Полоска «где сейчас изделия» — доли стадий их цветами */
.stage-bar { display: flex; gap: 2px; height: 8px; margin-top: 6px; border-radius: 999px; overflow: hidden; }
.stage-bar span { min-width: 4px; background: var(--c); }
.project-summary .stage-bar { height: 10px; margin-top: 0; }
.project-summary .visits { margin-top: 8px; }
.project-summary p { margin: 0; }

.project-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; margin-top: 14px; }
.project-actions .btn { padding: 10px 4px; font-size: 14px; white-space: nowrap; }

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px 1px 6px;
  border-radius: 999px;
  background: var(--bg);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  font-size: 12px;
  font-weight: 600;
}
.stage-pill::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.row-note { font-size: 13px; font-style: italic; color: var(--hint); overflow-wrap: anywhere; }

/* Режим выбора изделий */
.product-row.picked { box-shadow: inset 0 0 0 2px var(--accent); }
.check {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 800;
}
.product-row.picked .check { background: var(--accent); border-color: var(--accent); }
.bar-link { align-self: flex-start; font-size: 12px; }
body.has-bar #project { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
#project-bar .btn { padding: 10px 12px; }

#project-danger { margin-top: 28px; }
#project-danger .hint { margin: 6px 2px 0; }
#project-delete[hidden] + .hint { margin-top: 0; }

/* Изделия пачкой: что получится */
.field select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.field-hint { margin: 4px 2px 0; font-size: 12px; }
.add-preview p { margin: 8px 0 0; overflow-wrap: anywhere; }
.error-text { color: var(--danger); }
.warn-text { color: #c27c00; }
@media (prefers-color-scheme: dark) {
  .warn-text { color: var(--warn); }
}
.card-sheet .sheet-form { margin-top: 4px; }
