/* ==========================================================================
   Айлёшка — Корпоративная дизайн-система (aileshka.ru · Modern Web 2026)
   ========================================================================== */

:root {
  /* Фирменная палитра aileshka.ru: hsl(0 100% 35%) #B30000 / #D92626 */
  --brand-light: #b30000;
  --brand-dark: #d92626;
  --brand-hover-light: #8f0000;
  --brand-hover-dark: #ef3b3b;

  --bg-canvas-light: #f6f7f9;
  --bg-canvas-dark: #0a0b0f;
  --bg-surface-light: #ffffff;
  --bg-surface-dark: #12141b;
  --bg-elevated-light: #f1f3f7;
  --bg-elevated-dark: #191d27;

  --text-main-light: #14161d;
  --text-main-dark: #f3f5f9;
  --text-muted-light: #596073;
  --text-muted-dark: #97a0b5;

  --border-light: #e2e5ee;
  --border-dark: #252b3b;

  --ok-light: #0d7a43;
  --ok-dark: #34d399;

  --shadow-card-light: 0 1px 2px rgba(16, 20, 30, 0.04), 0 8px 24px rgba(16, 20, 30, 0.04);
  --shadow-card-dark: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 28px rgba(0, 0, 0, 0.28);

  /* Значения по умолчанию + fallback без light-dark() */
  --brand: var(--brand-light);
  --brand-hover: var(--brand-hover-light);
  --bg-canvas: var(--bg-canvas-light);
  --bg-surface: var(--bg-surface-light);
  --bg-elevated: var(--bg-elevated-light);
  --text-main: var(--text-main-light);
  --text-muted: var(--text-muted-light);
  --border-color: var(--border-light);
  --ok-color: var(--ok-light);
  --shadow-card: var(--shadow-card-light);
  --scrollbar-track: #eceef3;
  --scrollbar-thumb: #848ca1;

  @media (prefers-color-scheme: dark) {
    --brand: var(--brand-dark);
    --brand-hover: var(--brand-hover-dark);
    --bg-canvas: var(--bg-canvas-dark);
    --bg-surface: var(--bg-surface-dark);
    --bg-elevated: var(--bg-elevated-dark);
    --text-main: var(--text-main-dark);
    --text-muted: var(--text-muted-dark);
    --border-color: var(--border-dark);
    --ok-color: var(--ok-dark);
    --shadow-card: var(--shadow-card-dark);
    --scrollbar-track: #141821;
    --scrollbar-thumb: #687189;
  }

  color-scheme: light dark;

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
    --brand: var(--brand-dark);
    --brand-hover: var(--brand-hover-dark);
    --bg-canvas: var(--bg-canvas-dark);
    --bg-surface: var(--bg-surface-dark);
    --bg-elevated: var(--bg-elevated-dark);
    --text-main: var(--text-main-dark);
    --text-muted: var(--text-muted-dark);
    --border-color: var(--border-dark);
    --ok-color: var(--ok-dark);
    --shadow-card: var(--shadow-card-dark);
  }

  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
    --brand: var(--brand-light);
    --brand-hover: var(--brand-hover-light);
    --bg-canvas: var(--bg-canvas-light);
    --bg-surface: var(--bg-surface-light);
    --bg-elevated: var(--bg-elevated-light);
    --text-main: var(--text-main-light);
    --text-muted: var(--text-muted-light);
    --border-color: var(--border-light);
    --ok-color: var(--ok-light);
    --shadow-card: var(--shadow-card-light);
  }

  @supports (color: light-dark(white, black)) {
    --brand: light-dark(var(--brand-light), var(--brand-dark));
    --brand-hover: light-dark(var(--brand-hover-light), var(--brand-hover-dark));
    --bg-canvas: light-dark(var(--bg-canvas-light), var(--bg-canvas-dark));
    --bg-surface: light-dark(var(--bg-surface-light), var(--bg-surface-dark));
    --bg-elevated: light-dark(var(--bg-elevated-light), var(--bg-elevated-dark));
    --text-main: light-dark(var(--text-main-light), var(--text-main-dark));
    --text-muted: light-dark(var(--text-muted-light), var(--text-muted-dark));
    --border-color: light-dark(var(--border-light), var(--border-dark));
    --ok-color: light-dark(var(--ok-light), var(--ok-dark));
    --scrollbar-track: light-dark(#eceef3, #141821);
    --scrollbar-thumb: light-dark(#848ca1, #687189);
  }

  accent-color: var(--brand);
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;

  --radius: 0.55rem;
  --radius-lg: 0.85rem;
  --font-sans: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --target-size: 32px;
}

@media (pointer: coarse) {
  :root {
    --target-size: 44px;
  }
}

@supports not (scrollbar-color: auto) {
  *::-webkit-scrollbar {
    width: 9px;
    height: 9px;
  }
  *::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
  }
  *::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-main);
  line-height: 1.5;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  text-wrap: balance;
}

p, li {
  margin: 0;
  text-wrap: pretty;
}

img, video {
  max-inline-size: 100%;
  block-size: auto;
  display: block;
}

:where(button, select, textarea, input:not([type="checkbox"], [type="radio"]), [role="button"], label:has(input[type="checkbox"], input[type="radio"])) {
  min-block-size: var(--target-size);
  min-inline-size: var(--target-size);
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.visually-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Векторные иконки (строгая геометрия без эмодзи) */
.ui-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}

.ui-icon-xs {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}

/* ==========================================================================
   1. СТРАНИЦА АВТОРИЗАЦИИ (/login)
   ========================================================================== */

.auth-body {
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 12% 15%, color-mix(in srgb, var(--brand) 9%, transparent), transparent 42%),
    radial-gradient(circle at 88% 85%, color-mix(in srgb, var(--brand) 6%, transparent), transparent 40%),
    var(--bg-canvas);
}

.auth-layout {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(1.25rem, env(safe-area-inset-top, 0px))
    max(1.25rem, env(safe-area-inset-right, 0px))
    max(1.25rem, env(safe-area-inset-bottom, 0px))
    max(1.25rem, env(safe-area-inset-left, 0px));
}

.auth-shell {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.12fr 0.95fr;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 1.1rem;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.auth-showcase {
  padding: 2.5rem 2.4rem;
  background: linear-gradient(
    155deg,
    color-mix(in srgb, var(--brand) 7%, var(--bg-elevated)) 0%,
    var(--bg-elevated) 100%
  );
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.6rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.auth-avatar-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid color-mix(in srgb, var(--brand) 45%, var(--border-color));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 18%, transparent);
}

.auth-brand-name {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-brand-tag {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.auth-pitch-title {
  font-size: clamp(1.25rem, 1.05rem + 0.7vw, 1.55rem);
  font-weight: 800;
  line-height: 1.28;
  letter-spacing: -0.02em;
}

.auth-pitch-lead {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.auth-pillars {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-pillars li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.auth-pillars .ui-icon {
  width: 20px;
  height: 20px;
  color: var(--brand);
  margin-top: 0.12rem;
}

.auth-pillars strong {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.auth-pillars span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.48;
}

.auth-card {
  padding: 2.5rem 2.3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.35rem;
}

.eyebrow-label {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--brand);
  margin-bottom: 0.35rem;
}

.auth-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.auth-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.auth-alert {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--brand) 10%, var(--bg-surface));
  border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--border-color));
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.pw-toggle-btn {
  background: none;
  border: none;
  padding: 0.15rem 0.35rem;
  min-block-size: auto;
  min-inline-size: auto;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
  border-radius: 4px;
}

.pw-toggle-btn:hover {
  text-decoration: underline;
}

.form-input {
  width: 100%;
  min-block-size: 48px;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  /* Минимум 16px (1rem), чтобы мобильный Safari не масштабировал экран при фокусе */
  font-size: max(1rem, 1em);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

@media (pointer: coarse) {
  .form-input {
    min-block-size: 52px;
  }
}

.form-input:focus {
  border-color: var(--brand);
  background: var(--bg-surface);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.form-input[aria-invalid="true"] {
  border-color: var(--brand);
}

.auth-footer-note {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border-color);
}

@media (max-width: 820px) {
  .auth-shell {
    grid-template-columns: 1fr;
    max-width: 460px;
  }
  .auth-showcase {
    padding: 1.6rem 1.5rem;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
  }
  .auth-pillars {
    display: none;
  }
  .auth-card {
    padding: 1.75rem 1.5rem;
  }
}

/* ==========================================================================
   2. РАБОЧЕЕ ПРОСТРАНСТВО ПРИЛОЖЕНИЯ (my.aileshka.ru)
   ========================================================================== */

/* Переключатель темы без мигания */
.theme-label-to-dark,
.theme-label-to-light {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.theme-label-to-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-label-to-dark { display: none; }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-label-to-light { display: inline-flex; }
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-label-to-dark { display: none; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-label-to-light { display: inline-flex; }

.app-shell {
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding-top: max(0.7rem, env(safe-area-inset-top, 0px));
  padding-bottom: 0.7rem;
  padding-left: max(1.15rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.15rem, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 25;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-inline-size: 0;
}

.brand-mark {
  width: 14px;
  height: 28px;
  border-radius: 4px;
  background: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
  flex-shrink: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.brand-name {
  font-size: clamp(1.08rem, 0.95rem + 0.45vw, 1.32rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.69rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.badge-compliance {
  background: color-mix(in srgb, var(--ok-color) 12%, transparent);
  color: var(--ok-color);
  border: 1px solid color-mix(in srgb, var(--ok-color) 32%, transparent);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

:where(.toolbar > :not(button, input, select, textarea, a, [role="button"], label)) {
  min-inline-size: 0;
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.52rem 0.95rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.btn-ghost {
  background: var(--bg-elevated);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-ghost:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border-color));
}

.btn-sm {
  padding: 0.36rem 0.68rem;
  font-size: 0.77rem;
}

.btn-lg {
  min-block-size: 48px;
  padding: 0.7rem 1.15rem;
  font-size: 0.92rem;
  font-weight: 700;
}

.btn-block {
  width: 100%;
}

.btn-link {
  background: none;
  border: none;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.77rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  min-block-size: auto;
  min-inline-size: auto;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Трёхколоночная сетка */
.studio-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 365px;
  gap: 0.95rem;
  padding: 0.95rem max(1.15rem, env(safe-area-inset-right, 0px)) 1.1rem max(1.15rem, env(safe-area-inset-left, 0px));
  max-width: 1760px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.pane {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1rem;
  container-type: inline-size;
}

/* Левая колонка: Персонаж и бизнес-роли Айлёшки */
.pane-persona {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  position: sticky;
  top: 4.6rem;
}

.avatar-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.avatar-stage {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  view-transition-name: aileshka-portrait;
}

.avatar-stage.is-speaking {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 24%, transparent);
}

.avatar-stage img,
.avatar-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.avatar-overlay-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.8rem 0.75rem 0.65rem;
  background: linear-gradient(to top, rgba(10, 12, 18, 0.88) 0%, rgba(10, 12, 18, 0.42) 60%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.badge-crimson {
  background: var(--brand);
  color: #ffffff;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
}

.look-caption {
  font-size: 0.69rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  text-align: right;
}

.speaking-indicator {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  right: 0.65rem;
  background: rgba(12, 14, 20, 0.88);
  color: #fff;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  backdrop-filter: blur(6px);
}

.wave-bar {
  width: 3px;
  height: 12px;
  background: #ff4d4d;
  border-radius: 2px;
  animation: wavePulse 0.8s ease-in-out infinite alternate;
}
.wave-bar:nth-child(2) { animation-delay: 0.15s; }
.wave-bar:nth-child(3) { animation-delay: 0.3s; }
.wave-bar:nth-child(4) { animation-delay: 0.45s; }

@keyframes wavePulse {
  from { transform: scaleY(0.35); }
  to { transform: scaleY(1.15); }
}

.avatar-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.role-title {
  font-size: 1.04rem;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.role-subtitle {
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.kpi-highlight {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.2rem;
  padding: 0.42rem 0.6rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--ok-color) 10%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--ok-color) 28%, var(--border-color));
  color: var(--ok-color);
  font-size: 0.73rem;
  font-weight: 700;
}

/* Визуальные карточки переключения 5 ролей Айлёшки с портретами */
.role-switcher {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.role-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.38rem 0.55rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.role-chip:hover {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border-color));
}

.role-chip.is-active {
  background: color-mix(in srgb, var(--brand) 10%, var(--bg-surface));
  border-color: var(--brand);
}

.role-chip-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  border: 1.5px solid var(--border-color);
  flex-shrink: 0;
}

.role-chip.is-active .role-chip-thumb {
  border-color: var(--brand);
}

.role-chip-copy {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.role-chip-title {
  font-size: 0.77rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-chip-badge {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.role-chip.is-active .role-chip-title,
.role-chip.is-active .role-chip-badge {
  color: var(--brand);
}

.field-label {
  display: block;
  font-size: 0.71rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.select-input {
  width: 100%;
  padding: 0.48rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 0.79rem;
  font-weight: 500;
}

.call-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.call-hint {
  font-size: 0.71rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Финансовый блок Unit-экономики */
.econ-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.8rem;
}

.econ-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.55rem;
}

.econ-title {
  font-size: 0.75rem;
  font-weight: 700;
}

.econ-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.12rem 0.48rem;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.econ-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.econ-stat {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 0.48rem 0.6rem;
  border: 1px solid var(--border-color);
}

.econ-stat.econ-saved {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--ok-color) 40%, var(--border-color));
}

.econ-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.econ-val {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
}

.econ-muted {
  text-decoration: line-through;
  color: var(--text-muted);
}

.econ-saved .econ-val {
  color: var(--ok-color);
}

/* Центральная колонка: Бизнес-витрина и диалог */
.pane-workspace {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-block-size: calc(100dvh - 5.9rem);
}

/* Полоса ключевых бизнес-преимуществ */
.value-ribbon {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--brand) 7%, var(--bg-elevated)) 0%,
    var(--bg-elevated) 100%
  );
  border: 1px solid var(--border-color);
}

@container (inline-size > 36rem) {
  .value-ribbon {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.value-metric {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.value-num {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--brand);
  white-space: nowrap;
}

.value-caption {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
}

.chain-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border-color);
}

.tier-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tier-pill {
  padding: 0.36rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tier-pill:hover:not(.is-active) {
  border-color: color-mix(in srgb, var(--brand) 50%, var(--border-color));
}

.tier-pill.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.toggles-group {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.strip-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.section-heading {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Контейнерные запросы для карточек бизнес-сценариев */
.scenarios-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

@container (inline-size > 34rem) {
  .scenarios-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (inline-size > 54rem) {
  .scenarios-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.scenario-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
}

.scenario-card:hover {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 4%, var(--bg-surface));
  transform: translateY(-1px);
}

.scenario-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.scenario-category {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.scenario-arrow {
  color: var(--text-muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

.scenario-card:hover .scenario-arrow {
  color: var(--brand);
  transform: translateX(2px);
}

.scenario-title {
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.32;
}

.scenario-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Поток диалога */
.chat-stream {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  overflow-y: auto;
  padding: 0.35rem 0.15rem;
  min-block-size: 280px;
  max-block-size: 60dvh;
}

.msg {
  padding: 0.95rem 1.05rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  max-width: 92%;
}

.msg-user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--brand) 10%, var(--bg-surface));
  border-color: color-mix(in srgb, var(--brand) 32%, var(--border-color));
}

.msg-assistant {
  align-self: flex-start;
  background: var(--bg-elevated);
  width: 100%;
  max-width: 100%;
}

.msg-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
  font-size: 0.73rem;
  color: var(--text-muted);
}

.msg-author {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.msg-avatar-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  border: 1px solid var(--brand);
}

.msg-badges {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.mini-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.67rem;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.mini-tag-shield {
  color: var(--ok-color);
  border-color: color-mix(in srgb, var(--ok-color) 40%, var(--border-color));
}

.msg-body {
  font-size: 0.87rem;
  line-height: 1.6;
}

.msg-body p + p,
.msg-body ul,
.msg-body ol,
.msg-body h3,
.msg-body h4 {
  margin-top: 0.55rem;
}

.msg-body ul,
.msg-body ol {
  padding-left: 1.25rem;
}

.msg-body code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 0.1rem 0.32rem;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.msg-footer {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border-color);
}

/* Сравнение контуров: 0 ₽ и Флагман Pro */
.battle-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  margin-top: 0.5rem;
}

@container (inline-size > 38rem) {
  .battle-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.battle-col {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.6rem;
}

.battle-col-pro {
  border-color: color-mix(in srgb, var(--brand) 50%, var(--border-color));
}

.battle-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border-color);
}

.battle-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.tier-dot-free { background: var(--ok-color); }
.tier-dot-pro { background: var(--brand); }

/* Консилиум 4 профильных экспертов */
.council-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}

@container (inline-size > 38rem) {
  .council-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.council-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  font-size: 0.79rem;
}

.council-agent-name {
  font-weight: 700;
  font-size: 0.74rem;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 0.3rem;
}

.council-synth-heading {
  font-size: 0.84rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
}

.skill-born-banner {
  margin-top: 0.65rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--ok-color) 10%, var(--bg-surface));
  border: 1px solid color-mix(in srgb, var(--ok-color) 42%, var(--border-color));
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Поле ввода сообщения */
.composer {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border-color);
}

.composer textarea {
  flex: 1;
  min-inline-size: 0;
  resize: vertical;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: max(1rem, 0.9rem);
}

.composer textarea:focus {
  border-color: var(--brand);
  background: var(--bg-surface);
  outline: none;
}

.btn-mic.is-recording {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
  animation: pulseBorder 1.1s infinite;
}

@keyframes pulseBorder {
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 28%, transparent); }
}

/* Правая колонка: Трассировка маршрута, Регламенты и CRM */
.pane-inspector {
  position: sticky;
  top: 4.6rem;
  max-block-size: calc(100dvh - 5.6rem);
  overflow-y: auto;
}

.inspector-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
}

.insp-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  padding: 0.42rem 0.4rem;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  cursor: pointer;
}

.insp-tab.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.count-dot {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  padding: 0.04rem 0.34rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
}

.node-status-box {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.8rem;
  padding: 0.7rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  font-size: 0.74rem;
}

.node-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
}

.node-row p {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-top: 0.1rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.34rem;
  flex-shrink: 0;
}
.status-online { background: var(--ok-color); }
.status-standby { background: #d97706; }

.xray-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.xray-step {
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--brand);
  background: var(--bg-elevated);
  font-size: 0.76rem;
}

.xray-step-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.xray-mono {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  background: var(--bg-surface);
  padding: 0.45rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  margin-top: 0.4rem;
  white-space: pre-wrap;
}

.skills-list,
.sandbox-data-view {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.skill-item,
.data-card {
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  font-size: 0.78rem;
}

.data-card-title {
  display: block;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--brand);
  margin-bottom: 0.4rem;
}

.data-list {
  padding-left: 1.1rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.skill-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.panel-lead,
.empty-hint,
.sandbox-banner {
  font-size: 0.76rem;
  color: var(--text-muted);
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  margin-bottom: 0.65rem;
  line-height: 1.5;
}

.sandbox-banner strong {
  display: block;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

/* Модальные окна <dialog> */
dialog {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-main);
  padding: 0;
  max-width: min(640px, 92vw);
  width: 100%;
  box-shadow: var(--shadow-card);
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(8, 10, 16, 0.64);
  backdrop-filter: blur(4px);
}

.dialog-card {
  padding: 1.25rem 1.35rem;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.dialog-header h2 {
  font-size: 1rem;
  font-weight: 800;
}

.install-steps {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.65rem;
  font-size: 0.85rem;
}

.dialog-actions {
  margin-top: 1rem;
}

.code-viewer {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg-elevated);
  padding: 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Нижняя мобильная навигация */
.mobile-bottom-nav {
  display: none;
}

/* Планшеты (iPad) */
@media (max-width: 1200px) {
  .studio-grid {
    grid-template-columns: 310px minmax(0, 1fr);
  }
  .pane-inspector {
    grid-column: 1 / -1;
    position: static;
    max-block-size: none;
  }
}

/* Смартфоны (iPhone / Android) */
@media (max-width: 760px) {
  .brand-sub {
    display: none;
  }
  .topbar-actions .btn span:not(.theme-label-to-dark):not(.theme-label-to-light) {
    display: none;
  }
  .studio-grid {
    grid-template-columns: 1fr;
    padding-bottom: calc(4.8rem + env(safe-area-inset-bottom, 0px));
  }
  .pane-persona,
  .pane-workspace,
  .pane-inspector {
    position: static;
    min-block-size: auto;
    max-block-size: none;
  }
  .pane[data-mob-hidden="true"] {
    display: none;
  }
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding-top: 0.35rem;
    padding-bottom: max(0.45rem, env(safe-area-inset-bottom, 0px));
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
  }
  .mob-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.72rem;
    border-radius: var(--radius);
    padding: 0.25rem;
  }
  .mob-nav-btn.is-active {
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 10%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
  .wave-bar,
  .btn-mic.is-recording {
    animation: none !important;
  }
}
