:root {
  --bg: #0f1419;
  --surface: #1a222c;
  --surface2: #212d3a;
  --border: #2a3847;
  --text: #e8ecf0;
  --muted: #7a8fa3;
  --accent: #2d8cff;
  --accent-dim: #1a5599;
  --green: #27ae60;
  --red: #e74c3c;
  --yellow: #f39c12;
  --radius: 12px;
  --radius-sm: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

body { padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }

/* ─── ШАПКА ─────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-title {
  flex: 1;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  min-width: 0;
}
.header-title--role {
  display: flex;
  align-items: center;
  gap: 9px;
}
.header-title--right {
  justify-content: flex-end;
  text-align: right;
}
.role-menu-arrow {
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 13px solid #aeb0b3;
  flex: 0 0 auto;
  transition: transform .16s ease;
}
.header-title.role-menu-open .role-menu-arrow {
  transform: rotate(90deg);
}
.header-title .role-head {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.header-title .role-head b {
  color: #f0f50f;
  font-size: 0.98rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-title .role-head small {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.role-rename-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
  flex: 0 0 auto;
}
.role-rename-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border: 2px solid #0aa6c0;
  border-radius: 50%;
  color: #0aa6c0;
  font-size: 0.65rem;
  font-weight: 700;
}
.role-menu {
  position: fixed;
  right: 12px;
  top: 54px;
  z-index: 180;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: 0 12px 30px #0008;
}
.role-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  cursor: pointer;
}
.role-menu button:active { background: var(--surface2); }
.onboarding-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 620px;
  margin: 0 auto;
}
.onboarding-panel h2 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}
.choice-btn {
  width: 100%;
  text-align: left;
  background: linear-gradient(180deg, #27384e 0%, #101820 100%);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  color: var(--text);
  padding: 16px;
  cursor: pointer;
}
.choice-btn span {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.choice-btn small {
  display: block;
  color: var(--muted);
  line-height: 1.35;
}
.catalog-item {
  align-items: center;
  justify-content: space-between;
}
.catalog-item-main {
  min-width: 0;
}
.catalog-item-main b {
  display: block;
  font-size: 0.92rem;
}
.catalog-item-main small {
  color: var(--muted);
  font-size: 0.76rem;
}
.catalog-popular {
  color: #f0f50f;
  font-size: 0.75rem;
  white-space: nowrap;
}
.roles-summary {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid #24485a;
  background:
    linear-gradient(135deg, rgba(45, 140, 255, .16), rgba(18, 24, 31, .98) 58%),
    var(--surface);
}
.roles-summary-loading {
  color: var(--muted);
  font-size: 0.86rem;
}
.roles-summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.roles-summary-head b {
  display: block;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 2px;
}
.roles-summary-head span {
  color: var(--muted);
  font-size: 0.78rem;
}
.roles-summary-head strong {
  min-width: 42px;
  text-align: center;
  color: var(--accent);
  font-size: 1.55rem;
  line-height: 1;
}
.roles-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.roles-summary-item {
  min-width: 0;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  background: rgba(11, 18, 24, .56);
  border: 1px solid rgba(255,255,255,.06);
}
.roles-summary-item span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 4px;
}
.roles-summary-item b {
  display: block;
  color: var(--text);
  font-size: 0.93rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.roles-media-track {
  height: 6px;
  margin-top: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.roles-media-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8fd8ff);
}
.role-card {
  flex-direction: column;
  gap: 10px;
}
.role-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}
.role-card-title {
  color: #f0f50f;
  font-weight: 700;
}
.role-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.role-card-kind {
  color: var(--text);
  font-size: 0.92rem;
}
.role-card-meta {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}
.role-card-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}
.role-media-mb {
  min-width: 92px;
  max-width: 44%;
  padding: 12px 14px;
  border-radius: 20px;
  text-align: center;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  background: linear-gradient(180deg, #273649 0%, #121923 100%);
  border: 1px solid #2d8cff;
  box-shadow: inset 0 1px 14px rgba(45, 140, 255, .18), 0 2px 10px rgba(0, 0, 0, .24);
  white-space: nowrap;
}
.role-active-pill {
  color: var(--accent);
  font-size: 0.78rem;
  white-space: nowrap;
}
.role-card-actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}
.role-card-actions .role-open-btn {
  flex: 1;
}
.role-delete-btn {
  width: 44px;
  flex: 0 0 44px;
  border: 1px solid #6d2a2a;
  border-radius: var(--radius-sm);
  background: #4a1818;
  color: #ffb3b3;
  cursor: pointer;
  font-size: 1rem;
}
.role-delete-btn:active {
  background: #612020;
}
.btn-icon {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.btn-icon:active { background: var(--surface2); }
.btn-home {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.home-icon {
  display: block;
  width: 27px;
  height: 27px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.35));
}
.home-icon__roof,
.home-icon__chimney,
.home-icon__body {
  fill: #d2d4d6;
}
.home-icon__door {
  fill: #18222c;
}

/* ─── СТРАНИЦЫ ───────────────────────────────────────────── */
.page { display: none; padding: 14px; }
.page.active { display: block; }

/* ─── TOAST ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #263040;
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  z-index: 200;
  border: 1px solid var(--border);
  max-width: 80vw;
  text-align: center;
  box-shadow: 0 4px 16px #0006;
}
.toast.error { background: #3a1a1a; border-color: var(--red); }
.hidden { display: none !important; }

/* ─── СТАТС-БАННЕР ───────────────────────────────────────── */
.stats-banner {
  background:
    radial-gradient(circle at 50% 0%, rgba(69, 91, 118, .55), transparent 58%),
    linear-gradient(180deg, #192331 0%, #10171f 100%);
  border: 1px solid #2d70ba;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  min-height: 260px;
  box-shadow: inset 0 1px 24px rgba(45, 140, 255, .13), 0 3px 12px rgba(0,0,0,.22);
}
.stats-banner.is-stats-collapsed {
  min-height: 0;
  padding-top: 10px;
  padding-bottom: 8px;
}
.stats-banner-top {
  display: grid;
  grid-template-columns: 42px 1fr 42px 34px;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.stats-month-title {
  text-align: center;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
}
.stats-nav-btn,
.stats-help-btn {
  border: 0;
  background: transparent;
  color: #c9d0d5;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  text-shadow: 0 2px 6px rgba(0,0,0,.45);
}
.stats-help-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #8c8f89;
  color: #fff;
  font-size: 1.15rem;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}
.stats-month-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}
.stat-item {
  min-width: 0;
}
.stat-item--tile {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #2d70ba;
  background: linear-gradient(180deg, #27384b 0%, #0d141d 100%);
  box-shadow: inset 0 1px 16px rgba(255,255,255,.06), 0 3px 8px rgba(0,0,0,.24);
}
.stat-item .val { font-size: 1.1rem; font-weight: 700; color: #f0f50f; }
.stat-item .stat-den,
.stat-item .stat-sep { color: #b8bdc2; }
.stat-item .stat-date { color: var(--text); font-size: 0.95rem; }
.stat-item .lbl { font-size: 0.78rem; color: var(--muted); }
.stats-inline-month {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.stats-inline-nav {
  border: 0;
  background: transparent;
  color: #c9d0d5;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.stats-help-link {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: #8c8f89;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}
.stats-banner-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
  position: relative;
}
.stats-muted-toggle {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 0.72rem;
  cursor: pointer;
}
.stats-muted-toggle.active {
  color: var(--accent);
  border-color: #2d70ba;
}
.stats-collapse-toggle {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #c9d0d5;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  text-shadow: 0 2px 6px rgba(0,0,0,.45);
}
.stats-collapse-toggle:active {
  background: var(--surface2);
}
.stats-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 0;
  background: #87909a;
  padding: 0;
  cursor: pointer;
}
.stats-dot.active { background: #f0f50f; }
.is-stat-den-hidden .stat-den,
.is-stat-den-hidden .stat-sep,
.is-button-labels-hidden .menu-btn-sub {
  display: none !important;
}

/* ─── КНОПКИ ────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-secondary{ background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger   { background: #3a1a1a; color: var(--red); border: 1px solid #5a2a2a; }
.btn-primary:active, .btn-secondary:active, .btn-danger:active { opacity: .7; }
.wide { width: 100%; }

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: stretch;
}
.action-row > * { flex: 1; min-width: 0; }
.sticky-bottom {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) + 8px);
  background: var(--bg);
  padding-top: 10px;
  margin-top: 20px;
}

/* ─── ГЛАВНОЕ МЕНЮ ───────────────────────────────────────── */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
.menu-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.menu-btn:active { background: var(--surface2); }
.menu-btn--wide {
  width: 100%;
  margin-bottom: 14px;
}
.menu-btn-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #f0f50f;
  font-size: 1rem;
}
.menu-btn-icon { color: var(--text); }
.menu-btn-sub {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
  line-height: 1.35;
}
#btnNewProject,
#btnOldProject {
  flex-direction: column;
  min-height: 0;
  height: auto;
  align-self: stretch;
  padding-top: 12px;
  padding-bottom: 12px;
  line-height: 1.2;
}
#btnNewProject .menu-btn-title,
#btnOldProject .menu-btn-title {
  color: #f0f50f;
}

.stats-help-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.45;
}

/* ─── БЫСТРЫЙ ВЫБОР ПРОШЛЫХ МЕСЯЦЕВ ───────────────────────── */
.recent-months-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 10px;
  padding-bottom: 2px;
}
.recent-months-wrap::-webkit-scrollbar { display: none; }
.recent-months-nav { align-items: center; flex: 0 0 auto; min-width: max-content; flex-wrap: nowrap; }

/* ─── ЧИПСЫ ФИЛЬТРА ──────────────────────────────────────── */
.filter-row { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.filter-group { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 7px 15px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:active { opacity: 0.92; }

/* Чипы сортировки в окне проектов */
.chip.chip--status-all,
.chip.chip--fold-all {
  border-color: #687582;
  color: #d5d8dc;
  background: #252c32;
}
.chip.chip--status-draft,
.chip.chip--status-ready,
.chip.chip--fold-new,
.chip.chip--fold-old,
.chip.chip--month,
.chip.chip--archive {
  border-color: #324f6d;
  color: #cfe5f8;
  background: rgba(21, 38, 58, .68);
}
.chip.active {
  border-width: 2px;
  border-color: #f0f50f !important;
  padding: 6px 14px;
}
.chip.chip--archive {
  color: #cfe5f8;
}
.chip.chip--archive:active {
  background: rgba(31, 58, 86, .78);
}
.archive-filter-row {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 9px;
  padding-bottom: 2px;
}
.archive-filter-row::-webkit-scrollbar { display: none; }
.chip.chip--archive-year:not(.active),
.chip.chip--archive-month:not(.active),
.chip.chip--archive-tag:not(.active) {
  border-color: #3b5871;
  color: #a9c7df;
  background: #142232;
}
.chip.chip--archive-year.active,
.chip.chip--archive-month.active,
.chip.chip--archive-tag.active {
  border-color: #3498db;
  color: #fff;
  background: #1f6dad;
}
.chip.chip--archive-month-label,
.chip.chip--archive-tag-label {
  border-color: #7d5ba6;
  color: #eadcff;
  background: #22182e;
}

/* Совместимость со старыми селекторами по data-* */
.chip[data-fstatus="draft"].active  { border-color: #8bc34a; color: #fff; background: #4f8c2f; }
.chip[data-fstatus="ready"].active  { border-color: #95a5a6; color: #fff; background: #5d6d7e; }
.chip[data-fold="0"].active         { border-color: #fdd835; color: #222; background: #e6bc00; }
.chip[data-fold="1"].active         { border-color: #bdc3c7; color: #fff; background: #5d6973; }

/* ─── СПИСОК КАРТОЧЕК ────────────────────────────────────── */
.card-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.project-card-shell {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
}
.project-card-actions {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: stretch;
  justify-content: flex-end;
  padding: 6px 6px 6px 50%;
  background: #10171f;
}
.project-card-actions .pc-swipe-btn:only-child {
  grid-column: 1 / -1;
}
.pc-swipe-btn {
  border: 1px solid #324f6d;
  background: rgba(21, 38, 58, .86);
  color: #cfe5f8;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 8px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: inset 0 1px 10px rgba(255,255,255,.06), 0 2px 7px rgba(0,0,0,.22);
}
.pc-swipe-btn--move {
  border-color: #687582;
  color: #d5d8dc;
  background: #252c32;
}
.pc-swipe-btn--portfolio {
  border-color: #2d70ba;
}
.project-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  z-index: 1;
  transition: transform .18s ease;
  touch-action: pan-y;
}
.project-card-shell.is-swiped .project-card {
  transform: translateX(-50%);
}
/* Как chip.chip--fold-old:not(.active) — старые проекты в ленте */
.project-card.project-card--old {
  border-color: #6d7d8a;
  background: #2a3036;
  color: #bdc3c7;
}
.project-card.project-card--old .pc-no { color: #e8edf0; }
.project-card.project-card--old .pc-desc { color: #9aaebc; }
.project-card.project-card--old .pc-meta { color: #9aaebc; }
.project-card:active { background: var(--surface2); }
.project-card.project-card--old:active { background: #323840; }
.pc-content { flex: 1; min-width: 0; }
.pc-thumb {
  width: 76px;
  height: 76px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface2);
  align-self: center;
}
.card-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .25s;
}
.project-card .pc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.project-card .pc-no { font-weight: 700; font-size: 1rem; }
.project-card .pc-badges {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.project-card .pc-status { font-size: 0.78rem; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
/* Завершён — как chip.chip--status-ready:not(.active) */
.project-card .pc-status.status-ready {
  background: #252b32;
  color: #bdc3c7;
  border: 1px solid #5f6f7a;
}
/* В работе — как chip chip--status-draft неактивный */
.project-card .pc-status.status-draft {
  border: 1px solid #558b35;
  color: #8bc34a;
  background: #1a2910;
}
.project-card .pc-status.pc-status--portfolio {
  border: 1px solid #f0f50f;
  color: #f0f50f;
  background: rgba(240,245,15,.08);
}
/* Зелёные чипы счётчиков медиа (список зрителя) — не путать с status-ready серым */
.project-card .pc-media-stats {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
  max-width: 58%;
}
.project-card .pc-media-stat-chip {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  background: #1a3a25;
  color: #8bc34a;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pc-media-ico::before {
  font-style: normal;
  font-weight: normal;
  line-height: 1;
  display: inline-block;
}
/* Unicode вместо литералов — лучше в WebView MAX */
.pc-media-ico--photo::before { content: "\1F4F7"; }
.pc-media-ico--video::before { content: "\1F3AC"; }
.pc-media-ico--doc::before { content: "\1F4C4"; }
.project-card.project-card--old .pc-media-stat-chip {
  background: #253528;
  color: #9ccc65;
}
.project-card .pc-month {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  margin-top: 4px;
}
.project-card .pc-month--new {
  color: #1a1410;
  background: linear-gradient(180deg, #ffe082 0%, #ffc107 100%);
  border-color: #c9a31a;
  font-weight: 700;
}
.project-card .pc-month--old {
  color: #bdc3c7;
  background: #252b32;
  border-color: #6d7d8a;
}
.project-card .pc-desc { font-size: 0.88rem; margin-top: 6px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card .pc-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag-chip { font-size: 0.73rem; background: #1a3a50; color: var(--accent);
  padding: 2px 7px; border-radius: 8px; }
.project-card .pc-meta { display: flex; gap: 12px; margin-top: 6px; font-size: 0.8rem; color: var(--muted); }

/* ─── РЕДАКТОР ПРОЕКТА ───────────────────────────────────── */
.project-header { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; color: var(--accent); }

.section-block { margin-bottom: 16px; }
.section-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 6px; font-weight: 600; }

.textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px;
  font-size: 0.92rem; font-family: inherit; resize: vertical; line-height: 1.45;
}
.textarea:focus { outline: none; border-color: var(--accent); }

.input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px;
  font-size: 0.95rem; font-family: inherit;
}
.input:focus { outline: none; border-color: var(--accent); }
.input.wide { width: 100%; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field > span { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }

.rate-calc-hint { margin-bottom: 10px; }
.rate-calc-row { margin-top: 4px; }
.rate-calc-result { display: block; margin-top: 10px; }
.input--rate-out {
  font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, #273242 0%, #1c2530 50%, #151b24 100%);
  border-color: var(--border);
  -moz-appearance: textfield;
}
.input--rate-out::-webkit-inner-spin-button,
.input--rate-out::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input--rate-out:focus {
  outline: none;
  border-color: var(--border);
  box-shadow: none;
}

/* ─── ТЕГИ ───────────────────────────────────────────────── */
.tag-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-wrap { display: inline-flex; align-items: stretch; max-width: 100%; }
.tag-toggle {
  padding: 6px 12px; border-radius: 10px; font-size: 0.82rem; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  transition: background .12s, border-color .12s;
}
.tag-toggle.on { background: #1a3a50; color: var(--accent); border-color: var(--accent); }
.tag-wrap-custom .tag-toggle { border-radius: 10px 0 0 10px; }
.tag-delete {
  width: 30px; border: 1px solid var(--border); border-left: 0; border-radius: 0 10px 10px 0;
  background: #2a1f25; color: #ff9d9d; cursor: pointer; font-size: 1rem; line-height: 1;
}
.tag-add-row {
  display: flex; gap: 8px; width: 100%; margin-top: 6px; align-items: center;
}
.tag-add-row input {
  flex: 1; min-width: 0; padding: 9px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.tag-add-row button { width: auto; white-space: nowrap; }
.tag-empty { width: 100%; color: var(--muted); font-size: 0.84rem; padding: 4px 0; }

/* ─── TOGGLE ─────────────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer; }
.toggle { width: 42px; height: 24px; appearance: none; background: var(--border);
  border-radius: 12px; position: relative; cursor: pointer; transition: background .2s; }
.toggle:checked { background: var(--accent); }
.toggle:after { content:""; position:absolute; top:3px; left:3px; width:18px; height:18px;
  background: #fff; border-radius: 50%; transition: transform .2s; }
.toggle:checked:after { transform: translateX(18px); }

/* ─── МЕДИА ─────────────────────────────────────────────── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px; margin-bottom: 10px; }
.media-cell { position: relative; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface); aspect-ratio: 1; border: 1px solid var(--border); }
.media-cell img, .media-cell video { width:100%; height:100%; object-fit: cover; display: block; }
.media-cell .media-type { position:absolute; top:4px; left:4px; background:#000a;
  color:#fff; font-size:0.68rem; padding:1px 5px; border-radius:6px; }
.media-cell .del-btn { position:absolute; top:4px; right:4px; background:#c0392b;
  color:#fff; border:none; border-radius:50%; width:22px; height:22px; font-size:0.8rem;
  cursor:pointer; display:flex; align-items:center; justify-content:center; }
.media-cell .media-bot-btn { position:absolute; right:4px; bottom:4px; background:#2d8cff;
  color:#fff; border:none; border-radius:999px; padding:4px 8px; min-width:28px; height:24px;
  font-size:0.78rem; font-weight:700; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.doc-cell { padding: 10px; display:flex; flex-direction:column; align-items:center;
  justify-content:center; text-align:center; font-size:0.72rem; color:var(--muted);
  aspect-ratio: 1; }
.doc-cell .doc-icon { font-size:1.6rem; margin-bottom:4px; }

.upload-area {
  display: flex; align-items: center; justify-content: center;
  width: 100%; border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 18px; cursor: pointer; color: var(--muted); font-size: 0.9rem;
  gap: 8px; transition: border-color .15s;
}
.upload-area:hover { border-color: var(--accent); color: var(--accent); }
.upload-area input { display: none; }

.upload-progress { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.85rem;
  color: var(--muted); margin-top: 8px; }
.upload-progress-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  color: var(--text); font-weight: 600; margin-bottom: 8px;
}
.upload-progress-track {
  height: 6px; overflow: hidden; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--border);
}
.upload-progress-fill {
  height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8fd8ff);
  transition: width .12s ease-out;
}
.upload-progress-name {
  margin-top: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ─── РЕЗЮМЕ ─────────────────────────────────────────────── */
.resume-text {
  white-space: pre-wrap; font-family: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; min-height: 100px; margin-bottom: 14px; font-size: 0.9rem;
  line-height: 1.55;
}
.resume-meta {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

/* ─── СТАТИСТИКА ─────────────────────────────────────────── */
.stats-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stats-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
}
.stats-card .sc-val { font-size: 1.25rem; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.stats-card .sc-lbl { font-size: 0.78rem; color: var(--muted); }

.tag-stats-list { display: flex; flex-direction: column; gap: 8px; }
.tag-stat-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
}
.tag-stat-row .ts-label { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.tag-stat-row .ts-meta { font-size: 0.8rem; color: var(--muted); display:flex; gap:12px; }
.tag-stat-row .ts-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 6px; }
.tag-stat-row .ts-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* ─── ПОДЕЛИТЬСЯ ─────────────────────────────────────────── */
.share-link-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.share-link-box code { word-break: break-all; font-size: 0.85rem; color: var(--accent); }

/* ─── VIEWER ─────────────────────────────────────────────── */
.portfolio-summary {
  background: linear-gradient(145deg, #111922 0%, #32445c 62%, #182433 100%);
  border: 1px solid #2d70ba;
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 16px;
  box-shadow: inset 0 1px 22px rgba(255,255,255,.06), 0 3px 12px rgba(0,0,0,.28);
}
.portfolio-summary-title {
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 18px;
  text-align: center;
}
.portfolio-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.portfolio-summary-value {
  color: #f0f50f;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.1;
  text-shadow: 0 2px 5px rgba(0,0,0,.45);
}
.portfolio-summary-label {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 6px;
}
.portfolio-note {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.35;
  margin: 0 2px 18px;
}
.portfolio-note p + p { margin-top: 4px; }
.portfolio-main-btn { margin-bottom: 10px; }
.portfolio-projects-block { margin-top: 8px; }
.portfolio-viewers { margin-top: 18px; }
.portfolio-viewer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #2d70ba;
}
.portfolio-viewer-name,
.portfolio-viewer-date {
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}
.portfolio-viewer-date { margin-top: 12px; }
.portfolio-viewer-label {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 3px;
}
.portfolio-access-toggle {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 138px;
  cursor: pointer;
}
.portfolio-access-toggle input { display: none; }
.portfolio-access-toggle span {
  width: 72px;
  height: 36px;
  border-radius: 999px;
  background: #8f9295;
  position: relative;
  box-shadow: inset 0 1px 5px rgba(0,0,0,.35);
}
.portfolio-access-toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f4f5f6;
  box-shadow: 0 1px 5px rgba(0,0,0,.35);
  transition: transform .16s ease;
}
.portfolio-access-toggle input:checked + span { background: #27a9dc; }
.portfolio-access-toggle input:checked + span::after { transform: translateX(36px); }
.portfolio-access-toggle em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.82rem;
}

.viewer-owner-header {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px; text-align: center;
}
.viewer-owner-header .vo-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 4px; }
.viewer-owner-header .vo-sub { font-size: 0.82rem; color: var(--muted); }

/* ─── МОДАЛ ──────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: #000a; z-index: 300;
  display: flex; align-items: flex-end; padding: 16px;
}
.modal.hidden { display: none !important; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; width: 100%; max-width: 480px; margin: 0 auto;
}
.modal-box p { margin-bottom: 16px; line-height: 1.5; }

/* ─── УТИЛИТЫ ────────────────────────────────────────────── */
.hint { color: var(--muted); font-size: 0.88rem; margin-bottom: 12px; line-height: 1.5; }
.error { color: var(--red); font-size: 0.85rem; margin-top: 6px; }
.section-block .muted { color: var(--muted); font-size: 0.85rem; }
code { background: #1e2d3d; padding: 1px 5px; border-radius: 4px; font-size: .88em; }

/* ─── SPINNER ────────────────────────────────────────────── */
.spinner { text-align: center; padding: 40px 0; color: var(--muted); font-size: 0.9rem; }

/* ─── КНОПКИ СТАТУСА В РЕДАКТОРЕ ────────────────────────── */
.status-btn-group { display: flex; gap: 8px; }
.status-toggle {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  text-align: center;
}
.status-toggle[data-status="draft"].active {
  background: #1a2d14; border-color: #6aaa3a; color: #8bc34a;
}
.status-toggle[data-status="ready"].active {
  background: #1f1f2e; border-color: #5a6a8a; color: var(--text);
}

/* ─── FULLSCREEN МЕДИА ───────────────────────────────────── */
.media-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  gap: 12px;
  touch-action: none; /* отдаём свайп нашему обработчику */
  user-select: none;
}
.media-fullscreen.hidden { display: none !important; }
.mf-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 1.6rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 501;
}
.mf-media {
  max-width: 100vw;
  max-height: 78vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.mf-media img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.mf-media video {
  max-width: 100%;
  max-height: 78vh;
  border-radius: var(--radius-sm);
}
.mf-loader {
  position: absolute;
  inset: 0;
  min-width: 160px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #d8dde2;
  background: rgba(15,20,25,.72);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.mf-loader.hidden { display: none !important; }
.mf-loader-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: #f0f50f;
  animation: spin .85s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.mf-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 2.2rem;
  width: 44px;
  height: 72px;
  border-radius: 8px;
  cursor: pointer;
  z-index: 502;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.mf-prev { left: 6px; }
.mf-next { right: 6px; }
.mf-nav.hidden { display: none !important; }
.mf-actions { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.mf-counter { color: rgba(255,255,255,0.55); font-size: 0.85rem; min-width: 36px; text-align: center; }
.mf-dl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
