:root {
  color-scheme: light;
  --bg: #f8f4ee;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --text: #333333;
  --muted: #7a7065;
  --line: rgba(51, 51, 51, 0.1);

  --accent: #e0544a;
  --accent-strong: #c84840;
  --accent-soft: rgba(224, 84, 74, 0.1);
  --accent-warn: #ffc145;
  --accent-rare: #9b51e0;

  --blue: var(--accent);
  --blue-strong: var(--accent-strong);
  --green: var(--accent-warn);
  --orange: var(--accent-warn);
  --red: var(--accent);
  --purple: var(--accent-rare);

  --shadow: 0 1px 2px rgba(51, 51, 51, 0.06);
  --soft-shadow: 0 1px 2px rgba(51, 51, 51, 0.04);
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1714;
  --panel: #25201c;
  --panel-strong: #2d2823;
  --text: #f5efe6;
  --muted: #a89e92;
  --line: rgba(245, 239, 230, 0.1);
  --accent-soft: rgba(224, 84, 74, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --soft-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1714;
    --panel: #25201c;
    --panel-strong: #2d2823;
    --text: #f5efe6;
    --muted: #a89e92;
    --line: rgba(245, 239, 230, 0.1);
    --accent-soft: rgba(224, 84, 74, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --soft-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Google Sans Text", "Google Sans", "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "ss01", "cv01";
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.brand,
.score-number,
.big-number {
  font-family: "Google Sans", "Google Sans Text", "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

/* Экран загрузки */
.app-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.app-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-panel {
  text-align: center;
  padding: 24px;
  max-width: 360px;
}

.loader-track {
  position: relative;
  width: min(300px, 78vw);
  height: 10px;
  margin: 0 auto 22px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 80%, transparent);
  overflow: visible;
}

.loader-runner {
  position: absolute;
  top: 50%;
  left: 10%;
  transform: translate(-50%, -58%);
  font-size: 30px;
  line-height: 1;
  animation: loader-run 1.35s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
}

@keyframes loader-run {
  0% {
    left: 8%;
  }
  50% {
    left: 92%;
  }
  100% {
    left: 8%;
  }
}

.loader-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

.tg-hint-block {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.tg-bot-link {
  color: var(--blue);
  font-weight: 700;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 16px auto 96px;
}

.app-shell > main {
  width: 100%;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 760;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.dot-logo {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 2px;
}

.dot-logo i {
  display: inline-flex;
  gap: 3px;
}

.dot-logo span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
}

.nav-tabs,
.topbar-actions,
.theme-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tabs {
  justify-content: center;
}

.nav-tab,
.theme-option,
.link-button,
.bottom-nav button {
  border: 0;
  color: var(--muted);
  background: transparent;
}

.nav-tab {
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 14px;
  transition: 0.2s ease;
}

.nav-tab.is-active,
.nav-tab:hover,
.bottom-nav button.is-active {
  color: var(--blue);
  background: var(--accent-soft);
}

.theme-switch {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.06);
}

.theme-option {
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 12px;
}

.theme-option.is-active {
  color: var(--text);
  background: var(--panel-strong);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #fff;
  background: var(--blue);
}

.button-primary:hover {
  background: var(--blue-strong);
}

.button-ghost,
.button-soft {
  color: var(--blue);
  border-color: var(--line);
  background: transparent;
}

.button-ghost:hover,
.button-soft:hover {
  background: rgba(224, 84, 74, 0.06);
}

.screen {
  display: none;
  padding-top: 22px;
}

.screen.is-active {
  display: block;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
}

.hero-card,
.glass-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-main {
  min-height: 280px;
  padding: clamp(26px, 4.5vw, 52px);
  overflow: hidden;
  position: relative;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 850px;
  margin-bottom: 16px;
  font-size: clamp(34px, 5vw, 70px);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  letter-spacing: -0.04em;
}

h3 {
  margin-bottom: 10px;
  font-size: 14px;
  letter-spacing: -0.02em;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 700px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.rules-card {
  padding: 24px;
}

.rules-details {
  display: block;
}

.rules-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  -webkit-tap-highlight-color: transparent;
}

.rules-details > summary::-webkit-details-marker {
  display: none;
}

.rules-summary-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.rules-chevron {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(127, 127, 127, 0.08);
  color: var(--muted);
  font-size: 12px;
  transition: transform 0.25s ease, background 0.18s ease, color 0.18s ease;
}

.rules-details[open] > summary .rules-chevron {
  transform: rotate(-180deg);
  background: var(--accent-soft);
  color: var(--accent);
}

.rules-details > summary:hover .rules-chevron {
  background: var(--accent-soft);
  color: var(--accent);
}

.rules-details > .steps-list {
  overflow: hidden;
  animation: rules-slide-in 0.28s ease;
}

@keyframes rules-slide-in {
  from { opacity: 0; transform: translateY(-4px); max-height: 0; }
  to   { opacity: 1; transform: translateY(0);  max-height: 600px; }
}

.card-title-row,
.section-toolbar,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.soft-pill,
.rocket-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.steps-list {
  display: grid;
  gap: 12px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: steps;
}

.steps-list li {
  position: relative;
  min-height: 42px;
  padding-left: 50px;
  color: var(--muted);
  line-height: 1.35;
}

.steps-list li::before {
  counter-increment: steps;
  content: counter(steps);
  position: absolute;
  left: 0;
  top: -3px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}

.catalog-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.filter-panel {
  align-self: start;
  position: sticky;
  top: 104px;
  padding: 20px;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 13px;
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(224, 84, 74, 0.45);
  box-shadow: 0 0 0 4px rgba(224, 84, 74, 0.12);
}

.legend {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.legend span,
.tag,
.mini-fact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.catalog-panel {
  min-width: 0;
}

.section-toolbar {
  margin-bottom: 14px;
  padding: 4px 2px;
}

.project-list {
  display: grid;
  gap: 14px;
}

.project-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}

.project-card::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 0;
  width: 2px;
  height: calc(var(--traction) * 1%);
  max-height: calc(100% - 32px);
  border-radius: 999px;
  background: var(--blue);
  opacity: 0.18;
}

.project-card.tier-green {
  border-left-color: var(--green);
}

.project-card.tier-purple {
  border-left-color: var(--purple);
}

.project-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.project-id {
  color: var(--blue);
  font-weight: 850;
  font-size: 13px;
}

.project-title {
  margin: 4px 0 6px;
  font-size: 19px;
  letter-spacing: -0.03em;
}

.project-description {
  color: var(--muted);
  line-height: 1.45;
}

.category-row,
.tag-cloud,
.mini-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
}

.category.main {
  color: #fff;
  background: var(--blue);
}

.project-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.tag {
  min-height: 28px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(127, 127, 127, 0.06);
  font-size: 12px;
  font-weight: 720;
}

.level {
  --dots: 1;
  display: inline-grid;
  width: 6px;
  height: 18px;
  grid-template-rows: repeat(var(--dots), 4px);
  gap: 2px;
  align-content: center;
  flex: 0 0 6px;
}

.level::before,
.level::after {
  content: "";
}

.level,
.level::before,
.level::after {
  border-radius: 999px;
  background: var(--blue);
}

.level-1 {
  --dots: 1;
  height: 5px;
}

.level-2 {
  --dots: 2;
  background:
    radial-gradient(circle, var(--blue) 0 2px, transparent 2.2px) top center / 6px 8px no-repeat,
    radial-gradient(circle, var(--blue) 0 2px, transparent 2.2px) bottom center / 6px 8px no-repeat;
}

.level-2::before,
.level-2::after,
.level-3::before,
.level-3::after {
  display: none;
}

.level-3 {
  background:
    radial-gradient(circle, var(--blue) 0 2px, transparent 2.2px) top center / 6px 6px no-repeat,
    radial-gradient(circle, var(--blue) 0 2px, transparent 2.2px) center center / 6px 6px no-repeat,
    radial-gradient(circle, var(--blue) 0 2px, transparent 2.2px) bottom center / 6px 6px no-repeat;
}

.score-panel {
  display: grid;
  align-content: space-between;
  gap: 12px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.score-number {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 38px;
  font-weight: 850;
  letter-spacing: -0.07em;
  line-height: 1;
}

.score-number small {
  display: flex;
  align-items: center;
  margin-top: 0;
}

.traction-dots {
  transform: scale(1.2);
  transform-origin: left center;
}

.chains {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.chain {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
}

.chain b {
  color: var(--text);
  font-weight: 700;
}

.chain .sep {
  color: rgba(15, 23, 42, 0.25);
}

:root[data-theme="dark"] .chain .sep,
:root:not([data-theme="light"]) .chain .sep {
  color: rgba(248, 250, 252, 0.3);
}

.project-actions {
  display: grid;
  gap: 8px;
}

.mini-grid {
  margin-top: 14px;
}

.mini-fact {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  gap: 18px;
}

.founder-grid,
.curator-grid {
  grid-template-columns: minmax(0, 1fr) 380px;
}

.profile-panel,
.side-stack,
.requests-panel {
  min-width: 0;
}

.profile-panel,
.metric-panel,
.quota-panel,
.help-card,
.requests-panel {
  padding: 22px;
}

.side-stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.notice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(224, 84, 74, 0.08);
}

.notice-card.success {
  color: #8a6018;
  background: rgba(255, 193, 69, 0.18);
  border-color: rgba(255, 193, 69, 0.35);
}

.notice-card.purple {
  margin: 20px 0 0;
  color: var(--purple);
  background: rgba(155, 81, 224, 0.1);
}

.notice-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fact-grid,
.curator-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.fact-box {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(127, 127, 127, 0.05);
}

.fact-box span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.fact-box strong {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.25;
}

.split-block {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.metric-panel .big-number {
  margin: 10px 0;
  font-size: 44px;
  font-weight: 860;
  letter-spacing: -0.07em;
}

.meter,
.platform-scale {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.14);
}

.meter span,
.platform-scale span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.meter.blue span,
.platform-scale span {
  background: var(--accent);
  opacity: 0.75;
}

.metric-panel p,
.help-card p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.quota-panel {
  display: grid;
  gap: 10px;
}

.quota-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.quota-row:last-child {
  border-bottom: 0;
}

.curator-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
}

.avatar {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  font-size: 24px;
  font-weight: 850;
}

.rating-card {
  min-width: 110px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  text-align: center;
}

.rating-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.rating-card strong {
  font-size: 30px;
  letter-spacing: -0.05em;
}

.platform-scale {
  margin-top: 18px;
}

.platform-scale span {
  width: 78%;
}

.request-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.request-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(127, 127, 127, 0.05);
}

.request-card h3 {
  margin: 6px 0;
  font-size: 17px;
}

.request-card p {
  color: var(--muted);
  line-height: 1.4;
}

.request-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.bottom-nav {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 30;
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.bottom-nav button {
  min-height: 42px;
  border-radius: 999px;
  font-weight: 800;
}

@media (min-width: 1121px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .nav-tabs {
    justify-content: center;
    min-width: 0;
  }
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: 1fr;
    border-radius: 28px;
  }

  .nav-tabs,
  .topbar-actions {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .hero-grid,
  .catalog-layout,
  .founder-grid,
  .curator-grid {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    margin-top: 10px;
  }

  .topbar {
    position: static;
  }

  .nav-tabs,
  .topbar-actions {
    display: none;
  }

  h1 {
    font-size: 36px;
    line-height: 1;
  }

  .hero-main,
  .rules-card,
  .profile-panel,
  .metric-panel,
  .quota-panel,
  .help-card,
  .requests-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .project-card {
    grid-template-columns: 1fr;
  }

  .score-panel {
    padding: 12px 0 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .project-columns,
  .split-block,
  .fact-grid,
  .curator-metrics {
    grid-template-columns: 1fr;
  }

  .notice-card,
  .curator-header {
    grid-template-columns: 1fr;
    display: grid;
  }

  .bottom-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
  }

  .bottom-nav button {
    flex: 1 1 0;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    padding: 0 4px;
    white-space: nowrap;
  }

  .bottom-nav button.nav-btn-icon {
    flex: 0 0 40px;
    max-width: 40px;
    padding: 0;
  }
}

/* === Модалка «Больше фактуры» === */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 10, 5, 0.5);
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-panel {
  width: min(680px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: 0 32px 80px rgba(15, 10, 5, 0.22);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

.faktura-block {
  margin-bottom: 18px;
}

.faktura-block h3 {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.faktura-block p {
  color: var(--text);
  line-height: 1.6;
}

.faktura-empty {
  color: var(--muted);
  font-style: italic;
}

/* === Модалка «Топ-3 мэтчей» === */

.modal-panel--wide {
  width: min(780px, 100%);
}

.match-list {
  display: grid;
  gap: 14px;
}

.match-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(127, 127, 127, 0.04);
  transition: background 0.18s ease;
}

.match-card:hover {
  background: var(--accent-soft);
}

.match-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.match-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  letter-spacing: -0.03em;
}

.match-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.match-compat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 80px;
}

.match-compat-value {
  font-size: 28px;
  font-weight: 860;
  letter-spacing: -0.06em;
  line-height: 1;
  color: var(--accent);
}

.match-compat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.match-compat-bar {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.14);
  overflow: hidden;
}

.match-compat-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.match-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

@media (max-width: 560px) {
  .match-card {
    grid-template-columns: 1fr;
  }

  .match-compat {
    flex-direction: row;
    min-width: 0;
  }
}

/* === Модалка «Запрос на связь» === */

.match-card-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.match-request-btn {
  align-self: flex-start;
  margin-top: 14px;
  font-size: 13px;
  min-height: 34px;
  padding: 8px 14px;
}

.request-type-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.request-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.request-char-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.request-char-count.is-over {
  color: var(--accent);
}

.request-textarea {
  width: 100%;
  height: auto;
  min-height: 130px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--panel-strong);
  font-size: 15px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.request-textarea:focus {
  border-color: rgba(224, 84, 74, 0.45);
  box-shadow: 0 0 0 4px rgba(224, 84, 74, 0.12);
}

.request-hint {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.request-form-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.request-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 0;
  text-align: center;
}

.request-success-icon {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 50%;
  background: rgba(155, 81, 224, 0.14);
  color: var(--accent-rare);
  font-size: 26px;
  font-weight: 700;
}

.request-success h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.request-success p {
  margin: 0;
  max-width: 360px;
  color: var(--muted);
  line-height: 1.5;
}

/* === Избранное (сердечко) === */

.panel-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.heart-toggle,
.heart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease, border-color 0.18s ease;
}

.heart-toggle svg,
.heart-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  transition: fill 0.18s ease, stroke 0.18s ease, transform 0.2s ease;
}

.heart-toggle:hover,
.heart-button:hover {
  color: var(--accent);
  border-color: rgba(224, 84, 74, 0.4);
  transform: translateY(-1px);
}

.heart-toggle.is-active,
.heart-button.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.heart-toggle.is-active svg,
.heart-button.is-active svg {
  fill: var(--accent);
  stroke: var(--accent);
  animation: heart-pop 0.32s ease;
}

@keyframes heart-pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.heart-button {
  width: auto;
  padding: 0 10px 0 8px;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.heart-button .heart-count {
  min-width: 12px;
  text-align: center;
}

.heart-button.has-items {
  color: var(--accent);
}

.heart-toggle--score {
  flex-shrink: 0;
}

.heart-toggle--match {
  width: 28px;
  height: 28px;
  margin-left: auto;
}

.heart-toggle--match svg {
  width: 15px;
  height: 15px;
}

/* score-row объединяет число + точки + сердечко в одну строку */
.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* === Оферта === */

#offerOverlay {
  z-index: 110;
}

.offer-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.offer-link:hover {
  color: var(--accent-strong);
}

.offer-fields {
  display: grid;
  gap: 6px;
  margin-bottom: 6px;
}

.offer-fields .field {
  margin-top: 6px;
}

.offer-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(127, 127, 127, 0.05);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  cursor: pointer;
}

.offer-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.offer-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(224, 84, 74, 0.1);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

/* === Welcome (приветственная модалка) === */

#welcomeOverlay .modal-panel {
  align-self: center;
}

@media (min-width: 720px) {
  #welcomeOverlay,
  #matchesOverlay,
  #fakturaOverlay,
  #offerOverlay,
  #requestOverlay,
  #founderEditOverlay,
  #curatorEditOverlay,
  #tgVerifyOverlay {
    align-items: center;
  }
}

/* === Кабинет фаундера: описание и tg-статус === */

.founder-description {
  margin: 4px 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.tg-status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.tg-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(80, 200, 120, 0.18);
  color: #1d8a4e;
  font-size: 12px;
  font-weight: 800;
  margin-right: 6px;
}

:root[data-theme="dark"] .tg-status-badge,
:root:not([data-theme="light"]) .tg-status-badge {
  color: #6cd494;
}

/* === Кабинет куратора: actions === */

.curator-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 4px;
}

/* === Edit-формы (фаундер + куратор) === */

.edit-grid {
  display: grid;
  gap: 12px;
}

.edit-grid .field {
  margin-top: 0;
}

.edit-row-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.edit-section {
  margin-top: 22px;
}

.edit-section > h3 {
  margin-bottom: 8px;
}

.edit-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.edit-list {
  display: grid;
  gap: 8px;
}

.edit-row {
  display: grid;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(127, 127, 127, 0.04);
}

.edit-row input,
.edit-row select {
  height: 40px;
}

.edit-row-3 {
  grid-template-columns: 1fr 1fr 1fr auto;
}

.edit-row-market {
  grid-template-columns: 1fr 100px auto;
}

.edit-remove {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(224, 84, 74, 0.08);
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.edit-remove:hover {
  background: rgba(224, 84, 74, 0.18);
}

textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

textarea:focus {
  border-color: rgba(224, 84, 74, 0.45);
  box-shadow: 0 0 0 4px rgba(224, 84, 74, 0.12);
}

@media (max-width: 560px) {
  .edit-row-3 {
    grid-template-columns: 1fr auto;
  }

  .edit-row-3 input {
    grid-column: 1 / 2;
  }

  .edit-row-3 .edit-remove {
    grid-column: 2 / 3;
    grid-row: 1 / 4;
    align-self: start;
  }

  .edit-row-two {
    grid-template-columns: 1fr;
  }
}

/* === TG-верификация (OTP-инпуты) === */

.tg-sent-line {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.tg-sent-line strong {
  color: var(--text);
}

.tg-sent-line .link-button {
  margin-left: 4px;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.tg-otp {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 6px 0 12px;
}

.tg-otp-input {
  height: 56px;
  padding: 0;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-strong);
  color: var(--text);
}

.tg-otp-input:focus {
  border-color: rgba(224, 84, 74, 0.45);
  box-shadow: 0 0 0 4px rgba(224, 84, 74, 0.12);
  outline: none;
}

.tg-dev-hint {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: rgba(127, 127, 127, 0.05);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.tg-dev-hint span {
  color: var(--accent);
  font-weight: 800;
  margin-right: 4px;
}

.tg-dev-hint b {
  display: inline-block;
  padding: 2px 8px;
  margin: 0 2px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  letter-spacing: 0.05em;
}

/* === Edit UX: подсказки, счётчики, цепочки === */

.edit-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.edit-hint-inline {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
}

.char-counter {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}

.char-counter.is-over {
  color: var(--accent);
}

.version-badge {
  display: inline-block;
  margin: 0 0 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(155, 81, 224, 0.12);
  color: var(--accent-rare);
  font-size: 12px;
  font-weight: 800;
}

.pilot-check {
  margin: 0 0 10px;
}

.pilot-date-wrap.is-hidden {
  display: none !important;
}

.pilot-date-wrap:not(.is-hidden) {
  margin-top: 10px;
}

.founder-eval-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.evaluate-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.edit-row-chain {
  grid-template-columns: auto 1fr 1fr 1fr auto;
  align-items: center;
}

.edit-drag {
  cursor: grab;
  color: var(--muted);
  font-size: 14px;
  user-select: none;
  padding: 0 4px;
}

.edit-row-chain.is-dragging {
  opacity: 0.55;
  border-color: var(--accent);
}

.edit-row-actions {
  display: inline-flex;
  gap: 4px;
}

.edit-move,
.edit-remove {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.edit-move:hover,
.edit-remove:hover {
  color: var(--accent);
  border-color: rgba(224, 84, 74, 0.35);
}

.faktura-blocks {
  display: grid;
  gap: 12px;
}

.label-with-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.info-btn {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-strong);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.info-popover {
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}

.readonly-field {
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: rgba(127, 127, 127, 0.05);
}

.readonly-field span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.input-with-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel-strong);
}

.input-with-prefix:focus-within {
  border-color: rgba(224, 84, 74, 0.45);
  box-shadow: 0 0 0 4px rgba(224, 84, 74, 0.12);
}

.input-with-prefix .input-prefix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 800;
  font-size: 15px;
  background: rgba(127, 127, 127, 0.06);
  border-right: 1px solid var(--line);
  flex-shrink: 0;
}

.input-with-prefix input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  height: 44px;
}

.input-with-prefix input:focus {
  box-shadow: none;
}

@media (max-width: 720px) {
  .edit-row-chain {
    grid-template-columns: auto 1fr auto;
  }

  .edit-row-chain input:nth-of-type(2),
  .edit-row-chain input:nth-of-type(3) {
    grid-column: 2 / 3;
  }
}

/* Telegram Mini App */
body.tg-miniapp {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

body.tg-miniapp .topbar {
  padding-top: env(safe-area-inset-top, 0px);
}

body.tg-miniapp .bottom-nav {
  display: flex !important;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.tg-miniapp .bottom-nav button {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  min-height: 38px;
  padding: 0 4px;
  line-height: 1.1;
  white-space: nowrap;
}

body.tg-miniapp .bottom-nav button.nav-btn-icon {
  flex: 0 0 40px;
  max-width: 40px;
  padding: 0;
}

body.tg-miniapp .bottom-nav .nav-icon {
  display: block;
  flex-shrink: 0;
}

body.tg-miniapp .bottom-nav > button.nav-unlocked {
  display: inline-flex !important;
}

.miniapp-auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
}

.miniapp-auth-bar[hidden] {
  display: none !important;
}

.miniapp-auth-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.button-small {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
  white-space: nowrap;
}

.button-block {
  width: 100%;
  margin-top: 8px;
}

.account-card {
  margin-top: 0;
}

body.tg-miniapp #logoutBtn {
  display: none !important;
}

body.tg-miniapp.tg-authed #founderConfirmBtn,
body.tg-miniapp.tg-authed #curatorConfirmBtn {
  display: none;
}

/* ─── Организатор / участники / сообщения ─── */

.organizer-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.organizer-enable-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin: 12px 0;
}

.organizer-enable-row .input-with-prefix {
  flex: 1;
  min-width: 180px;
}

.organizer-curator-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.organizer-curator-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.curator-participants-block {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.participant-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.participant-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(127, 127, 127, 0.04);
}

.participant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.participant-meta,
.participant-note {
  margin: 4px 0;
  font-size: 13px;
  color: var(--muted);
}

.button-sm {
  font-size: 12px;
  min-height: 32px;
  padding: 6px 12px;
}

.messages-inbox {
  margin-top: 16px;
}

.messages-section-title {
  margin: 20px 0 10px;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.message-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: var(--panel-strong);
}

.message-meta {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
}

.messages-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 560px) {
  .organizer-stats {
    grid-template-columns: 1fr;
  }
}

/* Метрики и отчёт */
.quota-current {
  margin: 0 0 12px;
  font-size: 14px;
}

.quota-row.is-active-tier {
  border-color: var(--blue);
  background: var(--accent-soft);
}

.report-banner {
  border-color: color-mix(in srgb, var(--blue) 40%, var(--line));
}

.report-banner--warn {
  border-color: color-mix(in srgb, #e85 50%, var(--line));
}

.report-toast {
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  background: color-mix(in srgb, var(--blue) 15%, var(--panel));
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Мессенджер */
.messenger {
  padding: 0 !important;
  overflow: hidden;
}

.messenger-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  min-height: min(72vh, 640px);
  max-height: min(78vh, 700px);
}

.messenger-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  min-height: 0;
}

.messenger-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.messenger-title {
  margin: 0;
  font-size: 20px;
}

.messenger-head-actions {
  display: flex;
  gap: 6px;
}

.messenger-chats {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.messenger-section-label {
  margin: 12px 8px 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.messenger-chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  position: relative;
  color: inherit;
}

.messenger-chat-item:hover,
.messenger-chat-item.is-active {
  background: var(--accent-soft);
}

.messenger-chat-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.messenger-chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.messenger-chat-item-top time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.messenger-chat-item-preview {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messenger-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--blue) 18%, var(--panel));
  color: var(--blue);
  font-weight: 800;
  flex-shrink: 0;
}

.messenger-avatar--sm {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

.messenger-unread {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  background: var(--blue);
  color: #fff;
  flex-shrink: 0;
}

.messenger-connection-card {
  margin: 0 8px 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  font-size: 13px;
}

.messenger-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: color-mix(in srgb, var(--bg) 40%, var(--panel));
}

.messenger-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.messenger-empty-icon {
  font-size: 40px;
  margin: 0;
}

.messenger-chat-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messenger-chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.messenger-back-btn {
  display: none;
  border: 0;
  background: transparent;
  font-size: 20px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--blue);
}

.messenger-chat-peer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.messenger-chat-peer strong {
  display: block;
  font-size: 16px;
}

.messenger-chat-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.messenger-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.messenger-day {
  align-self: center;
  margin: 8px 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
  background: color-mix(in srgb, var(--line) 50%, transparent);
}

.messenger-bubble-row {
  display: flex;
  width: 100%;
}

.messenger-bubble-row--mine {
  justify-content: flex-end;
}

.messenger-bubble-row--theirs {
  justify-content: flex-start;
}

.messenger-bubble {
  max-width: min(82%, 420px);
  padding: 10px 14px 6px;
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.messenger-bubble--mine {
  background: color-mix(in srgb, var(--blue) 22%, var(--panel));
  border-bottom-right-radius: 6px;
}

.messenger-bubble--theirs {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}

.messenger-bubble p {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.messenger-bubble time {
  display: block;
  font-size: 10px;
  color: var(--muted);
  text-align: right;
}

.messenger-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.messenger-composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  font-size: 15px;
  line-height: 1.35;
}

.messenger-send-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.messenger-send-btn:disabled {
  opacity: 0.5;
}

.messenger-composer-error {
  margin: 0;
  padding: 0 14px 8px;
}

@media (max-width: 820px) {
  .messenger-layout {
    grid-template-columns: 1fr;
    min-height: min(70vh, 600px);
  }

  .messenger-sidebar {
    border-right: 0;
  }

  .messenger-layout--chat-open .messenger-sidebar {
    display: none;
  }

  .messenger-back-btn {
    display: inline-block;
  }

  .messenger-chat-empty {
    display: none;
  }

  .messenger-layout:not(.messenger-layout--chat-open) .messenger-chat-active {
    display: none !important;
  }
}

body.tg-miniapp .messenger-layout {
  max-height: calc(100vh - 120px);
  min-height: calc(100vh - 140px);
}

body.tg-miniapp .messenger-composer {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
