:root {
    --text-light: #1f2937;
    --text-dark: #f8fafc;
    --box-light: rgba(255, 255, 255, 0.20);
    --box-dark: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.28);
    --border-dark: rgba(255, 255, 255, 0.14);
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    width: 100%;
}

body {
    height: auto;
    overflow-x: hidden;
    min-height: 100vh;
    margin: 0;
    flex: 1;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    color: var(--text-light);
    background:
        linear-gradient(135deg, #fff1eb, #ace0f9, #fad0c4, #ffd1ff, #f6d365, #fda085, #c2e9fb);
    transition: background 0.3s ease, color 0.3s ease;
    position: relative;
}


/*! ТЕМА !*/


html.dark-mode body {
    color: var(--text-dark);
    background:
        linear-gradient(135deg, #0f172a, #111827, #1e1b4b, #312e81, #1f2937, #0f1a2b, #111111);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    mix-blend-mode: soft-light;
    opacity: 0.9;
}

html.dark-mode body::before {
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

.theme-toggle {
    position: absolute;
    top: 5px;
    right: 16px;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    appearance: none;
    padding: 0;
}

html.dark-mode .theme-toggle {
    background: rgba(10, 15, 25, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

label, input {
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.theme-icon {
    display: block;
    width: 30px;
    height: 30px;
    background: url("/static/images/sun.png") center / contain no-repeat;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45)) brightness(1.15) contrast(1.15);
    transition: background-image 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}

html.dark-mode .theme-icon {
    background-image: url("/static/images/moon.png");
}

.theme-toggle:active .theme-icon {
    transform: scale(0.94);
}

/*! HEADER !*/

.box {
    display: flex;
    flex-direction: column;
    max-width: 270px;
    max-height: 60px;
    margin: 17px;
    padding: 1px;
    text-align: center;
    gap: 8px;
    border-radius: 18px;
    justify-content: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    border: 1px solid var(--border-light);
    background: var(--box-light);
    color: var(--text-light);
}

html.dark-mode .box {
    background: var(--box-dark);
    border: 1px solid var(--border-dark);
    color: var(--text-dark);
}

/*! МЕНЮ !*/

.menu-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
}

.bot-card {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 14px;
    align-items: start;
    padding: 16px;
    border-radius: 18px;
    text-decoration: none;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

html.dark-mode .bot-card {
    background: rgba(10, 15, 25, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-dark);
}

.bot-card:hover {
    transform: translateY(-2px);
}

.bot-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.bot-content {
    min-width: 0;
    text-align: left;
}

.bot-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    color: inherit;
}

.bot-description {
    margin: 6px 0 0;
    font-size: 0.92rem;
    line-height: 1.4;
    opacity: 0.82;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

.bot-arrow {
    margin-top: 20px;
    font-size: 1.3rem;
    opacity: 0.75;
}

/* !BOT! */


.chat-clear-wrap {
    display: flex;
    justify-content: center;
    padding: 0 16px 10px;
    flex-shrink: 0;
}

.chat-clear-form {
    display: flex;
    justify-content: center;
}

.chat-clear-button {
    border: none;
    border-radius: 14px;
    padding: 10px 16px;
    cursor: pointer;
    font: inherit;
    background: rgba(235, 32, 32, 0.298);
    color: inherit;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

html.dark-mode .chat-clear-button {
    background: rgba(235, 32, 32, 0.22);
}

.chat-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 75vh;
    min-height: 0; 
    box-sizing: border-box;
    padding: 0 16px;
    margin-bottom: 20px;
    padding-bottom: env(safe-area-inset-bottom); 
}

.chat-history {
    flex: 1;
    min-height: 0; 
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    padding-bottom: 16px; 
    scroll-behavior: smooth;
    touch-action: pan-y; 
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-row {
    display: flex;
    width: 100%;
}

.chat-row.user {
    justify-content: flex-end;
}

.chat-row.bot {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 82%;
    padding: 12px 14px;
    border-radius: 16px;
    line-height: 1.45;
    word-break: break-word;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

html.dark-mode .chat-bubble {
    background: rgba(10, 15, 25, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.chat-row.user .chat-bubble {
    border-radius: 16px 16px 4px 16px;
}

.chat-row.bot .chat-bubble {
    border-radius: 16px 16px 16px 4px;
}

.chat-form {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-shrink: 0; 
    width: 100%;
    box-sizing: border-box;
    touch-action: manipulation;
}

html.dark-mode .chat-form {
    background: rgba(10, 15, 25, 0.26);
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    border-radius: 14px;
    padding: 14px 16px;
    font: inherit;
    background: rgba(255, 255, 255, 0.85);
    color: #111;
    resize: none;
    overflow-y: hidden;
    max-height: 120px;
    line-height: 1.4;
}

html.dark-mode .chat-input {
    background: rgba(255, 255, 255, 0.10);
    color: #f8fafc;
}

.chat-send {
    width: 52px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-send:active {
    transform: scale(0.98);
}