/* AI Rector -- hand-written styles (no build step, no Tailwind).
   Brand palette matches the original app: deep blue + gold on a light slate canvas. */

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Space Grotesk", sans-serif;
  --font-mono: "Fira Code", monospace;

  --brand-green: #003366;
  --brand-green-light: #004080;
  --brand-gold: #C5A059;
  --brand-gold-dark: #A88448;

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-700: #b91c1c;

  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-500: #f59e0b;
  --amber-800: #92400e;

  --emerald-500: #10b981;

  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1rem;
}

* { box-sizing: border-box; }

/* A class-based `display` (e.g. `.welcome-cta { display: flex }`) has the same specificity as
   the UA `[hidden] { display: none }` rule, so the later one (always the author's) wins and the
   `hidden` attribute is silently ignored unless every such class carries its own `[hidden]`
   override. One global, higher-specificity rule covers all of them instead. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--slate-800);
  background: var(--slate-50);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

.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;
}

.icon { width: 1.15rem; height: 1.15rem; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 0.9rem; height: 0.9rem; }
.icon-lg { width: 1.75rem; height: 1.75rem; }
.icon-gold { color: var(--brand-gold); }

/* ---------------------------------------------------------------- shell */

.app-shell {
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------------------------------------------------------- header */

.app-header {
  background: var(--brand-green);
  border-bottom: 1px solid rgba(197, 160, 89, 0.3);
  color: #fff;
  padding: 1rem 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.header-brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }

.header-logo {
  background: rgba(197, 160, 89, 0.15);
  border: 1px solid rgba(197, 160, 89, 0.3);
  border-radius: 0.75rem;
  padding: 0.6rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-gold);
  flex-shrink: 0;
}

.header-titles { min-width: 0; }

.header-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  display: flex; align-items: center; gap: 0.5rem;
}

.header-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(197, 160, 89, 0.2);
  color: var(--brand-gold);
  border: 1px solid rgba(197, 160, 89, 0.4);
}

.header-subtitle {
  font-size: 0.75rem;
  color: var(--slate-300);
  margin: 0.1rem 0 0;
}

.header-quote {
  display: none;
  align-items: center; gap: 0.75rem;
  background: rgba(0, 64, 128, 0.4);
  border: 1px solid rgba(197, 160, 89, 0.2);
  border-radius: 0.75rem;
  padding: 0.5rem 1rem;
  max-width: 26rem;
  color: var(--brand-gold);
}

.header-quote-text {
  background: none; border: none; padding: 0; color: var(--slate-200);
  font-size: 0.75rem; font-style: italic; text-align: left; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.header-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.icon-button {
  background: none; border: none; color: var(--slate-300);
  border-radius: 0.5rem; padding: 0.5rem;
  display: flex; align-items: center; justify-content: center;
  transition: background-color .15s, color .15s;
}
.icon-button:hover { color: var(--red-500); background: rgba(255,255,255,0.1); }

/* language switcher (header) */
.language-switcher { position: relative; }
.lang-button {
  display: flex; align-items: center; gap: 0.4rem;
  background: rgba(197, 160, 89, 0.1);
  border: 1px solid rgba(197, 160, 89, 0.3);
  color: #fff; border-radius: 0.5rem; padding: 0.5rem 0.65rem; font-size: 0.75rem; font-weight: 500;
  transition: background-color .15s;
}
.lang-button:hover { background: rgba(197, 160, 89, 0.2); }
.lang-button .icon:first-child { color: var(--brand-gold); }
.lang-button[aria-expanded="true"] .icon-sm { transform: rotate(180deg); }

.lang-menu {
  position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 50;
  width: 11.5rem; background: #fff; border: 1px solid var(--slate-200);
  border-radius: 0.75rem; box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  overflow: hidden; padding: 0.25rem 0;
}
.lang-menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  width: 100%; padding: 0.65rem 0.9rem; background: none; border: none;
  font-size: 0.75rem; font-weight: 500; color: var(--slate-600); text-align: left;
}
.lang-menu-item:hover { background: var(--slate-100); color: var(--slate-900); }
.lang-menu-item.is-active { background: rgba(0, 51, 102, 0.06); color: var(--brand-green); }
.lang-menu-item .code { font-family: var(--font-mono); font-size: 0.65rem; color: var(--slate-400); }

/* segmented variant (used inside welcome modal) */
.lang-segmented { display: inline-flex; align-items: center; gap: 0.2rem; border: 1px solid var(--slate-200); background: var(--slate-50); border-radius: 999px; padding: 0.2rem; }
.lang-segmented button {
  border: none; background: none; border-radius: 999px; padding: 0.3rem 0.6rem;
  font-family: var(--font-mono); font-size: 0.65rem; font-weight: 600; text-transform: uppercase; color: var(--slate-500);
}
.lang-segmented button.is-active { background: var(--brand-green); color: #fff; }

/* ---------------------------------------------------------------- mobile tabs */

.mobile-tabs { display: flex; background: #fff; border-bottom: 1px solid var(--slate-200); box-shadow: 0 1px 2px rgba(0,0,0,0.04); flex-shrink: 0; }
.mobile-tab {
  flex: 1; padding: 0.75rem; text-align: center; font-size: 0.85rem; font-weight: 500;
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--slate-500);
}
.mobile-tab.is-active { border-color: var(--brand-green); color: var(--brand-green); background: rgba(0,51,102,0.04); }

/* ---------------------------------------------------------------- workspace */

.workspace {
  flex: 1; width: 100%; max-width: 84rem; margin: 0 auto;
  padding: 1rem; display: flex; gap: 1.5rem; overflow: hidden;
}

.info-column { width: 100%; flex-shrink: 0; display: none; flex-direction: column; overflow: hidden; }
.info-column.is-active { display: flex; }

.chat-column { flex: 1; display: none; flex-direction: column; background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-2xl); box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow: hidden; }
.chat-column.is-active { display: flex; }

@media (min-width: 1024px) {
  .info-column { width: 380px; display: flex !important; }
  .chat-column { display: flex !important; }
  .mobile-tabs { display: none; }
}
@media (min-width: 1280px) {
  .info-column { width: 420px; }
  .header-quote { display: flex; }
}

/* quick questions panel */

.quick-questions { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-2xl); box-shadow: 0 1px 3px rgba(0,0,0,0.06); padding: 1.25rem; display: flex; flex-direction: column; flex: 1; min-height: 0; }

.quick-questions-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-shrink: 0; }
.quick-questions-head h3 { font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; margin: 0; display: flex; align-items: center; gap: 0.4rem; color: var(--slate-900); }
.hint-chip { font-family: var(--font-mono); font-size: 0.62rem; color: var(--slate-400); background: var(--slate-100); padding: 0.15rem 0.5rem; border-radius: 0.35rem; }

.category-selectors { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.65rem; margin-bottom: 0.75rem; border-bottom: 1px solid var(--slate-100); flex-shrink: 0; scrollbar-width: none; }
.category-selectors::-webkit-scrollbar { display: none; }
/* Hidden scrollbar + a row that no longer fits: fade the side that has more tabs on it. */
.category-selectors.can-scroll-right { mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent); }
.category-selectors.can-scroll-left { mask-image: linear-gradient(to right, transparent, #000 2rem); }
.category-selectors.can-scroll-left.can-scroll-right {
  mask-image: linear-gradient(to right, transparent, #000 2rem, #000 calc(100% - 2rem), transparent);
}

.category-pill {
  padding: 0.4rem 0.85rem; border-radius: 999px; font-size: 0.72rem; font-weight: 500; flex-shrink: 0;
  display: flex; align-items: center; gap: 0.4rem; border: 1px solid var(--slate-200);
  background: var(--slate-50); color: var(--slate-600); white-space: nowrap; transition: all .15s;
}
.category-pill:hover { background: var(--slate-100); }
.category-pill.is-active { background: var(--brand-green); color: #fff; border-color: var(--brand-green); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.category-pill svg { width: 1.1rem; height: 1.1rem; }

.questions-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; padding-right: 0.25rem; }

.question-card {
  width: 100%; text-align: left; padding: 0.85rem; border-radius: 0.75rem; border: 1px solid var(--slate-100);
  background: rgba(248, 250, 252, 0.5); display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem;
  transition: all .15s;
}
.question-card:hover { background: rgba(0, 51, 102, 0.05); border-color: rgba(0, 51, 102, 0.2); }
.question-card:disabled { opacity: 0.5; cursor: not-allowed; }
.question-card .q-label { font-weight: 700; color: var(--brand-green); display: block; font-size: 0.72rem; margin-bottom: 0.2rem; }
.question-card .q-text { color: var(--slate-600); font-size: 0.72rem; line-height: 1.4; font-weight: 500; margin: 0; }
.question-card svg { color: var(--slate-400); flex-shrink: 0; margin-top: 0.15rem; transition: transform .15s; }
.question-card:hover svg { color: var(--brand-green); transform: translateX(3px); }

/* ---------------------------------------------------------------- chat column */

.chat-workspace-header { background: var(--slate-50); border-bottom: 1px solid var(--slate-100); padding: 0.75rem 1.25rem; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.chat-header-left { display: flex; align-items: center; gap: 0.75rem; }
.chat-avatar {
  width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; background: rgba(0,51,102,0.1); border: 1px solid rgba(0,51,102,0.1);
  display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; color: var(--brand-green);
}
.chat-title { font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; color: var(--slate-900); display: flex; align-items: center; gap: 0.4rem; }
.status-dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: var(--emerald-500); display: inline-block; }
.chat-subtitle { font-size: 0.65rem; color: var(--slate-500); font-family: var(--font-mono); margin: 0.1rem 0 0; }
.chat-hours { font-size: 0.65rem; color: var(--slate-400); background: rgba(241,245,249,0.8); border: 1px solid rgba(226,232,240,0.5); border-radius: 0.5rem; padding: 0.25rem 0.6rem; display: flex; align-items: center; gap: 0.25rem; }

.chat-thread { flex: 1; overflow-y: auto; padding: 1.25rem; background: #fcfdfe; display: flex; flex-direction: column; gap: 1rem; }

.msg-row { display: flex; gap: 0.75rem; max-width: 85%; animation: msg-in .25s ease; }
.msg-row.from-user { margin-left: auto; flex-direction: row-reverse; }
.msg-row.from-assistant { margin-right: auto; }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.msg-avatar {
  width: 2rem; height: 2rem; border-radius: 0.5rem; display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; flex-shrink: 0;
}
.msg-row.from-user .msg-avatar { background: rgba(197, 160, 89, 0.2); color: var(--brand-gold-dark); border: 1px solid rgba(197, 160, 89, 0.3); }
.msg-row.from-assistant .msg-avatar { background: var(--brand-green); color: #fff; }

.msg-body { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.msg-sender { font-size: 0.62rem; font-weight: 500; color: var(--slate-400); margin-left: 0.25rem; }

.msg-bubble { padding: 1rem; border-radius: 1rem; box-shadow: 0 1px 2px rgba(0,0,0,0.04); line-height: 1.55; font-size: 0.8rem; }
.msg-row.from-user .msg-bubble { background: var(--brand-green); color: #fff; border: 1px solid var(--brand-green); border-top-right-radius: 0; white-space: pre-line; }
.msg-row.from-assistant .msg-bubble { background: #fff; color: var(--slate-800); border: 1px solid var(--slate-100); border-top-left-radius: 0; }

.msg-meta { font-size: 0.6rem; color: var(--slate-400); font-family: var(--font-mono); display: flex; align-items: center; gap: 0.25rem; margin-top: 0.1rem; }
.msg-row.from-user .msg-meta { justify-content: flex-end; margin-right: 0.25rem; }
.msg-row.from-assistant .msg-meta { margin-left: 0.25rem; }
.msg-meta .icon { color: var(--emerald-500); width: 0.7rem; height: 0.7rem; }

.msg-quote { margin-top: 0.75rem; padding-top: 0.6rem; border-top: 1px solid var(--slate-100); font-size: 0.68rem; font-style: italic; display: flex; gap: 0.4rem; color: var(--slate-500); }
.msg-row.from-user .msg-quote { border-color: rgba(255,255,255,0.2); color: var(--slate-100); }
.msg-quote svg { flex-shrink: 0; margin-top: 0.1rem; }

/* markdown rendering inside assistant bubbles */
.markdown-body ul { list-style: disc; padding-left: 1.25rem; margin: 0.5rem 0; }
.markdown-body ol { list-style: decimal; padding-left: 1.25rem; margin: 0.5rem 0; }
.markdown-body li { margin-bottom: 0.25rem; }
.markdown-body p { margin: 0 0 0.5rem; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body strong { font-weight: 600; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { font-weight: 600; margin: 0.75rem 0 0.25rem; }
.markdown-body a {
  color: var(--brand-green-light); font-weight: 600; text-decoration: underline;
  text-decoration-color: rgba(197, 160, 89, 0.7); text-underline-offset: 2px; text-decoration-thickness: 2px;
  border-radius: 3px; transition: color .15s, background-color .15s; overflow-wrap: anywhere;
}
.markdown-body a:hover { color: var(--brand-green); background-color: rgba(197, 160, 89, 0.18); text-decoration-color: var(--brand-gold); }

/* typing indicator */
.typing-loader { display: flex; align-items: center; gap: 0.75rem; margin-right: auto; max-width: 80%; }
.typing-dots { background: #fff; border: 1px solid var(--slate-100); border-radius: 1rem; border-top-left-radius: 0; padding: 0.75rem 1rem; display: flex; align-items: center; gap: 0.25rem; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.typing-dots span { width: 0.45rem; height: 0.45rem; border-radius: 999px; background: rgba(0,51,102,0.6); animation: bounce 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-4px); } }

/* error / voice notice boxes */
.notice-box { padding: 0.85rem; border-radius: 0.75rem; font-size: 0.72rem; display: flex; gap: 0.6rem; align-items: flex-start; }
.notice-box.error { background: var(--red-50); border: 1px solid var(--red-100); color: var(--red-700); }
.notice-box.error svg { color: var(--red-500); flex-shrink: 0; margin-top: 0.1rem; }
.notice-box.error .title { font-weight: 700; margin: 0; }
.notice-box.error .detail { font-size: 0.68rem; margin: 0.15rem 0 0; line-height: 1.4; }
.notice-box.error .retry { color: var(--red-700); text-decoration: underline; font-size: 0.62rem; font-weight: 700; background: none; border: none; margin-top: 0.4rem; padding: 0; }

.notice-box.warn { background: var(--amber-50); border: 1px solid var(--amber-100); color: var(--amber-800); align-items: center; }
.notice-box.warn svg { color: var(--amber-500); flex-shrink: 0; }
.notice-box.warn p { margin: 0; line-height: 1.4; flex: 1; }
.notice-box.warn .dismiss { background: none; border: none; color: var(--amber-500); margin-left: auto; padding: 0.1rem; border-radius: 0.25rem; }

/* input form */

.chat-input-form { padding: 0.85rem 1rem; background: var(--slate-50); border-top: 1px solid var(--slate-100); display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.chat-input {
  /* min-width:0 -- без него флекс-элемент не сжимается уже своей внутренней ширины (~200px),
     и на узком экране строка ввода выталкивала кнопки за край. */
  flex: 1; min-width: 0; background: #fff; border: 1px solid var(--slate-200); border-radius: 0.75rem;
  padding: 0.65rem 1rem; font-size: 0.78rem; color: var(--slate-800); transition: all .15s;
}
.chat-input:focus { outline: none; border-color: var(--brand-green); box-shadow: 0 0 0 3px rgba(0,51,102,0.12); }
.chat-input:disabled { opacity: 0.6; }

.voice-button { border: 1px solid var(--slate-200); background: #fff; color: var(--slate-500); border-radius: 0.75rem; padding: 0.65rem; }
.voice-button:hover { border-color: rgba(0,51,102,0.3); color: var(--brand-green); }
.voice-button.is-recording { background: var(--red-500); color: #fff; border-color: var(--red-500); }
.voice-button:disabled { opacity: 0.5; cursor: not-allowed; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.send-button {
  background: var(--brand-green); color: #fff; border: none; border-radius: 0.75rem;
  padding: 0.65rem 1rem; font-size: 0.75rem; font-weight: 500; display: flex; align-items: center; gap: 0.4rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06); transition: all .15s;
}
.send-button:hover:not(:disabled) { background: var(--brand-green-light); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.send-button:disabled { opacity: 0.5; cursor: not-allowed; }

.voice-recording-status {
  flex: 1; display: flex; align-items: center; gap: 0.5rem; border: 1px solid var(--red-100); background: var(--red-50);
  border-radius: 0.75rem; padding: 0.6rem 1rem; font-size: 0.72rem; color: var(--red-700);
}
.rec-dot { width: 0.6rem; height: 0.6rem; border-radius: 999px; background: var(--red-500); animation: pulse-slow 1.5s infinite; flex-shrink: 0; }
.rec-seconds { font-family: var(--font-mono); font-size: 0.68rem; color: var(--red-500); }
.voice-cancel { margin-left: auto; background: none; border: none; color: var(--red-600); text-decoration: underline; font-size: 0.68rem; font-weight: 500; }
@keyframes pulse-slow { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ---------------------------------------------------------------- footer */

.app-footer {
  background: #fff; border-top: 1px solid var(--slate-200); text-align: center; padding: 0.75rem 1.5rem;
  font-size: 0.68rem; color: var(--slate-500); flex-shrink: 0; display: flex; flex-direction: column;
  gap: 0.25rem; justify-content: space-between; align-items: center; max-width: 84rem; width: 100%; margin: 0 auto;
}
.footer-stats { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-mono); font-size: 0.65rem; }
.footer-stats strong { color: var(--brand-green-light); }
.footer-stats .divider { color: var(--slate-300); }
@media (min-width: 640px) { .app-footer { flex-direction: row; } }

/* ---------------------------------------------------------------- scrollbars */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-300); }

/* ---------------------------------------------------------------- modals */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(241, 245, 249, 0.85); backdrop-filter: blur(12px);
  animation: fade-in .3s ease;
}
.modal-backdrop--dark { z-index: 60; background: rgba(2, 6, 23, 0.6); backdrop-filter: blur(4px); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* welcome modal */
.welcome-modal {
  position: relative; aspect-ratio: 3 / 4; max-height: 92dvh; width: 100%; max-width: 30rem;
  overflow: hidden; border-radius: 1.75rem; border: 1px solid rgba(255,255,255,0.1);
  background: var(--brand-green); box-shadow: 0 25px 60px rgba(0,0,0,0.35);
  animation: modal-in .4s cubic-bezier(.16,1,.3,1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(24px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

.welcome-modal-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.welcome-modal-cover-tint { position: absolute; inset: 0; background: rgba(0,51,102,0.25); pointer-events: none; }
.welcome-modal-scrim-top { position: absolute; inset: 0 0 auto 0; height: 6rem; background: linear-gradient(to bottom, rgba(0,0,0,0.45), transparent); pointer-events: none; }
.welcome-modal-scrim-bottom { position: absolute; inset: auto 0 0 0; height: 60%; background: linear-gradient(to top, var(--brand-green) 0%, rgba(0,51,102,0.85) 55%, transparent 100%); pointer-events: none; }

.welcome-modal-play-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.play-fab {
  pointer-events: auto; width: 5rem; height: 5rem; border-radius: 999px; background: rgba(197,160,89,0.95);
  color: var(--brand-green); display: flex; align-items: center; justify-content: center; border: none;
  box-shadow: 0 15px 40px rgba(0,0,0,0.3); outline: 4px solid rgba(255,255,255,0.2); transition: transform .15s;
}
.play-fab:hover { transform: scale(1.05); }

.welcome-modal-topbar { position: absolute; inset: 0 0 auto 0; display: flex; align-items: center; justify-content: space-between; padding: 0.85rem; }
.modal-close-button {
  border-radius: 999px; border: 1px solid rgba(255,255,255,0.25); background: rgba(0,0,0,0.35); color: #fff;
  padding: 0.5rem; backdrop-filter: blur(4px);
}
.modal-close-button:hover { background: rgba(0,0,0,0.6); }

.welcome-modal-bottom { position: absolute; inset: auto 0 0 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; padding: 1.5rem; color: #fff; }
.welcome-modal-badge {
  display: inline-flex; align-items: center; gap: 0.4rem; border: 1px solid rgba(197,160,89,0.4);
  background: rgba(197,160,89,0.15); border-radius: 999px; padding: 0.25rem 0.65rem; font-size: 0.62rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--brand-gold);
}
.welcome-modal-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin: 0; text-shadow: 0 1px 3px rgba(0,0,0,0.2); }

.welcome-cta {
  margin-top: 0.25rem; width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  border-radius: 0.75rem; background: var(--brand-gold); color: var(--brand-green); border: none;
  padding: 0.75rem 1.25rem; font-size: 0.85rem; font-weight: 700; box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  transition: all .15s;
}
.welcome-cta:hover { background: var(--brand-gold-dark); color: #fff; }
.welcome-watch-hint { margin-top: 0.25rem; width: 100%; text-align: center; font-size: 0.72rem; color: rgba(255,255,255,0.7); }

/* session timeout modal */
.timeout-modal {
  width: 100%; max-width: 24rem; background: #fff; border: 1px solid var(--slate-200); border-radius: 1rem;
  padding: 1.75rem; text-align: center; box-shadow: 0 25px 60px rgba(0,0,0,0.25);
  animation: modal-in .32s cubic-bezier(.16,1,.3,1);
}
.timeout-modal-icon {
  margin: 0 auto 1rem; width: 3rem; height: 3rem; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(197,160,89,0.3); background: rgba(197,160,89,0.1); color: var(--brand-gold-dark);
}
.timeout-modal h2 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; margin: 0; color: var(--slate-900); }
.timeout-modal p { font-size: 0.85rem; color: var(--slate-600); margin: 0.5rem 0 0; }
.timeout-actions { margin-top: 1.5rem; display: flex; gap: 0.6rem; }
.timeout-actions button { flex: 1; border-radius: 0.75rem; padding: 0.65rem 1rem; font-size: 0.85rem; font-weight: 600; border: 1px solid var(--slate-200); background: #fff; color: var(--slate-600); }
.timeout-actions button:hover { background: var(--slate-50); color: var(--slate-900); }
.timeout-actions button.primary { border: none; background: var(--brand-green); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.timeout-actions button.primary:hover { background: var(--brand-green-light); }

/* ---------------------------------------------------------------- message reactions */

.msg-feedback { display: flex; align-items: center; gap: 0.25rem; margin-top: 0.35rem; margin-left: 0.25rem; }
.msg-feedback-button {
  display: flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem;
  border-radius: 0.5rem; border: 1px solid transparent; background: transparent; color: var(--slate-400);
  transition: all .15s;
}
.msg-feedback-button .icon { width: 0.9rem; height: 0.9rem; }
.msg-feedback-button:hover { background: var(--slate-100); color: var(--slate-600); }
.msg-feedback-button.is-active[data-reaction="like"] { color: var(--emerald-500); background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.25); }
.msg-feedback-button.is-active[data-reaction="dislike"] { color: var(--red-600); background: var(--red-50); border-color: var(--red-100); }

/* ---------------------------------------------------------------- feedback form modal */

.feedback-modal {
  position: relative; width: 100%; max-width: 32rem; max-height: 90dvh; background: #fff;
  border: 1px solid var(--slate-200); border-radius: 1.25rem; box-shadow: 0 25px 60px rgba(0,0,0,0.25);
  animation: modal-in .3s cubic-bezier(.16,1,.3,1); display: flex; flex-direction: column;
}
.feedback-close { position: absolute; top: 0.85rem; right: 0.85rem; z-index: 1; background: var(--slate-100); color: var(--slate-600); border: none; }
.feedback-close:hover { background: var(--slate-200); }
.feedback-scroll { overflow-y: auto; padding: 1.75rem; }
.feedback-modal h2 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; margin: 0 1.75rem 1rem 0; color: var(--slate-900); }

.feedback-context { background: var(--slate-50); border: 1px solid var(--slate-100); border-radius: 0.75rem; padding: 0.75rem 0.9rem; margin-bottom: 1.25rem; }
.feedback-context-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--slate-400); margin: 0.5rem 0 0.15rem; }
.feedback-context-label:first-child { margin-top: 0; }
.feedback-context-text { font-size: 0.78rem; color: var(--slate-700); margin: 0; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

.feedback-field { margin-bottom: 1.1rem; }
.feedback-field legend, .feedback-field > label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--slate-800); margin-bottom: 0.5rem; padding: 0; }
.feedback-field textarea, .feedback-field input[type="email"], .feedback-other-input {
  width: 100%; border: 1px solid var(--slate-200); border-radius: 0.6rem; padding: 0.55rem 0.7rem;
  font: inherit; font-size: 0.8rem; resize: vertical; background: #fff; color: var(--slate-800);
}
.feedback-field textarea:focus, .feedback-field input:focus, .feedback-other-input:focus { outline: 2px solid var(--brand-gold); outline-offset: 1px; }
.feedback-other-input { margin-top: 0.5rem; }

.feedback-checkboxes { display: flex; flex-direction: column; gap: 0.45rem; }
.feedback-checkbox { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.8rem; color: var(--slate-700); cursor: pointer; }
.feedback-checkbox input { margin-top: 0.15rem; accent-color: var(--brand-green); }

.feedback-error { color: var(--red-600); font-size: 0.7rem; margin: 0.4rem 0 0; }

.feedback-survey { background: var(--slate-50); border: 1px solid var(--slate-100); border-radius: 0.75rem; padding: 1rem; margin-bottom: 1.1rem; }
.feedback-survey .feedback-field:last-child { margin-bottom: 0; }
.feedback-scale-label { font-size: 0.78rem; font-weight: 600; color: var(--slate-800); margin: 0 0 0.5rem; }
.feedback-scale { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.feedback-scale-option { display: flex; }
.feedback-scale-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.feedback-scale-option label {
  display: flex; align-items: center; justify-content: center; min-width: 2.1rem; height: 2.1rem; padding: 0 0.4rem;
  border-radius: 0.5rem; border: 1px solid var(--slate-200); background: #fff; color: var(--slate-600);
  font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: all .15s;
}
.feedback-scale--nps label { min-width: 1.9rem; font-size: 0.7rem; }
.feedback-scale-option input:checked + label { background: var(--brand-green); border-color: var(--brand-green); color: #fff; }
.feedback-scale-option input:focus-visible + label { outline: 2px solid var(--brand-gold); outline-offset: 1px; }

.feedback-actions { display: flex; gap: 0.6rem; margin-top: 1.4rem; }
.feedback-actions button { flex: 1; border-radius: 0.75rem; padding: 0.7rem 1rem; font-size: 0.85rem; font-weight: 600; border: 1px solid var(--slate-200); background: #fff; color: var(--slate-600); }
.feedback-actions button:hover { background: var(--slate-50); color: var(--slate-900); }
.feedback-actions button.primary { border: none; background: var(--brand-green); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.feedback-actions button.primary:hover { background: var(--brand-green-light); }
.feedback-actions button.primary:disabled { background: var(--slate-200); color: var(--slate-400); box-shadow: none; cursor: not-allowed; }

.feedback-toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--slate-900); color: #fff; padding: 0.65rem 1.1rem; border-radius: 999px;
  font-size: 0.78rem; box-shadow: 0 10px 30px rgba(0,0,0,0.3); animation: fade-in .2s ease;
}

@media (max-width: 640px) {
  .feedback-modal { max-width: 100%; max-height: 85dvh; align-self: flex-end; border-radius: 1.25rem 1.25rem 0 0; }
  #feedback_form_backdrop { align-items: flex-end; }
}

/* ---------------------------------------------------------------- attachments */

/* The composer became two rows (chips above the input), so the form itself is a column now. */
.chat-input-form { flex-direction: column; align-items: stretch; gap: 0.5rem; }
.composer-row { display: flex; align-items: center; gap: 0.5rem; }

.attach-button { border: 1px solid var(--slate-200); background: #fff; color: var(--slate-500); border-radius: 0.75rem; padding: 0.65rem; flex-shrink: 0; }
.attach-button:hover:not(:disabled) { border-color: rgba(0,51,102,0.3); color: var(--brand-green); background: #fff; }
.attach-button:disabled { opacity: 0.5; cursor: not-allowed; }

.attachment-strip { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.attachment-chip {
  display: flex; align-items: center; gap: 0.45rem; max-width: 15rem;
  background: #fff; border: 1px solid var(--slate-200); border-radius: 0.65rem;
  padding: 0.35rem 0.5rem; font-size: 0.7rem; color: var(--slate-600);
}
.attachment-chip img { width: 1.85rem; height: 1.85rem; border-radius: 0.4rem; object-fit: cover; flex-shrink: 0; }
.attachment-chip > .icon { color: var(--brand-green); flex-shrink: 0; }
.attachment-chip .chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.attachment-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--slate-800); }
.attachment-chip .chip-meta { font-size: 0.6rem; color: var(--slate-400); font-family: var(--font-mono); }
.attachment-chip .chip-remove { background: none; border: none; color: var(--slate-400); padding: 0.15rem; border-radius: 0.35rem; flex-shrink: 0; }
.attachment-chip .chip-remove:hover { color: var(--red-500); background: var(--red-50); }
.attachment-chip.is-uploading { opacity: 0.75; }
.attachment-chip.is-uploading .chip-meta { color: var(--brand-green-light); }
.attachment-chip.is-error { border-color: var(--red-100); background: var(--red-50); }
.attachment-chip.is-error .chip-meta { color: var(--red-600); white-space: normal; }

.attachment-error { margin: 0; font-size: 0.68rem; color: var(--red-600); line-height: 1.35; }

/* chips repeated inside the sent bubble (user bubbles are dark, hence the translucent fill) */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.6rem; }
.msg-attachment {
  display: flex; align-items: center; gap: 0.35rem; max-width: 100%;
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.25); border-radius: 0.5rem;
  padding: 0.25rem 0.45rem; font-size: 0.66rem;
}
.msg-attachment img { width: 1.5rem; height: 1.5rem; border-radius: 0.3rem; object-fit: cover; }
.msg-attachment .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 11rem; }
.msg-attachment .att-size { font-family: var(--font-mono); font-size: 0.58rem; opacity: 0.75; }
.msg-row.from-assistant .msg-attachment { background: var(--slate-50); border-color: var(--slate-200); color: var(--slate-600); }

/* drag & drop */
.chat-column { position: relative; }
.chat-drop-overlay {
  position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(0,51,102,0.12); backdrop-filter: blur(2px); border-radius: var(--radius-2xl); padding: 1rem;
}
.chat-drop-overlay[hidden] { display: none; }
.chat-drop-card {
  background: #fff; border: 2px dashed var(--brand-green); border-radius: 1rem; padding: 1.5rem 2rem;
  text-align: center; color: var(--brand-green); box-shadow: 0 10px 30px rgba(0,0,0,0.12); max-width: 22rem;
}
.chat-drop-card .icon { width: 1.6rem; height: 1.6rem; margin-bottom: 0.4rem; }
.chat-drop-card p { margin: 0; font-size: 0.82rem; font-weight: 600; }
.chat-drop-card .hint { display: block; margin-top: 0.3rem; font-size: 0.68rem; color: var(--slate-500); font-weight: 500; }

/* Узкий экран: подпись у кнопки отправки съедала ширину строки ввода (композер вылезал за 390px
   ещё до появления скрепки) -- на телефоне оставляем только иконку, подпись читает скринридер. */
@media (max-width: 640px) {
  .chat-input-form { padding: 0.75rem 0.85rem; }
  .composer-row { gap: 0.35rem; }
  .send-button span { display: none; }
  .send-button { padding: 0.65rem 0.85rem; }
  .attach-button, .voice-button { padding: 0.6rem; }
  .attachment-chip { max-width: 100%; }
}
