/*
 * =========================================
 * CHAT - Чат (Редизайн 2026)
 * Концепция: Архитектурная Эфемерность
 * =========================================
 */

:root {
  --input-bg: oklch(97% 0.005 260deg);
  --input-border: oklch(88% 0.01 260deg);
  --input-text: oklch(15% 0.02 260deg);
  --input-placeholder: oklch(45% 0.02 260deg);
  --input-shadow: inset 0 1px 2px oklch(0% 0 0deg / 5%), 0 1px 0 oklch(100% 0 0deg / 80%);
  --input-focus-glow: 0 0 0 3px oklch(45% 0.12 250deg / 15%);
  --icon-filter: opacity(55%);
  --btn-icon-hover-bg: oklch(92% 0.01 260deg);
  --btn-icon-active-bg: oklch(88% 0.01 260deg);
  --pill-bg: oklch(96% 0.005 260deg);
  --pill-border: oklch(88% 0.01 260deg);
  --pill-text: oklch(45% 0.02 260deg);
  --pill-active-bg: oklch(45% 0.12 250deg);
  --pill-active-border: oklch(45% 0.12 250deg);
  --pill-active-text: oklch(97% 0.005 260deg);
  --pill-active-shadow: inset 0 1px 2px oklch(0% 0 0deg / 15%), 0 4px 14px oklch(45% 0.12 250deg / 30%);

  /* Эфемерные медиа */
  --blur-filter: blur(4px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --input-bg: oklch(18% 0.015 260deg);
    --input-border: oklch(30% 0.02 260deg);
    --input-text: oklch(92% 0.005 260deg);
    --input-placeholder: oklch(60% 0.02 260deg);
    --input-shadow: inset 0 1px 3px oklch(0% 0 0deg / 30%), 0 1px 0 oklch(100% 0 0deg / 5%);
    --input-focus-glow: 0 0 0 3px oklch(65% 0.12 250deg / 25%);
    --icon-filter: invert(1) opacity(70%);
    --btn-icon-hover-bg: oklch(25% 0.02 260deg);
    --btn-icon-active-bg: oklch(30% 0.02 260deg);
    --pill-bg: oklch(20% 0.015 260deg);
    --pill-border: oklch(30% 0.02 260deg);
    --pill-text: oklch(70% 0.02 260deg);
    --pill-active-bg: oklch(65% 0.12 250deg);
    --pill-active-border: oklch(65% 0.12 250deg);
    --pill-active-text: oklch(98% 0.002 260deg);
    --pill-active-shadow: inset 0 1px 2px oklch(0% 0 0deg / 20%), 0 4px 14px oklch(65% 0.12 250deg / 20%);
  }
}

.vibe-shift {
  --input-bg: oklch(95% 0.03 110deg);
  --input-border: oklch(75% 0.2 130deg / 50%);
  --input-text: oklch(15% 0.05 110deg);
  --input-placeholder: oklch(50% 0.1 110deg);
  --input-shadow: inset 0 0 10px oklch(75% 0.2 130deg / 10%);
  --input-focus-glow: 0 0 0 3px oklch(75% 0.2 130deg / 40%);
  --icon-filter: invert(1) sepia(1) saturate(5) hue-rotate(80deg) brightness(80%);
  --btn-icon-hover-bg: oklch(85% 0.15 110deg);
  --btn-icon-active-bg: oklch(75% 0.2 130deg);
  --pill-bg: oklch(90% 0.02 110deg);
  --pill-border: oklch(75% 0.2 130deg / 50%);
  --pill-text: oklch(30% 0.1 110deg);
  --pill-active-bg: oklch(75% 0.2 130deg);
  --pill-active-border: oklch(75% 0.2 130deg);
  --pill-active-text: oklch(10% 0 0 0deg);
  --pill-active-shadow: 0 0 15px oklch(75% 0.2 130deg / 50%), inset 0 0 8px oklch(0% 0 0deg / 50%);
}

@media (prefers-color-scheme: dark) and (prefers-color-scheme: dark) {
  .vibe-shift {
    --input-bg: oklch(10% 0.02 260deg);
    --input-border: oklch(75% 0.2 130deg / 30%);
    --input-text: oklch(90% 0.01 160deg);
    --input-placeholder: oklch(55% 0.03 160deg);
    --input-shadow: inset 0 0 15px oklch(0% 0 0deg / 60%);
    --input-focus-glow: 0 0 0 3px oklch(75% 0.2 130deg / 40%), 0 0 10px oklch(75% 0.2 130deg / 20%);
    --icon-filter: invert(1) sepia(1) saturate(5) hue-rotate(80deg) brightness(140%) drop-shadow(0 0 4px) oklch(75% 0.2 130deg);
    --btn-icon-hover-bg: oklch(20% 0.03 260deg);
    --btn-icon-active-bg: oklch(75% 0.2 130deg / 20%);
    --pill-bg: oklch(12% 0.015 260deg);
    --pill-border: oklch(30% 0.03 260deg);
    --pill-text: oklch(55% 0.03 160deg);
    --pill-active-bg: oklch(75% 0.2 130deg);
    --pill-active-border: oklch(75% 0.2 130deg);
    --pill-active-text: oklch(5% 0 0 0deg);
    --pill-active-shadow: 0 0 12px oklch(75% 0. 2 130deg / 50%), inset 0 0 8px oklch(0% 0 0deg / 50%);
  }
}

/* =========================================
   CHAT LAYOUT
   ========================================= */
.chat-layout {
  background: transparent;
}

/* =========================================
   CHAT HEADER
   ========================================= */
.chat-header {
  padding: var(--space-3) var(--container-pad-mobile);
  padding-top: calc(var(--space-3) + var(--safe-top));
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--bg-surface);
  border-bottom: var(--border-glass);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.chat-header::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, oklch(99% 0.002 260deg / 60%), transparent);
  pointer-events: none;
}

.vibe-shift .chat-header {
  border-bottom: 1px solid oklch(75% 0.2 130deg / 20%);
  box-shadow: 0 2px 10px oklch(0% 0 0deg / 50%);
}

.chat-header__rules {
  flex: 0 0 auto;
  font-size: var(--font-size-sm);
  white-space: nowrap;
}

.chat-header__geo {
  flex: 1;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.vibe-shift .chat-header__geo {
  font-family: var(--font-vibe);
  text-shadow: 0 0 8px oklch(75% 0.2 130deg / 30%);
}

/* Индикатор неактивности сессии (chat_controller.js):
   idle — скрыт; warning (≤ 60 сек) — мягкая тревога; critical (≤ 30 сек) — усиление.
   Цвета — семантические токены (--color-warning/--color-error) всех 4 режимов,
   оттенки — color-mix, поэтому пилюля самонастраивается под тему. */
.chat-header__session {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  color: var(--text-secondary);
  background: transparent;
  white-space: nowrap;
  visibility: hidden;
  opacity: 0%;
  transform: translateY(2px);
  transition:
    opacity var(--duration-normal) var(--ease-out-quart),
    transform var(--duration-normal) var(--ease-out-quart),
    visibility 0s linear var(--duration-normal); /* скрытие — после fade-out */
}

/* Точка-статус наследует цвет состояния */
.chat-header__session::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentcolor;
  box-shadow: 0 0 0 0 transparent;
  flex-shrink: 0;
}

/* За минуту: тёплое предупреждение */
.chat-header__session[data-state='warning'] {
  visibility: visible;
  opacity: 100%;
  transform: translateY(0);
  transition-delay: 0s; /* появление — сразу, с fade-in */
  color: color-mix(in oklab, var(--color-warning) 65%, var(--text-primary));
  background: color-mix(in oklab, var(--color-warning) 12%, var(--bg-secondary));
  border-color: color-mix(in oklab, var(--color-warning) 38%, transparent);
}

.chat-header__session[data-state='warning']::before {
  box-shadow: 0 0 6px 1px color-mix(in oklab, var(--color-warning) 55%, transparent);
}

/* За полминуты: тревога + медленное дыхание свечения */
.chat-header__session[data-state='critical'] {
  visibility: visible;
  opacity: 100%;
  transform: translateY(0);
  transition-delay: 0s; /* появление — сразу, с fade-in */
  color: color-mix(in oklab, var(--color-error) 65%, var(--text-primary));
  background: color-mix(in oklab, var(--color-error) 10%, var(--bg-secondary));
  border-color: color-mix(in oklab, var(--color-error) 45%, transparent);
  animation: session-breathe 2s var(--ease-in-out-quart) infinite;
}

.chat-header__session[data-state='critical']::before {
  box-shadow: 0 0 6px 1px color-mix(in oklab, var(--color-error) 60%, transparent);
}

@keyframes session-breathe {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--color-error) 0%, transparent); }
  50% { box-shadow: 0 0 12px 1px color-mix(in oklab, var(--color-error) 30%, transparent); }
}

/* Vibe Shift: моноширинная архитектура деградации */
.vibe-shift .chat-header__session {
  font-family: var(--font-vibe);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  border-radius: 0;
}

/* Вайб: тревога — жёсткий аварийный бит «сломанного ИИ» */
.vibe-shift .chat-header__session[data-state='critical'] {
  color: var(--color-error);
  text-shadow: 0 0 8px color-mix(in oklab, var(--color-error) 60%, transparent);
  animation: session-alarm 1.6s steps(1, end) infinite;
}

@keyframes session-alarm {
  0%, 100% { opacity: 100%; }
  50% { opacity: 45%; }
}

/* Доступность: без движения — только цвет */
@media (prefers-reduced-motion: reduce) {
  .chat-header__session {
    transform: none;
    transition: none;
  }

  .chat-header__session[data-state='critical'] {
    animation: none;
  }
}

.chat-header__actions {
  display: flex;
  gap: var(--space-2);
}

.chat-header__geo {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header__instant,
.chat-header__report {
  flex-shrink: 0;
}

.farewell-bar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border: var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  animation: fade-in var(--duration-normal) var(--ease-out-quart);
}

.farewell-bar[hidden] { display: none; }

.farewell-bar__copy { font-size: var(--font-size-sm); }
.farewell-bar__undo { min-height: 44px; padding-inline: var(--space-3); }
.farewell-bar__line {
  grid-column: 1 / -1;
  height: 2px;
  overflow: hidden;
  background: var(--bg-surface-hover);
}

.farewell-bar__line::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent-primary);
  transform-origin: left;
  transform: scaleX(0);
}

.farewell-bar__line--running::after {
  animation: farewell-progress var(--farewell-duration, 5s) linear forwards;
}

.chat-input.is-farewell .chat-input__inner { display: none; }

@keyframes farewell-progress { to { transform: scaleX(1); } }

.chat-bubble--icebreaker,
.chat-bubble--nudge {
  padding: var(--space-3) var(--space-4);
  border-color: color-mix(in oklab, var(--accent-primary) 35%, transparent);
}

.chat-bubble--nudge-dismissed { display: none; }
.nudge__dismiss { margin-top: var(--space-2); min-height: 36px; padding: var(--space-1) var(--space-3); font-size: var(--font-size-xs); }

body.vibe-shift .farewell-bar { border-radius: 0; font-family: var(--font-vibe); text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  .farewell-bar { animation: none; }
  .farewell-bar__line--running::after { animation: none; transform: scaleX(1); }
}

/* =========================================
   CHAT BODY
   ========================================= */
.chat-body {
  flex: 1;
  padding: var(--space-4) var(--container-pad-mobile);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--bg-app);
  position: relative;
}

.vibe-shift .chat-body {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(/%23noiseFilter)' opacity='0.08'/%3E%3C/svg%3E");
}

/* =========================================
   CHAT BUBBLES
   ========================================= */
.chat-bubble {
  position: relative;
  width: fit-content;
  max-width: 88%;
  padding: 2px 4px;
  border-radius: var(--radius-md);
  animation: bubble-in 0.3s var(--ease-out-quart);
  font-size: var(--fs-body);
  line-height: 1.45;
  word-break: break-word;
  z-index: 1;
  transition: max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              border-radius 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-bubble p {
  white-space: pre-wrap;
}

.chat-bubble--me {
  background: var(--accent-primary);
  color: var(--accent-on-accent);
  border-bottom-left-radius: var(--radius-sm);
  align-self: flex-end;
  border: 1px solid oklch(from var(--accent-primary) calc(l - 0.04) c h);
  box-shadow:
    0 1px 1px oklch(from var(--accent-primary) calc(l + 0.03) c h / 60%),
    0 -1px 1px oklch(from var(--accent-primary) calc(l - 0.02) c h / 40%),
    inset 0 1px 1px oklch(from var(--accent-primary) calc(l + 0.08) c h / 50%),
    0 4px 12px oklch(15% 0.02 265deg / 12%),
    0 2px 4px oklch(15% 0.02 265deg / 8%);
}

@media (prefers-color-scheme: dark) {
  .chat-bubble--me {
    border: 1px solid oklch(from var(--accent-primary) calc(l - 0.03) c h);
    box-shadow:
      0 1px 1px oklch(from var(--accent-primary) calc(l + 0.06) c h / 50%),
      0 -1px 1px oklch(from var(--accent-primary) calc(l - 0.04) c h / 30%),
      inset 0 1px 1px oklch(from var(--accent-primary) calc(l + 0.1) c h / 40%),
      0 5px 16px oklch(0% 0 0deg / 25%),
      0 2px 5px oklch(0% 0 0deg / 15%);
  }
}

.vibe-shift .chat-bubble--me {
  border: 1px solid var(--accent-primary);
  box-shadow:
    0 0 0 1px oklch(from var(--accent-primary) c h / 50%),
    0 0 25px oklch(from var(--accent-primary) c h / 55%),
    0 0 50px oklch(from var(--accent-primary) c h / 28%),
    inset 0 0 15px oklch(from var(--accent-primary) c h / 18%);
}

.chat-bubble--stranger {
  background: oklch(94% 0.01 260deg);
  color: var(--text-primary);
  border-bottom-right-radius: var(--radius-sm);
  align-self: flex-start;
  border: 1px solid oklch(88% 0.012 260deg);
  box-shadow:
    0 1px 1px oklch(98% 0.008 260deg / 50%),
    0 -1px 1px oklch(85% 0.015 260deg / 30%),
    inset 0 1px 1px oklch(99% 0.005 260deg / 60%),
    0 4px 12px oklch(15% 0.02 260deg / 10%),
    0 2px 4px oklch(15% 0.02 260deg / 6%);
}

@media (prefers-color-scheme: dark) {
  .chat-bubble--stranger {
    background: oklch(28% 0.015 260deg);
    border: 1px solid oklch(35% 0.02 260deg / 50%);
    box-shadow:
      0 1px 1px oklch(42% 0.02 260deg / 45%),
      0 -1px 1px oklch(22% 0.015 260deg / 25%),
      inset 0 1px 1px oklch(38% 0.02 260deg / 40%),
      0 5px 16px oklch(0% 0 0deg / 22%),
      0 2px 5px oklch(0% 0 0deg / 14%);
  }
}

.vibe-shift .chat-bubble--stranger {
  background: oklch(20% 0.02 260deg);
  color: oklch(90% 0.01 160deg);
  border: 1px solid oklch(30% 0.03 160deg / 60%);
  box-shadow:
    0 0 0 1px oklch(30% 0.03 160deg / 50%),
    inset 0 1px 0 oklch(35% 0.03 160deg / 40%),
    inset 0 -1px 1px oklch(12% 0.02 260deg / 30%),
    0 0 15px oklch(55% 0.03 160deg / 20%);
}

.chat-bubble--bot {
  background: transparent;
  border: 1px dashed oklch(80% 0.01 260deg);
  color: var(--text-secondary);
  text-align: center;
  align-self: center;
  font-size: var(--fs-caption);
  max-width: 90%;
  border-radius: var(--radius-sm);
  padding: 6px 16px;
}

.vibe-shift .chat-bubble--bot {
  border-color: oklch(20% 0.02 260deg);
  font-family: var(--font-vibe);
}

.chat-bubble__time {
  font-size: 10px;
  opacity: 45%;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.chat-bubble:has(.ephemeral-media) .chat-bubble__time {
  display: none;
}

/* =========================================
   CHAT INPUT & CONTROLS
   ========================================= */
.chat-input {
  padding: var(--space-3) var(--container-pad-mobile);
  padding-bottom: calc(var(--space-3) + var(--safe-bottom));
  background: var(--bg-surface);
  border-top: var(--border-glass);
  flex-shrink: 0;
  position: relative;
}

.chat-input::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, oklch(50% 0.02 260deg / 10%), transparent);
  pointer-events: none;
}

.vibe-shift .chat-input {
  border-top: 1px solid oklch(75% 0.2 130deg / 20%);
}

.chat-input__inner {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.btn--icon img {
  filter: var(--icon-filter);
  transition: filter 0.2s ease;
  pointer-events: none;
}

.btn--icon:hover {
  background: oklch(0.95 0.01 260deg);
}

.btn--icon:active {
  background: var(--btn-icon-active-bg);
  transform: scale(0.95);
}

/* В тёмной теме при наведении иконка снова тёмная */
@media (prefers-color-scheme: dark) {
  .btn--icon:hover img {
    filter: opacity(55%);
  }
}

.vibe-shift .btn--icon {
  border-radius: 0;
  border: 1px solid transparent;
}

.vibe-shift .btn--icon:hover {
  border-color: oklch(75% 0.2 130deg / 40%);
  box-shadow: 0 0 10px oklch(75% 0.2 130deg / 20%);
}

.chat-input__text {
  flex: 1;
  field-sizing: content;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
  resize: none;
  vertical-align: bottom;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--input-text);
  font-family: var(--font-main);
  font-size: var(--fs-body);
  box-shadow: var(--input-shadow);
  transition: all 0.15s ease;
}

.chat-input__text::placeholder {
  color: var(--input-placeholder);
}

.chat-input__text:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--input-shadow), var(--input-focus-glow);
}

.vibe-shift .chat-input__text {
  border-radius: 0;
  font-family: var(--font-vibe);
  border-color: oklch(75% 0.2 130deg / 30%);
}

.chat-input__recorder,
.chat-input__cancel-btn,
.chat-input__send-voice-btn,
.chat-input__photo-editor,
.chat-input__cancel-photo-btn,
.chat-input__send-photo-btn {
  display: none;
}

.chat-input__cancel-btn {
  color: var(--color-error);
}

.chat-input__recorder {
  flex: 1;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-2);
  height: 40px;
}

.chat-input__wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
  flex: 1;
}

.chat-input__bar {
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  height: 6px;
  transition: height 0.1s ease;
}

.vibe-shift .chat-input__bar {
  box-shadow: 0 0 4px oklch(75% 0.2 130deg / 80%);
}

.chat-input__timer {
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text-secondary);
}

.vibe-shift .chat-input__timer {
  font-family: var(--font-vibe);
  color: var(--accent);
}

.chat-input.is-recording .chat-input__cancel-btn,
.chat-input.is-recording .chat-input__send-voice-btn,
.chat-input.is-recording .chat-input__recorder {
  display: flex;
}

.chat-input.is-recording .chat-input__attachments,
.chat-input.is-recording .chat-input__text,
.chat-input.is-recording [data-voice-recorder-target="recordBtn"],
.chat-input.is-recording [type="submit"] {
  display: none;
}

.chat-input.is-sending .chat-input__send-voice-btn {
  opacity: 40%;
  pointer-events: none;
}

/* =========================================
   INLINE PHOTO EDITOR
   ========================================= */
.chat-input__photo-editor {
  flex: 1;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  overflow: hidden;
  animation: fade-in 0.2s ease-out;
}

.chat-input__photo-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  box-shadow: var(--input-shadow);
}

.vibe-shift .chat-input__photo-thumb {
  border-radius: 0;
  border-color: oklch(75% 0.2 130deg / 40%);
  box-shadow: 0 0 12px oklch(75% 0.2 130deg / 25%);
}

.chat-input__photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-input__photo-timers {
  display: flex;
  gap: 6px;
  padding: 24px 32px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chat-input__photo-timers::-webkit-scrollbar {
  display: none;
}

.chat-input__photo-timer {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  color: var(--pill-text);
  font-size: var(--fs-caption);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  min-width: 52px;
}

.chat-input__photo-timer:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-input__photo-timer--active {
  background: var(--pill-active-bg) !important;
  border-color: var(--pill-active-border) !important;
  color: var(--pill-active-text) !important;
  transform: scale(1.05);
  box-shadow: var(--pill-active-shadow);
}

.vibe-shift .chat-input__photo-timer {
  border-radius: 0;
  font-family: var(--font-vibe);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.vibe-shift .chat-input__photo-timer--active {
  text-shadow: 0 0 6px oklch(75% 0.2 130deg);
  animation: timer-glitch 0.4s var(--spring-md);
}

.chat-input.is-attaching .chat-input__cancel-photo-btn,
.chat-input.is-attaching .chat-input__send-photo-btn,
.chat-input.is-attaching .chat-input__photo-editor {
  display: flex;
}

.chat-input.is-attaching .chat-input__attachments,
.chat-input.is-attaching .chat-input__text,
.chat-input.is-attaching [data-voice-recorder-target="recordBtn"],
.chat-input.is-attaching [type="submit"] {
  display: none;
}

.chat-input.is-sending {
  pointer-events: none;
}

.chat-input.is-sending .btn--icon {
  opacity: 40%;
  pointer-events: none;
}

.chat-input.is-sending .chat-input__text {
  opacity: 60%;
  pointer-events: none;
}

.chat-input.is-sending .chat-input__photo-timer {
  pointer-events: none;
  opacity: 60%;
}

.chat-input.is-sending [type="submit"] {
  opacity: 40%;
  pointer-events: none;
}

/* =========================================
   EPHEMERAL MEDIA - Простая архитектура
   ========================================= */

/* Balun с фото имеет стандартный padding */
.chat-bubble--me:has(.ephemeral-media),
.chat-bubble--stranger:has(.ephemeral-media) {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  position: relative;
}

/* Эскиз фото */
.ephemeral-media {
  position: relative;
  width: auto;
  height: auto;
  max-width: 240px;
  max-height: 240px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ephemeral-media:hover {
  transform: scale(1.02);
}

.ephemeral-media__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Blur для собеседника */
.ephemeral-media--blur .ephemeral-media__img {
  filter: blur(8px);
  -webkit-filter: blur(8px);
}

.ephemeral-media--blur::after {
  content: '';
  position: absolute;
  inset: 0;
  background: oklch(from var(--bg-surface) calc(l - 0.2) c h / 20%);
  pointer-events: none;
}

/* Таймер-плашка */
.ephemeral-media__timer-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: oklch(0% 0 0deg / 60%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 10;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

/* Текст таймера */
.ephemeral-media__timer {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: white;
  text-shadow: 0 1px 2px oklch(0% 0 0deg / 50%);
}

/* Иконки замка и огня - белые для плашки с тёмным фоном */
.ephemeral-media__lock-icon,
.ephemeral-media__fire-icon {
  width: 16px;
  height: 16px;
  filter: brightness(0) invert(1);
}

/* В тёмной теме - инвертировать обратно */
@media (prefers-color-scheme: dark) {
  .ephemeral-media__lock-icon,
  .ephemeral-media__fire-icon {
    filter: brightness(0) invert(1) opacity(70%);
  }
}

/* Vibe shift - неоновое свечение */
.vibe-shift .ephemeral-media__lock-icon,
.vibe-shift .ephemeral-media__fire-icon {
  filter: brightness(0) invert(1);
  drop-shadow: 0 0 4px oklch(75% 0.2 130deg);
}

/* =========================================
   EPHEMERAL MEDIA FORM - Запуск таймера
   ========================================= */

.ephemeral-media__form {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

.ephemeral-media__form button {
  background: none;
  border: none;
  padding: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: block;
}

/* Прогресс-крутилка */
.ephemeral-media__spinner {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.ephemeral-media__spinner-dot {
  width: 4px;
  height: 4px;
  background: white;
  border-radius: 50%;
  animation: spinner-bounce 1.4s infinite ease-in-out both;
}

.ephemeral-media__spinner-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.ephemeral-media__spinner-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.ephemeral-media__spinner-dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes spinner-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  
  40% {
    transform: scale(1);
  }
}

/* Expanded state */
.chat-bubble--expanded {
  max-width: 92vw !important;
  max-height: 80vh !important;
  width: 92vw !important;
  border-radius: var(--radius-lg);
  padding: var(--space-1);
  z-index: 100;
  background: oklch(8% 0.01 260deg);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0 auto;
}

.chat-bubble--expanded .ephemeral-media {
  max-width: none !important;
  max-height: 80vh !important;
  width: auto !important;
  height: auto !important;
}

.chat-bubble--expanded .ephemeral-media__img {
  object-fit: contain;
}

/* Снять blur при раскрытии (собеседник видит чёткое фото) */
.chat-bubble--expanded .ephemeral-media--blur .ephemeral-media__img {
  filter: none;
  -webkit-filter: none;
}

.chat-bubble--expanded .ephemeral-media--blur::after {
  display: none;  /* убрать затемнение */
}

.chat-bubble--expanded .ephemeral-media__timer-panel {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
}

/* Burned state */
.chat-bubble--me.chat-bubble--burned,
.chat-bubble--stranger.chat-bubble--burned {
  pointer-events: none;
  cursor: default;
  width: auto !important;
  max-width: none !important;
  display: inline-flex !important;
  flex-direction: column;
}

.ephemeral-media--burned {
  width: 100px !important;
  height: 100px !important;
  max-width: 100px !important;
  max-height: 100px !important;
  background: oklch(from var(--bg-surface) l c h / 50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* В burned состоянии timer-panel не absolute, так как это основное содержимое */
.ephemeral-media--burned .ephemeral-media__timer-panel {
  position: static;
  transform: none;
}

.ephemeral-media--burned .ephemeral-media__img {
  display: none;
}

[data-burned="true"] {
  pointer-events: none;
  cursor: default;
}

/* Vibe Shift */
.vibe-shift .ephemeral-media__timer {
  color: var(--accent);
  text-shadow: 0 0 12px oklch(75% 0.2 130deg / 80%);
  font-family: var(--font-vibe);
}

.vibe-shift .ephemeral-media--burned .ephemeral-media__timer-panel {
  background: oklch(10% 0.02 260deg);
  border: 1px solid oklch(20% 0.02 260deg);
}

/* =========================================
   VOICE MESSAGE - Архитектурная Эфемерность
   Премиальный аудио-интерфейс (2026)
   ========================================= */
.voice-message {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 16px;
  position: relative;
  min-height: 60px;
}

/* Волновая форма - 40 палочек для плавной визуализации */
.voice-message__wave {
  display: flex;
  align-items: center;
  gap: 1px;
  height: 36px;
  transition: opacity 0.3s var(--ease-out-quart);
  padding: 0 2px;
  flex: 1;
  min-width: 120px;
}

/* Палочка - архитектурная точность */
.voice-message__bar {
  width: 2px;
  background: var(--text-secondary);
  border-radius: 1px;
  height: var(--bar-height, 8px);
  transition:
    background-color 0.2s var(--ease-out-quart),
    height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.2s var(--ease-out-quart),
    transform 0.2s var(--ease-out-quart);
  will-change: background-color, height, box-shadow;
  position: relative;

  /* Архитектурный shading - многослойный volume */
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(180deg,
      oklch(100% 0 0deg / 8%) 0%,
      oklch(100% 0 0deg / 3%) 60%,
      transparent 100%);
    border-radius: 1px 1px 0 0;
    pointer-events: none;
  }

  /* Micro shadow для глубины */
  box-shadow:
    0 1px 0 oklch(0% 0 0deg / 6%),
    inset 0 -1px 1px oklch(0% 0 0deg / 8%);
}

/* Воспроизведение - премиальный accent */
.voice-message.is-playing .voice-message__bar {
  background: var(--accent-primary);

  /* Ambient glow при воспроизведении */
  box-shadow:
    0 0 0 1px oklch(from var(--accent-primary) calc(l - 0.02) c h / 30%),
    0 0 8px oklch(from var(--accent-primary) c h / 25%),
    0 1px 2px oklch(0% 0 0deg / 10%),
    inset 0 -1px 1px oklch(0% 0 0deg / 15%);
}

/* Активные палочки - контрастная яркость */
.voice-message.is-playing .voice-message__bar--active {
  background: var(--accent-on-accent);

  /* Premium glow для активного progress */
  box-shadow:
    0 0 0 1px oklch(from var(--accent-on-accent) c h / 40%),
    0 0 12px oklch(from var(--accent-on-accent) c h / 35%),
    0 2px 4px oklch(0% 0 0deg / 12%),
    inset 0 -1px 1px oklch(0% 0 0deg / 20%);

  /* Легкое увеличение для emphasis */
  transform: scaleY(1.05);
}

/* Контейнер для текста времени - inline positioning */
.voice-message__time-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  min-width: 40px;
  padding-left: var(--space-1);
}

/* Текущее время воспроизведения */
.voice-message__time {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-primary);
  opacity: 0%;
  transition: opacity 0.2s var(--ease-out-quart);
  pointer-events: none;
  text-align: right;
  line-height: 1;
}

.voice-message.is-playing .voice-message__time {
  opacity: 100%;
}

/* Длительность аудио (всегда видна) */
.voice-message__duration {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  text-align: right;
  line-height: 1;
}

/* Dark mode adjustments для контраста */
@media (prefers-color-scheme: dark) {
  .voice-message__time {
    color: var(--text-primary);
  }

  .voice-message__duration {
    color: var(--text-secondary);
  }

  .voice-message__bar {
    /* Увеличиваем контраст в тёмной теме */
    background: oklch(55% 0.02 265deg);
  }

  .voice-message.is-playing .voice-message__bar {
    background: var(--accent-primary);
  }
}

/* =========================================
   VOICE MESSAGE - AUTHOR MESSAGES (высокий контраст)
   Для тёмного фона авторских bubble используем полупрозрачный white
   ========================================= */

/* Сообщения от автора - тёмный фон */
.chat-bubble--me .voice-message__bar {
  background: oklch(100% 0 0deg / 45%);
  box-shadow:
    0 1px 0 oklch(100% 0 0deg / 12%),
    inset 0 -1px 1px oklch(0% 0 0deg / 15%);
}

.chat-bubble--me .voice-message__bar::before {
  background: linear-gradient(180deg,
    oklch(100% 0 0deg / 25%) 0%,
    oklch(100% 0 0deg / 10%) 60%,
    transparent 100%);
}

.chat-bubble--me .voice-message.is-playing .voice-message__bar {
  background: oklch(100% 0 0deg / 75%);
  box-shadow:
    0 0 0 1px oklch(100% 0 0deg / 20%),
    0 0 8px oklch(100% 0 0deg / 30%),
    0 1px 2px oklch(0% 0 0deg / 15%);
}

.chat-bubble--me .voice-message.is-playing .voice-message__bar--active {
  background: oklch(100% 0 0deg / 95%);
  box-shadow:
    0 0 0 1px oklch(100% 0 0deg / 40%),
    0 0 12px oklch(100% 0 0deg / 50%),
    0 2px 4px oklch(0% 0 0deg / 20%);
}

/* Chat-bubble--me dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .chat-bubble--me .voice-message__bar {
    background: oklch(100% 0 0deg / 50%);
  }

  .chat-bubble--me .voice-message.is-playing .voice-message__bar {
    background: oklch(100% 0 0deg / 80%);
  }

  .chat-bubble--me .voice-message.is-playing .voice-message__bar--active {
    background: oklch(100% 0 0deg / 100%);
  }

  /* Stranger messages в тёмной теме - такой же контраст как у автора */
  .chat-bubble--stranger .voice-message__bar {
    background: oklch(100% 0 0deg / 45%);
    box-shadow:
      0 1px 0 oklch(100% 0 0deg / 12%),
      inset 0 -1px 1px oklch(0% 0 0deg / 15%);
  }

  .chat-bubble--stranger .voice-message__bar::before {
    background: linear-gradient(180deg,
      oklch(100% 0 0deg / 25%) 0%,
      oklch(100% 0 0deg / 10%) 60%,
      transparent 100%);
  }

  .chat-bubble--stranger .voice-message.is-playing .voice-message__bar {
    background: oklch(100% 0 0deg / 75%);
    box-shadow:
      0 0 0 1px oklch(100% 0 0deg / 20%),
      0 0 8px oklch(100% 0 0deg / 30%),
      0 1px 2px oklch(0% 0 0deg / 15%);
  }

  .chat-bubble--stranger .voice-message.is-playing .voice-message__bar--active {
    background: oklch(100% 0 0deg / 95%);
    box-shadow:
      0 0 0 1px oklch(100% 0 0deg / 40%),
      0 0 12px oklch(100% 0 0deg / 50%),
      0 2px 4px oklch(0% 0 0deg / 20%);
  }
}

/* Text colors for author messages - высокий контраст на тёмном фоне */
.chat-bubble--me .voice-message__time {
  color: oklch(98% 0.002 265deg);
}

.chat-bubble--me .voice-message__duration {
  color: oklch(98% 0.002 265deg / 75%);
}

/* =========================================
   VOICE MESSAGE - VIBE SHIFT MODE
   Void Noise: цифровая деградация
   ========================================= */
.vibe-shift .voice-message {
  gap: var(--space-2);
}

.vibe-shift .voice-message__wave {
  gap: 1px;
  height: 36px;
}

.vibe-shift .voice-message__bar {
  width: 2px;
  border-radius: 0;

  /* Digital grain - убрать плавные градиенты */
  &::before {
    display: none;
  }

  /* Cyber shadow - агрессивное свечение */
  box-shadow:
    0 0 4px oklch(75% 0.2 130deg / 40%),
    inset 0 0 2px oklch(0% 0 0deg / 30%);
}

/* Acid green при воспроизведении */
.vibe-shift .voice-message.is-playing .voice-message__bar {
  background: oklch(65% 0.18 130deg);
  box-shadow:
    0 0 6px oklch(75% 0.2 130deg / 60%),
    0 0 12px oklch(75% 0.2 130deg / 30%),
    inset 0 0 2px oklch(75% 0.2 130deg / 40%);
}

/* Toxic green для активного progress */
.vibe-shift .voice-message.is-playing .voice-message__bar--active {
  background: oklch(85% 0.25 130deg);
  box-shadow:
    0 0 0 1px oklch(85% 0.25 130deg / 50%),
    0 0 16px oklch(85% 0.25 130deg / 70%),
    0 0 24px oklch(75% 0.2 130deg / 40%),
    inset 0 0 3px oklch(100% 0 0deg / 30%);

  /* Jitter эффект для цифровой нестабильности */
  animation: bar-jitter 0.15s steps(2) infinite alternate;
}

/* Время в Vibe Shift - неоновое свечение с улучшенной читаемостью */
.vibe-shift .voice-message__time {
  font-family: var(--font-vibe);
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0%;
  color: oklch(85% 0.25 130deg);
  text-shadow:
    0 0 8px oklch(75% 0.2 130deg / 80%),
    0 0 4px oklch(75% 0.2 130deg / 50%);
}

.vibe-shift .voice-message.is-playing .voice-message__time {
  opacity: 100%;
}

/* Длительность в Vibe Shift */
.vibe-shift .voice-message__duration {
  font-family: var(--font-vibe);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Digital jitter animation */
@keyframes bar-jitter {
  0% { transform: scaleY(1) translateX(0); }
  100% { transform: scaleY(1.02) translateX(0.5px); }
}

/* =========================================
   VIBE SHIFT - AUTHOR MESSAGES (тёмный фон bubble)
   Acid green палочки на тёмном accent фоне
   ========================================= */

/* Авторские сообщения в Vibe Shift - базовые палочки */
.vibe-shift .chat-bubble--me .voice-message__bar {
  background: oklch(75% 0.22 130deg / 40%);
  box-shadow:
    0 0 6px oklch(75% 0.2 130deg / 50%),
    inset 0 0 2px oklch(0% 0 0deg / 40%);
}

/* Воспроизведение - более яркий acid green */
.vibe-shift .chat-bubble--me .voice-message.is-playing .voice-message__bar {
  background: oklch(80% 0.25 130deg / 65%);
  box-shadow:
    0 0 10px oklch(75% 0.2 130deg / 60%),
    inset 0 0 3px oklch(0% 0 0deg / 50%);
}

/* Активный progress - максимальная яркость */
.vibe-shift .chat-bubble--me .voice-message.is-playing .voice-message__bar--active {
  background: oklch(92% 0.28 130deg);
  box-shadow:
    0 0 0 1px oklch(92% 0.28 130deg / 60%),
    0 0 20px oklch(92% 0.28 130deg / 80%),
    0 0 30px oklch(75% 0.2 130deg / 50%),
    inset 0 0 4px oklch(100% 0 0deg / 40%);
}

/* Text colors for author messages in Vibe Shift - неоновый acid green */
.vibe-shift .chat-bubble--me .voice-message__time {
  color: oklch(92% 0.28 130deg);
  text-shadow:
    0 0 10px oklch(75% 0.2 130deg / 70%),
    0 0 5px oklch(75% 0.2 130deg / 40%);
}

.vibe-shift .chat-bubble--me .voice-message__duration {
  color: oklch(88% 0.25 130deg / 80%);
  text-shadow:
    0 0 8px oklch(75% 0.2 130deg / 60%);
}

/* =========================================
   VIBE SHIFT DARK MODE - Улучшенная читаемость
   ========================================= */
@media (prefers-color-scheme: dark) {
  .vibe-shift .voice-message__time {
    color: oklch(88% 0.25 130deg);
    text-shadow:
      0 0 12px oklch(75% 0.2 130deg / 90%),
      0 0 6px oklch(75% 0.2 130deg / 60%);
  }

  .vibe-shift .voice-message__duration {
    color: oklch(65% 0.03 160deg);
  }

  .vibe-shift .voice-message__bar {
    background: oklch(35% 0.03 160deg);
    box-shadow:
      0 0 6px oklch(75% 0.2 130deg / 50%),
      inset 0 0 2px oklch(0% 0 0deg / 40%);
  }

  .vibe-shift .voice-message.is-playing .voice-message__bar {
    background: oklch(70% 0.22 130deg);
  }

  .vibe-shift .voice-message.is-playing .voice-message__bar--active {
    background: oklch(90% 0.28 130deg);
    box-shadow:
      0 0 0 1px oklch(90% 0.28 130deg / 60%),
      0 0 20px oklch(90% 0.28 130deg / 80%),
      0 0 30px oklch(75% 0.2 130deg / 50%),
      inset 0 0 4px oklch(100% 0 0deg / 40%);
  }

  /* Author messages in Vibe Shift Dark - acid green на тёмном */
  .vibe-shift .chat-bubble--me .voice-message__bar {
    background: oklch(75% 0.22 130deg / 50%);
    box-shadow:
      0 0 8px oklch(75% 0.2 130deg / 60%),
      inset 0 0 2px oklch(0% 0 0deg / 50%);
  }

  .vibe-shift .chat-bubble--me .voice-message.is-playing .voice-message__bar {
    background: oklch(82% 0.25 130deg / 70%);
    box-shadow:
      0 0 12px oklch(75% 0.2 130deg / 70%),
      inset 0 0 3px oklch(100% 0 0deg / 30%);
  }

  .vibe-shift .chat-bubble--me .voice-message.is-playing .voice-message__bar--active {
    background: oklch(95% 0.28 130deg);
    box-shadow:
      0 0 0 1px oklch(95% 0.28 130deg / 70%),
      0 0 24px oklch(95% 0.28 130deg / 90%),
      0 0 36px oklch(75% 0.2 130deg / 60%),
      inset 0 0 5px oklch(100% 0 0deg / 50%);
  }

  /* Text colors for author messages in Vibe Shift Dark */
  .vibe-shift .chat-bubble--me .voice-message__time {
    color: oklch(95% 0.28 130deg);
    text-shadow:
      0 0 14px oklch(75% 0.2 130deg / 80%),
      0 0 8px oklch(75% 0.2 130deg / 50%);
  }

  .vibe-shift .chat-bubble--me .voice-message__duration {
    color: oklch(90% 0.25 130deg / 85%);
    text-shadow:
      0 0 10px oklch(75% 0.2 130deg / 70%);
  }
}

/* =========================================
   TOAST
   ========================================= */
.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: oklch(15% 0.02 260deg);
  color: oklch(95% 0.01 260deg);
  font-size: var(--fs-caption);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toast-in 0.2s ease-out;
  box-shadow: 0 8px 30px oklch(0% 0 0deg / 30%);
}

.vibe-shift .toast {
  border: 1px solid oklch(75% 0.2 130deg / 30%);
  border-radius: 0;
  font-family: var(--font-vibe);
  color: var(--accent);
}

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes toast-in {
  from {
    opacity: 0%;
    transform: translateX(-50%) translateY(10px);
  }

  to {
    opacity: 100%;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes timer-glitch {
  0% { transform: scale(1.05) translate(0); }
  20% { transform: scale(1.05) translate(-2px, 0); }
  40% { transform: scale(1.05) translate(2px, 0); }
  60% { transform: scale(1.05) translate(-1px, 0); }
  80% { transform: scale(1.05) translate(1px, 0); }
  100% { transform: scale(1.05) translate(0); }
}

@keyframes bubble-in {
  from {
    opacity: 0%;
    transform: translateY(10px) scale(0.97);
  }

  to {
    opacity: 100%;
    transform: translateY(0) scale(1);
  }
}

@keyframes fade-in {
  from { opacity: 0%; }

  to { opacity: 100%; }
}
