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

:root {
    --bg: #0A0A0C;
    --bg-elevated: rgba(20, 20, 23, 0.75);
    --bg-solid: #141416;
    --bg-surface: rgba(255, 255, 255, 0.03);
    --bg-surface-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text-primary: #F2F2F3;
    --text-secondary: #9B9BA1;
    --text-muted: #6E6E76;
    --accent: #3B82F6;
    --accent-2: #2563EB;
    --accent-3: #60A5FA;
    --gradient: linear-gradient(135deg, #2563EB 0%, #3B82F6 100%);
    --gradient-soft: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(37, 99, 235, 0.12));
    --success: #34D399;
    --danger: #EF4444;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 8px 24px rgba(59, 130, 246, 0.2);
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

/* Jedan suptilan, staticki glow gore - bez animacije, bez vise boja */
body::before {
    content: '';
    position: fixed;
    z-index: 0;
    top: -220px;
    left: 50%;
    transform: translateX(-50%);
    width: 900px;
    height: 500px;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(120px);
    opacity: 0.12;
    background: radial-gradient(circle, var(--accent), transparent 70%);
    transition: opacity 0.4s var(--ease);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-3);
}

/* ================= sidebar ================= */
.sidebar {
    width: 264px;
    background: var(--bg-elevated);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border-right: 1px solid var(--border);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: transform 0.35s var(--ease), background 0.4s var(--ease), border-color 0.4s var(--ease);
}

.sidebar-header {
    padding: 20px 16px 16px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 20px);
    border-bottom: 1px solid var(--border);
    transition: border-color 0.4s var(--ease);
    flex-shrink: 0;
}

.logo-wrapper {
    padding: 12px 14px;
    border-radius: 14px;
    margin-bottom: 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    background: var(--bg-solid);
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.logo-icon svg,
.welcome-icon svg,
.nav-logo-icon svg {
    width: 52%;
    height: 52%;
}

.header-logo-icon svg {
    width: 100%;
    height: 100%;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.new-chat-btn {
    width: 100%;
    padding: 11px;
    background: var(--gradient);
    background-size: 160% 160%;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background-position 0.4s var(--ease);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    background-position: 100% 0;
    box-shadow: var(--shadow-glow);
}

.new-chat-btn:active {
    transform: translateY(0) scale(0.98);
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 14px 0;
    padding: 8px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    transition: border-color 0.25s var(--ease);
}

.sidebar-search:focus-within {
    border-color: var(--accent);
}

.sidebar-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

.sidebar-search input::placeholder {
    color: var(--text-muted);
}

.sidebar-history {
    flex: 1;
    padding: 14px 10px;
    overflow-y: auto;
    min-height: 0;
}

.history-item-wrapper.hidden-by-search {
    display: none;
}

.history-item .title-input {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    padding: 2px 6px;
    outline: none;
    min-width: 0;
}

.rename-conv-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    opacity: 0;
    font-size: 12px;
    transition: 0.2s var(--ease);
}

.history-item-wrapper:hover .rename-conv-btn {
    opacity: 0.55;
}

.rename-conv-btn:hover {
    opacity: 1 !important;
    color: var(--accent);
    background: var(--bg-surface-hover);
}

.sidebar-history-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 0 10px 10px;
    font-weight: 700;
    transition: color 0.4s var(--ease);
}

.history-item-wrapper {
    display: flex;
    align-items: center;
    gap: 2px;
    border-radius: 10px;
    transition: background 0.25s var(--ease);
    margin-bottom: 2px;
}

.history-item-wrapper:hover {
    background: var(--bg-surface);
}

.history-item {
    flex: 1;
    padding: 9px 12px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    transition: color 0.25s var(--ease);
    min-width: 0;
}

.history-item .title-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    color: var(--text-primary);
}

.history-item.active {
    background: var(--gradient-soft);
    color: var(--text-primary);
    box-shadow: inset 2px 0 0 var(--accent);
}

.delete-conv-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    opacity: 0;
    font-size: 12px;
    transition: 0.2s var(--ease);
}

.history-item-wrapper:hover .delete-conv-btn {
    opacity: 0.55;
}

.delete-conv-btn:hover {
    opacity: 1 !important;
    color: var(--danger);
    background: rgba(239, 68, 68, 0.12);
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    transition: border-color 0.4s var(--ease);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    transition: background 0.25s var(--ease);
}

.sidebar-user:hover {
    background: var(--bg-surface);
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: var(--gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-info .username {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.4s var(--ease);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info .user-role {
    font-size: 11px;
    color: var(--text-muted);
    transition: color 0.4s var(--ease);
}

.sidebar-version {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 10px;
    opacity: 0.4;
    text-align: center;
    transition: color 0.4s var(--ease);
}

/* ================= glavni deo ================= */
.main-content {
    flex: 1;
    margin-left: 264px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: transparent;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.chat-header {
    padding: 14px 26px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
    background: var(--bg-elevated);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
    min-height: 62px;
    position: relative;
}

.chat-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.35), transparent);
    opacity: 0.7;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: 0.2s var(--ease);
}

.menu-toggle:hover {
    background: var(--bg-surface);
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-title h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    transition: color 0.4s var(--ease);
}

.header-logo-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    color: var(--accent);
    vertical-align: -3px;
}

.chat-title .status-dot {
    width: 7px;
    height: 7px;
    background: var(--success);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
    animation: pulseDot 2.4s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
    50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.1); }
}

.chat-title .status-text {
    font-size: 12px;
    color: var(--text-muted);
    transition: color 0.4s var(--ease);
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.model-toggle {
    position: relative;
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 14px 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    margin-right: 4px;
    transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), color 0.2s var(--ease);
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.model-toggle:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.model-toggle:active {
    transform: translateY(0) scale(0.97);
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 7px 9px;
    border-radius: 8px;
    transition: 0.2s var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.action-btn.danger:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ================= poruke ================= */
.messages-container {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    position: relative;
    z-index: 1;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--accent);
}

/* ================= pocetna ================= */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    flex-shrink: 0;
    animation: fadeInUp 0.5s var(--ease);
}

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

.welcome-icon {
    position: relative;
    margin-bottom: 22px;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 26px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--accent);
}

.welcome-screen h2 {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.welcome-screen p {
    font-size: 15.5px;
    color: var(--text-secondary);
    margin-bottom: 34px;
    transition: color 0.4s var(--ease);
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 520px;
}

.quick-btn {
    padding: 16px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.quick-btn:hover {
    border-color: transparent;
    background: var(--bg-surface-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.quick-btn:active {
    transform: translateY(-1px) scale(0.99);
}

.quick-btn .emoji {
    font-size: 18px;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--gradient-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================= chat poruke ================= */
#messages {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 0;
    flex-shrink: 0;
}

.message {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 800px;
    animation: slideUp 0.4s var(--ease);
    flex-shrink: 0;
    position: relative;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.user {
    align-items: flex-end;
    margin-left: auto;
    padding-right: 42px;
}

.message.ai {
    align-items: flex-start;
    margin-right: auto;
    padding-left: 42px;
}

/* Avatari - cist CSS trik preko pseudo-elemenata, bez izmena u HTML-u/JS-u */
.message.ai::before,
.message.user::after {
    content: '';
    position: absolute;
    top: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
}

.message.ai::before {
    content: '';
    left: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M13 2L3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E"), var(--gradient);
    background-repeat: no-repeat, no-repeat;
    background-position: center, center;
    background-size: 46%, cover;
}

.message.user::after {
    content: '👤';
    right: 0;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    font-size: 14px;
}

.message-content {
    max-width: 75%;
    padding: 14px 20px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
}

.message.user .message-content {
    background: var(--gradient);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.message.ai .message-content {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: background 0.4s var(--ease), color 0.4s var(--ease), border-color 0.4s var(--ease);
}

.message-meta-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
}

.message-timestamp {
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 8px;
    opacity: 0.6;
    transition: color 0.4s var(--ease);
}

.edit-msg-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 6px;
    opacity: 0;
    transition: 0.2s var(--ease);
}

.message.user:hover .edit-msg-btn {
    opacity: 0.6;
}

.edit-msg-btn:hover {
    opacity: 1 !important;
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.speak-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 6px;
    opacity: 0.5;
    transition: 0.2s var(--ease);
}

.speak-btn:hover {
    opacity: 1;
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.edit-msg-textarea {
    width: 100%;
    min-width: 220px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: inherit;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.6;
    padding: 10px 12px;
    resize: vertical;
    outline: none;
}

.edit-msg-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.edit-msg-save,
.edit-msg-cancel {
    font-size: 12px;
    font-family: inherit;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s var(--ease);
}

.edit-msg-save {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-weight: 600;
}

.edit-msg-save:hover {
    background: rgba(255, 255, 255, 0.3);
}

.edit-msg-cancel {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.85);
}

.edit-msg-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* kod */
.message.ai .message-content code {
    background: rgba(0, 0, 0, 0.35);
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    color: var(--accent-3);
    transition: background 0.4s var(--ease);
}

.message.ai .message-content pre {
    background: rgba(0, 0, 0, 0.35);
    padding: 16px;
    padding-top: 34px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid var(--border);
    position: relative;
    transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
}

.message.ai .message-content pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
    transition: color 0.4s var(--ease);
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: 0.2s var(--ease);
    font-family: inherit;
}

.copy-code-btn:hover {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
}

.message.ai .message-content ul,
.message.ai .message-content ol {
    padding-left: 24px;
    margin: 8px 0;
}

.message.ai .message-content li {
    margin-bottom: 4px;
}

.message.ai .message-content h1,
.message.ai .message-content h2,
.message.ai .message-content h3,
.message.ai .message-content h4 {
    margin: 12px 0 8px;
    color: var(--text-primary);
}

.message.ai .message-content strong {
    color: var(--accent-3);
    font-weight: 700;
}

/* typing indikator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    background: var(--bg-surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
    align-self: flex-start;
    transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
    flex-shrink: 0;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: dotBounce 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ================= input ================= */
.input-container {
    padding: 14px 26px 22px;
    border-top: 1px solid var(--border);
    background: transparent;
    flex-shrink: 0;
    transition: border-color 0.4s var(--ease);
    position: relative;
    z-index: 1;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px 8px 8px 20px;
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
    max-width: 800px;
    margin: 0 auto;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14), var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    padding: 8px 0;
    outline: none;
    line-height: 1.5;
    min-height: 20px;
    transition: color 0.4s var(--ease);
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.attach-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: 0.2s var(--ease);
}

.attach-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.mic-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: 0.2s var(--ease);
}

.mic-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.mic-btn.recording {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
    animation: micPulse 1.4s ease-in-out infinite;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.1); }
}

.image-preview-bar {
    max-width: 800px;
    margin: 0 auto 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.image-preview-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px 6px 6px;
    animation: fadeInUp 0.25s var(--ease);
}

.stop-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: 0.2s var(--ease);
}

.stop-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.regenerate-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    font-family: inherit;
    padding: 4px 9px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 6px;
    transition: 0.2s var(--ease);
}

.regenerate-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.image-preview-chip img {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border-radius: 6px;
}

.image-preview-chip span {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-preview-chip button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: 0.2s var(--ease);
}

.image-preview-chip button:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.message-image {
    max-width: 280px;
    max-height: 280px;
    border-radius: 12px;
    margin-bottom: 8px;
    display: block;
    box-shadow: var(--shadow-sm);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-glow);
}

.send-btn:active {
    transform: scale(0.96);
}

.send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-footer {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    opacity: 0.5;
    transition: color 0.4s var(--ease);
}

/* ================= bela tema ================= */
body.light-mode {
    --bg: #EEF0F7;
    --bg-elevated: rgba(255, 255, 255, 0.75);
    --bg-solid: #FFFFFF;
    --bg-surface: rgba(20, 20, 45, 0.035);
    --bg-surface-hover: rgba(20, 20, 45, 0.06);
    --border: rgba(20, 20, 45, 0.09);
    --border-strong: rgba(20, 20, 45, 0.16);
    --text-primary: #17172B;
    --text-secondary: #55557A;
    --text-muted: #9494AC;
}

body.light-mode::before {
    opacity: 0.06;
}

body.light-mode .message.ai .message-content code,
body.light-mode .message.ai .message-content pre {
    background: rgba(20, 20, 45, 0.05);
}

body.light-mode .logo-icon,
body.light-mode .user-avatar {
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.18);
}

/* ================= responzivan deo ================= */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .quick-actions {
        grid-template-columns: 1fr;
        max-width: 100%;
    }

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

    .messages-container {
        padding: 18px;
    }

    .input-container {
        padding: 10px 16px 18px;
    }

    .chat-header {
        padding: 10px 16px;
        padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
    }

    .message {
        max-width: 100%;
    }

    .message.ai {
        padding-left: 34px;
    }

    .message.user {
        padding-right: 34px;
    }

    .message.ai::before,
    .message.user::after {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .model-toggle span {
        font-size: 11px;
    }

    .welcome-screen {
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .chat-title h1 {
        font-size: 14px;
    }

    .chat-title .status-text {
        display: none;
    }

    .welcome-icon {
        width: 76px;
        height: 76px;
    }

    .welcome-screen h2 {
        font-size: 21px;
    }

    .message-content {
        font-size: 13px;
        padding: 10px 14px;
    }

    .quick-btn {
        padding: 12px 14px;
        font-size: 12px;
    }

    .input-wrapper {
        padding: 5px 5px 5px 14px;
    }
}

/* ---------- Podesavanja naloga (modal) ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-box {
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--bg-solid);
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 24px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 18px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: 0.2s var(--ease);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.modal-section {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.modal-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.modal-section h3 {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.modal-section .form-group {
    margin-bottom: 14px;
}

.modal-section .form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.modal-section .form-group input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.modal-section .form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-section .auth-btn {
    width: 100%;
    padding: 12px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.25s var(--ease);
}

.modal-section .auth-btn:hover {
    transform: translateY(-2px);
}

.modal-section .auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.settings-message {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 14px;
}

.settings-message.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.settings-message.success {
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.2);
    color: var(--success);
}

.danger-section p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

#memoryCount {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.memory-list {
    list-style: none;
    max-height: 160px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.memory-list li {
    font-size: 13px;
    color: var(--text-primary);
    padding: 8px 10px;
    background: var(--bg-surface);
    border-radius: 8px;
    margin-bottom: 6px;
}

.danger-btn {
    width: 100%;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s var(--ease);
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.18);
}

/* ---------- Voice mode ---------- */
.voice-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.voice-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
}

.voice-orb {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    box-shadow: var(--shadow-glow);
    transition: transform 0.3s var(--ease);
    animation: voicePulse 2.5s ease-in-out infinite;
}

.voice-orb.listening {
    animation: voicePulse 1.2s ease-in-out infinite;
}

.voice-orb.speaking {
    animation: voicePulse 0.6s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.voice-status {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.voice-transcript {
    max-width: 600px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
    padding: 0 24px;
    min-height: 24px;
}
