/* Оформление снято с макета Figma «Ластик: фикс дизайна», ряд MVP (без истории):
 * ПР3 — страница на Ньютоне (565:7405), макет чат-окна (565:7634), карточка
 * кнопок payload.form (565:8103). Цвета, градиенты, радиусы и кегли — из макета
 * один в один; добавлены только состояния, которых в макете нет (фокус, disabled,
 * системные сообщения фронта, экран входа) — они собраны из тех же токенов.
 *
 * Шрифты лежат рядом (assets/fonts): стенд бывает офлайн, внешний CDN недопустим.
 * Inter — переменный, одним файлом на подмножество закрывает 400–600. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
/* PT Sans — только меню портала в шапке. */
@font-face {
  font-family: "PT Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/ptsans-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "PT Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/ptsans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

:root {
  /* Фон: страница портала под шапкой залита градиентом из макета. */
  --page-bg: #f2f2f2;
  --page-grad: linear-gradient(155.26deg, #ffffff 10.87%, #f7fafd 47.1%, #edf3fa 83.33%);

  --surface: #ffffff;      /* neutral/bg_white */
  --line: #e4e9f0;         /* границы карточек чата */
  --line-strong: #d8dee7;  /* граница поля ввода */
  --line-gray: #e3e5e8;    /* neutral/line gray — аватар в шапке портала */

  --ink: #30353b;          /* текст реплик и заголовок */
  --ink-soft: #747f8b;     /* primary/main gray — подзаголовок */
  --muted: #8a93a1;        /* подпись «Ластик · 12:03», сноска */
  --muted-2: #9aa1ac;      /* подпись «Вы · 12:03», плейсхолдер */

  /* Фирменный градиент Ластика. Один набор стопов, три угла из макета:
   * знак и круглая кнопка отправки — 109.89°, пузырь сотрудника — 147.29°,
   * кнопка карточки — 171.43°. */
  --brand-cool: #1a85b4;
  --brand-warm: #c55c36;
  --brand-badge: linear-gradient(109.89deg, #1a85b4 1.56%, #5e7288 28.13%, #8b6c76 51.56%, #c55c36 76.56%);
  --brand-bubble: linear-gradient(147.29deg, #1a85b4 1.56%, #5e7288 28.13%, #8b6c76 51.56%, #c55c36 76.56%);
  --brand-button: linear-gradient(171.43deg, #1a85b4 1.56%, #5e7288 28.13%, #8b6c76 51.56%, #c55c36 76.56%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--page-bg);
}

.hidden { display: none !important; }

/* --- шапка портала Ньютон (статичная) -------------------------------------- */
.portal {
  height: 90px;
  background: url("/assets/newton-header-bg.png") center / cover no-repeat;
}
.portal-inner {
  max-width: 1280px;
  height: 100%;
  margin: 0 auto;
  padding: 19px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.portal-logo { width: 212px; height: 52.22px; flex-shrink: 0; }
.portal-menu {
  display: flex;
  align-items: center;
  gap: 40px;
  font-family: "PT Sans", "Inter", sans-serif;
  font-size: 16px;
  line-height: 1.3;
  color: #fff;
  text-transform: uppercase;
  white-space: nowrap;
}
.portal-icons { display: flex; align-items: center; gap: 24px; flex-shrink: 0; }
.portal-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.portal-icon-bell { width: 24px; height: 33.31px; }
.portal-icon-chat { width: 30px; height: 30px; }
.portal-avatar {
  width: 48px;
  height: 48px;
  border-radius: 130px;
  background: var(--line-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.portal-avatar img { width: 17.4px; height: 18.44px; }

/* --- страница Ластика ------------------------------------------------------- */
.page {
  height: calc(100vh - 90px);
  padding: 32px 20px;
  background: var(--page-grad);
  display: flex;
  justify-content: center;
}
.assistant {
  width: 920px;
  max-width: 100%;
  height: min(826px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.assistant-head {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}
.assistant-badge {
  width: 30px;
  height: 30px;
  border-radius: 9.6px;
  background: var(--brand-badge);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.assistant-badge img { width: 20px; height: 20px; }
.assistant-title { flex: 1; min-width: 0; }
.assistant-name { font-size: 17px; font-weight: 500; color: var(--ink); }

.session { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.session-user { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; }
.session-user:empty { display: none; }

/* Первичная кнопка макета: тот же градиент и радиус, что у кнопки карточки. */
.btn-primary {
  height: 34px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: var(--brand-button);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-primary:disabled { opacity: .45; cursor: default; }
.btn-wide { width: 100%; height: 46px; font-size: 14.5px; }
.btn-ghost {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--brand-cool); color: var(--brand-cool); }

/* --- лента ------------------------------------------------------------------ */
.feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Подпись реплики: у сотрудника — над пузырём справа, у Ластика — внутри карточки. */
.msg-label { font-size: 11.5px; color: var(--muted-2); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.msg.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}
.msg.user .msg-text {
  max-width: 460px;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--brand-bubble);
  color: #fff;
  font-size: 15px;
}

.msg.bot,
.msg.typing {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 15px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.msg.bot .msg-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.msg.bot .msg-text { font-size: 15px; color: var(--ink); }

/* ДФ5: индикатор ожидания ответа — карточка Ластика без подписи. */
.msg.typing { color: var(--muted); font-size: 15px; }

/* ДФ6/FR-036: системные сообщения фронта отличимы от сообщений Ластика.
 * Тёплый конец фирменного градиента — единственный акцент, который макет
 * оставляет под предупреждения. */
.msg.system {
  align-self: center;
  max-width: 560px;
  padding: 10px 16px;
  background: rgba(197, 92, 54, .05);
  border: 1px solid rgba(197, 92, 54, .24);
  border-radius: 12px;
  color: var(--brand-warm);
  font-size: 13px;
  text-align: center;
}
.msg.system button.retry {
  margin-top: 8px;
  height: 30px;
  padding: 0 14px;
  border: 1px solid rgba(197, 92, 54, .5);
  border-radius: 8px;
  background: transparent;
  color: var(--brand-warm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.msg.system button.retry:disabled { opacity: .5; cursor: default; }

/* Карточка кнопок (payload.form). */
.card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.card button {
  height: 46px;
  border: none;
  border-radius: 10px;
  background: var(--brand-button);
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
}
/* ДФ1/ДФ2: нажатая и вытесненные карточки остаются в ленте, но неактивны. */
.card button:disabled { opacity: .45; cursor: default; }

/* --- композер --------------------------------------------------------------- */
.composer {
  flex-shrink: 0;
  padding: 14px 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px 13px 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}
/* Фокуса в макете нет: подсвечиваем поле холодным концом фирменного градиента. */
.composer-field:focus-within {
  border-color: var(--brand-cool);
  box-shadow: 0 0 0 3px rgba(26, 133, 180, .12);
}
.composer-attach {
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: none;
  flex-shrink: 0;
  cursor: default;
}
.composer-attach img { width: 18px; height: 18px; }
.composer input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
}
.composer input::placeholder { color: var(--muted-2); }
.composer-send {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 17px;
  background: var(--brand-badge);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.composer-send img { width: 17px; height: 17px; }
.composer-send:disabled { opacity: .45; cursor: default; }

.composer-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
}
.composer-note { flex: 1; min-width: 0; }
.composer-counter { width: 130px; text-align: right; flex-shrink: 0; }
/* О5: лимит длины реплики держит app.js, здесь только цвет предупреждения. */
.composer-note.warn,
.composer-counter.warn { color: var(--brand-warm); }

/* --- узкие экраны ----------------------------------------------------------- */
@media (max-width: 1100px) {
  /* Меню портала — декорация: на узком экране уступает место логотипу и иконкам. */
  .portal-menu { display: none; }
}
@media (max-width: 700px) {
  .portal { height: 72px; }
  .portal-inner { padding: 0 16px; gap: 12px; }
  .portal-logo { width: 150px; height: 37px; }
  .portal-icons { gap: 12px; }
  .portal-icon, .portal-avatar { width: 36px; height: 36px; }
  .portal-icon-bell { width: 18px; height: 25px; }
  .portal-icon-chat { width: 22px; height: 22px; }
  .portal-avatar img { width: 13px; height: 13.8px; }

  .page { height: calc(100vh - 72px); padding: 12px; }
  .assistant { height: 100%; border-radius: 14px; }
  .assistant-head { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .feed { padding: 16px; }
  .session-user { display: none; }
  .msg.user .msg-text { max-width: 86%; }
  .composer { padding: 12px 16px 16px; }
}

/* --- вход по токену (стенд с авторизацией) --------------------------------- */
.login {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(48, 53, 59, .45);
  backdrop-filter: blur(2px);
}
.login-card {
  width: min(420px, calc(100vw - 48px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(48, 53, 59, .18);
}
.login-title { font-size: 17px; font-weight: 500; }
.login-text { margin: 0; color: var(--ink-soft); font-size: 13px; }
/* Вкладки «Вход» / «Регистрация»: переключают одну и ту же пару полей. */
.login-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f4f6f9;
  border-radius: 10px;
}
.login-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.login-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(48, 53, 59, .08);
}
.login-hint { margin: 0; color: var(--muted); font-size: 11.5px; }
.login-card input {
  padding: 13px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.login-card input:focus {
  outline: none;
  border-color: var(--brand-cool);
  box-shadow: 0 0 0 3px rgba(26, 133, 180, .12);
}
/* Ошибка входа; пустая — не занимает места. */
.login-error { color: var(--brand-warm); font-size: 13px; }
.login-error:empty { display: none; }
