/* Flow Mini App — ИИ-двойник */

.twin-mark {
  background: linear-gradient(135deg, var(--flow), #8b5cf6);
}

.twin-root {
  padding-bottom: 8px;
}

/* ---------- Главная карточка с переключателем ---------- */
.twin-hero {
  margin: 4px 14px 0;
  padding: 18px 18px 16px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.twin-hero.is-on {
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(139, 92, 246, 0.22), transparent 55%),
    radial-gradient(120% 140% at 0% 100%, rgba(var(--flow-rgb), 0.2), transparent 60%),
    var(--surface);
  box-shadow: inset 0 0 0 1px rgba(var(--flow-rgb), 0.35);
}

.hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.hero-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.hero-sub {
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.twin-hero.is-on .hero-sub {
  color: var(--flow);
  font-weight: 600;
}

.hero-note {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-2);
}

/* ---------- Переключатель ---------- */
.switch {
  position: relative;
  flex-shrink: 0;
  width: 54px;
  height: 32px;
  border-radius: 16px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.22s var(--ease);
}

.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.25);
  transition: transform 0.22s var(--ease);
}

.switch.on {
  background: var(--flow);
}

.switch.on i {
  transform: translateX(22px);
}

.switch.sm {
  width: 46px;
  height: 28px;
}

.switch.sm i {
  width: 22px;
  height: 22px;
}

.switch.sm.on i {
  transform: translateX(18px);
}

/* ---------- Карточки и поля ---------- */
.card {
  margin: 0 14px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.card.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-text {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-2);
  margin-bottom: 12px;
}

.card.stack .card-text {
  margin-bottom: 0;
}

.card-text.muted {
  font-size: 12.5px;
  color: var(--ink-3);
}

.tone-flow {
  color: var(--flow) !important;
}

.field {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  border: 0;
  outline: none;
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow 0.15s ease;
}

.field:focus {
  box-shadow: inset 0 0 0 1.5px var(--flow);
}

.field::placeholder {
  color: var(--ink-3);
}

.area {
  resize: none;
  line-height: 1.4;
  margin-top: 8px;
}

.opt {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opt-inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.opt-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.opt-hint {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.35;
}

/* ---------- Сегменты ---------- */
.seg {
  display: flex;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: var(--surface-2);
}

.seg-btn {
  flex: 1;
  min-width: 0;
  padding: 8px 6px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.18s ease, color 0.18s ease;
}

.seg-btn.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12), inset 0 0 0 1px var(--line);
}

.card > .seg {
  margin-bottom: 12px;
}

/* ---------- Чипсы ---------- */
.chip-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip-row.wrap {
  flex-wrap: wrap;
  overflow: visible;
}

.chip {
  flex-shrink: 0;
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  transition: background 0.18s ease, color 0.18s ease;
}

.chip.on {
  color: #fff;
  background: var(--flow);
}

/* ---------- Примеры стиля: как исходящие пузыри ---------- */
.ex-list {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-height: 290px;
  overflow-y: auto;
  scrollbar-width: none;
  margin: 0 -2px;
  padding: 2px;
}

.ex-list::-webkit-scrollbar {
  display: none;
}

.ex {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  max-width: 88%;
  padding: 8px 8px 8px 12px;
  border-radius: 16px 16px 5px 16px;
  background: var(--bubble-out);
  font-size: 14.5px;
  line-height: 1.35;
  animation: viewEnter 0.2s ease;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.ex.leaving {
  opacity: 0;
  transform: scale(0.96);
}

.ex-text {
  word-break: break-word;
}

.ex-del {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: -1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  background: rgba(16, 24, 40, 0.06);
}

.ex-empty {
  align-self: stretch;
  padding: 18px 12px;
  border-radius: 14px;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-3);
  background: var(--surface-2);
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-soft,
.btn-ghost {
  flex: 1;
  height: 44px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn-soft {
  color: #fff;
  background: var(--flow);
}

.btn-ghost {
  flex: 0 0 auto;
  padding: 0 14px;
  color: var(--flow);
  background: var(--flow-soft);
}

.btn-soft:active,
.btn-ghost:active {
  transform: scale(0.97);
}

.btn-ghost:disabled,
.btn-primary:disabled {
  opacity: 0.45;
}

/* ---------- Ползунки ---------- */
.range-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.range-head b {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
  color: var(--flow);
  white-space: nowrap;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
}

input[type='range']::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(16, 24, 40, 0.3), inset 0 0 0 6px var(--flow);
}

input[type='range']::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(16, 24, 40, 0.3), inset 0 0 0 6px var(--flow);
}

/* ---------- Проверка ---------- */
.test-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
  border-radius: 14px;
  background: var(--paper);
  scrollbar-width: none;
}

.test-log::-webkit-scrollbar {
  display: none;
}

.test-empty {
  margin: auto;
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
}

.tb {
  max-width: 82%;
  padding: 8px 12px;
  font-size: 14.5px;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
  animation: viewEnter 0.22s ease;
}

.tb-in {
  align-self: flex-start;
  border-radius: 16px 16px 16px 5px;
  background: var(--bubble-in);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tb-out {
  align-self: flex-end;
  border-radius: 16px 16px 5px 16px;
  background: var(--bubble-out);
}

.tb.typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
}

.tb.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: typingDot 1.1s infinite ease-in-out;
}

.tb.typing i:nth-child(2) { animation-delay: 0.15s; }
.tb.typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.test-form {
  display: flex;
  gap: 8px;
  margin: 10px 0 8px;
}

.test-form .field {
  margin-top: 0;
}

.send-btn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--flow);
}

.send-btn:active {
  transform: scale(0.95);
}

.twin-bottom-pad {
  height: 12px;
}

/* ---------- Лист выбора сообщений ---------- */
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 18px 16px calc(14px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  animation: sheetUp 0.34s var(--ease);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-title {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sheet-sub {
  margin: 4px 0 12px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.sheet .search-inline {
  margin: 0 0 10px;
}

.sheet .chip-row {
  margin-bottom: 10px;
}

.pick-list {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: none;
}

.pick-list::-webkit-scrollbar {
  display: none;
}

.pick {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  text-align: left;
  background: var(--surface-2);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.pick.on {
  background: var(--flow-soft);
  box-shadow: inset 0 0 0 1.5px var(--flow);
}

.pick-check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: transparent;
  box-shadow: inset 0 0 0 2px var(--ink-3);
  transition: background 0.15s ease;
}

.pick.on .pick-check {
  color: #fff;
  background: var(--flow);
  box-shadow: none;
}

.pick-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pick-text {
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--ink);
  word-break: break-word;
}

.pick-meta {
  font-size: 12px;
  color: var(--ink-3);
}

.sheet-foot {
  padding-top: 12px;
}

/* ---------- Тост ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 120;
  width: max-content;
  max-width: calc(100% - 40px);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  background: rgba(16, 24, 40, 0.88);
  animation: viewEnter 0.18s ease;
  pointer-events: none;
}

.toast.toast-bad {
  background: var(--caught);
}

/* Исключённые чаты — красным: здесь двойник молчит */
.chip.chip-off.on {
  background: var(--caught);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
