:root {
    font-size: 10px;

    --color-primary: #5B21B6;
    --color-secondary: #7C3AED;
    --bg-page: linear-gradient(160deg, #A78BFA 0%, #EDE9FE 55%, #EDE9FE 100%);
    --bg-surface: #ffffff;
    --bg-messages: #fafafa;
    --bg-bot: #e0e0e0;
    --bg-input: #ffffff;
    --text-primary: #1a1a1a;
    --text-bot: #333333;
    --text-muted: #666666;
    --border: #cccccc;
    --accent: #7C3AED;
    --accent-hover: #5B21B6;
    --shadow: rgba(0, 0, 0, 0.1);
    --toggle-bg: rgba(237, 233, 254, 0.75);
    --toggle-border: #C4B5FD;
    --gradient-main: linear-gradient(135deg, #7C3AED, #8B5CF6, #A78BFA);
    --gradient-main-hover: linear-gradient(135deg, #5B21B6, #7C3AED, #8B5CF6);
}

[data-theme="dark"] {
    --bg-page: linear-gradient(160deg, #5B21B6 0%, #1a1625 55%, #12141a 100%);
    --bg-surface: #1c1f28;
    --bg-messages: #151820;
    --bg-bot: #2a2f3a;
    --bg-input: #222633;
    --text-primary: #e8eaef;
    --text-bot: #d4d7de;
    --text-muted: #9aa0ad;
    --border: #3a4050;
    --accent: #A78BFA;
    --accent-hover: #C4B5FD;
    --shadow: rgba(0, 0, 0, 0.45);
    --toggle-bg: rgba(91, 33, 182, 0.45);
    --toggle-border: #7C3AED;
    --gradient-main: linear-gradient(135deg, #5B21B6, #7C3AED, #A78BFA);
    --gradient-main-hover: linear-gradient(135deg, #6D28D9, #8B5CF6, #C4B5FD);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family:  Helvetica, sans-serif, Arial;
    background: var(--bg-page);
    background-attachment: fixed;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100%;
    min-height: 100dvh;
    margin: 0;
    padding: 1.6rem;
    gap: 0.5rem;
    transition: background 250ms ease, color 250ms ease;
}

.chat__header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: min(100%, 50rem);
    margin-bottom: 1rem;
}

.header__brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 2.5rem;
  color: var(--color-dark);
  text-decoration: none;
}

.logo__icon {
  font-size: 3rem;
}

.logo__accent {
  color: var(--color-secondary);
}

.header__title {
    font-size: clamp(1.8rem, 4.5vw, 3rem);
    font-weight: bold;
    color: var(--accent);
    text-align: left;
    margin: 0;
    line-height: 1.2;
}

.header__title-ini {
    font-size: clamp(1.8rem, 4.5vw, 3rem);
    font-weight: bold;
    color: var(--text-primary);
    text-align: right;
    margin: 0;
    line-height: 1.2;
}   

.header__icon {
    height: clamp(2.8rem, 6vw, 4rem);
    width: auto;
    flex-shrink: 0;
}

.theme-toggle {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4.2rem;
    height: 4.2rem;
    border-radius: 999px;
    border: 1px solid var(--toggle-border);
    background: var(--toggle-bg);
    cursor: pointer;
    font-size: 1.8rem;
    line-height: 1;
    padding: 0;
    transition: background-color 250ms ease, border-color 250ms ease, transform 150ms ease;
}

.theme-toggle:hover {
    transform: scale(1.05);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.theme-toggle__icon--sun {
    display: none;
}

[data-theme="dark"] .theme-toggle__icon--moon {
    display: none;
}

[data-theme="dark"] .theme-toggle__icon--sun {
    display: inline;
}

.chat {
    width: min(100%, 60rem);
    background-color: var(--bg-surface);
    border-radius: 1rem;
    box-shadow: 0 0.5px 5px var(--shadow);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    max-height: calc(130dvh - 10rem);
    transition: background-color 250ms ease, box-shadow 250ms ease;
}

.chat__messages {
    flex: 1 1 auto;
    min-height: 18rem;
    height: min(70rem, 45dvh);
    overflow-y: auto;
    padding: 1rem;
    border-radius: 0.8rem;
    background-color: var(--bg-messages);
    box-shadow: inset 0 0 5px var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: background-color 250ms ease;
}

.chat__message {
    max-width: 75%;
    padding: 1.5rem;
    font-size: 1.2rem;
    border-radius: 1rem;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.chat__message--user {
    background-color: var(--accent);
    color: white;
    text-align: right;
    margin-left: auto;
}

.chat__message--bot {
    background-color: var(--bg-bot);
    color: var(--text-bot);
    text-align: left;
    margin-right: auto;
}

.chat__input-group {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    margin-top: 1rem;
    flex-shrink: 0;
}

.chat__input {
    width: 100%;
    outline: none;
    border: 1px solid var(--border);
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-size: 1.6rem;
    border-radius: 5px;
    padding: 1rem;
    transition: border-color 300ms ease-in-out, box-shadow 300ms ease-in-out, background-color 250ms ease;
    flex: 4;
}

.chat__input::placeholder {
    color: var(--text-muted);
}

.chat__input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 5px var(--accent);
}

.chat__inputs {
    display: flex;
    gap: 1rem;
}

.chat__select,
.chat__button {
    font-size: 1.6rem;
    padding: 1rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    min-height: 4.4rem;
}

.chat__select {
    flex: 2;
    min-width: 0;
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: background-color 250ms ease, border-color 250ms ease, color 250ms ease;
}

.chat__button {
    flex: 1;
    background: var(--gradient-main);
    color: white;
    cursor: pointer;
    border: none;
    outline: none;
    box-shadow: 0 0.4rem 1.2rem rgba(124, 58, 237, 0.35);
    transition: background 300ms ease, box-shadow 300ms ease, transform 150ms ease;
    white-space: nowrap;
}

.chat__button:hover {
    background: var(--gradient-main-hover);
    box-shadow: 0 0.6rem 1.6rem rgba(124, 58, 237, 0.45);
    transform: translateY(-1px);
}

.chat__button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 600px) {
    body {
        padding: 1rem;
        justify-content: flex-start;
    }

    .chat {
        padding: 1.2rem;
        max-height: calc(100dvh - 8rem);
        border-radius: 0.8rem;
        flex: 1;
        width: 100%;
    }

    .chat__messages {
        height: auto;
        min-height: 12rem;
        flex: 1;
    }

    .chat__message {
        max-width: 88%;
        padding: 1.2rem;
        font-size: 1.35rem;
    }

    .chat__inputs {
        flex-direction: column;
    }

    .chat__select,
    .chat__button {
        width: 100%;
        flex: none;
    }

    .header__title {
        font-size: 2rem;
    }
}

@media (max-width: 380px) {
    .header__title {
        font-size: 1.7rem;
    }

    .theme-toggle {
        width: 3.8rem;
        height: 3.8rem;
        font-size: 1.6rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
    }
}
