/* GminiAI — основные стили (светлая тема, мобильно-адаптивные) */
:root {
    --bg: #f6f8ff;
    --bg-soft: #eef2fb;
    --bg-card: #ffffff;
    --bg-elev: rgba(255, 255, 255, 0.78);
    --text: #1f2533;
    --text-muted: #6b7280;
    --text-soft: #9aa1ad;
    --border: #e5e9f2;
    --border-soft: rgba(31, 37, 51, .07);
    --primary: #4d8af0;
    --primary-dark: #3372dc;
    --accent: #a26ee0;
    --accent-2: #f4a8c9;
    --warn: #f59e0b;
    --danger: #e0455c;
    --success: #16a34a;
    --shadow-sm: 0 2px 8px rgba(20, 32, 70, .04);
    --shadow-md: 0 8px 28px rgba(20, 32, 70, .07);
    --shadow-lg: 0 22px 60px rgba(20, 32, 70, .12);
    --r-xs: 8px;
    --r-sm: 12px;
    --r-md: 18px;
    --r-lg: 26px;
    --r-xl: 36px;
    --grad: linear-gradient(135deg, #5b8cf5 0%, #8b6fe1 50%, #f4a8c9 100%);
    --grad-soft: linear-gradient(135deg, #e3ecff 0%, #f0e7fb 50%, #fce4ed 100%);
    --max-w: 1180px;
}

* { box-sizing: border-box; }
html, body { padding: 0; margin: 0; }
body {
    font-family: 'Inter', 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    font-size: 15px;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ============== Layout helpers ============== */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }
.row { display: flex; gap: 16px; align-items: center; }
.muted { color: var(--text-muted); }
.center { text-align: center; }
.hide-sm { display: initial; }
@media (max-width: 720px) { .hide-sm { display: none; } }

/* ============== Buttons ============== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 20px;
    font-weight: 600; font-size: 14px;
    border: 1px solid transparent; border-radius: 999px;
    background: #fff; color: var(--text);
    transition: all .15s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn--primary { background: var(--grad); color: #fff; }
.btn--primary:hover { color: #fff; }
.btn--ghost { background: transparent; border-color: var(--border); }
.btn--danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn--danger-ghost { color: #b91c1c; display: inline-flex; align-items: center; gap: 6px; }
.btn--danger-ghost:hover { background: rgba(220, 38, 38, .08); border-color: rgba(220, 38, 38, .35); color: #991b1b; }
.btn--ghost:hover { background: var(--bg-card); }
.btn--lg { padding: 14px 26px; font-size: 15px; }
.btn--block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.iconbtn {
    background: transparent; border: 0;
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px; color: var(--text);
    transition: background .15s ease;
}
.iconbtn:hover { background: var(--bg-soft); }
.iconbtn--ghost { color: var(--text-muted); }

/* ============== Topbar (public) ============== */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 28px;
    position: sticky; top: 0; z-index: 50;
    background: rgba(246, 248, 255, .85);
    backdrop-filter: saturate(150%) blur(14px);
    -webkit-backdrop-filter: saturate(150%) blur(14px);
}
.topbar--public { gap: 24px; }
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 18px; letter-spacing: -0.01em;
    color: var(--text);
}
.brand__name {
    background: var(--grad); -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.topbar__nav { display: flex; gap: 24px; align-items: center; }
.topbar__nav a {
    color: var(--text-muted); font-weight: 500;
    transition: color .15s ease;
}
.topbar__nav a:hover { color: var(--text); }
.topbar__actions { display: flex; gap: 10px; align-items: center; }

/* Овальная кнопка-пилюля с чётким контуром (используется и для EN, и для "Войти") */
.pill-btn,
.topbar__nav a.lang-switch {
    display: inline-flex; align-items: center; justify-content: center;
    border: 1.5px solid #1f2533;
    background: transparent;
    border-radius: 999px;
    padding: 8px 18px; min-height: 36px;
    font-size: 13px; font-weight: 600; color: #1f2533;
    line-height: 1; letter-spacing: .02em;
    text-decoration: none;
    transition: all .18s ease;
    white-space: nowrap;
}
.pill-btn:hover,
.topbar__nav a.lang-switch:hover {
    background: #1f2533;
    color: #fff;
    border-color: #1f2533;
}
.pill-btn--accent {
    background: var(--grad);
    color: #fff !important;
    border-color: transparent;
}
.pill-btn--accent:hover {
    color: #fff !important;
    background: var(--grad);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

@media (max-width: 720px) {
    .topbar { padding: 14px 16px; }
    .topbar__nav { display: none; }
    .pill-btn { padding: 6px 12px; }
}

/* ============== Hero / Landing ============== */
.hero {
    padding: 60px 0 60px;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: ""; position: absolute; inset: -200px -200px auto auto;
    width: 700px; height: 700px;
    background: radial-gradient(closest-side, rgba(91,140,245,.16), transparent 70%);
    z-index: 0;
}
.hero::after {
    content: ""; position: absolute; left: -200px; bottom: -150px;
    width: 600px; height: 600px;
    background: radial-gradient(closest-side, rgba(244,168,201,.18), transparent 70%);
    z-index: 0;
}
.hero__inner {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: 1.05fr .95fr; gap: 60px; align-items: center;
}
@media (max-width: 920px) {
    .hero__inner { grid-template-columns: 1fr; gap: 36px; }
    .hero { padding: 32px 0 36px; }
}
.kicker {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 999px;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-muted); font-size: 13px; font-weight: 500;
    box-shadow: var(--shadow-sm);
}
.kicker .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }

.hero__title {
    font-size: clamp(34px, 5vw, 56px);
    line-height: 1.05;
    letter-spacing: -0.025em;
    font-weight: 800;
    margin: 18px 0 14px;
}
.hero__title em {
    font-style: normal;
    background: var(--grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero__subtitle {
    font-size: 17px; color: var(--text-muted);
    max-width: 540px; line-height: 1.55;
    margin-bottom: 24px;
}
.hero__cta { display: flex; gap: 12px; flex-wrap: wrap; }

/* Demo card on hero */
.demo {
    background: var(--bg-card); border-radius: var(--r-xl);
    padding: 28px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-soft);
    position: relative;
}
.demo h3 { margin: 0 0 18px; font-size: 18px; font-weight: 700; }
.demo__items { display: flex; flex-direction: column; gap: 14px; }
.demo__bubble {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 18px;
    background: var(--bg-soft);
    border-radius: var(--r-md);
}
.demo__bubble .dot {
    width: 14px; height: 14px; border-radius: 4px;
    background: var(--grad); flex-shrink: 0; margin-top: 4px;
}
.demo__bubble p { margin: 0; font-size: 14.5px; }
.demo__photo {
    height: 160px; border-radius: var(--r-md);
    background: var(--grad-soft);
    margin-bottom: 18px;
    display: flex; align-items: center; justify-content: center; gap: 12px;
}
.demo__photo svg { width: 64px; height: 64px; opacity: .7; }

/* ============== Features ============== */
.section { padding: 70px 0; }
.section h2 {
    font-size: clamp(28px, 3.4vw, 40px);
    letter-spacing: -0.02em; line-height: 1.1;
    font-weight: 800; margin: 0 0 12px;
    text-align: center;
}
.section .section__sub {
    color: var(--text-muted); text-align: center;
    max-width: 600px; margin: 0 auto 40px;
}
.features {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
@media (max-width: 920px) { .features { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .features { grid-template-columns: 1fr; } }

.feature {
    background: var(--bg-card); border-radius: var(--r-lg);
    padding: 26px; border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease;
}
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.feature__icon {
    width: 48px; height: 48px; border-radius: 14px;
    background: var(--grad-soft);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
    color: var(--primary-dark);
}
.feature h3 { margin: 0 0 8px; font-size: 18px; }
.feature p { margin: 0; color: var(--text-muted); font-size: 14.5px; line-height: 1.55; }

/* ============== Tariffs ============== */
.tariffs {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
    margin-top: 40px;
}
@media (max-width: 1100px) { .tariffs { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .tariffs { grid-template-columns: 1fr; } }

.tariff {
    background: var(--bg-card); border-radius: var(--r-lg);
    padding: 28px 24px; border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 14px;
    position: relative;
}
.tariff--featured {
    background: linear-gradient(180deg, #fff 0%, #fbf6ff 100%);
    border: 2px solid transparent;
    background-clip: padding-box;
    position: relative;
}
.tariff--featured::before {
    content: ""; position: absolute; inset: -2px; border-radius: var(--r-lg);
    background: var(--grad); z-index: -1;
}
.tariff__badge {
    position: absolute; top: -12px; right: 18px;
    background: var(--grad); color: #fff;
    padding: 5px 14px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
}
.tariff h3 { margin: 0; font-size: 22px; font-weight: 700; }
.tariff__price {
    font-size: 32px; font-weight: 800; letter-spacing: -0.02em;
}
.tariff__price small { font-weight: 500; color: var(--text-muted); font-size: 14px; }
.tariff__credits {
    margin: 6px 0 14px;
    padding: 8px 14px;
    background: #eaf1fe;
    color: var(--primary-dark);
    border: 1px solid #d6e4fc;
    border-radius: 999px;
    font-size: 13px;
    display: inline-flex; align-items: baseline; gap: 6px;
}
.tariff__credits strong { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tariff__features { list-style: none; padding: 0; margin: 0; flex: 1; }
.tariff__features li {
    padding: 6px 0 6px 24px; position: relative;
    font-size: 14.5px;
}
.tariff__features li::before {
    content: ""; position: absolute; left: 0; top: 11px;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--grad-soft);
}
.tariff__features li::after {
    content: ""; position: absolute; left: 4px; top: 14px;
    width: 6px; height: 4px;
    border-left: 2px solid var(--primary-dark);
    border-bottom: 2px solid var(--primary-dark);
    transform: rotate(-45deg);
}

/* ============== Footer ============== */
.footer {
    padding: 50px 0 40px; border-top: 1px solid var(--border);
    color: var(--text-muted); font-size: 14px;
    margin-top: 60px;
}
.footer__row { display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap; }
.footer__brand { max-width: 360px; }
.footer__nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer__nav a { color: var(--text-muted); }
.footer__nav a:hover { color: var(--text); }
.footer__bottom { margin-top: 28px; font-size: 13px; }

/* ============== Auth page ============== */
.auth {
    max-width: 460px; margin: 60px auto;
    background: var(--bg-card); border-radius: var(--r-xl);
    padding: 44px 36px; box-shadow: var(--shadow-md);
    border: 1px solid var(--border-soft);
}
.auth h1 {
    margin: 0 0 8px; font-size: 26px; font-weight: 800; letter-spacing: -0.01em;
}
.auth p.muted { margin: 0 0 28px; }
.auth__btn {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    width: 100%; padding: 14px;
    border-radius: var(--r-sm); border: 1px solid var(--border);
    background: #fff; font-weight: 600; font-size: 15px;
    margin-bottom: 12px; transition: background .15s;
    text-decoration: none; color: var(--text);
}
.auth__btn:hover { background: var(--bg-soft); color: var(--text); }
.auth__btn img, .auth__btn svg { width: 22px; height: 22px; }
button.auth__btn { font: inherit; cursor: pointer; text-align: center; }
.auth__legal { color: var(--text-muted); font-size: 12px; text-align: center; margin-top: 18px; }

.auth__divider {
    display: flex; align-items: center; gap: 12px;
    color: var(--text-muted); font-size: 12px; text-transform: uppercase;
    letter-spacing: .08em; margin: 18px 0 12px;
}
.auth__divider::before, .auth__divider::after {
    content: ""; flex: 1; height: 1px; background: var(--border);
}

.auth__pwd-block {
    border: 1px dashed var(--border); border-radius: var(--r-sm);
    padding: 0; overflow: hidden;
    background: rgba(91,140,245,.04);
}
.auth__pwd-block > summary {
    list-style: none; cursor: pointer;
    padding: 12px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted);
    user-select: none;
}
.auth__pwd-block > summary::-webkit-details-marker { display: none; }
.auth__pwd-block > summary::before {
    content: "▸"; display: inline-block; margin-right: 8px;
    transition: transform .15s ease;
}
.auth__pwd-block[open] > summary::before { transform: rotate(90deg); }
.auth__pwd-form {
    padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 12px;
}
.auth__pwd-field { display: flex; flex-direction: column; gap: 6px; }
.auth__pwd-field label {
    font-size: 12px; font-weight: 600; color: var(--text-muted);
}
.auth__pwd-field input {
    width: 100%; padding: 11px 14px;
    border: 1px solid var(--border); border-radius: var(--r-sm);
    font-size: 14px; background: #fff; color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.auth__pwd-field input:focus {
    outline: none; border-color: rgba(91,140,245,.6);
    box-shadow: 0 0 0 3px rgba(91,140,245,.15);
}
.auth__pwd-error {
    background: rgba(220,53,69,.08); color: #c92a3b;
    border: 1px solid rgba(220,53,69,.2); border-radius: var(--r-sm);
    padding: 10px 12px; font-size: 13px;
}

/* ============== App layout (chat etc.) ============== */
.app {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    height: 100dvh; /* mobile: учитывает динамическую клавиатуру/topbar */
    background: var(--bg);
    overflow: hidden;
}
.app__main {
    display: flex; flex-direction: column;
    min-width: 0; min-height: 0;
    height: 100%;
    overflow: hidden;
}
/* Все обычные страницы внутри app-оболочки (settings, tariffs, my-content, notebooks и т.п.)
   должны прокручиваться. Чат имеет свой внутренний скролл (.messages), его не трогаем. */
.app__main > main:not(.chat) {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.topbar--app {
    padding: 12px 18px; background: rgba(246,248,255,.82);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar--app .topbar__title {
    font-weight: 700; color: var(--text); margin-left: 4px;
}
.iconbtn--menu { display: none; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    background: var(--bg-soft); color: var(--text);
}
.badge--upgrade { background: linear-gradient(135deg, #cce0ff, #f6d9ec); color: #5b3a8e; }
.badge--plan {
    background: #eaf1fe;
    color: var(--primary-dark);
    border: 1px solid #d6e4fc;
    padding: 5px 12px;
    letter-spacing: .02em;
}

/* Кредиты в топбаре */
.credits-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 999px;
    background: #fff; color: var(--text);
    border: 1px solid var(--border);
    font-size: 13px; font-weight: 600;
    transition: background .15s, border-color .15s, transform .12s;
    text-decoration: none;
}
.credits-pill svg { color: var(--primary); }
.credits-pill:hover {
    background: #f7faff;
    border-color: #cfdcf6;
    color: var(--text);
    transform: translateY(-1px);
}
.credits-pill__value { font-variant-numeric: tabular-nums; }

.topbar__avatar {
    width: 32px; height: 32px; border-radius: 50%;
    overflow: hidden; cursor: pointer;
    background: #1f2533; color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
    border: 1px solid var(--border-soft);
    transition: background .15s;
}
.topbar__avatar:hover { background: #2c3243; }
.topbar__avatar img { width: 100%; height: 100%; object-fit: cover; }
.dropdown {
    position: absolute; top: 56px; right: 16px;
    background: var(--bg-card); border-radius: var(--r-md);
    box-shadow: var(--shadow-lg); border: 1px solid var(--border-soft);
    min-width: 240px; padding: 12px; z-index: 60;
}
.dropdown__head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; display: flex; flex-direction: column; gap: 4px; }
.dropdown__head strong { font-size: 14px; }
.dropdown__head span { color: var(--text-muted); font-size: 12px; }
.dropdown a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); }
.dropdown a:hover { background: var(--bg-soft); }
.dropdown__item--admin {
    color: #5b8cf5 !important;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(91,140,245,.08), rgba(232,143,192,.08));
    margin-bottom: 4px;
}
.dropdown__item--admin:hover {
    background: linear-gradient(135deg, rgba(91,140,245,.14), rgba(232,143,192,.14)) !important;
}

/* ============== Sidebar ============== */
.sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 14px 12px;
    display: flex; flex-direction: column; gap: 4px;
    overflow-y: auto;
    height: 100vh; position: sticky; top: 0;
}
.sidebar__head {
    display: flex; gap: 4px; padding: 4px 6px 12px;
}
.sidebar__link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 12px;
    color: var(--text); font-size: 14px; font-weight: 500;
    transition: background .15s;
}
.sidebar__link:hover { background: var(--bg-soft); color: var(--text); }
.sidebar__link--accent { background: var(--bg-soft); }
.sidebar__link--sub { padding-left: 22px; font-weight: 400; color: var(--text-muted); font-size: 13.5px; }
.sidebar__link--sub:hover { color: var(--text); }
.sidebar__link--add { color: var(--primary); }

.sidebar__group { margin-top: 14px; }
.sidebar__group-title {
    padding: 8px 12px; color: var(--text-muted);
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    display: flex; justify-content: space-between; align-items: center;
}
.sidebar__group-arrow { color: var(--text-soft); }
.sidebar__empty { padding: 8px 12px; color: var(--text-soft); font-size: 13px; }
.sidebar__foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot--notebook { background: linear-gradient(135deg, #f6c46b, #ed905f); }
.dot--bot { background: linear-gradient(135deg, #6fc7ed, #a26ee0); }
.pin { color: var(--accent); margin-left: auto; }

/* ============== Chat ============== */
.chat {
    flex: 1 1 0%;
    display: flex; flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: 0;
    background: linear-gradient(180deg, #fbfcff 0%, #f6f8ff 100%);
}
.chat__welcome {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 40px 20px; text-align: center;
}
.chat__welcome h1 {
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px;
    background: var(--grad); -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.chat__welcome h2 {
    font-size: clamp(22px, 3vw, 32px);
    font-weight: 600; color: var(--text-muted);
    margin: 0 0 32px;
}
.chat__welcome .composer { width: 100%; max-width: 720px; }
.suggests {
    display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
    margin-top: 24px;
}
.chip {
    padding: 9px 18px; border-radius: 999px;
    background: var(--bg-card); border: 1px solid var(--border);
    font-size: 14px; color: var(--text);
    transition: background .15s, transform .15s;
    cursor: pointer; display: inline-flex; gap: 8px; align-items: center;
}
.chip:hover { background: var(--bg-soft); transform: translateY(-1px); }

/* === Messages (Gemini-style) === */
.messages {
    flex: 1 1 0%;
    overflow-y: auto; overflow-x: hidden;
    padding: 24px 24px 12px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}
.messages__inner {
    max-width: 820px; margin: 0 auto;
    display: flex; flex-direction: column; gap: 28px;
}

.msg { display: flex; flex-direction: column; }

/* --- User message: soft blue pill on the right, no avatar --- */
.msg--user { align-items: flex-end; }
.msg--user .msg__bubble {
    /* fit-content + max-width: pill сжимается по тексту, но не шире 580px */
    width: fit-content;
    max-width: min(78%, 580px);
    padding: 10px 18px;
    border-radius: 20px;
    background: #e8efff;
    color: var(--text);
    font-size: 15px; line-height: 1.45;
    word-wrap: break-word; overflow-wrap: anywhere;
    white-space: pre-wrap;
    text-align: left;
}
.msg--user .msg__avatar { display: none; }

/* User-actions: компактнее, выровнены вправо под пузырём,
   видимы только при ховере (на десктопе) или всегда (на мобильном). */
.msg--user .msg__actions {
    display: flex;
    gap: 2px;
    margin-top: 4px;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity .15s ease;
}
.msg--user:hover .msg__actions,
.msg--user:focus-within .msg__actions,
.msg--user .msg__action.is-open ~ .msg__action,
.msg--user .msg__actions:focus-within { opacity: 1; }
@media (hover: none) {
    .msg--user .msg__actions { opacity: 1; }
}
.msg--user .msg__action {
    width: 28px; height: 28px;
    color: #6b7280;
}
.msg--user .msg__action svg { width: 16px; height: 16px; }

/* --- Assistant message: 2-column grid (avatar | content) --- */
.msg--assistant {
    display: grid;
    grid-template-columns: 28px 1fr;
    column-gap: 14px;
    row-gap: 4px;
    align-items: start;
}
.msg--assistant .msg__head {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2px;
}
.msg--assistant .msg__avatar {
    width: 28px; height: 28px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 0;
}
.msg--assistant .msg__avatar svg { width: 22px; height: 22px; display: block; }
.msg--assistant .msg__bubble {
    grid-column: 2;
    grid-row: 1;
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--text);
    font-size: 15px; line-height: 1.65;
    word-wrap: break-word; overflow-wrap: anywhere;
    max-width: 100%;
    min-width: 0;
}
.msg--assistant .msg__bubble p { margin: 0 0 12px; }
.msg--assistant .msg__bubble p:first-child { margin-top: 0; }
.msg--assistant .msg__bubble p:last-child { margin-bottom: 0; }
.msg--assistant .msg__bubble h1,
.msg--assistant .msg__bubble h2,
.msg--assistant .msg__bubble h3 { margin: 18px 0 6px; font-weight: 600; line-height: 1.35; }
.msg--assistant .msg__bubble h1 { font-size: 18px; }
.msg--assistant .msg__bubble h2,
.msg--assistant .msg__bubble h3 { font-size: 16px; }
.msg--assistant .msg__bubble strong { font-weight: 600; }
.msg--assistant .msg__bubble pre {
    background: var(--bg-soft); padding: 12px 14px; border-radius: 12px;
    overflow-x: auto; font-size: 13px; max-width: 100%;
    border: 1px solid var(--border-soft);
}
.msg--assistant .msg__bubble code {
    background: var(--bg-soft); padding: 1px 6px; border-radius: 6px; font-size: .9em;
}
.msg--assistant .msg__bubble pre code { background: transparent; padding: 0; }
.msg--assistant .msg__bubble ul,
.msg--assistant .msg__bubble ol { padding-left: 22px; margin: 8px 0; }
.msg--assistant .msg__bubble a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

/* media (images, audio) — full-width inside assistant column */
.msg__media { margin: 10px 0 0; }
.msg__media img {
    max-width: 100%;
    width: min(560px, 100%);
    border-radius: 14px;
    display: block;
}
.msg__media audio { width: 100%; max-width: 460px; }

/* --- Track cards (two Suno variants) --- */
.track-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 8px;
    max-width: 560px;
}
@media (min-width: 720px) {
    .track-grid { grid-template-columns: 1fr 1fr; }
}
.track-card {
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 14px;
    padding: 12px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.track-card__head { display: flex; align-items: center; gap: 10px; }
.track-card__cover {
    width: 56px; height: 56px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}
.track-card__meta { min-width: 0; flex: 1; }
.track-card__variant {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--accent, #3372dc);
    font-weight: 600;
}
.track-card__title {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.track-card audio { width: 100%; }

/* --- Action bar under assistant reply --- */
.msg__actions {
    grid-column: 2;
    grid-row: 2;
    display: flex; gap: 2px; margin-top: 8px;
    padding-left: 0;
}
.msg__action {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent;
    color: #9ca3af;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.msg__action:hover { background: rgba(0,0,0,0.05); color: #4b5563; }
.msg__action svg { width: 18px; height: 18px; }
.msg__action.is-active { color: var(--primary, #2563eb); }
.msg__action.is-active.is-down { color: #e0457b; }

/* hide actions on the placeholder bubble while AI is typing */
.msg--assistant.is-typing .msg__actions { display: none; }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
    width: 7px; height: 7px; background: var(--text-soft);
    border-radius: 50%;
    animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .35; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ============== Composer (chat input) ============== */
.composer-wrap {
    padding: 12px 24px 22px;
    background: linear-gradient(180deg, transparent 0%, rgba(246,248,255,.95) 30%, var(--bg) 100%);
    flex-shrink: 0;
    /* iOS Safari: учитываем safe-area внизу */
    padding-bottom: max(22px, env(safe-area-inset-bottom));
}
.composer {
    max-width: 820px; margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 28px;
    padding: 10px 12px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, border-color .15s;
}
.composer:focus-within {
    border-color: rgba(91,140,245,.5);
    box-shadow: 0 0 0 6px rgba(91,140,245,.08);
}
.composer__field {
    width: 100%; min-height: 40px; max-height: 220px;
    padding: 10px 14px;
    border: 0; outline: 0; resize: none;
    background: transparent; color: var(--text);
    font-size: 15.5px; line-height: 1.5;
    font-family: inherit;
}
.composer__field::placeholder { color: var(--text-soft); }
.composer__row {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 6px;
}
.composer__row .left { display: flex; gap: 4px; align-items: center; flex: 1; min-width: 0; }
.composer__row .right { display: flex; gap: 6px; align-items: center; }
.composer__select {
    border: 0; background: transparent; padding: 8px 10px;
    border-radius: 999px; color: var(--text);
    font-size: 13px; font-weight: 500;
    cursor: pointer;
}
.composer__select:hover { background: var(--bg-soft); }
.composer__send {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary); color: #fff; border: 0;
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform .12s, background .15s, box-shadow .15s, opacity .12s;
    box-shadow: 0 2px 8px -2px rgba(77,138,240,.55);
}
.composer__send svg { transform: translateX(1px); }
.composer__send:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.composer__send:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.composer__send:active:not(:disabled) { transform: scale(.95); }
.composer__attach-list {
    display: flex; gap: 8px; padding: 6px 12px 0; flex-wrap: wrap;
}

/* === Mode tabs (Text / Image / Music) === */
.mode-tabs {
    display: inline-flex; gap: 4px;
    margin: 4px 8px 10px; padding: 5px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    width: fit-content;
}
.mode-tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border: 0; border-radius: 999px;
    background: transparent; color: var(--text-muted);
    font-size: 13.5px; font-weight: 600;
    cursor: pointer; transition: background .18s, color .18s, box-shadow .18s, transform .12s;
    white-space: nowrap; user-select: none;
}
.mode-tab:hover { color: var(--text); background: rgba(91,140,245,.06); }
.mode-tab:active { transform: scale(.97); }
.mode-tab.is-active {
    background: #fff; color: var(--primary);
    box-shadow: 0 1px 3px rgba(20, 32, 70, .08);
}
.mode-tab.is-active:hover { color: var(--primary-dark); background: #fff; }
.mode-tab svg { flex-shrink: 0; opacity: .9; }
.mode-tab.is-active svg { opacity: 1; }
@media (max-width: 540px) {
    .mode-tab span { display: none; }
    .mode-tab { padding: 9px 12px; }
}

/* В не-text режимах скрываем скрепку (для фото референсы — полоска img-strip сверху)
   и выбор скорости; микрофон доступен как в текстовом чате (диктовка промпта). */
.composer[data-mode="image"] [data-action="attach"],
.composer[data-mode="image"] .composer__select,
.composer[data-mode="music"] [data-action="attach"],
.composer[data-mode="music"] .composer__select {
    display: none !important;
}

/* === Microphone button === */
/* Скрываем file input визуально, но он остаётся в DOM и доступен для .click()
   на Android (атрибут [hidden] и display:none ломают программное открытие диалога) */
.visually-hidden-file {
    position: fixed;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Меню выбора типа вложения (для скрепки) */
.attach-menu {
    position: fixed;
    z-index: 1000;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 240px;
    max-width: calc(100vw - 24px);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.attach-menu[hidden] { display: none !important; }
.attach-menu__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: transparent;
    border: 0;
    text-align: left;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    width: 100%;
}
.attach-menu__item:hover,
.attach-menu__item:focus-visible { background: var(--bg-soft); outline: none; }
.attach-menu__item svg { flex-shrink: 0; color: var(--text-muted); }

@media (max-width: 720px) {
    /* На мобиле — выезжающий снизу bottom-sheet */
    .attach-menu {
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        max-width: none;
        border-radius: 18px 18px 0 0;
        padding: 10px 10px max(14px, env(safe-area-inset-bottom));
        animation: attach-menu-up .18s ease-out;
    }
    .attach-menu__item {
        padding: 14px 14px;
        font-size: 16px;
        min-height: 48px;
    }
    .attach-menu__item svg { width: 22px; height: 22px; }
}
@keyframes attach-menu-up {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.attach-menu__scrim {
    position: fixed; inset: 0; z-index: 999;
    background: rgba(15, 23, 40, .25);
}

.iconbtn--mic {
    position: relative;
    background: rgba(91,140,245,.08);
    color: var(--primary);
    transition: color .15s, background .15s, box-shadow .15s, transform .12s;
}
.iconbtn--mic:hover { background: rgba(91,140,245,.18); }
.iconbtn--mic:active { transform: scale(.95); }
.iconbtn--mic.is-listening {
    color: #fff; background: #e0457b;
    box-shadow: 0 0 0 0 rgba(224, 69, 123, .55);
    animation: mic-pulse 1.2s infinite;
}
@keyframes mic-pulse {
    0%   { box-shadow: 0 0 0 0    rgba(224, 69, 123, .55); }
    70%  { box-shadow: 0 0 0 14px rgba(224, 69, 123, 0); }
    100% { box-shadow: 0 0 0 0    rgba(224, 69, 123, 0); }
}
.attach-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px 5px 8px; border-radius: 999px;
    background: var(--bg-soft); font-size: 12.5px;
    max-width: 280px; overflow: hidden;
}
.attach-chip > span:not(.attach-chip__size) { display: inline; }
.attach-chip__size { color: var(--text-soft); font-size: 11.5px; flex-shrink: 0; }
.attach-chip button {
    background: transparent; border: 0; padding: 0 2px; line-height: 1;
    color: var(--text-muted); margin-left: 4px; font-size: 14px;
    flex-shrink: 0;
}
.attach-chip button:hover { color: var(--text); }

/* ============== Mobile ============== */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: -300px; top: 0; bottom: 0; width: 280px; z-index: 90;
        transition: left .25s ease;
        height: 100dvh;
    }
    .sidebar.is-open { left: 0; box-shadow: var(--shadow-lg); }
    .iconbtn--menu { display: inline-flex; }
    .composer-wrap {
        padding: 8px 10px 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    .messages { padding: 14px 12px 8px; }
    .topbar--app { padding: 10px 12px; }

    /* Composer на мобилке: меньше отступы, удобные тапы. */
    .composer { border-radius: 24px; padding: 6px 8px; }
    .composer__field {
        font-size: 16px; /* iOS не зумит при фокусе если >= 16 */
        padding: 10px 12px;
        min-height: 44px;
        max-height: 160px;
    }
    .composer__row { padding: 2px 4px; gap: 4px; }
    .composer__row .iconbtn { width: 38px; height: 38px; }
    .composer__send { width: 38px; height: 38px; }
    .composer__select { font-size: 12px; padding: 6px 8px; }

    /* Mode tabs: компактнее на узких экранах */
    .mode-tabs { gap: 4px; padding: 4px; }
    .mode-tab { padding: 6px 10px; font-size: 13px; }

    /* Сообщения: больше места под текст, меньше отступов между ними */
    .messages__inner { gap: 20px; }
    .msg--user .msg__bubble { max-width: 88%; padding: 9px 14px; font-size: 15px; }
    .msg--assistant .msg__bubble { font-size: 15.5px; }
    .msg__head { gap: 8px; }
    .msg__avatar { width: 24px; height: 24px; }
    .msg__actions { gap: 2px; }
    .msg__action { width: 30px; height: 30px; }
}

@media (max-width: 480px) {
    .composer-wrap { padding: 6px 8px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .messages { padding: 10px 10px 6px; }
    .messages__inner { gap: 18px; }
    .topbar__brand-text { display: none; }

    /* Модалки на узких экранах: меньше воздуха, прокрутка через .modal-wrap */
    .modal-wrap { padding: 12px; align-items: flex-start; padding-top: max(20px, env(safe-area-inset-top)); }
    .modal { padding: 18px 16px; border-radius: 18px; }
    .modal h2, .modal__title { font-size: 17px; margin: 0 0 12px; }
    .modal__field { margin-bottom: 10px; }
    .modal__field label { font-size: 12.5px; margin-bottom: 4px; }
    .modal__field input, .modal__field textarea, .modal__field select {
        padding: 10px 12px; border-radius: 10px; font-size: 16px;
    }
    .modal__actions { margin-top: 12px; gap: 8px; }
    .modal__actions .btn { padding: 10px 16px; font-size: 14px; }

    /* Модалка блокнота: эмодзи-кнопка меньше, сетка эмодзи в 6 колонок */
    .modal--nb { max-width: 100%; }
    .nb-form-row { gap: 8px; margin-bottom: 10px; }
    .nb-form-emoji { width: 44px; height: 44px; font-size: 22px; border-radius: 12px; }
    .nb-form-input { font-size: 16px; padding: 0 12px; border-radius: 12px; }
    .nb-emoji-picker { grid-template-columns: repeat(6, 1fr); padding: 8px; gap: 2px; margin: -4px 0 12px; }
    .nb-emoji-pick { font-size: 20px; border-radius: 6px; }
    .nb-color-row { gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
    .nb-color-row__list { gap: 6px; }
    .nb-color-pick { width: 24px; height: 24px; }
    .nb-color-label { font-size: 12px; }

    /* Уменьшаем отступы внутри страниц-«контейнеров» когда они в app-оболочке */
    .app__main > main.container { padding-left: 14px !important; padding-right: 14px !important; }
    .app__main > main.container h1 { font-size: clamp(22px, 6vw, 28px); }

    /* Тарифы — более компактная сетка */
    .tariffs { gap: 12px; }
    .tariff { padding: 18px 16px; }
}

.scrim {
    position: fixed; inset: 0; background: rgba(15, 23, 40, .35);
    z-index: 80; opacity: 0; pointer-events: none;
    transition: opacity .2s;
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

/* ============== Maintenance / 404 ============== */
.center-page {
    min-height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 40px 20px; text-align: center;
}
.center-page h1 { font-size: 32px; margin-bottom: 8px; }
.center-page p { color: var(--text-muted); max-width: 480px; }
.center-page .icon {
    width: 80px; height: 80px; margin-bottom: 22px;
    background: var(--grad-soft); border-radius: 22px;
    display: flex; align-items: center; justify-content: center;
}

/* ============== Toast ============== */
.toast {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: 28px; padding: 12px 18px;
    background: #1f2533; color: #fff; border-radius: 12px;
    font-size: 14px; z-index: 200;
    box-shadow: var(--shadow-lg);
    animation: toast-in .2s ease;
    max-width: min(560px, calc(100vw - 24px));
    line-height: 1.4;
    transition: opacity .4s ease;
}
.toast--err { background: var(--danger); }
.toast--ok { background: var(--success); }
@keyframes toast-in { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ============== Modal ============== */
.modal-wrap {
    position: fixed; inset: 0; background: rgba(20, 28, 50, .42);
    backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    z-index: 120; padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.modal-wrap[hidden] { display: none !important; }
.modal {
    background: var(--bg-card); border-radius: var(--r-lg);
    padding: 28px; max-width: 520px; width: 100%;
    box-shadow: var(--shadow-lg);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.modal h2 { margin: 0 0 14px; font-size: 20px; }
.modal__field { margin-bottom: 14px; }
.modal__field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }
.modal__field input, .modal__field textarea, .modal__field select {
    width: 100%; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: 12px;
    background: #fff; color: var(--text);
    outline: 0; transition: border-color .15s;
}
.modal__field input:focus, .modal__field textarea:focus { border-color: var(--primary); }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ============== Cards (My content / Notebooks) ============== */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.card {
    background: var(--bg-card); border-radius: var(--r-md);
    border: 1px solid var(--border-soft); overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column;
}
.card__media { aspect-ratio: 1/1; background: var(--grad-soft); }
.card__media img { width: 100%; height: 100%; object-fit: cover; }
.card__body { padding: 12px 14px; }
.card__title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.card__meta { color: var(--text-muted); font-size: 12px; }

/* === Settings page === */
.settings-page { padding: 24px; max-width: 820px; }
.settings-page h1 { font-size: 28px; margin: 0 0 22px; }
.settings-page__logout { text-align: center; margin-top: 28px; }

.settings-card { padding: 22px; margin-bottom: 18px; }
.settings-card h3 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.settings-card__row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
}
.settings-card__plan { font-size: 18px; font-weight: 600; }
.settings-card__user { display: flex; align-items: center; gap: 14px; }
.settings-card__avatar {
    width: 54px; height: 54px; border-radius: 50%;
    background: #1f2533; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700;
    overflow: hidden;
}
.settings-card__avatar img { width: 100%; height: 100%; object-fit: cover; }

/* === Balance card === */
.balance-card {
    position: relative;
    background: linear-gradient(135deg, #f3f7ff 0%, #ffffff 100%);
    border: 1px solid #d7e3fb;
    border-radius: 22px;
    padding: 22px 24px;
    margin-bottom: 18px;
    box-shadow: 0 8px 24px -10px rgba(77, 138, 240, .12);
}
.balance-card__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 8px;
}
.balance-card__label {
    font-size: 13px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .06em;
    font-weight: 600;
}
.balance-card__amount {
    display: flex; align-items: baseline; gap: 8px;
    margin: 4px 0 6px;
}
.balance-card__amount strong {
    font-size: 44px; line-height: 1; font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.balance-card__unit {
    font-size: 16px; color: var(--text-muted);
}
.balance-card__rub {
    font-size: 14px; color: var(--text-muted); margin-bottom: 18px;
}
.balance-card__rub .muted { font-size: 12px; }
.balance-card__breakdown {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    padding-top: 16px; border-top: 1px solid #e3ebfa;
}
.bcb {
    display: flex; align-items: center; gap: 10px;
}
.bcb__icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: #fff; border: 1px solid #d7e3fb;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--primary); flex-shrink: 0;
}
.bcb__title { font-size: 12px; color: var(--text-muted); }
.bcb__cost { font-size: 15px; font-weight: 600; color: var(--text); }
@media (max-width: 540px) {
    .balance-card__breakdown { grid-template-columns: 1fr; gap: 8px; }
    .balance-card__amount strong { font-size: 36px; }
}


/* История кредитов в личном кабинете */
.credit-log { display: flex; flex-direction: column; }
.credit-log__row {
    display: grid;
    grid-template-columns: 130px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--border);
    font-size: 14px;
}
.credit-log__row:first-child { border-top: 0; }
.credit-log__date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.credit-log__what { display: flex; gap: 8px; align-items: center; min-width: 0; }
.credit-log__what a { color: var(--accent); text-decoration: none; }
.credit-log__what a:hover { text-decoration: underline; }
.credit-log__what > span:not(.credit-log__type) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.credit-log__type {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2fb;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}
.credit-log__type--text   { background: #dbeafe; color: #1e40af; }
.credit-log__type--image  { background: #fef3c7; color: #92400e; }
.credit-log__type--music  { background: #d1fae5; color: #065f46; }
.credit-log__type--refund { background: #d1fae5; color: #065f46; }
.credit-log__type--grant  { background: #ddd6fe; color: #5b21b6; }
.credit-log__amount { font-weight: 700; white-space: nowrap; }
.credit-log__amount.is-minus { color: #dc2626; }
.credit-log__amount.is-plus  { color: #16a34a; }
@media (max-width: 600px) {
    .credit-log__row { grid-template-columns: 1fr auto; }
    .credit-log__date { grid-column: 1 / -1; order: -1; }
}

/* Меню чата в сайдбаре (Pin / Rename / Delete) */
.chat-row {
    position: relative;
    display: flex;
    align-items: center;
    border-radius: 8px;
}
.chat-row:hover { background: var(--bg-soft); }
.chat-row--pinned { background: rgba(96, 122, 255, 0.06); }
.chat-row__link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 6px 8px 12px;
    border-radius: 8px;
    background: transparent !important;
}
.chat-row__title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-row__pin { color: var(--accent); flex-shrink: 0; }
.chat-row__kind {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    border-radius: 6px;
    flex-shrink: 0;
    background: rgba(91, 140, 245, .1);
    color: var(--primary);
}
.chat-row__kind svg { width: 14px; height: 14px; }
.chat-row__kind--image { background: rgba(255, 138, 76, .12); color: #e07033; }
.chat-row__kind--music { background: rgba(168, 85, 247, .12); color: #9333ea; }
.chat-row__kind--text  { background: rgba(91, 140, 245, .12); color: var(--primary); }

/* Кнопки «Создать …» в сайдбаре — у каждого типа своя цветная иконка */
.sidebar__link--kind { gap: 10px; }
.sidebar__kind-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
}
.sidebar__kind-badge--text  { background: rgba(91, 140, 245, .12); color: var(--primary); }
.sidebar__kind-badge--image { background: rgba(255, 138, 76, .14); color: #e07033; }
.sidebar__kind-badge--music { background: rgba(168, 85, 247, .14); color: #9333ea; }
.sidebar__kind-label { flex: 1; min-width: 0; }

/* Активная (текущая) кнопка создания — окрашиваем фон под цвет типа,
   чтобы было сразу понятно: «вы сейчас в фото/музыкальном/текстовом чате». */
.sidebar__link--kind-text.is-active   { background: rgba(91, 140, 245, .14); color: var(--primary); }
.sidebar__link--kind-image.is-active  { background: rgba(255, 138, 76, .16); color: #c2541f; }
.sidebar__link--kind-music.is-active  { background: rgba(168, 85, 247, .16); color: #7e22ce; }
.sidebar__link--kind.is-active .sidebar__kind-badge { box-shadow: 0 0 0 2px rgba(255,255,255,.6) inset; }

/* Подсветка строки текущего открытого чата в списке. */
.chat-row.is-current { background: rgba(91, 140, 245, .1); }
.chat-row.is-current .chat-row__link { color: var(--primary); font-weight: 600; }
.chat-row.is-current.chat-row--kind-image { background: rgba(255, 138, 76, .12); }
.chat-row.is-current.chat-row--kind-image .chat-row__link { color: #c2541f; }
.chat-row.is-current.chat-row--kind-music { background: rgba(168, 85, 247, .12); }
.chat-row.is-current.chat-row--kind-music .chat-row__link { color: #7e22ce; }
.chat-row.is-current .chat-row__menu { display: inline-flex; }
.chat-row__menu {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    flex-shrink: 0;
}
.chat-row:hover .chat-row__menu,
.chat-row.is-active .chat-row__menu,
.chat-row__menu.is-open { display: inline-flex; }
.chat-row__menu:hover { background: rgba(0,0,0,0.06); color: var(--fg); }

.chat-menu {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    padding: 6px;
    min-width: 220px;
    display: flex;
    flex-direction: column;
}
.chat-menu[hidden] { display: none !important; }
.chat-menu__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 0;
    background: transparent;
    color: var(--fg);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: 10px;
    width: 100%;
}
.chat-menu__item:hover { background: var(--bg-soft); }
.chat-menu__item--danger { color: #dc2626; }
.chat-menu__item--danger:hover { background: #fee2e2; }
.chat-menu__label-unpin { display: none; }
.chat-menu.is-pinned .chat-menu__label-pin { display: none; }
.chat-menu.is-pinned .chat-menu__label-unpin { display: inline; }

/* На мобилке кнопка-меню всегда видима */
@media (max-width: 900px) {
    .chat-row__menu { display: inline-flex; }
}

/* === Popover-меню сообщения (три точки → Удалить) === */
.msg-menu {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    padding: 6px;
    min-width: 200px;
}
.msg-menu[hidden] { display: none !important; }
.msg-menu__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--fg);
    font-size: 14px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
}
.msg-menu__item:hover { background: var(--bg-soft); }
.msg-menu__item svg { width: 18px; height: 18px; flex-shrink: 0; }
.msg-menu__item--danger { color: #dc2626; }
.msg-menu__item--danger:hover { background: #fee2e2; }

/* === Универсальные модалки (gmPrompt / gmConfirm) === */
.gm-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}
.gm-modal.is-open { opacity: 1; pointer-events: auto; }
.gm-modal__scrim {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.gm-modal__card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    transform: translateY(8px) scale(.98);
    transition: transform .2s ease;
}
.gm-modal.is-open .gm-modal__card { transform: translateY(0) scale(1); }
.gm-modal__title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 600;
    color: var(--fg);
}
.gm-modal__msg {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}
.gm-modal__input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    color: var(--fg);
    background: var(--bg);
    transition: border-color .15s ease, box-shadow .15s ease;
    margin-bottom: 18px;
}
.gm-modal__input:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.gm-modal__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.gm-modal__actions .btn { min-width: 90px; }
@media (max-width: 480px) {
    .gm-modal { padding: 16px; }
    .gm-modal__card { padding: 20px; border-radius: 18px; }
    .gm-modal__actions { flex-direction: column-reverse; }
    .gm-modal__actions .btn { width: 100%; }
}

/* ====== Drag-and-drop overlay ====== */
.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(36, 64, 142, 0.18);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    pointer-events: none;
}
.drop-overlay.is-active {
    display: flex;
    animation: drop-fade .15s ease;
}
@keyframes drop-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.drop-overlay__inner {
    background: #fff;
    border: 2px dashed #6f9bff;
    border-radius: 24px;
    padding: 48px 64px;
    text-align: center;
    color: #2b4ea6;
    box-shadow: 0 24px 60px rgba(20,40,90,0.18);
    max-width: 90vw;
}
.drop-overlay__title {
    font-size: 22px;
    font-weight: 600;
    margin-top: 14px;
}
.drop-overlay__hint {
    margin-top: 6px;
    font-size: 14px;
    color: #6b7a99;
}

/* ====== Code blocks (Gemini-style) с кнопкой Copy ====== */
.md-code {
    position: relative;
    margin: 14px 0;
    border-radius: 14px;
    overflow: hidden;
    background: #0f1729;
    box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
}
.md-code__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: #1a2440;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.md-code__lang {
    font: 600 12px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    color: #a9b9e0;
    text-transform: lowercase;
    letter-spacing: 0.04em;
}
.md-code__copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: #cad8ff;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 4px 10px;
    font: 500 12px/1.4 system-ui, -apple-system, sans-serif;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.md-code__copy:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.2);
}
.md-code__copy.is-copied {
    color: #74e3a8;
    border-color: rgba(116, 227, 168, 0.4);
}
.md-code pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    background: transparent;
    color: #e3e9ff;
    font: 13px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    -webkit-font-smoothing: antialiased;
}
.md-code pre code {
    background: transparent;
    color: inherit;
    font: inherit;
    padding: 0;
}
.md-inline-code {
    background: rgba(99,128,200,0.14);
    color: #1d3a9b;
    padding: 1px 6px;
    border-radius: 5px;
    font: 0.92em/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.msg--assistant blockquote {
    margin: 10px 0;
    padding: 8px 14px;
    border-left: 3px solid #b9c8ee;
    color: #4a5680;
    background: rgba(170, 192, 240, 0.08);
    border-radius: 0 10px 10px 0;
}
.md-table {
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    display: block;
}
.md-table th, .md-table td {
    border: 1px solid #d8defa;
    padding: 6px 10px;
    text-align: left;
}
.md-table th {
    background: #f0f4ff;
    font-weight: 600;
}

/* ====== TTS-кнопка ====== */
.msg__action.is-speaking {
    color: #2858d8;
    background: rgba(40, 88, 216, 0.12);
}
.msg__action.is-speaking svg { animation: pulse-speak 1.2s ease-in-out infinite; }
@keyframes pulse-speak {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; transform: scale(1.05); }
}

/* ============================================================
   Notebooks — список и просмотр
   ============================================================ */
.nb-container { padding: 28px 24px 60px; max-width: 1180px; margin: 0 auto; }

.nb-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin-bottom: 28px;
}
.nb-title-h1 { margin: 0 0 6px; font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.nb-subtitle { margin: 0; max-width: 620px; color: var(--text-muted); line-height: 1.5; font-size: 14.5px; }
.nb-create { white-space: nowrap; flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; }

.nb-empty { text-align: center; padding: 80px 24px; }
.nb-empty__art { font-size: 64px; line-height: 1; margin-bottom: 16px; }
.nb-empty h2 { margin: 0 0 8px; font-weight: 600; }

/* Сетка карточек */
.nb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}
.nb-card {
    --nb-accent: #A299F3;
    position: relative;
    display: flex; flex-direction: column;
    min-height: 152px;
    padding: 18px 18px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    text-decoration: none; color: inherit;
    transition: transform .15s ease, box-shadow .2s ease, border-color .15s ease;
    overflow: hidden;
}
.nb-card::before {
    content: '';
    position: absolute; inset: 0 0 auto 0; height: 50px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--nb-accent) 55%, transparent), transparent);
    pointer-events: none;
}
.nb-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.06); border-color: color-mix(in srgb, var(--nb-accent) 50%, var(--border)); }
.nb-card__head {
    position: relative; z-index: 1;
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.nb-card__icon {
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px;
    font-size: 22px; line-height: 1;
    background: color-mix(in srgb, var(--nb-accent) 25%, #fff);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--nb-accent) 35%, transparent);
}
.nb-card__menu {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent; border-radius: 8px;
    color: var(--text-muted); cursor: pointer;
}
.nb-card__menu:hover { background: var(--bg-soft); color: var(--text); }
.nb-card__body { position: relative; z-index: 1; flex: 1; }
.nb-card__title {
    font-size: 16px; font-weight: 600; line-height: 1.3;
    margin-bottom: 6px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nb-card__meta { color: var(--text-muted); font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dotsep { color: var(--text-soft); }

/* Модалка создания/редактирования */
.modal--nb { max-width: 480px; }
.modal__title { margin: 0 0 16px; font-size: 19px; font-weight: 600; }
.nb-form-row { display: flex; gap: 10px; align-items: stretch; margin-bottom: 12px; }
.nb-form-emoji {
    width: 52px; height: 52px;
    border: 1px solid var(--border); border-radius: 14px; background: var(--bg-soft);
    font-size: 26px; line-height: 1; cursor: pointer;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.nb-form-emoji:hover { background: var(--bg); }
.nb-form-input {
    flex: 1; min-width: 0;
    border: 1px solid var(--border); border-radius: 14px;
    padding: 0 14px; font-size: 16px;
    background: var(--bg-card); color: var(--text);
}
.nb-form-input:focus { outline: 2px solid color-mix(in srgb, var(--accent, #5b8cf5) 40%, transparent); border-color: var(--accent, #5b8cf5); }

.nb-emoji-picker {
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
    padding: 10px; margin: -8px 0 14px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--bg-soft);
}
.nb-emoji-pick {
    width: 100%; aspect-ratio: 1; border: 0; background: transparent;
    border-radius: 8px; font-size: 22px; line-height: 1; cursor: pointer;
}
.nb-emoji-pick:hover { background: var(--bg-card); }

.nb-color-row {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px;
}
.nb-color-label { font-size: 13px; }
.nb-color-row__list { display: flex; gap: 8px; flex-wrap: wrap; }
.nb-color-pick {
    width: 26px; height: 26px;
    border: 2px solid transparent; border-radius: 50%;
    cursor: pointer; padding: 0;
    box-shadow: inset 0 0 0 2px #fff;
    transition: transform .12s ease;
}
.nb-color-pick:hover { transform: scale(1.1); }
.nb-color-pick.is-active {
    border-color: var(--text);
}

/* Внутренняя страница блокнота */
.nb-view { --nb-accent: #A299F3; max-width: 1180px; }
.nb-view-head {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 28px;
    padding: 20px 22px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--nb-accent) 18%, var(--bg-card)), var(--bg-card) 70%);
    border: 1px solid var(--border); border-radius: 22px;
}
.nb-view-back { flex-shrink: 0; }
.nb-view-icon {
    width: 56px; height: 56px;
    display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--nb-accent) 25%, #fff);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--nb-accent) 35%, transparent);
    border-radius: 16px;
    font-size: 28px; line-height: 1; flex-shrink: 0;
}
.nb-view-titles { flex: 1; min-width: 0; }
.nb-view-title { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
.nb-view-head__actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 720px) {
    .nb-view-head__actions { width: 100%; justify-content: stretch; }
    .nb-view-head__actions .btn { flex: 1; justify-content: center; }
}
.nb-view-prompt {
    margin: 0; font-size: 13.5px; line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nb-view-prompt--empty { font-style: italic; }

.nb-view-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
@media (max-width: 880px) {
    .nb-view-grid { grid-template-columns: 1fr; }
}

.nb-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
}
.nb-panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.nb-panel__title { margin: 0; font-size: 16px; font-weight: 600; }
.nb-panel__count { font-size: 13px; color: var(--text-muted); background: var(--bg-soft); padding: 2px 10px; border-radius: 999px; }

/* Dropzone */
.nb-dropzone {
    display: flex; align-items: center; gap: 12px;
    padding: 14px;
    border: 2px dashed var(--border); border-radius: 14px;
    cursor: pointer; transition: border-color .15s ease, background .15s ease;
    background: var(--bg-soft);
    margin-bottom: 14px;
}
.nb-dropzone:hover, .nb-dropzone.is-drag {
    border-color: var(--nb-accent);
    background: color-mix(in srgb, var(--nb-accent) 8%, var(--bg-soft));
}
.nb-dropzone__icon { color: var(--nb-accent); flex-shrink: 0; }
.nb-dropzone__text { display: flex; flex-direction: column; gap: 2px; line-height: 1.35; }
.nb-dropzone__text strong { font-weight: 600; font-size: 14px; }
.nb-dropzone__text span { font-size: 12.5px; color: var(--text-muted); }

/* Список источников */
.nb-source-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.nb-source {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--bg-card);
}
.nb-source--uploading { opacity: .6; }
.nb-source__icon { font-size: 22px; line-height: 1; flex-shrink: 0; width: 32px; text-align: center; }
.nb-source__main { flex: 1; min-width: 0; }
.nb-source__name {
    font-size: 14px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nb-source__meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.nb-source__remove {
    width: 28px; height: 28px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent; color: var(--text-muted);
    border-radius: 8px; cursor: pointer;
}
.nb-source__remove:hover { background: var(--bg-soft); color: #d04141; }
.nb-source-empty { font-size: 13px; line-height: 1.5; padding: 6px 4px 0; }

/* Список чатов в блокноте */
.nb-chat-new { display: inline-flex; align-items: center; gap: 6px; }
.nb-chat-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.nb-chat-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    text-decoration: none; color: inherit;
    transition: background .12s ease;
}
.nb-chat-row:hover { background: var(--bg-soft); }
.nb-chat-row__title {
    font-size: 14px; font-weight: 500; flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nb-chat-row__meta { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }

/* Эмодзи блокнота в sidebar */
.sidebar__nb-emoji {
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px; background: var(--bg-soft);
    font-size: 14px; line-height: 1;
    margin-right: 8px; flex-shrink: 0;
}
.sidebar__group-title--link {
    color: inherit; text-decoration: none;
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer;
}
.sidebar__group-title--link:hover { color: var(--text); }

/* Бейдж блокнота в шапке чата */
.chat-nb-banner {
    --nb-accent: #A299F3;
    flex-shrink: 0;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    margin: 8px 18px 0;
    background: linear-gradient(90deg, color-mix(in srgb, var(--nb-accent) 18%, var(--bg-card)), var(--bg-card) 80%);
    border: 1px solid color-mix(in srgb, var(--nb-accent) 35%, var(--border));
    border-radius: 14px;
}
.chat-nb-banner__icon {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--nb-accent) 28%, #fff);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--nb-accent) 35%, transparent);
    border-radius: 10px;
    font-size: 20px; line-height: 1; flex-shrink: 0;
}
.chat-nb-banner__main { flex: 1; min-width: 0; }
.chat-nb-banner__row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chat-nb-banner__label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
    color: var(--text-muted); font-weight: 600;
}
.chat-nb-banner__title {
    color: var(--text); text-decoration: none;
    font-weight: 600; font-size: 14.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 100%;
}
.chat-nb-banner__title:hover { text-decoration: underline; }
.chat-nb-banner__meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.chat-nb-banner__chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: color-mix(in srgb, var(--nb-accent) 12%, var(--bg-soft));
    color: var(--text-muted);
    padding: 2px 8px; border-radius: 999px;
    font-size: 11.5px;
}
.chat-nb-banner__settings {
    width: 32px; height: 32px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted); text-decoration: none;
    border-radius: 8px;
}
.chat-nb-banner__settings:hover { color: var(--text); background: var(--bg-soft); }
@media (max-width: 720px) {
    .chat-nb-banner { margin: 6px 10px 0; padding: 8px 10px; gap: 8px; }
    .chat-nb-banner__icon { width: 30px; height: 30px; font-size: 17px; }
    .chat-nb-banner__title { font-size: 13.5px; }
}

/* Строка блокнота в sidebar — ссылка на чат + кнопка настроек */
.sidebar__nb-row {
    display: flex; align-items: stretch; gap: 0;
    border-radius: 10px;
    transition: background .12s ease;
}
.sidebar__nb-row:hover { background: var(--bg-soft); }
.sidebar__nb-row__link {
    flex: 1; min-width: 0;
    display: flex; align-items: center;
    background: transparent !important;
    overflow: hidden;
}
.sidebar__nb-row__title {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.sidebar__nb-row__settings {
    width: 28px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-soft); text-decoration: none;
    border-radius: 8px;
    opacity: 0;
    transition: opacity .12s ease, color .12s ease, background .12s ease;
}
.sidebar__nb-row:hover .sidebar__nb-row__settings { opacity: 1; }
.sidebar__nb-row__settings:hover { color: var(--text); background: var(--bg-card); }

@media (max-width: 720px) {
    .nb-container { padding: 18px 14px 40px; }
    .nb-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .nb-create { align-self: flex-start; }
    .nb-grid { gap: 12px; }
    .nb-view-head { padding: 14px; gap: 10px; flex-wrap: wrap; }
    .nb-view-icon { width: 48px; height: 48px; font-size: 24px; }
    .nb-view-title { font-size: 18px; }
}

/* ==================== Image generation strip (kie.ai-style, compact) ====================
 * Тонкая полоса параметров прямо внутри композера. Структура:
 *   .img-strip
 *     .img-strip__refs        — сетка превью референсов (hidden, если пусто)
 *     .img-strip__bar         — панель пилюль (flex-wrap: wrap — переносится по строкам)
 *       .img-strip__chip--add — скрепка + счётчик 0/14
 *       .img-strip__group     — группа пилюль (aspect / resolution / format)
 *         .img-strip__pill    — одна пилюля
 */
.img-strip {
    margin: 0 4px 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.img-strip__refs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 6px;
    padding: 6px 8px 0;
}
.img-strip__refs[hidden] { display: none; }
.img-refs__item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-soft);
    border: 1px solid var(--border);
}
.img-refs__item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-refs__remove {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px;
    border: 0; padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.img-refs__remove:hover { background: rgba(0, 0, 0, .8); }
.img-refs__remove svg { width: 10px; height: 10px; }

/* === Bar of pills === */
.img-strip__bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    column-gap: 8px;
    row-gap: 6px;
    padding: 4px 6px;
}

.img-strip__group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
}
.img-strip__group-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    margin: 0 2px 0 4px;
    flex-shrink: 0;
}

/* === Pill === */
.img-strip__pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}

/* === Hover-preview формы для aspect-ratio пилюль ===
 * Над пилюлей всплывает прямоугольник правильных пропорций: тонкая голубая обводка
 * на светло-голубой заливке (как референс на скрине). Пропорции — через CSS-переменную
 * --ar (например, 16 / 9). Нормируем по большей стороне: max-width / max-height = 40px.
 */
.img-strip__pill.has-preview::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    width: 40px;
    aspect-ratio: var(--ar, 1 / 1);
    max-height: 40px;
    background: rgba(91, 140, 245, .08);
    border: 1.5px solid rgba(91, 140, 245, .55);
    border-radius: 3px;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 4px);
    transition: opacity .15s ease, transform .15s ease;
    z-index: 5;
}
.img-strip__pill.has-preview:hover::before,
.img-strip__pill.has-preview:focus-visible::before {
    opacity: 1;
    transform: translate(-50%, 0);
}
.img-strip__pill:hover { background: rgba(127, 142, 168, .12); }
.img-strip__pill.is-active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(20, 32, 70, .12), inset 0 0 0 1px rgba(20, 32, 70, .04);
}

/* Aspect ratio: фиолетовая активная пилюля (как на скрине) */
.img-strip__group--aspect .img-strip__pill.is-active {
    background: linear-gradient(180deg, #8b5cf6 0%, #7c3aed 100%);
    color: #fff;
    box-shadow: 0 2px 8px -2px rgba(124, 58, 237, .55);
}

/* Resolution: акцентная синяя активная пилюля. Стоимость не дублируем —
 * она показана крупно в кнопке Send (см. .composer__send-cost). */
.img-strip__group--res .img-strip__pill.is-active {
    background: linear-gradient(180deg, #4d8af0 0%, #3372dc 100%);
    color: #fff;
    box-shadow: 0 2px 8px -2px rgba(51, 114, 220, .55);
}

/* Output format: PNG зелёная, JPG амбер (две одинаково яркие активные кнопки) */
.img-strip__pill--png.is-active {
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 2px 8px -2px rgba(16, 185, 129, .55);
}
.img-strip__pill--jpg.is-active {
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    box-shadow: 0 2px 8px -2px rgba(245, 158, 11, .55);
}

/* Add (скрепка + 0/14) — отдельный компактный chip */
.img-strip__chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 999px;
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .12s ease, border-color .12s ease;
}
.img-strip__chip:hover { background: var(--bg-soft); border-color: var(--accent); }
.img-strip__chip[disabled] { opacity: .55; cursor: not-allowed; }

/* === Send button с бейджем стоимости («12 кредитов  →»)
 *  Число + слово помещаем в один овал, чтобы пилюля читалась как единое целое.
 */
.composer__send--image {
    width: auto;
    height: 40px;
    min-width: 56px;
    padding: 0 14px 0 8px;
    border-radius: 999px;
    gap: 8px;
}
.composer__send-cost {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    font-weight: 600;
    font-size: 12.5px;
    background: rgba(255, 255, 255, .22);
    padding: 4px 10px;
    border-radius: 99px;
    line-height: 1;
}
.composer__send-cost [data-cost-display] {
    font-weight: 700;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
}
.composer__send-cost [data-cost-word] {
    opacity: .9;
}

/* Reference-картинки в пузыре пользователя — компактная сетка */
.msg__refs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
    margin-top: 6px;
    max-width: 360px;
}
.msg__refs-grid img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

/* === Welcome-экран image-чата: разрешаем прокрутку, если контент не влез === */
.page-chat--kind-image .chat__welcome {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.page-chat--kind-image .chat__welcome h1 { margin-top: 8px; }

/* На мобилке strip не должен ломать composer — ограничиваем ширину и убираем margin */
@media (max-width: 720px) {
    .img-strip { margin: 0; }
    .img-strip__bar { padding: 4px; column-gap: 6px; row-gap: 5px; }
    .img-strip__pill { padding: 5px 9px; font-size: 12px; }
    .img-strip__group { padding: 2px; }
    .composer__send--image { min-width: 50px; padding: 0 12px 0 6px; gap: 6px; }
    .composer__send-cost { font-size: 11.5px; padding: 3px 8px; gap: 3px; }
    .composer__send-cost [data-cost-display] { font-size: 12.5px; }
}

/* ==================== Image result media: hover-overlay со «Скачать» + zoom ==================== */
.msg__img-wrap {
    position: relative;
    display: inline-block;
    line-height: 0;
    border-radius: 14px;
    overflow: hidden;
    max-width: 100%;
}
.msg__img-wrap img {
    display: block;
    max-width: 100%;
    max-height: 480px;
    height: auto;
    border-radius: 14px;
    cursor: zoom-in;
    transition: transform .25s ease;
}
.msg__img-wrap:hover img { transform: scale(1.005); }

.msg__img-download {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 0;
    background: rgba(15, 23, 42, .55);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px -4px rgba(0,0,0,.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .2s ease, transform .2s ease, background .15s ease;
    z-index: 2;
}
.msg__img-download:hover { background: rgba(15, 23, 42, .82); }
.msg__img-download:active { transform: translateY(0) scale(.95); }
.msg__img-download svg { width: 18px; height: 18px; }
.msg__img-wrap:hover .msg__img-download,
.msg__img-wrap:focus-within .msg__img-download,
.msg__img-download:focus-visible {
    opacity: 1;
    transform: translateY(0);
}
/* Тач-устройства: hover недоступен → кнопка всегда видна */
@media (hover: none), (pointer: coarse) {
    .msg__img-download { opacity: 1; transform: none; }
}

/* В рефах пользователя (msg__refs-grid) тоже делаем кликабельным для зума */
.msg__refs-grid img { cursor: zoom-in; }

/* ==================== Lightbox (полноэкранный просмотр + скачать) ==================== */
.lightbox {
    position: fixed; inset: 0;
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    isolation: isolate;
}
.lightbox[hidden] { display: none; }
.lightbox__backdrop {
    position: absolute; inset: 0;
    background: rgba(8, 12, 24, .82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: zoom-out;
    animation: lightbox-fade .18s ease-out;
}
.lightbox__content {
    position: relative;
    max-width: min(96vw, 1400px);
    max-height: 92vh;
    display: flex;
    align-items: center; justify-content: center;
    animation: lightbox-pop .22s cubic-bezier(.2,.7,.3,1);
}
.lightbox__img {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 14px;
    box-shadow: 0 18px 60px -18px rgba(0,0,0,.7);
    user-select: none;
    -webkit-user-select: none;
}
.lightbox__toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    gap: 8px;
    z-index: 2;
}
.lightbox__btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 0;
    background: rgba(15, 23, 42, .65);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px -6px rgba(0,0,0,.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background .15s ease, transform .12s ease;
}
.lightbox__btn:hover { background: rgba(15, 23, 42, .9); }
.lightbox__btn:active { transform: scale(.94); }
.lightbox__btn svg { width: 20px; height: 20px; }

html.is-lightbox-open { overflow: hidden; }

@keyframes lightbox-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes lightbox-pop {
    from { opacity: 0; transform: scale(.96); }
    to   { opacity: 1; transform: scale(1); }
}

@media (max-width: 540px) {
    .lightbox { padding: 12px; }
    .lightbox__btn { width: 36px; height: 36px; }
    .msg__img-download { top: 8px; right: 8px; width: 32px; height: 32px; }
    .msg__img-download svg { width: 16px; height: 16px; }
}

/* ==================== /my-content gallery ==================== *
 * Сетка превью (image / music). На десктопе — фикс. 4 в ряд, на узких
 * экранах — auto-fit с минимумом 130px. Клик по картинке открывает её
 * в общем lightbox (window.GMLightbox в app.js).
 *
 * NB: hover-эффекты намеренно сделаны без любых transform на самой карточке
 *     и на изображении — они вызывали «дёргание» при наезде мышкой между
 *     соседними карточками (каждый hover двигал предыдущую обратно).
 */
.my-content-page {
    padding: 24px clamp(20px, 3vw, 40px);
    max-width: 100%;
    width: 100%;
}
.my-content-page h1 { font-size: 28px; }

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}
/* На комфортных ширинах — ровно 4 в ряд, чтобы превью были однородного размера */
@media (min-width: 880px) {
    .gallery--images { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1280px) {
    .gallery--images { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 1600px) {
    .gallery--images { grid-template-columns: repeat(6, 1fr); }
}

.gallery__item {
    margin: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: box-shadow .15s ease, border-color .15s ease;
}
.gallery__item:hover {
    box-shadow: 0 6px 18px -8px rgba(20, 32, 70, .18);
    border-color: var(--border);
}

.gallery__media {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--grad-soft);
    overflow: hidden;
}
.gallery__media img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    cursor: zoom-in;
}

.gallery__dl {
    position: absolute;
    top: 6px; right: 6px;
    width: 30px; height: 30px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, .55);
    color: #fff;
    display: inline-flex;
    align-items: center; justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 3px 10px -3px rgba(0,0,0,.35);
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity .18s ease, transform .18s ease, background .15s ease;
    z-index: 2;
}
.gallery__dl:hover { background: rgba(15, 23, 42, .85); }
.gallery__dl:active { transform: scale(.92); }
.gallery__item:hover .gallery__dl,
.gallery__item:focus-within .gallery__dl,
.gallery__dl:focus-visible {
    opacity: 1;
    transform: translateY(0);
}
@media (hover: none), (pointer: coarse) {
    .gallery__dl { opacity: 1; transform: none; }
}

.gallery__caption {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gallery__title {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}
.gallery__meta { color: var(--text-muted); font-size: 11.5px; }

@media (max-width: 540px) {
    .gallery { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
    .gallery__caption { padding: 6px 8px 8px; }
    .gallery__title { font-size: 12px; }
}
