/* Стиль WayMax (30.09.2026): спокойный, «как ChatGPT/Claude», но в цветах
   логотипа — чернильно-синий и бирюзовый. Белое (в тёмной теме —
   графитовое) поле, плоские карточки без теней, мягкие поля ввода. Яркое
   место одно — поле ассистента рассылки (.composer). Эти же токены — в
   docs/waymax-design.md для CRM. */
:root {
  --font-body: "Onest", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  --font-heading: var(--font-body);

  /* Цвета логотипа */
  --ink: #14213a;             /* текст и заголовки — чернильно-синий */
  --brand-deep: #14213a;
  --brand-primary: #1d3f72;   /* главные кнопки */
  --brand-primary-hover: #16325c;
  --brand-accent: #11808a;    /* бирюза: ссылки, фокус, активное */
  --brand-accent-hover: #0c6972;
  --text-on-brand: #ffffff;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f4f5f7;     /* поля ввода, наведение, шапки таблиц */
  --border: #e6e8ec;
  --border-strong: #d3d7de;

  --text-primary: #14213a;
  --text-secondary: #4a5566;
  --text-muted: #646d7b;

  --accent-soft: rgba(17, 128, 138, 0.10);
  --accent-soft-border: rgba(17, 128, 138, 0.32);

  --shadow-sm: none;
  --shadow-md: 0 1px 2px rgba(20, 33, 58, 0.04), 0 8px 28px rgba(20, 33, 58, 0.08);
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 26px;

  --danger: #b42318; --danger-bg: #fef3f2; --danger-border: #fecdca;
  --success: #067647; --success-bg: #ecfdf3; --success-border: #abefc6;
  --warning: #b54708; --warning-bg: #fffaeb; --warning-border: #fedf89;
  --business: #6941c6; --business-bg: #f4f3ff; --business-border: #d9d6fe;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eceef1;
    --brand-deep: #eceef1;
    --brand-primary: #eceef1;          /* в тёмной теме главная кнопка светлая, как у ChatGPT */
    --brand-primary-hover: #ffffff;
    --brand-accent: #4fc1c9;
    --brand-accent-hover: #74d2d8;
    --text-on-brand: #16181d;

    --bg: #16181d;
    --surface: #1d2026;
    --surface-alt: #262a31;
    --border: #2f343c;
    --border-strong: #3d434d;

    --text-primary: #eceef1;
    --text-secondary: #b3bac4;
    --text-muted: #8e96a3;

    --accent-soft: rgba(79, 193, 201, 0.12);
    --accent-soft-border: rgba(79, 193, 201, 0.35);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);

    --danger: #f97066; --danger-bg: rgba(240, 68, 56, 0.12); --danger-border: rgba(240, 68, 56, 0.35);
    --success: #47cd89; --success-bg: rgba(23, 178, 106, 0.12); --success-border: rgba(23, 178, 106, 0.35);
    --warning: #fdb022; --warning-bg: rgba(247, 144, 9, 0.12); --warning-border: rgba(247, 144, 9, 0.35);
    --business: #a48afb; --business-bg: rgba(122, 90, 248, 0.14); --business-border: rgba(122, 90, 248, 0.4);
    color-scheme: dark;
  }
}
/* Тёмная тема, выбранная кнопкой в шапке (static/js/theme.js). Те же
   значения, что в блоке выше, — менять оба вместе. */
:root[data-theme="dark"] {
  --ink: #eceef1;
  --brand-deep: #eceef1;
  --brand-primary: #eceef1;
  --brand-primary-hover: #ffffff;
  --brand-accent: #4fc1c9;
  --brand-accent-hover: #74d2d8;
  --text-on-brand: #16181d;

  --bg: #16181d;
  --surface: #1d2026;
  --surface-alt: #262a31;
  --border: #2f343c;
  --border-strong: #3d434d;

  --text-primary: #eceef1;
  --text-secondary: #b3bac4;
  --text-muted: #8e96a3;

  --accent-soft: rgba(79, 193, 201, 0.12);
  --accent-soft-border: rgba(79, 193, 201, 0.35);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);

  --danger: #f97066; --danger-bg: rgba(240, 68, 56, 0.12); --danger-border: rgba(240, 68, 56, 0.35);
  --success: #47cd89; --success-bg: rgba(23, 178, 106, 0.12); --success-border: rgba(23, 178, 106, 0.35);
  --warning: #fdb022; --warning-bg: rgba(247, 144, 9, 0.12); --warning-border: rgba(247, 144, 9, 0.35);
  --business: #a48afb; --business-bg: rgba(122, 90, 248, 0.14); --business-border: rgba(122, 90, 248, 0.4);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

/* Кнопка темы в шапке: солнце / луна / «авто» (полумесяц-полусолнце) */
.theme-toggle {
  flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
  cursor: pointer; padding: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { background: var(--surface-alt); color: var(--ink); border-color: var(--border-strong); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle [data-icon] { display: none; }
.theme-toggle[data-mode="auto"] [data-icon="auto"],
.theme-toggle[data-mode="light"] [data-icon="light"],
.theme-toggle[data-mode="dark"] [data-icon="dark"] { display: block; }
.login-wrap .theme-toggle { position: fixed; top: 1rem; right: 1rem; }
.theme-toggle.push-right { margin-left: auto; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 0;
}
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 0.5em;
  line-height: 1.25;
}
h1 { font-size: 1.75rem; letter-spacing: -0.025em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 0.75em; color: var(--text-secondary); }
a { color: var(--brand-accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }

.layout { min-height: 100%; display: flex; flex-direction: column; }


/* Шапка: светлая, без цветной полосы; при прокрутке остаётся сверху */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.7rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { height: 32px; width: auto; border-radius: 8px; background: #fff; padding: 2px; }
.brand-text { font-family: var(--font-heading); font-weight: 650; font-size: 1.02rem; letter-spacing: -0.02em; line-height: 1.15; }
.brand-text small { display: block; font-weight: 400; font-size: 0.74rem; letter-spacing: 0; color: var(--text-muted); }

.nav-links { display: flex; gap: 0.15rem; margin-left: auto; }
.nav-links a {
  color: var(--text-secondary);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-links a:hover { background: var(--surface-alt); text-decoration: none; color: var(--ink); }
.nav-links a.active { background: var(--surface-alt); color: var(--ink); font-weight: 600; }
.nav-badge {
  display: inline-block; min-width: 1.3em; padding: 0.05em 0.4em; margin-left: 0.25em;
  border-radius: 999px; background: var(--brand-accent); color: #fff;
  font-size: 12px; font-weight: 600; text-align: center; line-height: 1.5;
}

.user-chip { display: flex; align-items: center; gap: 0.55rem; font-size: 0.86rem; color: var(--text-secondary); }
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-accent); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.82rem;
}
.user-chip a { color: var(--text-muted); font-size: 0.82rem; padding: 0.7rem 0.5rem; margin: -0.7rem -0.5rem; }
.user-chip a:hover { color: var(--ink); }


main.container { max-width: 1120px; margin: 0 auto; padding: 2.25rem 1.5rem 4rem; width: 100%; flex: 1; }
.page-head { margin-bottom: 1.75rem; }
.page-head p { max-width: 62ch; font-size: 0.98rem; }


.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card + .card { margin-top: 1.25rem; }


.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem 1.25rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label { font-weight: 500; font-size: 0.86rem; color: var(--text-secondary); }
.field .hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }
input[type="text"], input[type="date"], input[type="password"], input[type="number"], select, textarea {
  font: inherit;
  padding: 0.62rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand-accent); }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text-secondary); }
.checkbox-row input { width: 16px; height: 16px; }
.radio-group { display: flex; flex-direction: column; gap: 0.5rem; }
.radio-option { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }


.city-pair-row { display: flex; align-items: flex-end; gap: 0.75rem; }
.city-pair-row .field { flex: 1 1 0; min-width: 0; }
.swap-cities-btn {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--brand-accent);
  font-size: 1.15rem; line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.swap-cities-btn:hover { background: var(--accent-soft); border-color: var(--brand-accent); }
.swap-cities-btn:active { transform: rotate(180deg); }
.swap-cities-btn:focus-visible { outline: none; border-color: var(--brand-accent); box-shadow: 0 0 0 3px var(--accent-soft); }
@media (max-width: 640px) {
  .city-pair-row { flex-wrap: wrap; }
  .city-pair-row .field { flex: 1 1 100%; }
  .swap-cities-btn { align-self: center; margin: 0.15rem 0; }
}

/* Выбор города (static/js/city_picker.js): список под полем — город,
   страна, код аэропорта */
.city-picker { position: relative; }
.city-picker input { width: 100%; }
.cp-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-md);
  padding: 0.35rem; max-height: 340px; overflow-y: auto;
}
.cp-group { padding: 0.45rem 0.65rem 0.25rem; font-size: 0.78rem; color: var(--text-muted); }
.cp-item {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 0.6rem;
  padding: 0.55rem 0.65rem; border-radius: 10px; cursor: pointer;
}
.cp-item.is-active, .cp-item:hover { background: var(--surface-alt); }
.cp-name { font-weight: 500; color: var(--ink); }
.cp-name mark { background: none; color: var(--brand-accent); font-weight: 650; }
.cp-country { flex: 1; font-size: 0.84rem; color: var(--text-muted); }
.cp-code {
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; color: var(--text-secondary);
  background: var(--surface-alt); border-radius: 6px; padding: 0.1rem 0.4rem;
}
.cp-item.is-active .cp-code { background: var(--surface); }
/* Операторы с рейсами — второй строкой; города без рейсов — бледнее */
.cp-ops { flex-basis: 100%; font-size: 0.78rem; line-height: 1.3; color: var(--brand-accent); }
.cp-item.is-dim .cp-name { color: var(--text-muted); font-weight: 400; }
.cp-item.is-dim .cp-ops { color: var(--text-muted); }

/* Календарь дат (static/js/date_picker.js): один блок под строкой «с / по» */
.dp-anchor { position: relative; }
.dp-pop {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0;
  width: max-content; max-width: 100%; box-sizing: border-box;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-md);
  padding: 0.85rem; overflow-y: auto;
}
.dp-pop[hidden] { display: none; }
.dp-months { display: flex; gap: 1.5rem; }
.dp-month { width: 17.5rem; flex: 0 0 auto; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.dp-title { font-weight: 600; color: var(--ink); font-size: 0.95rem; }
.dp-nav, .dp-nav-gap { width: 2rem; height: 2rem; flex: 0 0 auto; }
.dp-nav {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface);
  color: var(--text-primary); font: inherit; font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.dp-nav:hover:not(:disabled) { background: var(--surface-alt); border-color: var(--border-strong); }
.dp-nav:disabled { opacity: 0.35; cursor: default; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.dp-wd { text-align: center; font-size: 0.76rem; color: var(--text-muted); padding: 0.3rem 0; }
.dp-day {
  height: 2.25rem; padding: 0; border: 0; border-radius: 999px; background: none;
  font: inherit; font-size: 0.9rem; color: var(--text-primary); cursor: pointer;
}
.dp-day:hover:not(:disabled):not(.is-start):not(.is-end) { background: var(--surface-alt); }
.dp-day:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: -2px; }
.dp-day:disabled { color: var(--text-muted); opacity: 0.4; cursor: default; }
.dp-day.is-today { font-weight: 700; color: var(--brand-accent); box-shadow: inset 0 0 0 1px var(--border-strong); }
.dp-day.is-range, .dp-day.is-preview { background: var(--accent-soft); color: var(--ink); border-radius: 0; box-shadow: none; }
.dp-day.is-start, .dp-day.is-end:not(.is-preview) {
  background: var(--brand-primary); color: var(--text-on-brand); font-weight: 600; box-shadow: none;
}
.dp-day.is-start:not(.is-single) { border-radius: 999px 0 0 999px; }
.dp-day.is-end { border-radius: 0 999px 999px 0; }
.dp-day.is-start.is-end, .dp-day.is-single { border-radius: 999px; }
.dp-day.is-preview { border-radius: 0 999px 999px 0; }
.dp-day.is-off, .dp-day.is-off:hover { color: var(--text-muted); opacity: 0.4; cursor: not-allowed; background: none; }
.dp-quick { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .dp-pop { left: 0; right: 0; width: auto; padding: 0.5rem; }
  .dp-months { display: block; }
  .dp-month { width: auto; }
  .dp-day { height: 2.75rem; }
  .dp-nav, .dp-nav-gap { width: 2.75rem; height: 2.75rem; }
  .dp-quick .btn { min-height: 2.6rem; }
}

.form-actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.25rem; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  font: inherit; font-weight: 550; font-size: 0.92rem;
  padding: 0.62rem 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-primary); color: var(--text-on-brand); }
.btn-primary:hover { background: var(--brand-primary-hover); text-decoration: none; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text-primary); }
.btn-secondary:hover { background: var(--surface-alt); text-decoration: none; }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.84rem; }


.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid color-mix(in srgb, var(--text-on-brand) 40%, transparent);
  border-top-color: var(--text-on-brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }


.alert { padding: 0.85rem 1.05rem; border-radius: var(--radius-md); font-size: 0.92rem; margin-bottom: 1.25rem; border: 1px solid; }
.alert-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.alert-info { background: var(--accent-soft); border-color: var(--accent-soft-border); color: var(--brand-accent); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }

.empty-state {
  text-align: center; padding: 3rem 1.5rem; color: var(--text-muted);
  background: var(--surface-alt); border-radius: var(--radius-lg);
}
.empty-state .icon { font-size: 2.2rem; margin-bottom: 0.75rem; opacity: 0.6; }


.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 640px; }
thead th {
  text-align: left; font-size: 0.8rem; font-weight: 500;
  color: var(--text-muted); background: var(--surface-alt);
  padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-primary); font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-alt) 60%, transparent); }
.price-cell { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--ink); }

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 550;
  border: 1px solid;
}
.badge-business { background: var(--business-bg); border-color: var(--business-border); color: var(--business); }
.badge-estimate { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.badge-real { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.badge-cache { background: var(--accent-soft); border-color: var(--accent-soft-border); color: var(--brand-accent); }
.badge-muted { background: var(--surface-alt); border-color: var(--border); color: var(--text-muted); }

.site-tag { font-size: 0.78rem; color: var(--text-secondary); }
.route-tag { font-weight: 600; color: var(--text-secondary); font-size: 0.82rem; }


.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-md); padding: 2.25rem 2rem; }
.login-card .brand { justify-content: center; margin-bottom: 1.5rem; flex-direction: column; text-align: center; }
.login-card .brand img { height: 56px; padding: 4px; border-radius: 14px; }
.login-card .brand-text { color: var(--ink); font-size: 1.2rem; }
.login-card .brand-text small { color: var(--text-muted); }
.login-card form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.25rem; }
.login-card .btn { width: 100%; margin-top: 0.25rem; padding: 0.75rem 1.25rem; }


.report-text {
  white-space: pre-wrap;
  font-family: "Cascadia Mono", "Consolas", "SFMono-Regular", Menlo, monospace;
  font-size: 0.86rem;
  line-height: 1.6;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  max-height: 70vh;
  overflow: auto;
}


.status-pill { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.9rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-running { background: var(--warning); animation: pulse 1.4s ease-in-out infinite; }
.dot-done { background: var(--success); }
.dot-error { background: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── AI-ассистент рассылки — пиксельный герой (см. assistant.js) ──────
   Герой — не <img>, а div с лентой кадров (static/img/pixel/<состояние>.png,
   собирается scripts/make_pixel_assistant.py). Ленту листает CSS steps():
   каждая фаза = своя лента и свой темп. Масштаб строго целый (--px-scale),
   image-rendering: pixelated — пиксели остаются квадратными.
   Фаза = класс assistant-idle/running/captcha на #assistant-widget;
   assistant-success — одноразовая реакция «нашёл маршрут» (ставит JS).

   «Сцена» (.assistant-frame) — комната человечка (static/js/pixel_room.js):
   на компьютере комната 92x104 клетки, на планшете и телефоне — низкая полоса
   160x96 «окно — стойка — полка» (человечек по пояс). Все размеры — клетки
   сетки × --px-scale, масштаб только целый: компьютер x4 (x3 на узком),
   планшет x3, телефон x2; «дом» на компьютере — та же сцена крупно, x5–x8
   под окно (свой --px-scale на сцене, «Комната крупно» ниже). Переменные
   заданы на .ai-layout — их читают и сетка колонок, и сцена. */
.assistant-face {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  min-width: 0;
  text-align: left;
}

.assistant-frame {
  --frame-w: 72;   /* ширина/высота одного кадра ленты в клетках сетки */
  --frame-h: 104;
  position: relative;
  width: calc(var(--scene-w) * var(--px-scale) * 1px);
  height: calc(var(--scene-h) * var(--px-scale) * 1px);
  margin: 0 auto;
  flex: 0 0 auto;
}
/* Пока pixel_room.js не поставил комнату и наряд дня (перекраска лент на
   canvas) — сцена скрыта, место занято, раскладка не прыгает: при переходе
   на страницу нет кадра «сначала костюм, потом худи». Атрибут стоит в HTML,
   снимает его pixel_room.js, когда наряд готов (подстраховка: скрипт не
   запустился — 3 с, rassylka.html; ленты не пришли — 10 с, pixel_room.js). */
.assistant-face[data-scene-wait] .assistant-frame { visibility: hidden; }

/* ── Комната (листы img/pixel/room/*.png, scripts/make_pixel_room.py) ──
   Лист desk.png / phone.png — сетка ячеек по 4 в ряд, каждая ячейка — целая
   сцена: задник и передний план на 3 света, горящая лампа, декор, предметы
   арки. Номер ячейки = --col/--row (порядок — CELLS в pixel_room.js).
   Окно, свет, сезон — атрибуты data-* на #pixel-room. Тёмная тема панели
   приглушает комнату (не человечка) до ~82% яркости: --room-dim. Утром, вечером
   и ночью декор, сувениры, растение и кот темнеют и теплеют (холодеют) вместе с
   мебелью: --light-k (яркость) и --light-tint (оттенок). Свет мебели и пятна
   от лампы и ноутбука нарисованы в самих ячейках листа (make_pixel_room.py). */
.pixel-room {
  --room-dim: 1;
  --light-k: 1;
  --light-tint: saturate(1);
  --sheet-cols: 4;
  --sheet-rows: 6;
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: #e4dbca;
}
.room-layer, .room-extra > *, .room-items > * {
  position: absolute;
  pointer-events: none;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.room-layer, .room-extra, .room-extra > * { inset: 0; }
.room-extra, .room-items { position: absolute; inset: 0; pointer-events: none; }
.room-cell, .room-extra > * {
  --col: 0;
  --row: 0;
  background-image: url("../img/pixel/room/desk.png");
  background-size: calc(var(--sheet-cols) * var(--scene-w) * var(--px-scale) * 1px)
                   calc(var(--sheet-rows) * var(--scene-h) * var(--px-scale) * 1px);
  background-position: calc(var(--col) * var(--scene-w) * var(--px-scale) * -1px)
                       calc(var(--row) * var(--scene-h) * var(--px-scale) * -1px);
  filter: brightness(var(--room-dim));
}
.room-extra > *, .room-items > * { filter: brightness(calc(var(--room-dim) * var(--light-k))) var(--light-tint); }
/* горящая лампа — сама источник света: не темнеет вечером и ночью */
.room-extra > [data-cell="lamp_on"] { filter: brightness(var(--room-dim)); }
.pixel-room[data-light="morning"] { --light-tint: sepia(0.12); }
.pixel-room[data-light="evening"] { --light-k: 0.72; --light-tint: sepia(0.3); }
.pixel-room[data-light="night"] { --light-k: 0.5; --light-tint: saturate(0.6); }
.room-back { --col: 0; }
.pixel-room[data-light="morning"] .room-back { --col: 3; --row: 4; }
.pixel-room[data-light="evening"] .room-back { --col: 1; }
.pixel-room[data-light="night"] .room-back { --col: 2; }
.room-front { --col: 3; }
.pixel-room[data-light="morning"] .room-front { --col: 0; --row: 5; }
.pixel-room[data-light="evening"] .room-front { --col: 0; --row: 1; }
.pixel-room[data-light="night"] .room-front { --col: 1; --row: 1; }
/* Человечек вечером и ночью чуть подсвечен тёплым от лампы — лёгкий тон,
   лицо и наряд читаются (тёмная тема панели его не приглушает). */
.pixel-room[data-light="evening"] .pixel-hero,
.pixel-room[data-light="evening"] .pixel-pose { filter: sepia(0.14) brightness(0.96); }
.pixel-room[data-light="night"] .pixel-hero,
.pixel-room[data-light="night"] .pixel-pose { filter: sepia(0.2) brightness(0.88); }

/* Вид в окне: лист windows.png — 6 времён (столбцы) × 3 сезона (строки), 14x29 */
.room-view {
  --wcol: 2;
  --wrow: 0;
  inset: auto;
  left: calc(var(--glass-x) * var(--px-scale) * 1px);
  top: calc(var(--glass-y) * var(--px-scale) * 1px);
  width: calc(14 * var(--px-scale) * 1px);
  height: calc(29 * var(--px-scale) * 1px);
  background-image: url("../img/pixel/room/windows.png");
  background-size: calc(84 * var(--px-scale) * 1px) calc(87 * var(--px-scale) * 1px);
  background-position: calc(var(--wcol) * 14 * var(--px-scale) * -1px) calc(var(--wrow) * 29 * var(--px-scale) * -1px);
  filter: brightness(var(--room-dim));
}
.pixel-room[data-window="early_morning"] .room-view { --wcol: 0; }
.pixel-room[data-window="morning"] .room-view { --wcol: 1; }
.pixel-room[data-window="sunset"] .room-view { --wcol: 3; }
.pixel-room[data-window="evening"] .room-view { --wcol: 4; }
.pixel-room[data-window="night"] .room-view { --wcol: 5; }
.pixel-room[data-wseason="winter"] .room-view { --wrow: 1; }
.pixel-room[data-wseason="spring"] .room-view { --wrow: 2; }

/* Сувениры на полке (лист souvenirs.png, иконки 8x8 в ряд) и кнопки на карте.
   Ячейка полки — клетки --dx/--dy (компьютер) и --mx/--my (телефон). */
.room-souvenir {
  left: calc(var(--dx) * var(--px-scale) * 1px);
  top: calc(var(--dy) * var(--px-scale) * 1px);
  width: calc(8 * var(--px-scale) * 1px);
  height: calc(8 * var(--px-scale) * 1px);
  background-image: url("../img/pixel/room/souvenirs.png");
  background-size: calc(var(--souv-n, 15) * 8 * var(--px-scale) * 1px) calc(8 * var(--px-scale) * 1px);
  background-position: calc(var(--i) * 8 * var(--px-scale) * -1px) 0;
}
.room-pin {
  left: calc(var(--dx) * var(--px-scale) * 1px);
  top: calc(var(--dy) * var(--px-scale) * 1px);
  width: calc(var(--px-scale) * 1px);
  height: calc(var(--px-scale) * 1px);
  background: #cc4840;
}
/* новый сувенир дня — одна короткая подсветка (класс ставит pixel_room.js);
   is-coming — ещё «в руке»: скрыт, пока человечек не поставит его на полку */
.room-souvenir.is-new { animation: souvenir-new 0.7s ease-in-out 2; }
.room-souvenir.is-coming { visibility: hidden; }
/* сувенир «в руке» (#room-carry): у поднятой ладони, потом два шага на полку */
.room-carry {
  position: absolute;
  left: calc(var(--cx, 0) * var(--px-scale) * 1px);
  top: calc(var(--cy, 0) * var(--px-scale) * 1px);
  width: calc(8 * var(--px-scale) * 1px);
  height: calc(8 * var(--px-scale) * 1px);
  background-image: url("../img/pixel/room/souvenirs.png");
  background-repeat: no-repeat;
  background-size: calc(var(--souv-n, 15) * 8 * var(--px-scale) * 1px) calc(8 * var(--px-scale) * 1px);
  background-position: calc(var(--i, 0) * 8 * var(--px-scale) * -1px) 0;
  image-rendering: pixelated;
  pointer-events: none;
  transition: left 0.3s steps(2, jump-end), top 0.3s steps(2, jump-end);
}
.room-carry[hidden] { display: none; }
@keyframes souvenir-new {
  0%, 100% { filter: brightness(calc(var(--room-dim) * var(--light-k))) var(--light-tint); }
  50% { filter: brightness(calc(var(--room-dim) * var(--light-k) * 1.35)) var(--light-tint) drop-shadow(0 0 3px #ffe08a); }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pixel-room { --room-dim: 0.82; background: #bbb4a6; }
}
:root[data-theme="dark"] .pixel-room { --room-dim: 0.82; background: #bbb4a6; }

/* Кадр человечка (72x104) ставится от левого верхнего угла сцены: отступ
   слева — --hero-x клеток; низ кадра закрывает стойка (на телефоне — ещё и
   край полосы). Размер ленты в пикселях (кадры × ширина × масштаб) — без дробей.
   Наряд дня: pixel_room.js подменяет ленты перекрашенными копиями через
   --strip-<лента>; без них — обычные файлы. */
.pixel-hero {
  --n: 18;          /* кадров в ленте */
  --dur: 3.6s;      /* длительность одного круга */
  --iter: infinite;
  position: absolute;
  left: calc(var(--hero-x) * var(--px-scale) * 1px);
  top: 0;
  width: calc(var(--frame-w) * var(--px-scale) * 1px);
  height: calc(var(--frame-h) * var(--px-scale) * 1px);
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: calc(var(--n) * var(--frame-w) * var(--px-scale) * 1px) calc(var(--frame-h) * var(--px-scale) * 1px);
  image-rendering: pixelated;
  animation: pixel-play var(--dur) steps(var(--n), jump-none) var(--iter);
}
/* 0% — первый кадр ленты, 100% — последний; jump-none даёт ровно n кадров */
@keyframes pixel-play {
  from { background-position-x: 0%; }
  to { background-position-x: 100%; }
}

.assistant-idle .pixel-hero {
  background-image: var(--strip-idle, url("/static/img/pixel/idle.png"));
  --n: 18; --dur: 3.6s;
}
.assistant-running .pixel-hero {
  background-image: var(--strip-running, url("/static/img/pixel/running.png"));
  --n: 12; --dur: 1.2s;
}
.assistant-captcha .pixel-hero {
  background-image: var(--strip-captcha, url("/static/img/pixel/captcha.png"));
  --n: 12; --dur: 1.8s;
}
/* рамка «нужна проверка» поверх всех слоёв комнаты (сама комната закрыла бы тень сцены) */
.pixel-room::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.assistant-captcha .pixel-room::after { box-shadow: inset 0 0 0 2px var(--warning-border); }
/* success: два прыжка подряд (лента 10 кадров играется дважды), потом JS
   возвращает фазу; объявлен последним — перекрывает idle/running */
#assistant-widget.assistant-success .pixel-hero {
  background-image: var(--strip-success, url("/static/img/pixel/success.png"));
  --n: 10; --dur: 1.2s; --iter: 2;
}

/* Человечек — кнопка (клик/Enter = реплика). Сброс стилей кнопки, фокус виден. */
button.pixel-hero {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background-color: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button.pixel-hero:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: -3px; border-radius: var(--radius-md); }

/* ── «Жизнь в покое» (static/js/pixel_life.js) ──────────────────────────
   Только в фазе idle и не во время success. JS ставит на виджет
   data-life="<действие>" (одноразовая лента) или data-mood="tired" (усталый
   вид вместо обычного покоя). Ленты: img/pixel/life_<действие>.png, собирает
   scripts/make_pixel_assistant.py; число кадров и длительности ниже должны
   совпадать с DURATIONS в pixel_life.js. */
@keyframes pixel-play-life {
  from { background-position-x: 0%; }
  to { background-position-x: 100%; }
}
.assistant-face.assistant-idle:not(.assistant-success)[data-life] .pixel-hero {
  animation-name: pixel-play-life;
  animation-fill-mode: forwards;
  --iter: 1;
}
.assistant-face.assistant-idle:not(.assistant-success)[data-life="look_l"] .pixel-hero { background-image: var(--strip-life_look_l, url("/static/img/pixel/life_look_l.png")); --n: 12; --dur: 1.8s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="look_r"] .pixel-hero { background-image: var(--strip-life_look_r, url("/static/img/pixel/life_look_r.png")); --n: 12; --dur: 1.8s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="blink2"] .pixel-hero { background-image: var(--strip-life_blink2, url("/static/img/pixel/life_blink2.png")); --n: 10; --dur: 1.2s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="stretch"] .pixel-hero { background-image: var(--strip-life_stretch, url("/static/img/pixel/life_stretch.png")); --n: 16; --dur: 2.4s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="yawn"] .pixel-hero { background-image: var(--strip-life_yawn, url("/static/img/pixel/life_yawn.png")); --n: 14; --dur: 2.1s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="phone"] .pixel-hero { background-image: var(--strip-life_phone, url("/static/img/pixel/life_phone.png")); --n: 18; --dur: 2.7s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="stomp"] .pixel-hero { background-image: var(--strip-life_stomp, url("/static/img/pixel/life_stomp.png")); --n: 12; --dur: 1.2s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="coffee"] .pixel-hero { background-image: var(--strip-life_coffee, url("/static/img/pixel/life_coffee.png")); --n: 24; --dur: 4.8s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="wake"] .pixel-hero { background-image: var(--strip-life_wake, url("/static/img/pixel/life_wake.png")); --n: 10; --dur: 1s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="hi"] .pixel-hero { background-image: var(--strip-life_hi, url("/static/img/pixel/life_hi.png")); --n: 8; --dur: 0.96s; }
/* сон — цикл до первого действия пользователя */
.assistant-face.assistant-idle:not(.assistant-success)[data-life="sleep"] .pixel-hero {
  /* спит за столом, голова на руках — картинка дремоты (life_nap), не стоя */
  background-image: var(--strip-life_sleep, url("/static/img/pixel/life_nap.png")); --n: 12; --dur: 3.6s; --iter: infinite;
}
/* усталый вид (полуприкрытые глаза) вместо обычного покоя */
.assistant-face.assistant-idle:not(.assistant-success)[data-mood="tired"]:not([data-life]) .pixel-hero {
  background-image: var(--strip-life_tired, url("/static/img/pixel/life_tired.png")); --n: 18; --dur: 3.6s;
}
/* Лицо по настроению («разум», pixel_life.js ставит data-feel): рад — улыбка,
   раздражён — брови к переносице (важнее сонного вида); тот же круг покоя */
.assistant-face.assistant-idle:not(.assistant-success)[data-feel="happy"]:not([data-life]):not([data-mood]) .pixel-hero {
  background-image: var(--strip-life_happy, url("/static/img/pixel/life_happy.png")); --n: 18; --dur: 3.6s;
}
.assistant-face.assistant-idle:not(.assistant-success)[data-feel="irked"]:not([data-life]) .pixel-hero {
  background-image: var(--strip-life_irked, url("/static/img/pixel/life_irked.png")); --n: 18; --dur: 3.6s;
}
/* Походка за стойкой (по кругу, пока идёт), у кота, дремота на сложенных руках
   (на телефоне стойка на 3 клетки выше — лента сдвигается: --nap-dy) */
.assistant-face.assistant-idle:not(.assistant-success)[data-life="walk_l"] .pixel-hero { background-image: var(--strip-life_walk_l, url("/static/img/pixel/life_walk_l.png")); --n: 4; --dur: 0.48s; --iter: infinite; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="walk_r"] .pixel-hero { background-image: var(--strip-life_walk_r, url("/static/img/pixel/life_walk_r.png")); --n: 4; --dur: 0.48s; --iter: infinite; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="pet_l"] .pixel-hero { background-image: var(--strip-life_pet_l, url("/static/img/pixel/life_pet_l.png")); --n: 10; --dur: 2.4s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="pet_r"] .pixel-hero { background-image: var(--strip-life_pet_r, url("/static/img/pixel/life_pet_r.png")); --n: 10; --dur: 2.4s; }
.assistant-face.assistant-idle:not(.assistant-success)[data-life="nap"] .pixel-hero {
  background-image: var(--strip-life_nap, url("/static/img/pixel/life_nap.png")); --n: 12; --dur: 3.6s; --iter: infinite;
  top: calc(var(--nap-dy, 0) * var(--px-scale) * 1px);
}

/* Знак над головой (pixel_life.js: data-sign на виджете, --sign-i — ячейка
   листа img/pixel/signs.png 11x11: «…», нота, тучка, сердце). Внутри кнопки-
   человечка — ходит вместе с ним; клетки 36–46 кадра, строки 5–15: над макушкой,
   левее пузыря и выше поднятой руки. Короткий: появился, качнулся, исчез;
   reduced-motion — без движения. */
.pixel-sign {
  position: absolute;
  left: calc(36 * var(--px-scale) * 1px);
  top: calc(5 * var(--px-scale) * 1px);
  width: calc(11 * var(--px-scale) * 1px);
  height: calc(11 * var(--px-scale) * 1px);
  background: url("/static/img/pixel/signs.png") no-repeat;
  background-size: calc(44 * var(--px-scale) * 1px) calc(11 * var(--px-scale) * 1px);
  background-position: calc(var(--sign-i, 0) * 11 * var(--px-scale) * -1px) 0;
  image-rendering: pixelated;
  pointer-events: none;
  display: none;
}
.assistant-face.assistant-idle:not(.assistant-success)[data-sign] .pixel-sign {
  display: block;
  animation: sign-pop 2.4s steps(1, end) 1 both;
}
.assistant-face[data-life="sleep"] .pixel-sign, .assistant-face[data-life="wake"] .pixel-sign,
.assistant-face[data-life="nap"] .pixel-sign, .assistant-face[data-pose-place] .pixel-sign,
.assistant-face[data-change] .pixel-sign { display: none !important; }
@keyframes sign-pop {
  0% { transform: translateY(calc(2 * var(--px-scale) * 1px)); opacity: 1; }
  6% { transform: translateY(calc(1 * var(--px-scale) * 1px)); }
  12%, 44% { transform: none; }
  45%, 69% { transform: translateY(calc(-1 * var(--px-scale) * 1px)); }
  70%, 93% { transform: none; opacity: 1; }
  94%, 100% { transform: none; opacity: 0; }
}

/* «Не беспокоить» или менеджер печатает (pixel_life.js ставит data-still):
   в покое человечек стоит неподвижно — первый кадр ленты покоя, без жизни. */
.assistant-face.assistant-idle:not(.assistant-success)[data-still] .pixel-hero { animation: none; }

/* «Разговор» (голос, pixel_voice.js ставит на виджет data-talk="0|1|2"): пока
   звучит реплика, человечек стоит на первом кадре покоя (без дыхания), поверх
   рта — накладка img/pixel/talk_mouth.png 7x3 клетки (кадр 0 — приоткрыт,
   1 — открыт; scripts/make_pixel_assistant.py --mouth), место — клетки 27/44
   кадра. Только в покое, без действия и позы; reduced-motion — без накладки. */
.pixel-mouth {
  position: absolute;
  left: calc(27 * var(--px-scale) * 1px);
  top: calc(44 * var(--px-scale) * 1px);
  width: calc(7 * var(--px-scale) * 1px);
  height: calc(3 * var(--px-scale) * 1px);
  background: url("/static/img/pixel/talk_mouth.png") no-repeat 0 0 / calc(14 * var(--px-scale) * 1px) calc(3 * var(--px-scale) * 1px);
  image-rendering: pixelated;
  pointer-events: none;
  display: none;
}
.assistant-face.assistant-idle:not(.assistant-success)[data-talk]:not([data-life]) .pixel-hero { animation: none; }
.assistant-face.assistant-idle:not(.assistant-success)[data-talk="1"]:not([data-life]):not([data-pose-place]) .pixel-mouth { display: block; }
.assistant-face.assistant-idle:not(.assistant-success)[data-talk="2"]:not([data-life]):not([data-pose-place]) .pixel-mouth {
  display: block;
  background-position: calc(7 * var(--px-scale) * -1px) 0;
}
@media (prefers-reduced-motion: reduce) {
  .pixel-mouth { display: none !important; }
}

/* Пузырь-реплика по клику: лежит внутри сцены справа от головы (голова —
   клетки 20–47 кадра, строки 16–43), хвостик смотрит влево на неё. Место
   задано в клетках × масштаб — двигается вместе с человечком. На узкой
   сцене (x3 на компьютере) пузырь может чуть выйти за правый край — в
   промежуток между колонками, поле ввода не закрывает. */
.pixel-bubble {
  --bubble-x: calc((var(--hero-x) + 50) * var(--px-scale) * 1px);
  position: absolute;
  left: var(--bubble-x);
  top: calc(13 * var(--px-scale) * 1px);
  transform: translate(-4px, 0);
  width: max-content;
  max-width: max(8.5rem, calc(100% - var(--bubble-x) - 0.5rem));
  padding: 0.35rem 0.6rem;
  border: 2px solid var(--text-primary);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, transform 0.15s, visibility 0s 0.15s;
  z-index: 5;
}
.pixel-bubble::after {          /* хвостик к голове */
  content: "";
  position: absolute;
  right: 100%;
  top: 0.55rem;
  border: 5px solid transparent;
  border-right-color: var(--text-primary);
}
.pixel-bubble.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.15s, transform 0.15s, visibility 0s;
}
/* Подсказка по делу (pixel_life.js, pixel_tips.py): весь пузырь — ссылка на
   нужную страницу («Снижения цен», «Подсказки ИИ»), бирюзовая рамка и «→».
   Нажимается только пока виден; цель нажатия — не ниже 40px. */
.pixel-bubble.has-link { padding: 0; border-color: var(--brand-accent); }
.pixel-bubble.has-link::after { border-right-color: var(--brand-accent); }
.pixel-bubble.has-link.is-on { pointer-events: auto; }
.pixel-bubble-link {
  display: flex; align-items: center;
  min-height: 40px; box-sizing: border-box;
  padding: 0.35rem 0.6rem;
  color: inherit; text-decoration: none; cursor: pointer;
}
.pixel-bubble-go { color: var(--brand-accent); font-weight: 700; white-space: nowrap; }
.pixel-bubble-link:hover { background: var(--accent-soft); }
.pixel-bubble-link:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 1px; }
.ai-layout.room-open .pixel-bubble.has-link { padding: 0; }
.ai-layout.room-open .pixel-bubble-link { padding: 0.45rem 0.75rem; }

@media (prefers-reduced-motion: reduce) {
  /* без движения: остаётся первый кадр ленты текущей фазы; пузырь — без анимации */
  .pixel-hero { animation: none !important; }
  .assistant-face.assistant-idle:not(.assistant-success)[data-sign] .pixel-sign { animation: none; }
  .pixel-bubble, .pixel-bubble.is-on { transition: none; }
  .room-souvenir.is-new { animation: none; }
}

.assistant-bubble { display: flex; align-items: flex-start; gap: 0.5rem; width: 100%; min-width: 0; overflow-wrap: anywhere; }
.assistant-status { flex: 1 1 auto; min-width: 0; }
.assistant-bubble p { margin: 0; }
/* «Не беспокоить» — маленькая кнопка-луна рядом со сценой (pixel_life.js) */
.pixel-dnd {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.pixel-dnd svg { width: 16px; height: 16px; }
.pixel-dnd:hover { color: var(--text-primary); border-color: var(--border-strong); }
.pixel-dnd:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.pixel-dnd[aria-pressed="true"] { color: var(--surface); background: var(--text-primary); border-color: var(--text-primary); }
.pixel-dnd[aria-pressed="true"] svg { fill: currentColor; }
/* «Дом» (pixel_room.js): на телефоне и планшете — вся комната в блоке, на
   компьютере — комната крупно поверх страницы (правила «Комната крупно» ниже) */
.pixel-home {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.pixel-home svg { width: 16px; height: 16px; }
.pixel-home:hover { color: var(--text-primary); border-color: var(--border-strong); }
.pixel-home:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.pixel-home[aria-expanded="true"] { color: var(--surface); background: var(--text-primary); border-color: var(--text-primary); }

/* ── Комната крупно (компьютер, шире 900px; pixel_room.js setZoom) ──
   Та же сцена .assistant-frame (не копия: человечек, пузырь, кот, походы
   идут дальше) уходит из потока в position: fixed. Масштаб — целый
   --zoom-scale (около 60% высоты окна, крупнее обычного, не больше
   влезающего), угол — целые --zoom-left/--zoom-top: пиксели квадратные,
   без размытия. Всё внутри считается через --px-scale — оно и подменено.
   На прежнем месте — пустой блок того же размера (::before), страница не
   прыгает. Фон затемнён (#room-backdrop); кнопка «дом» — над фоном, под комнатой. */
.room-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(20, 33, 58, 0.55);
  animation: room-fade-in 0.18s ease-out;
}
.room-backdrop[hidden], .room-close[hidden] { display: none; }
.room-close {
  position: absolute;
  top: 0;
  left: calc(100% + 12px);      /* справа от комнаты, на фоне — не закрывает сцену */
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
}
.room-close svg { width: 18px; height: 18px; }
.room-close:hover { border-color: var(--border-strong); }
.room-close:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .room-backdrop { background: rgba(0, 0, 0, 0.66); }
}
:root[data-theme="dark"] .room-backdrop { background: rgba(0, 0, 0, 0.66); }
@media (min-width: 901px) {
  .ai-layout.room-open .assistant-face::before {
    content: "";
    order: -1;
    flex: 0 0 auto;
    width: calc(var(--scene-w) * var(--px-scale) * 1px);
    height: calc(var(--scene-h) * var(--px-scale) * 1px);
    margin: 0 auto;
  }
  .ai-layout.room-open .assistant-frame {
    --px-scale: var(--zoom-scale, 5);
    position: fixed;
    left: var(--zoom-left, 0px);
    top: var(--zoom-top, 0px);
    margin: 0;
    z-index: 202;
    border-radius: var(--radius-md);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    animation: room-zoom-in 0.18s ease-out;
  }
  /* «дом» над затемнением (им же и закрыть), но под комнатой, если она его накрыла */
  .ai-layout.room-open .pixel-home { position: relative; z-index: 201; }
  /* реплики крупнее — под стать комнате */
  .ai-layout.room-open .pixel-bubble { font-size: 0.95rem; padding: 0.45rem 0.75rem; }
  .ai-layout.room-open .cat-bubble { font-size: 0.9rem; }
}
/* открытие/закрытие: переход сдвига человечка и сувенира «в руке» на миг
   выключен — масштаб сменился, они сразу на своих клетках (pixel_room.js) */
.zoom-snap .pixel-hero, .zoom-snap .room-carry { transition: none !important; }
@keyframes room-fade-in { from { opacity: 0; } }
@keyframes room-zoom-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  .room-backdrop, .ai-layout.room-open .assistant-frame { animation: none; }
}
/* Голос — кнопка-динамик рядом с луной (pixel_voice.js): по умолчанию
   выключен; спрятана, пока у фраз дня нет озвучки */
.pixel-sound {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.pixel-sound[hidden] { display: none; }
.pixel-sound svg { width: 16px; height: 16px; }
.pixel-sound:hover { color: var(--text-primary); border-color: var(--border-strong); }
.pixel-sound:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.pixel-sound[aria-pressed="true"] { color: var(--surface); background: var(--text-primary); border-color: var(--text-primary); }
.pixel-sound .snd-on, .pixel-sound[aria-pressed="true"] .snd-off { display: none; }
.pixel-sound[aria-pressed="true"] .snd-on { display: inline; }
@media (max-width: 640px) {
  .pixel-sound { width: 40px; height: 40px; }
}

/* ── «Живой дом» (этап 2, pixel_room.js) ──────────────────────────────────
   Растение на подоконнике, кот, пиджак на ширме и «пуф» при переодевании,
   позы, нарисованные руками. Листы img/pixel/room/plant.png (ячейки 12x16),
   cat.png (14x10), fx.png (12x8) собирает scripts/make_pixel_room.py, места —
   layout.json → «life». Место элемента — клетки --dx/--dy (комната) или
   --mx/--my (полоса телефона, правила в конце файла). */
.room-at {
  position: absolute;
  left: calc(var(--dx, 0) * var(--px-scale) * 1px);
  top: calc(var(--dy, 0) * var(--px-scale) * 1px);
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.room-at[hidden] { display: none; }
.room-plant, .room-plant-fx {
  width: calc(12 * var(--px-scale) * 1px);
  height: calc(16 * var(--px-scale) * 1px);
  background-image: url("../img/pixel/room/plant.png");
  background-size: calc(96 * var(--px-scale) * 1px) calc(16 * var(--px-scale) * 1px);
  image-rendering: pixelated;
  background-repeat: no-repeat;
}
.room-plant {
  background-position: calc(var(--stage, 0) * 12 * var(--px-scale) * -1px) 0;
  pointer-events: none;
  filter: brightness(calc(var(--room-dim) * var(--light-k))) var(--light-tint);
}
/* «полит сегодня»: капля падает на землю и блеск — один раз */
.room-plant-fx { position: absolute; inset: 0; opacity: 0; background-position: calc(72 * var(--px-scale) * -1px) 0; }
.room-plant.is-watered .room-plant-fx { animation: plant-water 1.6s steps(1, end) 1 both; }
@keyframes plant-water {
  0% { opacity: 1; transform: translateY(calc(-4 * var(--px-scale) * 1px)); }
  12% { opacity: 1; transform: translateY(calc(-3 * var(--px-scale) * 1px)); }
  24% { opacity: 1; transform: translateY(calc(-1 * var(--px-scale) * 1px)); }
  36% { opacity: 1; transform: none; }
  48%, 88% { opacity: 1; transform: none; background-position: calc(84 * var(--px-scale) * -1px) 0; }
  100% { opacity: 0; background-position: calc(84 * var(--px-scale) * -1px) 0; }
}

/* Кот — кнопка (клик — «мур»); невидимое поле вокруг — цель нажатия не меньше 40px */
.room-cat {
  --walk: var(--walk-d, 0);
  width: calc(14 * var(--px-scale) * 1px);
  height: calc(10 * var(--px-scale) * 1px);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.room-cat::before { content: ""; position: absolute; inset: -10px -6px; }
.room-cat:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; border-radius: 4px; }
.room-cat-sprite {
  position: absolute;
  inset: 0;
  background-image: url("../img/pixel/room/cat.png");
  background-size: calc(84 * var(--px-scale) * 1px) calc(10 * var(--px-scale) * 1px);
  background-repeat: no-repeat;
  background-position: 0 0;
  image-rendering: pixelated;
  filter: brightness(calc(var(--room-dim) * var(--light-k))) var(--light-tint);
}
.room-cat[data-pose="sit"] .room-cat-sprite { animation: cat-blink 7s steps(1, end) infinite; }
.room-cat[data-pose="sleep"] .room-cat-sprite { background-position: calc(28 * var(--px-scale) * -1px) 0; animation: cat-breathe 2.6s steps(1, end) infinite; }
.room-cat[data-pose="walk"] { animation: cat-walk 10s linear 1 forwards; }
.room-cat[data-pose="walk"] .room-cat-sprite { background-position: calc(56 * var(--px-scale) * -1px) 0; animation: cat-step 0.6s steps(1, end) infinite; }
@keyframes cat-blink {
  0%, 92%, 100% { background-position: 0 0; }
  93%, 96% { background-position: calc(14 * var(--px-scale) * -1px) 0; }
}
@keyframes cat-breathe {
  0%, 49% { background-position: calc(28 * var(--px-scale) * -1px) 0; }
  50%, 100% { background-position: calc(42 * var(--px-scale) * -1px) 0; }
}
@keyframes cat-step {
  0%, 49% { background-position: calc(56 * var(--px-scale) * -1px) 0; }
  50%, 100% { background-position: calc(70 * var(--px-scale) * -1px) 0; }
}
/* туда и обратно один раз (обратно — мордой влево), потом садится (pixel_room.js) */
@keyframes cat-walk {
  0% { transform: translateX(0) scaleX(1); }
  49.9% { transform: translateX(calc(var(--walk) * var(--px-scale) * 1px)) scaleX(1); }
  50% { transform: translateX(calc(var(--walk) * var(--px-scale) * 1px)) scaleX(-1); }
  99.9% { transform: translateX(0) scaleX(-1); }
  100% { transform: translateX(0) scaleX(1); }
}
/* работа важнее: во время поиска, капчи, ввода и «не беспокоить» кот замирает */
.assistant-face:not(.assistant-idle) .room-cat, .assistant-face:not(.assistant-idle) .room-cat-sprite,
.assistant-face[data-still] .room-cat, .assistant-face[data-still] .room-cat-sprite { animation-play-state: paused; }
.cat-bubble {
  transform: translate(calc(4 * var(--px-scale) * 1px), calc(-100% - 4px));
  padding: 0.1rem 0.4rem;
  border: 2px solid var(--text-primary);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0s 0.15s;
  z-index: 4;
}
.cat-bubble.is-on { opacity: 1; visibility: visible; transition: opacity 0.15s, visibility 0s; }

/* Переодевание: пиджак летит и ложится на ширму, «пуф» на телефоне (лист fx.png) */
.room-fx {
  width: calc(12 * var(--px-scale) * 1px);
  height: calc(8 * var(--px-scale) * 1px);
  background-image: url("../img/pixel/room/fx.png");
  background-size: calc(84 * var(--px-scale) * 1px) calc(8 * var(--px-scale) * 1px);
  background-position: calc(var(--fx-i, 0) * 12 * var(--px-scale) * -1px) 0;
  pointer-events: none;
  filter: brightness(calc(var(--room-dim) * var(--light-k))) var(--light-tint);
}
/* человечек уходит за ширму (влево, тает) и выходит; на телефоне просто тает.
   Поход по комнате (pixel_life.js): сдвиг translate в целых клетках --trip-x,
   шагами — по клетке (--trip-n шагов за --trip-ms) */
.pixel-hero {
  translate: calc(var(--trip-x, 0) * var(--px-scale) * 1px) 0;
  transition: opacity 0.3s ease, transform 0.3s ease, translate var(--trip-ms, 0ms) steps(var(--trip-n, 1), jump-end);
}
.assistant-face[data-change="out"] .pixel-hero { opacity: 0; transform: translateX(calc(-12 * var(--px-scale) * 1px)); }
.assistant-face[data-change="pouf"] .pixel-hero { opacity: 0; }

/* Позы, нарисованные руками (img/pixel/poses.json, pose_*.png): «привет»,
   телефон и кофе — вместо обычной ленты; диван и окно — отдельный слой
   .pixel-pose на своём месте комнаты, человечек на это время прячется. */
.assistant-face.assistant-idle:not(.assistant-success)[data-life="hi"][data-pose-hi] .pixel-hero {
  background-image: var(--strip-pose_wave); --n: var(--pose-hi-n); --dur: var(--pose-hi-dur);
}
.assistant-face.assistant-idle:not(.assistant-success)[data-life="phone"][data-pose-phone] .pixel-hero {
  background-image: var(--strip-pose_phone); --n: var(--pose-phone-n); --dur: var(--pose-phone-dur);
}
.assistant-face.assistant-idle:not(.assistant-success)[data-life="coffee"][data-pose-coffee] .pixel-hero {
  background-image: var(--strip-pose_cup); --n: var(--pose-coffee-n); --dur: var(--pose-coffee-dur);
}
/* обед — сэндвич (pose_lunch.png, собрана из позы «чашка»); полить и погладить
   кота — позы появятся, когда их нарисуют (assets/pixel/poses/water.ase, pet.ase) */
.assistant-face.assistant-idle:not(.assistant-success)[data-life="lunch"][data-pose-lunch] .pixel-hero {
  background-image: var(--strip-pose_lunch); --n: var(--pose-lunch-n); --dur: var(--pose-lunch-dur);
}
.assistant-face.assistant-idle:not(.assistant-success)[data-life="water"][data-pose-water] .pixel-hero {
  background-image: var(--strip-pose_water); --n: var(--pose-water-n); --dur: var(--pose-water-dur);
}
.assistant-face.assistant-idle:not(.assistant-success)[data-life="pet"][data-pose-pet] .pixel-hero {
  background-image: var(--strip-pose_pet); --n: var(--pose-pet-n); --dur: var(--pose-pet-dur);
}
/* ставит сувенир на полку: рука поднята (первый кадр позы «привет»), стоит */
.assistant-face.assistant-idle:not(.assistant-success)[data-life="shelf"][data-pose-hi] .pixel-hero {
  background-image: var(--strip-pose_wave); --n: var(--pose-hi-n); animation: none; background-position: 0 0;
}
.pixel-pose {
  display: none;
  width: calc(var(--pw, 72) * var(--px-scale) * 1px);
  height: calc(var(--ph, 104) * var(--px-scale) * 1px);
  background-image: var(--pose-img);
  background-size: calc(var(--pn, 1) * var(--pw, 72) * var(--px-scale) * 1px) calc(var(--ph, 104) * var(--px-scale) * 1px);
  pointer-events: none;
  animation: pixel-play var(--pdur, 1s) steps(var(--pn, 1), jump-none) infinite;
}
.assistant-face.assistant-idle:not(.assistant-success)[data-pose-place] .pixel-pose { display: block; }
.assistant-face.assistant-idle:not(.assistant-success)[data-pose-place] .pixel-hero { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .room-cat, .room-cat-sprite, .room-plant-fx, .pixel-pose { animation: none !important; }
  .room-cat[data-pose="walk"] .room-cat-sprite { background-position: 0 0; }
  .pixel-hero { transition: none; }
  .cat-bubble, .cat-bubble.is-on { transition: none; }
}

#assistant-text { font-weight: 600; font-size: 0.92rem; }
.assistant-captcha #assistant-text { color: var(--warning); }

.route-flight { display: inline-flex; align-items: center; gap: 0.35rem; }
.route-flight .flight-dots { color: var(--text-muted); letter-spacing: 1px; }


.site-footer { text-align: center; padding: 1.5rem; color: var(--text-muted); font-size: 0.78rem; }


.stack { display: flex; flex-direction: column; gap: 0.5rem; }
.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }

.row-actions { display: flex; align-items: center; gap: 0.75rem; }
.inline-form { display: inline; margin: 0; }
.link-danger {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 0.82rem; color: var(--danger); text-decoration: underline;
}
.link-danger:hover { opacity: 0.8; }
.link-plain {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 0.82rem; color: var(--brand-accent); text-decoration: underline;
}
.link-plain:hover { opacity: 0.8; }

/* Шапка списка очереди: заголовок слева, "Очистить завершённые" справа
   (см. rassylka.html). Кнопка лежит в своей форме, поэтому выравниваем
   их flex'ом, а не отступами — иначе форма как блочный элемент уехала бы
   на свою строку. */
.queue-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin-bottom: 0.75rem;
}

@media (min-width: 641px) and (max-width: 1100px) {
  /* Планшет: меню в одну строку */
  .topbar-inner { gap: 0.6rem; }
  .brand-text small { display: none; }
  .nav-links a { padding: 0.4rem 0.5rem; font-size: 0.86rem; white-space: nowrap; }
  .nav-links { gap: 0; }
}
@media (min-width: 641px) and (max-width: 900px) {
  .brand-text { display: none; }          /* остаётся логотип: меню важнее */
}
@media (max-width: 960px) {
  /* Планшет: имя сотрудника прячем (остаются аватар и «Выйти»), меню компактнее */
  .topbar-inner { gap: 0.75rem; padding-left: 1rem; padding-right: 1rem; }
  .user-chip > span:not(.avatar) { display: none; }
  .nav-links { min-width: 0; }
  .nav-links a { padding: 0.45rem 0.6rem; }
}
@media (max-width: 640px) {
  /* Телефон: логотип и выход в одной строке, меню — строкой ниже с
     прокруткой вбок внутри себя, чтобы страница не уезжала в сторону. */
  .topbar-inner { flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.6rem 1rem 0; }
  .user-chip { margin-left: auto; }
  .user-chip > span:not(.avatar) { display: none; }
  .nav-links {
    order: 3; width: calc(100% + 2rem); margin: 0 -1rem; padding: 0.2rem 1rem 0.55rem;
    overflow-x: auto; scrollbar-width: none; justify-content: flex-start;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { white-space: nowrap; flex: 0 0 auto; }
  /* затухание у правого края: намёк, что меню прокручивается */
  .nav-links {
    padding-right: 2.5rem;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.75rem), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 2.75rem), transparent);
  }
  .sug-actions .btn { min-height: 2.75rem; }
  main.container { padding: 1.5rem 1rem 3rem; }
  .ai-head h2 { font-size: 1.35rem; }
  .composer { padding: 0.75rem 0.7rem 0.55rem 1rem; }
  .composer textarea { min-height: 4.8rem; }
  .composer-hint { display: none; }               /* про Enter на телефоне не нужно */
  .ai-hint { font-size: 0.82rem; text-align: left; }
}

/* Страница «Обучение» (training.html) */
.tr-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.tr-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.75rem 0.9rem; display: flex; flex-direction: column; gap: 0.15rem; }
.tr-num { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.tr-tabs { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tr-card { margin-bottom: 0.75rem; }
.tr-context { margin-bottom: 0.6rem; }
.tr-context summary { cursor: pointer; color: var(--text-muted); }
.tr-line { padding: 0.2rem 0; color: var(--text-secondary); white-space: pre-wrap; overflow-wrap: anywhere; }
.tr-message { font-size: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; padding: 0.6rem 0.8rem; background: var(--surface-alt); border-radius: var(--radius-sm); margin-bottom: 0.6rem; }
.tr-label { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.5rem; }
.tr-problems { color: var(--warning); margin-bottom: 0.5rem; }
.tr-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.tr-note { flex: 1 1 180px; min-width: 0; padding: 0.4rem 0.6rem; font-size: 0.82rem; }

/* ИИ-ассистент рассылки (rassylka.html, ai_assistant.js) — единственное
   «громкое» место интерфейса: поле ввода как у ChatGPT, по центру, с
   круглой кнопкой отправки внутри. Enter — отправить, Shift+Enter — строка. */
.ai-assistant { border: none; background: transparent; padding: 0.5rem 0 1rem; }
/* сцена человечка слева (ширина — --scene-w клеток × масштаб), поле ввода справа;
   планшет и телефон — сцена сверху во всю ширину (правила в конце файла) */
.ai-layout {
  --px-scale: 4;     /* целый масштаб пикселя сетки; меньше — на узких экранах */
  --scene-w: 92;     /* сцена в клетках: комната 92x104 (layout.json, desk) */
  --scene-h: 104;
  --hero-x: 3;       /* кадр человечка от левого края сцены, в клетках */
  --glass-x: 6;      /* стекло окна (вид из windows.png), в клетках */
  --glass-y: 9;
  display: grid;
  grid-template-columns: calc(var(--scene-w) * var(--px-scale) * 1px) minmax(0, 1fr);
  gap: 1.5rem; align-items: start; max-width: 1040px; margin: 0 auto;
}
.ai-main { min-width: 0; }
.ai-head { text-align: left; margin: 0.25rem 0 1.1rem; max-width: 640px; }
.ai-head h2 { font-size: 1.6rem; letter-spacing: -0.025em; margin-bottom: 0.35rem; }
.ai-head p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }
.composer {
  position: relative;
  max-width: 760px; margin: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 0.85rem 0.85rem 0.6rem 1.15rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer:focus-within { border-color: var(--brand-accent); box-shadow: var(--shadow-md), 0 0 0 3px var(--accent-soft); }
.composer textarea {
  display: block; width: 100%;
  border: none; background: transparent; padding: 0.2rem 0; margin: 0;
  resize: none; min-height: 3.2rem; max-height: 14rem; overflow-y: auto; scrollbar-width: thin;
  field-sizing: content;
  font-size: 1rem; line-height: 1.55; box-shadow: none;
}
.composer textarea:hover, .composer textarea:focus { border: none; box-shadow: none; background: transparent; }
.composer-bar { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.35rem; }
.composer-bar .small { flex: 1; }
.composer-bar:has(#ai-status:not(:empty)) .composer-hint { display: none; }
.composer-send {
  flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 50%;
  border: none; cursor: pointer;
  background: var(--brand-primary); color: var(--text-on-brand);
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.composer-send:hover { background: var(--brand-primary-hover); }
.composer-send:disabled { opacity: 0.35; cursor: progress; }
.composer-send svg { width: 18px; height: 18px; }
.ai-hints { display: flex; flex-wrap: wrap; gap: 0.5rem; max-width: 760px; margin: 0.9rem 0 0; }
.ai-hint {
  font: inherit; font-size: 0.85rem; color: var(--text-secondary); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0.35rem 0.85rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ai-hint:hover { background: var(--surface-alt); border-color: var(--border-strong); }
.ai-log { display: flex; flex-direction: column; gap: 0.6rem; max-width: 760px; margin: 1.1rem 0 0; }
.ai-log:empty { display: none; }
.ai-msg { padding: 0.7rem 0.95rem; border-radius: var(--radius-lg); white-space: normal; overflow-wrap: anywhere; font-size: 0.94rem; line-height: 1.6; }
.ai-me { background: var(--surface-alt); align-self: flex-end; max-width: 85%; border-bottom-right-radius: 6px; }
.ai-bot { background: transparent; border: 1px solid var(--border); }
.ai-progress { border-style: dashed; color: var(--text-secondary); }
.ai-error { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.ai-links { margin-top: 0.45rem; font-size: 0.86rem; }

/* Подсказки ИИ (/ai-suggestions) */
.sug-list { display: flex; flex-direction: column; gap: 1rem; }
.sug-card { margin-bottom: 0; display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.sug-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.75rem; }
.sug-client { font-weight: 600; color: var(--ink); }
.sug-route { font-size: 1.15rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.sug-text {
  margin: 0.25rem 0 0; overflow-wrap: anywhere; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.sug-chat { margin-top: 0.5rem; }
.sug-chat summary { cursor: pointer; font-size: 0.86rem; color: var(--brand-accent); }
.sug-log {
  display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.6rem; padding-right: 0.25rem;
  max-height: 60vh; overflow-y: auto; overflow-x: hidden;
}
.sug-log-note { text-align: center; }
.sug-msg {
  max-width: 85%; padding: 0.5rem 0.75rem; border: 1px solid var(--border);
  border-radius: var(--radius-md); min-width: 0;
}
.sug-msg.from-client { align-self: flex-start; background: var(--surface-alt); border-color: transparent; }
.sug-msg.from-agent { align-self: flex-end; background: var(--surface); }
.sug-msg.is-trigger { border-color: var(--brand-accent); }
.sug-msg-meta { font-size: 0.74rem; color: var(--text-muted); margin-bottom: 0.15rem; }
.sug-msg-text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: 0.9rem; }
.sug-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; margin-top: 0.75rem; }
.sug-form .field { flex: 1 1 11rem; min-width: 0; }
.sug-form input, .sug-form select { width: 100%; box-sizing: border-box; }
.sug-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sug-price-hint { font-size: 0.82rem; color: var(--text-muted); }
.sug-empty { border: 0; background: var(--surface-alt); }
.sug-empty .empty-state { background: none; }
@media (max-width: 640px) {
  .sug-form .field { flex: 1 1 100%; }
  .sug-actions { width: 100%; }
  .sug-msg { max-width: 94%; }
  .sug-actions .btn { flex: 1 1 auto; }
}
.sug-section { margin: 2rem 0 0.75rem; font-size: 1.1rem; }
.sug-route-sm { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.sug-status { font-size: 0.92rem; color: var(--text-secondary); overflow-wrap: anywhere; }
.sug-status.is-found { color: var(--success); font-weight: 550; }
.sug-flight { overflow-wrap: anywhere; }
.sug-warn { margin: 0; flex: 1 1 100%; }
.sug-watch .sug-actions { margin-top: 0.4rem; }

/* «Отправить клиенту» (static/js/share.js) */
.share-btn { min-height: 2.5rem; white-space: nowrap; }
.share-dlg {
  width: min(92vw, 30rem); max-height: 90vh; padding: 1.25rem; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-md);
}
.share-dlg::backdrop { background: rgba(20, 33, 58, 0.4); }
.share-form h3 { margin: 0 0 0.6rem; }
.share-label { display: block; margin-bottom: 0.35rem; font-size: 0.84rem; color: var(--text-muted); }
.share-text {
  width: 100%; box-sizing: border-box; min-height: 9rem; resize: vertical;
  font: inherit; font-size: 1rem; line-height: 1.5;
}
.share-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; }
.share-actions .btn { min-height: 2.75rem; flex: 1 1 auto; }
.share-note { margin: 0.6rem 0 0; }
.wm-toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 100; transform: translate(-50%, 0.5rem);
  max-width: 90vw; padding: 0.6rem 1.1rem; border-radius: 999px; font-size: 0.9rem;
  background: var(--brand-primary); color: var(--text-on-brand);
  opacity: 0; pointer-events: none; transition: opacity 0.18s ease, transform 0.18s ease;
}
.wm-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Уведомления на странице «Подсказки ИИ» (static/js/notify.js) */
.notify-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 1rem; }
.notify-bar .btn { min-height: 2.5rem; }
.notify-bar [hidden] { display: none; }
.nav-badge.is-new { animation: badge-pop 0.5s ease; }
@keyframes badge-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .nav-badge.is-new { animation: none; }
  .wm-toast { transition: none; }
}
@media (max-width: 640px) {
  .sug-watch .sug-actions .btn { min-height: 2.75rem; }
}

/* ---- Оформление таблиц: даты без переноса, затухание у края при прокрутке ---- */
.nowrap { white-space: nowrap; }
.nav-links a { white-space: nowrap; }
.table-wrap[data-scroll-fade].fade-r {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
}
.table-wrap[data-scroll-fade].fade-l {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 2.5rem), transparent);
          mask-image: linear-gradient(to left, #000 calc(100% - 2.5rem), transparent);
}
.table-wrap[data-scroll-fade].fade-l.fade-r {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 2.5rem, #000 calc(100% - 2.5rem), transparent);
          mask-image: linear-gradient(to right, transparent, #000 2.5rem, #000 calc(100% - 2.5rem), transparent);
}
.nav-short { display: none; }

/* кнопка «Скопировать» не уезжает при прокрутке таблицы вбок */
.table-wrap table tbody td:has(.share-copy) {
  position: sticky; right: 0; background: var(--surface);
  box-shadow: -8px 0 8px -8px rgba(20, 33, 58, 0.18);
}
@media (max-width: 640px) {
  .table-wrap table { min-width: 760px; }
  .table-wrap table.history-table { min-width: 0; }
  /* кнопка «Скопировать» остаётся под рукой: колонка прилипает к правому краю */
  .table-wrap table .share-copy { min-height: 2.5rem; padding-left: 0.9rem; padding-right: 0.9rem; }
  .nav-full { display: none; }
  .nav-short { display: inline; }
  .nav-links { padding-right: 1rem; -webkit-mask-image: none; mask-image: none; }
  .nav-links.fade-r {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
  }
  .nav-links a { min-height: 2.5rem; display: inline-flex; align-items: center; }

  /* «История»: карточки вместо строк таблицы */
  .history-table { min-width: 0; display: block; }
  .history-table thead { display: none; }
  .history-table tbody { display: block; }
  .table-wrap:has(.history-table) { border: none; border-radius: 0; overflow: visible; }
  .history-table tbody tr {
    display: grid; grid-template-columns: 1fr auto; column-gap: 0.75rem; row-gap: 0.25rem;
    align-items: center; padding: 0.8rem 0.9rem; margin-bottom: 0.6rem;
    border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
  }
  .history-table tbody tr:last-child { margin-bottom: 0; }
  .history-table tbody td { display: block; padding: 0; border: none; }
  .history-table .h-route { grid-column: 1; grid-row: 1; font-size: 1rem; color: var(--ink); }
  .history-table .h-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .history-table .h-dates { grid-column: 1 / -1; grid-row: 2; font-size: 0.9rem; }
  .history-table .h-rt { grid-column: 1 / -1; grid-row: 3; font-size: 0.82rem; color: var(--text-muted); }
  .history-table .h-rt-empty { display: none; }
  .history-table .h-when, .history-table .h-who, .history-table .h-kind {
    font-size: 0.8rem; color: var(--text-muted);
  }
  .history-table .h-when { grid-column: 1; grid-row: 4; }
  .history-table .h-kind { grid-column: 2; grid-row: 4; justify-self: end; }
  .history-table .h-who { grid-column: 1 / -1; grid-row: 5; }
  .history-table .h-actions { grid-column: 1 / -1; grid-row: 6; gap: 0.5rem; margin-top: 0.35rem; }
  .history-table .h-actions a, .history-table .h-actions button {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 2.5rem; padding: 0 1rem; border-radius: 999px;
    border: 1px solid var(--border-strong); background: var(--surface); text-decoration: none;
    font-size: 0.85rem;
  }
  .history-table .h-actions .link-danger { color: var(--danger); }
  .history-table .h-actions a:hover, .history-table .h-actions button:hover { background: var(--surface-alt); }
}
.price-cell { white-space: nowrap; }
@media (max-width: 640px) {
  .quick-route-btn, .swap-cities-btn { min-height: 2.5rem; }
  .swap-cities-btn { min-width: 2.5rem; }
}
@media (max-width: 640px) {
  .history-table .h-actions { flex-wrap: nowrap; }
  .history-table .h-actions > a, .history-table .h-actions > .inline-form { flex: 1 1 0; display: flex; min-width: 0; }
  .history-table .h-actions a, .history-table .h-actions button { flex: 1; padding: 0 0.5rem; }
}
@media (max-width: 640px) {
  .history-table tbody td.h-actions { display: flex; }
}

/* Цели нажатия не меньше 40px на сенсорных и узких экранах (вид на компьютере не меняется) */
@media (max-width: 640px), (pointer: coarse) {
  .theme-toggle { width: 40px; height: 40px; }
  .brand { min-height: 40px; }
  .composer-send { width: 40px; height: 40px; }
  .ai-hint { min-height: 40px; display: inline-flex; align-items: center; }
  .sug-client a, .link-plain, .link-danger, a.small, .small a, details > summary {
    display: inline-flex; align-items: center; min-height: 40px;
  }
  .lr-reset { min-height: 40px; }
}

/* Масштаб сцены человечка — только целые числа (см. .assistant-frame).
   Узкий компьютер (901–999px): x4 съел бы поле ввода (уже ~520px) — x3.
   Планшет (641–900px): над полем низкая полоса 160x96 «окно — стойка —
   полка» (layout.json, phone), x3 = 480x288.
   Телефон (до 640px) и низкий экран: та же полоса x2 = 320x192 — влезает в
   360px с полями 16px. Стоит после базовых правил. */
@media (max-width: 999px) {
  .ai-layout { --px-scale: 3; }
}
@media (max-width: 900px) {
  .ai-layout {
    grid-template-columns: minmax(0, 1fr); gap: 1rem;
    --scene-w: 160; --scene-h: 96; --hero-x: 44; --glass-x: 17; --glass-y: 15;
  }
  .room-cell, .room-extra > * { background-image: url("../img/pixel/room/phone.png"); }
  .room-souvenir { left: calc(var(--mx) * var(--px-scale) * 1px); top: calc(var(--my) * var(--px-scale) * 1px); }
  .room-pin { display: none; }   /* карты в полосе нет */
  /* растение, кот, «пуф» — места полосы; чего в полосе нет (ширма) — не видно */
  .room-at { left: calc(var(--mx, 0) * var(--px-scale) * 1px); top: calc(var(--my, 0) * var(--px-scale) * 1px); }
  .room-at.no-phone { display: none; }
  .room-cat { --walk: var(--walk-m, 0); }
  .ai-layout { --nap-dy: -3; }   /* стойка полосы — строка 80, а не 83 */
  /* «дом» открыт: та же сцена, но вся комната 92x104 (как на компьютере) целым
     масштабом x4 на планшете, x3 на телефоне — влезает в 320px без прокрутки вбок */
  .ai-layout.room-open { --scene-w: 92; --scene-h: 104; --hero-x: 3; --glass-x: 6; --glass-y: 9; --px-scale: 4; }
  .ai-layout.room-open .room-cell, .ai-layout.room-open .room-extra > * { background-image: url("../img/pixel/room/desk.png"); }
  .ai-layout.room-open .room-souvenir, .ai-layout.room-open .room-at {
    left: calc(var(--dx, 0) * var(--px-scale) * 1px); top: calc(var(--dy, 0) * var(--px-scale) * 1px);
  }
  .ai-layout.room-open .room-at.no-phone:not([hidden]) { display: block; }
  .ai-layout.room-open .room-pin { display: block; }
  .ai-layout.room-open .room-cat { --walk: var(--walk-d, 0); }
  .ai-layout.room-open { --nap-dy: 0; }
}
@media (max-width: 640px) {
  .ai-layout { gap: 0.75rem; }
  .ai-hint { min-height: 2.5rem; }
  .pixel-dnd, .pixel-home { width: 40px; height: 40px; }
  /* реплика справа от головы, не шире остатка полосы */
  .pixel-bubble { max-width: calc(100% - var(--bubble-x) - 4px); }
}
@media (max-width: 640px), (max-height: 520px) {
  .ai-layout { --px-scale: 2; }
}
@media (max-width: 640px) {
  .ai-layout.room-open { --px-scale: 3; }
}
