:root {
    --bg: #f5f6f8;
    --panel-bg: #ffffff;
    --accent: #8eb533;
    --accent-dark: #6f8f24;
    --accent-secondary: #2f7b6d;
    --text-main: #222222;
    --text-muted: #7b7f88;
    --border: #e4e7ec;
    --shadow-soft: 0 10px 35px rgba(18, 38, 63, 0.08);
    --shadow-card: 0 30px 60px rgba(25, 35, 52, 0.08);
    --history-width: 280px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

p {
    margin: 0 !important;
    padding: 0 !important;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-main) !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-shell {
    width: 100% !important;
    max-width: 1760px !important;
    margin: 0 auto !important;
    padding: 36px 16px 36px !important;
    display: flex !important;
    gap: 32px !important;
    align-items: stretch !important;
    box-sizing: border-box !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    height: auto !important;
    max-height: 100vh !important;
}

.history-panel {
    width: var(--history-width);
    max-width: var(--history-width);
    flex-shrink: 0;
    background: var(--panel-bg);
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
    box-sizing: border-box;
    min-height: 600px;
    flex: 0 0 var(--history-width);
    max-height: 100%;
}

.history-panel__header h2 {
    font-size: 19px !important;
    font-weight: 700;
    margin-bottom: 4px;
}

.history-panel__header p {
    font-size: 14px !important;
    color: var(--text-muted) !important;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    padding-right: 15px;
    padding-top: 3px;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: #D1EB95;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #8EB533;
}

.history-item {
    background: #f8f9fb;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid transparent;
}

.history-item:hover {
    transform: translateY(-2px);
    border-color: rgba(142, 181, 51, 0.2);
}

.history-item__header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-main) !important;
    font-size: 15px !important;
}

.history-status {
    width: 28px;
    height: 28px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px !important;
    flex-shrink: 0;
    line-height: 0;
}

.history-status svg {
    width: 20px;
    height: 20px;
    display: block;
}

.history-status--success {
    background: rgba(142, 181, 51, 0.15);
    color: var(--accent) !important;
}

.history-status--pending {
    background: rgba(47, 123, 109, 0.15);
    color: var(--accent-secondary) !important;
}

.history-status--error {
    background: rgba(220, 53, 69, 0.15);
    color: #d33c36 !important;
}

.history-item-date {
    font-size: 13px !important;
    color: var(--text-muted) !important;
}

.history-item-rating {
    font-size: 14px !important;
    color: var(--text-muted) !important;
}

.empty-message {
    text-align: center;
    color: var(--text-muted) !important;
    padding: 16px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: #fafbfc;
}

.workspace,
.main-content {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 24px !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.chat-stage {
    background: var(--panel-bg);
    border-radius: 21px;
    padding: 32px 32px 40px;
    flex: 1 1 auto !important;
    min-height: 600px !important;
    max-height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    max-height: 100%;
    position: relative;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 28px;
    overflow: hidden;
    box-sizing: border-box;
    z-index: 1;
}

.chat-stage__scroll {
    flex: 1 !important;
    min-height: 0 !important;
    max-height: 100% !important;
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.chat-messages {
    position: relative !important;
    flex: 1 !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    display: flex !important;
    box-sizing: border-box !important;
    flex-direction: column;
    gap: 16px;
    padding-right: 16px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #D1EB95;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #8EB533;
}

.chat-input-area {
    box-sizing: border-box;
    width: min(100%, 1052px);
    max-width: 1052px;
    min-height: 97px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    gap: 15px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 25px;
    box-shadow: 5px 5px 25px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    margin-left: auto;
    margin-right: auto;
    margin-top: auto;
    position: relative;
    z-index: 100;
}

.chat-arrow {
    position: absolute;
    bottom: 170px;
    left: 20%;
    width: 170px;
    height: auto;
    pointer-events: none;
    transition: opacity 0.2s ease, height 0.3s ease, bottom 0.3s ease;
}

.chat-arrow svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-arrow path {
    fill: #8EB533;
}

.chat-arrow.hidden {
    opacity: 0;
    visibility: hidden;
}

.generation-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.controls-surface {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 15px;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 15px;
    height: 77px;
    width: 100%;
}

.controls-row.controls-row--upload-preview {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    align-items: stretch;
}

.control-group {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.control-group--upload {
    flex: 1;
}

.control-group--upload.has-preview {
    flex: 0;
    width: auto;
}

.upload-tile,
.select-tile,
.cta-button {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: #bfbfbf0d;
    padding: 0 24px;
    gap: 12px;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.6), 0 6px 15px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.upload-tile {
    cursor: pointer;
}

.upload-tile:hover,
.select-tile:hover,
.cta-button:hover {
    border-color: rgba(142, 181, 51, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 16px 26px rgba(25, 76, 32, 0.08);
}

.upload-tile input[type="file"] {
    display: none;
}

.upload-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.upload-inline.has-preview {
    width: auto;
    flex: none;
    gap: 0;
}

.upload-inline.has-preview .upload-icon {
    display: none;
}

.upload-inline.has-preview .upload-label {
    display: none;
}

.upload-preview {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    overflow: visible;
    display: none;
    align-items: center;
    justify-content: center;
    position: relative;
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.upload-preview.visible {
    display: flex;
}

.upload-tile.has-preview {
    padding: 12px 16px;
    flex: 0;
    width: auto;
}

.upload-tile.has-preview .upload-preview {
    width: 52px;
    height: 52px;
}

.upload-clear {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: #fff;
}

.upload-clear svg {
    pointer-events: none;
}

.upload-preview.visible .upload-clear {
    display: flex;
}

.upload-label {
    font-weight: 600;
    font-size: 15px !important;
    text-align: left;
}

.upload-filename {
    display: none;
}

.select-tile {
    position: relative;
    cursor: pointer;
    padding-right: 48px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.6), 0 6px 15px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    overflow: visible;
}

.select-label {
    font-weight: 600;
    font-size: 15px !important;
}

.select-arrow {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    pointer-events: none;
}

.select-tile select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    border: none;
    background: transparent;
}

.select-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    height: 100%;
    cursor: pointer;
    justify-content: center;
}

.select-value {
    font-weight: 600;
    font-size: 15px !important;
    color: var(--text-main) !important;
    display: flex;
    align-items: center;
    gap: 6px;
}

.select-value.is-placeholder {
    font-weight: 500;
    color: var(--text-muted) !important;
}

.select-value-emoji {
    font-size: 16px !important;
    line-height: 1;
}

.select-value-text {
    font-size: 15px !important;
    font-weight: 600;
    line-height: 1.2;
}

.select-display[data-has-value="true"] .select-label {
    display: none;
}

.select-dropdown {
    box-sizing: border-box;
    position: fixed;
    width: 334px;
    height: 560px;
    left: 50%;
    transform: translateX(-50%);
    bottom: 80px;
    display: none;
    flex-direction: column;
    align-items: flex-start;
    padding: 25px 20px 25px 25px;
    gap: 10px;
    background: rgba(249, 249, 249, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    box-shadow: 0 30px 60px rgba(25, 35, 52, 0.15);
    overflow: hidden;
    z-index: 1001;
}

/* Показываем выпадающий список на мобильных */
.select-dropdown.mobile-open {
    display: flex !important;
}

.select-dropdown::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(249, 249, 249, 0.7);
    backdrop-filter: blur(50px);
    -webkit-backdrop-filter: blur(50px);
    pointer-events: none;
    z-index: -1;
}

.select-dropdown-header {
    font-weight: 600;
    font-size: 14px !important;
    color: var(--text-main) !important;
    margin-bottom: 4px;
}

.select-options-scroll {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-right: 6px;
    margin-right: -6px;
}

.select-options-scroll::-webkit-scrollbar {
    display: none;
}

.select-options-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.select-option {
    border: none;
    background: transparent;
    font-family: 'Inter', var(--font-main), sans-serif;
    font-size: 14px !important;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    color: var(--text-main) !important;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.select-option-emoji {
    font-size: 16px !important;
    line-height: 1;
    flex-shrink: 0;
}

.select-option-text {
    font-size: 14px !important;
    font-weight: 400;
    line-height: 1.4;
}

.select-option:hover {
    background: rgba(142, 181, 51, 0.12);
    color: var(--accent) !important;
}

.select-divider {
    height: 1px;
    width: 100%;
    background: rgba(0, 0, 0, 0.08);
    margin: 4px 0;
    flex-shrink: 0;
}

.select-scroll-indicator {
    margin-top: 8px;
    height: 44px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.select-scroll-indicator svg {
    display: block;
}
.select-option.is-active {
    background: rgba(142, 181, 51, 0.18);
    color: var(--accent) !important;
}

.select-tile.open .select-dropdown {
    display: flex !important;
    z-index: 1001;
    position: fixed !important;
}

/* Гарантируем, что список открывается на десктопе (ширина больше 1200px) */
@media (min-width: 1201px) {
    .select-tile.open .select-dropdown {
        display: flex !important;
        z-index: 3000 !important;
        position: fixed !important;
        /* Позиционирование будет установлено через JavaScript */
        left: auto !important;
        right: auto !important;
        transform: none !important;
        bottom: auto !important;
    }
}

/* Показываем выпадающий список на мобильных, если добавлен класс mobile-open */
.select-dropdown.mobile-open {
    display: flex !important;
}

.select-arrow svg {
    transition: transform 0.2s ease;
}

.select-tile.open .select-arrow svg {
    transform: rotate(180deg);
}

.cta-button {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: linear-gradient(120deg, #005258, #8EB533);
    color: white !important;
    font-weight: 600;
    border: none;
    cursor: pointer;
    position: relative;
    padding: 10px 14px;
    text-align: center;
    height: 100%;
}

.cta-line {
    display: block;
    color: white !important;
}

.cta-line-main {
    font-size: 14px !important;
    letter-spacing: 0.04em;
    color: white !important;
}

.cta-line-sub {
    font-size: 12px !important;
    color: rgba(255, 255, 255, 0.85) !important;
}

.limit-info {
    font-size: 12px !important;
    font-weight: 300;
    font-style: normal;
}

.limit-info[data-state="ok"] {
    color: rgba(255, 255, 255, 0.95) !important;
}

.limit-info[data-state="danger"] {
    color: #ffddd8 !important;
}

.limit-info[data-state="neutral"] {
    color: rgba(255, 255, 255, 0.7) !important;
}

.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    display: none;
    margin: 0 auto;
}

.cta-button.loading .loader {
    display: block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.custom-prompt-card {
    background: #f8faf6;
    border-radius: 12px;
    border: 1px dashed rgba(142, 181, 51, 0.4);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.custom-prompt-card label {
    font-weight: 600;
    color: var(--text-main) !important;
}

.custom-prompt-card textarea {
    width: 100%;
    border: none;
    border-radius: 8px;
    padding: 12px 14px;
    resize: vertical;
    min-height: 110px;
    font-family: inherit;
    font-size: 15px !important;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(142, 181, 51, 0.2);
    margin-top: 5px;
}

.custom-prompt-card textarea:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(142, 181, 51, 0.5);
}

.message {
    display: flex;
    width: 100%;
    animation: slideIn 0.3s ease;
    position: relative;
    z-index: 1;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    padding: 18px 20px;
    border-radius: 14px;
    max-width: 50%;
    line-height: 1.5;
    box-shadow: none;
    font-weight: 400;
    font-style: normal;
    font-size: 16px !important;
}

.bot-message .message-content {
    background: #8EB533;
    color: #fff !important;
    margin-right: auto;
}

.user-message .message-content {
    background: #3498DB;
    color: #fff !important;
    margin-left: auto;
}

.message-content img,
.message-content video {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 12px;
}

.message.image-message {
    justify-content: flex-start;
}

.message.image-message .message-content {
    max-width: 90%;
    width: 90%;
    padding: 0 !important;
    margin-left: 0;
    margin-right: auto;
    background: transparent;
    box-shadow: none;
}

/* Выравнивание сообщений пользователя с изображениями по правому краю */
.user-message.image-message {
    justify-content: flex-end;
}

.user-message.image-message .message-content {
    margin-left: auto;
    margin-right: 0;
}

/* Убираем padding у message-content, если внутри есть chat-image-wrapper */
.message-content:has(.chat-image-wrapper),
.bot-message .message-content:has(.chat-image-wrapper),
.message.bot-message .message-content:has(.chat-image-wrapper) {
    padding: 0 !important;
}

/* Для image-message-content padding уже 0, поэтому компенсация не нужна */
.image-message-content .chat-image-wrapper {
    margin-left: 0;
    margin-right: 0;
    margin-top: 0;
    width: 100%;
}

.image-message-content {
    width: 100%;
    display: flex;
    justify-content: flex-start;
}

.chat-image-wrapper {
    width: 100%;
    margin: 0;
    position: relative;
    margin-top: 0;
}


.chat-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 18px;
    margin-top: 0;
    box-shadow: none;
    cursor: zoom-in;
}

.chat-image-download {
    position: absolute;
    top: 20px;
    right: 8px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 139px;
    height: 54px;
    backdrop-filter: blur(5px);
    color: #000;
    font-family: 'Inter', var(--font-main), sans-serif;
    font-size: 16px !important;
    line-height: 150%;
    font-weight: 400;
    cursor: pointer;
    z-index: 1;
    gap: 10px;
    padding: 15px 20px;
    border-radius: 20px;
    border: none;
    background: rgba(241, 241, 241, 0.5);
    transition: background 0.2s;
}

.chat-image-download:hover {
    background: rgba(255, 255, 255, 0.65);
}

.chat-image-download:focus-visible {
    outline: 2px solid rgba(142, 181, 51, 0.6);
    outline-offset: 3px;
}

.chat-image-download svg {
    width: 16px;
    height: 16px;
}

.alert {
    padding: 14px 18px;
    border-radius: 9px;
    font-size: 15px !important;
    font-weight: 500;
}

.alert-error {
    background: #fdecea;
    color: #b42318 !important;
    font-size: 15px !important;
}

.alert-success {
    background: #e8f7ef;
    color: #227447 !important;
    font-size: 15px !important;
}

.action-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 10px 0 4px;
    padding: 16px 0;
    border-radius: 0;
    background: transparent;
    align-items: flex-start;
}

.action-button {
    width: 100%;
    max-width: 320px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    border-radius: 999px;
    padding: 14px 18px;
    background: #D1EB95;
    color: var(--text-main) !important;
    font-weight: 500;
    font-size: 16px !important;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.action-button:hover:not(:disabled) {
    transform: translateY(-2px);
}

.report-card {
    background: #D1EB95 !important;
    border-radius: 18px;
    padding: 16px 18px 0;
    max-width: 90%;
    box-shadow: none;
    color: #000 !important;
    font-size: 15px !important;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
}

.report-card * {
    color: #000 !important;
}

.report-card strong {
    font-weight: 600;
}

.report-card small {
    font-size: 13px !important;
}

.report-action-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 999px;
    font-size: 15px !important;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.report-action-btn--view {
    background: rgba(0, 0, 0, 0.1);
    color: #000 !important;
}

.report-action-btn--download {
    background: rgba(0, 0, 0, 0.15);
    color: #000 !important;
}

.report-action-btn:hover {
    background: rgba(0, 0, 0, 0.25);
}

.report-actions-row {
    display: flex;
    width: calc(100% + 36px);
    margin-left: -18px;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
}

.report-actions-row .report-action-btn {
    flex: 1;
    border-radius: 0;
    border-top: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.report-action-btn--view {
    border-right: 1px solid rgba(0, 0, 0, 0.15);
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-loader {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.markdown-modal {
    font-size: 15px !important;
}

.markdown-modal p {
    margin: 0.7em 0 !important;
    color: #2c2e33 !important;
}

.markdown-modal h1,
.markdown-modal h2,
.markdown-modal h3 {
    margin: 1.5em 0 0.5em;
    color: #19202f !important;
}

.markdown-modal ul,
.markdown-modal ol {
    margin-left: 1.2em;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 9px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    color: #fff !important;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(142, 181, 51, 0.35);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 1200px) {
    .app-shell {
        flex-direction: column;
    }

    .history-panel {
        width: 100%;
        flex: 0 0 auto;
        min-height: 300px;
        max-height: 400px;
    }
    
    .workspace {
        flex: 1;
        min-height: 0;
    }
    
    .chat-stage {
        flex: 1;
        min-height: 500px;
    }
}


@media (max-width: 992px) {
    .controls-row {
        flex-direction: column;
        height: auto;
    }
}

@media (max-width: 1200px) {
    .photo-arrow {
        display: none;
    }

    .chat-stage {
        padding: 24px;
    }

    .chat-input-area {
        padding: 20px;
    }

    .chat-arrow {
        display: block;
        position: absolute;
        /* bottom будет установлен через JavaScript */
        left: 50%;
        transform: translateX(-50%);
        width: 120px;
        height: auto;
        z-index: 100;
    }
    
    .chat-arrow svg {
        width: 100%;
        height: auto;
    }

    .chat-image-download {
        width: 120px;
        height: 46px;
        font-size: 15px !important;
        padding: 12px 16px;
        gap: 8px;
        top: 16px;
        right: 6px;
    }

    .chat-image-download svg {
        width: 15px;
        height: 15px;
    }
}

@media (max-width: 600px) {
    .app-shell {
        padding: 0;
    }

    .chat-stage {
        padding: 12px;
        border-radius: 0;
        gap: 12px;
    }

    .chat-stage__scroll {
        flex: 1;
        min-height: 0;
    }

    .chat-messages {
        height: 100%;
        padding-right: 8px;
    }

    .upload-tile,
    .select-tile,
    .cta-button {
        min-height: auto;
        max-height: none;
    }

    .message-content {
        max-width: 100%;
    }

    /* Изображения в сообщениях пользователя на мобильных должны быть такого же размера, как у бота */
    .user-message .message-content {
        max-width: 90%;
        margin-left: auto;
        margin-right: 0;
    }

    .chat-image-download {
        width: 100px;
        height: 40px;
        font-size: 14px !important;
        padding: 10px 14px;
        gap: 6px;
        right: 6px;
    }

    .chat-image-download svg {
        width: 14px;
        height: 14px;
    }
}

/* Мобильная версия нижнего блока кнопок */
.mobile-bottom-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 0;
    padding-bottom: 15px;
    margin: 0 12px 12px;
    pointer-events: none;
    animation: slideUpMobileControls 0.3s ease-out;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

@keyframes slideUpMobileControls {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mobile-controls-container {
    width: 100%;
    margin: 0;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 11.5px;
}

.mobile-controls-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.mobile-controls-row--top {
    margin-bottom: 11.5px;
}

.mobile-controls-row--bottom {
    gap: 10px;
}

.mobile-photo-btn,
.mobile-style-btn {
    flex: 1;
    height: 60px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(249, 249, 249, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 700;
    font-size: 15px !important;
    color: var(--text-main) !important;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.6), 0 6px 15px rgba(0, 0, 0, 0.05);
}

.mobile-photo-btn {
    position: relative;
}

.mobile-photo-btn input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.mobile-upload-preview {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: visible;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.mobile-upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.mobile-upload-preview.visible {
    display: flex;
}

.mobile-photo-btn.has-preview {
    /* padding-left: 40px; */
    flex: 0 0 auto;
    width: auto;
    min-width: 58px;
}

.mobile-photo-btn.has-preview #mobilePhotoLabel,
.mobile-photo-btn.has-preview > svg {
    display: none;
}

.mobile-upload-clear {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 4px;
    background: var(--accent);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    color: #fff;
    z-index: 2;
}

.mobile-upload-clear svg {
    pointer-events: none;
    width: 10px;
    height: 10px;
}

.mobile-upload-preview.visible .mobile-upload-clear {
    display: flex;
}

.mobile-history-btn {
    flex: 1;
    width: 90px;
    height: 90px;
    min-width: 90px;
    max-width: 90px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(249, 249, 249, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px !important;
    color: var(--text-main) !important;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.6), 0 6px 15px rgba(0, 0, 0, 0.05);
}

.mobile-style-btn {
    flex: 1;
    min-width: 0;
}

.mobile-photo-btn:hover,
.mobile-history-btn:hover,
.mobile-style-btn:hover {
    background: rgba(249, 249, 249, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.mobile-photo-btn:active,
.mobile-history-btn:active,
.mobile-style-btn:active {
    transform: translateY(0);
}

.mobile-history-btn svg,
.mobile-style-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.mobile-history-btn span,
.mobile-style-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
}

.mobile-style-btn span {
    font-weight: 700;
}

.mobile-generate-btn {
    flex: 3;
    height: 90px;
    border-radius: 20px;
    border: none;
    background: linear-gradient(135deg, #005258 0%, #8EB533 100%);
    color: white !important;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 20px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 82, 88, 0.3);
    position: relative;
    overflow: hidden;
}

.mobile-btn-main {
    font-size: 16px !important;
    color: white !important;
    font-weight: 600;
}

.mobile-btn-sub {
    font-size: 12px !important;
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 300;
}

.mobile-generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 82, 88, 0.4);
}

.mobile-generate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.mobile-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mobile-generate-btn .loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@media (max-width: 1200px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }
    
    /* На десктопе (больше 1200px) разрешаем overflow для выпадающих списков */
    @media (min-width: 1201px) {
        html, body {
            overflow: visible;
        }
        
        /* Убеждаемся, что выпадающий список открывается на десктопе */
        .select-tile.open .select-dropdown {
            display: flex !important;
            z-index: 3000 !important;
            position: fixed !important;
        }
    }

    body {
        padding-bottom: 0;
        display: flex;
        flex-direction: column;
    }

    .mobile-bottom-controls {
        display: block;
    }

    /* Скрываем обычный блок на мобильных */
    .chat-input-area {
        display: none;
    }
    
    /* На десктопе (больше 1200px) показываем обычный блок */
    @media (min-width: 1201px) {
        .chat-input-area {
            display: block !important;
        }
        
        .mobile-bottom-controls {
            display: none !important;
        }
    }

    /* Окно чата на весь экран */
    .app-shell {
        padding: 0 !important;
        flex: 1 !important;
        min-height: 0 !important;
        height: 100vh !important;
        max-height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        overflow: hidden !important;
    }

    /* Скрываем панель истории на мобильных */
    .history-panel {
        display: none;
    }

    /* Окно чата занимает всю доступную высоту */
    .workspace,
    .main-content {
        flex: 1 !important;
        min-height: 0 !important;
        max-height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 0 !important;
        gap: 0 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .chat-stage {
        flex: 1 !important;
        min-height: 0 !important;
        max-height: 100% !important;
        padding: 16px !important;
        border-radius: 0 !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        gap: 16px !important;
        box-shadow: none !important;
        background: var(--panel-bg) !important;
        box-sizing: border-box !important;
    }

    .chat-stage__scroll {
        flex: 1 !important;
        min-height: 0 !important;
        max-height: 100% !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .chat-messages {
        height: 100% !important;
        max-height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        /* Добавляем padding-bottom, чтобы последние сообщения были видны выше блока кнопок */
        /* Высота: 15px (container padding-top) + 60px (верхний ряд) + 11.5px (gap) + 90px (нижний ряд) + 15px (container padding-bottom) + 12px (bottom margin) = 203.5px */
        padding-bottom: calc(15px + 70px + 11.5px + 90px + 15px + 12px) !important;
        box-sizing: border-box !important;
    }

    /* Увеличиваем z-index выпадающего списка на мобильных */
    /* Стили для выпадающего списка только на действительно мобильных устройствах */
    @media (max-width: 768px) {
        .select-dropdown {
            z-index: 1500 !important;
            bottom: calc(15px + 60px + 11.5px + 90px + 15px + 12px + 20px); /* Высота мобильного блока кнопок + отступ */
            width: calc(100% - 32px);
            max-width: 400px;
            left: 50%;
            transform: translateX(-50%);
        }
        
        /* Гарантируем, что выпадающий список виден на мобильных */
        .select-dropdown.mobile-open {
            display: flex !important;
            z-index: 1500 !important;
        }
    }

    /* Улучшаем отображение на маленьких экранах */
    .mobile-controls-container {
        width: 100%;
        padding: 15px;
    }

    .mobile-history-btn {
        flex: 0 0 90px;
        width: 90px;
        min-width: 90px;
        max-width: 90px;
    }

    .mobile-style-btn span {
        font-size: 15px !important;
    }
}

/* Модальное окно истории */
.history-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.history-modal.active {
    opacity: 1;
}

.history-modal.closing {
    opacity: 0;
}

.history-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.history-modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 80vh;
    max-height: 80vh;
    margin: auto;
    margin-top: auto;
    background: var(--panel-bg);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.history-modal.active .history-modal-content {
    transform: translateY(0);
}

.history-modal.closing .history-modal-content {
    transform: translateY(100%);
}

.history-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.history-modal-header h2 {
    font-size: 19px !important;
    font-weight: 700;
    margin: 0;
    color: var(--text-main) !important;
}

.history-modal-close {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    padding: 0;
}

.history-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.history-modal-close svg {
    width: 24px;
    height: 24px;
}

.history-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-modal-list::-webkit-scrollbar {
    width: 6px;
}

.history-modal-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-modal-list::-webkit-scrollbar-thumb {
    background: #D1EB95;
    border-radius: 3px;
}

.history-modal-list::-webkit-scrollbar-thumb:hover {
    background: #8EB533;
}

/* Скрываем панель истории на мобильных */
@media (max-width: 1200px) {
    .history-panel {
        display: none;
    }

    .history-modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .history-modal-overlay {
        background: rgba(0, 0, 0, 0.3);
    }
}

@media (max-width: 480px) {
    .history-modal-content {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .history-modal-header {
        padding: 16px 20px;
    }

    .history-modal-list {
        padding: 16px 20px;
    }
}

@media (max-width: 480px) {
    .mobile-controls-container {
        padding: 12px;
        gap: 10px;
    }

    .mobile-photo-btn,
    .mobile-style-btn {
        height: 60px;
    }

    .mobile-style-btn {
        font-size: 14px !important;
        padding: 0 12px;
    }

    .mobile-history-btn {
        width: 90px;
        height: 90px;
        min-width: 90px;
        max-width: 90px;
        flex: 0 0 90px;
        padding: 0;
    }

    .mobile-generate-btn {
        height: 90px;
        font-size: 15px !important;
    }

    .mobile-history-btn svg,
    .mobile-style-btn svg {
        width: 18px;
        height: 18px;
    }

}

/* Модальные окна для custom prompt на мобильных */
@keyframes slideUpModal {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.custom-prompt-modal-overlay {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.custom-prompt-modal {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-prompt-modal::-webkit-scrollbar {
    width: 6px;
}

.custom-prompt-modal::-webkit-scrollbar-track {
    background: transparent;
}

.custom-prompt-modal::-webkit-scrollbar-thumb {
    background: #D1EB95;
    border-radius: 3px;
}

.custom-prompt-modal::-webkit-scrollbar-thumb:hover {
    background: #8EB533;
}

