/* agent: стили части «agent» второго захода (18.10.2026).
   Вкладка агента как мессенджер: лента по дням, пузыри, поле ввода
   закреплено над меню. Макеты A09 (разговор) и A10 (утро). */

/* ---------- шапка вкладки ---------- */

body[data-tab="agent"] .header { border-bottom: 1px solid var(--line); }

.agenthead { display: flex; align-items: center; gap: 10px; min-width: 0; }
.agenthead__titles { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.agenthead__title {
  margin: 0; font-family: var(--serif); font-weight: 400; font-size: 21px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.agenthead__sub {
  margin: 0; font-size: 13px; line-height: 1.3; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.agenthead__sub.is-typing { color: var(--accent-dark); font-weight: 600; }

.avatar { display: inline-block; flex: none; border-radius: 50%; line-height: 0; }
.avatar svg { display: block; }

/* ---------- лента ---------- */

/* Под лентой место под закреплённое поле: его высоту меряет ui-agent.js. */
.agent { padding-bottom: calc(var(--agent-dock-h, 130px) - 24px + var(--status-h, 0px)); }
.agent__feed { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }

.agent__day {
  display: flex; align-items: center; gap: 10px; margin: 12px 6px 6px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.agent__day::before, .agent__day::after { content: ''; flex: 1 1 auto; height: 1px; background: var(--line); }

.agent__group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.agent__group--me { align-items: flex-end; }
/* ряд во всю ширину ленты: иначе пузырь считает свои 78% от собственной ширины и рвёт строку на слова */
.agent__row { display: flex; align-items: flex-start; gap: 8px; min-width: 0; width: 100%; }
.agent__row--me { justify-content: flex-end; }
/* аватар у верхнего края пузыря, как в макете A09: видно, кто начал говорить */
.agent__avatar { flex: none; width: 28px; height: 28px; margin-top: 2px; }
.agent__avatar--gap { display: inline-block; }

.agent__time { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.2; }
.agent__group--agent .agent__time { margin-left: 36px; }
.agent__group--me .agent__time { margin-right: 4px; }

/* ---------- пузыри ---------- */

.bubble {
  padding: 10px 14px; border-radius: 20px;
  font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; min-width: 0;
}
.bubble--me {
  max-width: min(78%, 420px); background: var(--accent-btn); color: #fff;
  border-bottom-right-radius: 6px; white-space: pre-wrap;
}
.bubble--agent {
  max-width: min(calc(100% - 44px), 460px); background: var(--card); border: 1px solid var(--line);
  border-bottom-left-radius: 6px; color: var(--text);
}
.bubble--error {
  max-width: min(calc(100% - 44px), 460px); background: #f7ebd8; border: 1px solid #ebd2ab;
  border-bottom-left-radius: 6px; color: var(--text);
}
.bubble__p { margin: 0 0 8px; white-space: pre-wrap; }
.bubble__p:last-child { margin-bottom: 0; }
.bubble__clip {
  display: inline-block; margin-right: 6px; padding: 1px 8px;
  border-radius: 999px; background: rgba(255, 255, 255, .25); font-size: 12px;
}
.bubble__retry {
  margin-top: 6px; min-height: 44px; padding: 0 16px; border-radius: 22px;
  border: 1px solid var(--sand); background: var(--card); color: var(--sand-deep);
  font-size: 14px; font-weight: 600;
}

/* ---------- карточка записи внутри ответа ---------- */

.rec__wrap, .rec--line {
  display: flex; align-items: center; gap: 0; min-width: 0;
  margin: 8px -4px; border-radius: 14px; background: var(--bg);
}
.bubble--agent > .rec__wrap:first-child, .bubble--agent > .rec--line:first-child { margin-top: 0; }
.bubble--agent > .rec__wrap:last-child, .bubble--agent > .rec--line:last-child { margin-bottom: 0; }
.rec {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 10px 6px 10px 10px; border: 0; background: none; color: inherit; text-align: left;
  font: inherit; border-radius: 14px;
}
button.rec:active { background: var(--card-2); }
.rec__pic {
  flex: none; width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: var(--card-2);
}
.rec__pic img, .rec__pic .photo-stub { width: 100%; height: 100%; object-fit: cover; display: block; font-size: 0; }
/* без снимка: тарелка рисунком, а не пустой кружок */
.rec__pic--none {
  background:
    radial-gradient(circle at 46% 54%, #d9b36c 0 22%, transparent 23%),
    radial-gradient(circle, #fff 0 60%, #e4dccb 61% 64%, transparent 65%),
    #e9dfcf;
}
.rec__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rec__title {
  font-size: 15px; line-height: 1.3; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.rec__big { font-family: var(--serif); font-size: 22px; line-height: 1.15; color: var(--text); }
.rec__sub { font-size: 13px; line-height: 1.3; color: var(--muted); }
.rec__undo {
  flex: none; min-height: 44px; min-width: 44px; padding: 0 10px;
  border: 0; background: none; color: var(--accent-dark); font-size: 13px; font-weight: 600;
}
.rec__undo:disabled { opacity: .5; }
.rec__done { flex: none; padding: 0 12px; font-size: 13px; color: var(--muted); }
.rec__done:empty { display: none; }
.rec__line { flex: 1 1 auto; min-width: 0; padding: 10px 12px; font-size: 14px; line-height: 1.35; }
/* давление 180/120 и выше: песочным, без красного */
.rec__wrap:has(.rec--urgent), .rec--line.rec--urgent { background: #f7ebd8; box-shadow: inset 0 0 0 1px var(--sand); }
.rec.is-undone, .rec--line.is-undone { opacity: .55; }
.rec.is-undone .rec__title, .rec.is-undone .rec__big { text-decoration: line-through; text-decoration-color: var(--muted); }

/* ---------- «печатает» ---------- */

.bubble--typing { display: inline-flex; align-items: center; gap: 5px; width: 64px; height: 40px; padding: 0 14px; }
.typing__dot {
  width: 8px; height: 8px; border-radius: 50%; background: #9a9384;
  animation: typing 1.2s ease-in-out infinite;
}
.typing__dot:nth-child(2) { animation-delay: .15s; }
.typing__dot:nth-child(3) { animation-delay: .3s; }
@keyframes typing {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.typing__step { align-self: center; font-size: 12px; color: var(--muted); }

/* ---------- чипы ---------- */

.agent__chips { display: flex; gap: 8px; }
.agent__next { flex-wrap: wrap; row-gap: 10px; margin: 2px 0 8px 36px; }
.achip {
  position: relative; flex: none;
  min-height: 36px; padding: 0 13px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 13.5px; font-weight: 500; line-height: 1.2; white-space: nowrap;
}
.achip:active { background: var(--accent-soft); border-color: var(--accent); }
/* зона касания 44, вид не меняется */
.achip::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
}

/* ---------- пустой экран ---------- */

.agent__empty {
  min-height: calc(100dvh - 64px - var(--nav-h) - var(--agent-dock-h, 130px) - 60px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 24px 12px; text-align: center;
}
.agent__empty-text { margin: 0; max-width: 270px; font-size: 15px; line-height: 1.45; color: var(--muted); }

/* ---------- поле ввода над меню ---------- */

.agent__dock {
  position: fixed; z-index: 22;
  left: 50%; transform: translateX(-50%); width: min(100%, var(--app-w));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 14px 12px 10px;
  background: linear-gradient(to top, var(--bg) 82%, rgba(247, 244, 236, 0));
  display: flex; flex-direction: column; gap: 10px;
}
.agent__hints {
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin: 0 -12px; padding: 5px 12px;
}
.agent__hints::-webkit-scrollbar { display: none; }
.agent__hints .achip { min-height: 34px; background: var(--bg-soft); color: var(--accent-dark); border-color: #cfe3d0; }

.agent__bar { display: flex; align-items: flex-end; gap: 6px; }
.agent__photo { color: var(--muted); margin-bottom: 2px; }
.agent__photo svg { width: 24px; height: 24px; }
.agent__photo:disabled { opacity: .4; }
.agent__input {
  flex: 1 1 auto; min-width: 0; min-height: 48px; max-height: 120px;
  padding: 12px 18px; border-radius: 24px; border: 1px solid #d6cfbc;
  background: var(--card); color: var(--text);
  font: inherit; font-size: 15px; line-height: 1.4; resize: none; overflow-y: auto;
}
.agent__input::placeholder { color: #9a9384; }
.agent__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.agent__main {
  flex: none; display: grid; place-items: center;
  width: 56px; height: 56px; margin-left: 2px; margin-bottom: -4px; border-radius: 50%;
  border: 0; background: var(--accent-btn); color: #fff;
  box-shadow: 0 4px 12px rgba(47, 43, 37, .2);
}
.agent__main svg { width: 26px; height: 26px; }
.agent__main:active { transform: scale(.96); }
.agent__main:disabled { opacity: .5; }
.agent__main.is-listening { background: var(--accent-dark); animation: listen 1.4s ease-out infinite; }
@keyframes listen {
  0% { box-shadow: 0 0 0 0 rgba(53, 147, 90, .45); }
  100% { box-shadow: 0 0 0 14px rgba(53, 147, 90, 0); }
}

.agent__shots { display: flex; gap: 8px; }
.agent__shot { position: relative; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; background: var(--card-2); }
.agent__shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.agent__shot-del {
  position: absolute; top: 0; right: 0; width: 28px; height: 28px;
  border: 0; border-radius: 0 0 0 10px; background: rgba(47, 43, 37, .55); color: #fff;
  font-size: 18px; line-height: 1;
}
.agent__shot-del::after { content: ''; position: absolute; inset: -8px -8px -8px -8px; }

/* Полоса фоновых дел и подсказки встают над полем ввода, а не под него. */
body[data-tab="agent"] .statusbar { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--agent-dock-h, 130px) + 4px); }
body[data-tab="agent"] .toasts { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--agent-dock-h, 130px) + 8px); }
/* поверх вкладки открыт экран со стрелкой: поле агента под ним не нужно */
body.has-layer .agent__dock { display: none; }

/* ---------- «⋯»: что умею, начать заново ---------- */

.amenu { display: flex; flex-direction: column; gap: 8px; }
.amenu__row {
  display: flex; align-items: center; gap: 12px; min-height: 60px; width: 100%;
  padding: 10px 12px 10px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); text-align: left;
}
.amenu__text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.amenu__title { font-size: 16px; }
.amenu__sub { font-size: 13px; color: var(--muted); line-height: 1.3; }
.amenu__chev { flex: none; color: #9a9384; line-height: 0; }
.amenu__ask.sheet__ask { position: static; padding: 4px 0 0; box-shadow: none; border: 0; border-radius: 0; background: none; }

.askills { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.4; }
.askills__foot { margin: 14px 0 0; font-size: 13px; }

@media (min-width: 620px) {
  .agent__dock { padding-left: 16px; padding-right: 16px; }
}
